Spaces:
Running
Running
File size: 1,722 Bytes
6cd9596 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
/**
* @author benaadams / https://twitter.com/ben_a_adams
*/
function InterleavedBuffer( array, stride ) {
this.array = array;
this.stride = stride;
this.count = array !== undefined ? array.length / stride : 0;
this.dynamic = false;
this.updateRange = { offset: 0, count: - 1 };
this.version = 0;
}
Object.defineProperty( InterleavedBuffer.prototype, 'needsUpdate', {
set: function ( value ) {
if ( value === true ) this.version ++;
}
} );
Object.assign( InterleavedBuffer.prototype, {
isInterleavedBuffer: true,
onUploadCallback: function () {},
setArray: function ( array ) {
if ( Array.isArray( array ) ) {
throw new TypeError( 'THREE.BufferAttribute: array should be a Typed Array.' );
}
this.count = array !== undefined ? array.length / this.stride : 0;
this.array = array;
return this;
},
setDynamic: function ( value ) {
this.dynamic = value;
return this;
},
copy: function ( source ) {
this.array = new source.array.constructor( source.array );
this.count = source.count;
this.stride = source.stride;
this.dynamic = source.dynamic;
return this;
},
copyAt: function ( index1, attribute, index2 ) {
index1 *= this.stride;
index2 *= attribute.stride;
for ( var i = 0, l = this.stride; i < l; i ++ ) {
this.array[ index1 + i ] = attribute.array[ index2 + i ];
}
return this;
},
set: function ( value, offset ) {
if ( offset === undefined ) offset = 0;
this.array.set( value, offset );
return this;
},
clone: function () {
return new this.constructor().copy( this );
},
onUpload: function ( callback ) {
this.onUploadCallback = callback;
return this;
}
} );
export { InterleavedBuffer };
|