preact
This commit is contained in:
parent
6acf267d48
commit
b7614eb3f8
4794 changed files with 1280808 additions and 1546 deletions
77
frontend/node_modules/three/examples/jsm/renderers/common/Attributes.js
generated
vendored
Normal file
77
frontend/node_modules/three/examples/jsm/renderers/common/Attributes.js
generated
vendored
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
import DataMap from './DataMap.js';
|
||||
import { AttributeType } from './Constants.js';
|
||||
import { DynamicDrawUsage } from 'three';
|
||||
|
||||
class Attributes extends DataMap {
|
||||
|
||||
constructor( backend ) {
|
||||
|
||||
super();
|
||||
|
||||
this.backend = backend;
|
||||
|
||||
}
|
||||
|
||||
delete( attribute ) {
|
||||
|
||||
const attributeData = super.delete( attribute );
|
||||
|
||||
if ( attributeData !== undefined ) {
|
||||
|
||||
this.backend.destroyAttribute( attribute );
|
||||
|
||||
}
|
||||
|
||||
return attributeData;
|
||||
|
||||
}
|
||||
|
||||
update( attribute, type ) {
|
||||
|
||||
const data = this.get( attribute );
|
||||
|
||||
if ( data.version === undefined ) {
|
||||
|
||||
if ( type === AttributeType.VERTEX ) {
|
||||
|
||||
this.backend.createAttribute( attribute );
|
||||
|
||||
} else if ( type === AttributeType.INDEX ) {
|
||||
|
||||
this.backend.createIndexAttribute( attribute );
|
||||
|
||||
} else if ( type === AttributeType.STORAGE ) {
|
||||
|
||||
this.backend.createStorageAttribute( attribute );
|
||||
|
||||
}
|
||||
|
||||
data.version = this._getBufferAttribute( attribute ).version;
|
||||
|
||||
} else {
|
||||
|
||||
const bufferAttribute = this._getBufferAttribute( attribute );
|
||||
|
||||
if ( data.version < bufferAttribute.version || bufferAttribute.usage === DynamicDrawUsage ) {
|
||||
|
||||
this.backend.updateAttribute( attribute );
|
||||
|
||||
data.version = bufferAttribute.version;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_getBufferAttribute( attribute ) {
|
||||
|
||||
if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;
|
||||
|
||||
return attribute;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default Attributes;
|
||||
Loading…
Add table
Add a link
Reference in a new issue