123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- import { _Math } from '../math/Math';
- /**
- * @author benaadams / https://twitter.com/ben_a_adams
- */
- function InterleavedBuffer( array, stride ) {
- this.uuid = _Math.generateUUID();
- this.array = array;
- this.stride = stride;
- this.count = array !== undefined ? array.length / stride : 0;
- this.dynamic = false;
- this.updateRange = { offset: 0, count: - 1 };
- this.onUploadCallback = function () {};
- this.version = 0;
- }
- Object.defineProperty( InterleavedBuffer.prototype, "needsUpdate", {
- set: function(value) {
-
- if ( value === true ) this.version ++;
-
- }
- });
- Object.assign( InterleavedBuffer.prototype, {
- isInterleavedBuffer: true,
- 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;
- },
- 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 };
|