| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- /**
- * @author mrdoob / http://mrdoob.com/
- */
- THREE.BufferAttribute = function ( array, itemSize ) {
- this.array = array;
- this.itemSize = itemSize;
- this.needsUpdate = false;
- };
- THREE.BufferAttribute.prototype = {
- constructor: THREE.BufferAttribute,
- get length () {
- return this.array.length;
- },
- copyAt: function ( index1, attribute, index2 ) {
- index1 *= this.itemSize;
- index2 *= attribute.itemSize;
- for ( var i = 0, l = this.itemSize; i < l; i ++ ) {
- this.array[ index1 + i ] = attribute.array[ index2 + i ];
- }
- return this;
- },
- copyColorsArray: function ( colors ) {
- var array = this.array, offset = 0;
- for ( var i = 0, l = colors.length; i < l; i ++ ) {
- var color = colors[ i ];
- if ( color === undefined ) {
- console.warn( 'THREE.BufferAttribute.copyColorsArray(): color is undefined', i );
- color = new THREE.Color();
- }
- array[ offset ++ ] = color.r;
- array[ offset ++ ] = color.g;
- array[ offset ++ ] = color.b;
- }
- return this;
- },
- copyFacesArray: function ( faces ) {
- var array = this.array, offset = 0;
- for ( var i = 0, l = faces.length; i < l; i ++ ) {
- var face = faces[ i ];
- array[ offset ++ ] = face.a;
- array[ offset ++ ] = face.b;
- array[ offset ++ ] = face.c;
- }
- return this;
- },
- copyVector2sArray: function ( vectors ) {
- var array = this.array, offset = 0;
- for ( var i = 0, l = vectors.length; i < l; i ++ ) {
- var vector = vectors[ i ];
- if ( vector === undefined ) {
- console.warn( 'THREE.BufferAttribute.copyVector2sArray(): vector is undefined', i );
- vector = new THREE.Vector2();
- }
- array[ offset ++ ] = vector.x;
- array[ offset ++ ] = vector.y;
- }
- return this;
- },
- copyVector3sArray: function ( vectors ) {
- var array = this.array, offset = 0;
- for ( var i = 0, l = vectors.length; i < l; i ++ ) {
- var vector = vectors[ i ];
- if ( vector === undefined ) {
- console.warn( 'THREE.BufferAttribute.copyVector3sArray(): vector is undefined', i );
- vector = new THREE.Vector3();
- }
- array[ offset ++ ] = vector.x;
- array[ offset ++ ] = vector.y;
- array[ offset ++ ] = vector.z;
- }
- return this;
- },
- set: function ( value, offset ) {
- if ( offset === undefined ) offset = 0;
- this.array.set( value, offset );
- return this;
- },
- setX: function ( index, x ) {
- this.array[ index * this.itemSize ] = x;
- return this;
- },
- setY: function ( index, y ) {
- this.array[ index * this.itemSize + 1 ] = y;
- return this;
- },
- setZ: function ( index, z ) {
- this.array[ index * this.itemSize + 2 ] = z;
- return this;
- },
- setXY: function ( index, x, y ) {
- index *= this.itemSize;
- this.array[ index + 0 ] = x;
- this.array[ index + 1 ] = y;
- return this;
- },
- setXYZ: function ( index, x, y, z ) {
- index *= this.itemSize;
- this.array[ index + 0 ] = x;
- this.array[ index + 1 ] = y;
- this.array[ index + 2 ] = z;
- return this;
- },
- setXYZW: function ( index, x, y, z, w ) {
- index *= this.itemSize;
- this.array[ index + 0 ] = x;
- this.array[ index + 1 ] = y;
- this.array[ index + 2 ] = z;
- this.array[ index + 3 ] = w;
- return this;
- },
- clone: function () {
- return new THREE.BufferAttribute( new this.array.constructor( this.array ), this.itemSize );
- }
- };
- //
- THREE.Int8Attribute = function ( data, itemSize ) {
- THREE.warn( 'THREE.Int8Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead.' );
- return new THREE.BufferAttribute( data, itemSize );
- };
- THREE.Uint8Attribute = function ( data, itemSize ) {
- THREE.warn( 'THREE.Uint8Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead.' );
- return new THREE.BufferAttribute( data, itemSize );
- };
- THREE.Uint8ClampedAttribute = function ( data, itemSize ) {
- THREE.warn( 'THREE.Uint8ClampedAttribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead.' );
- return new THREE.BufferAttribute( data, itemSize );
- };
- THREE.Int16Attribute = function ( data, itemSize ) {
- THREE.warn( 'THREE.Int16Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead.' );
- return new THREE.BufferAttribute( data, itemSize );
- };
- THREE.Uint16Attribute = function ( data, itemSize ) {
- THREE.warn( 'THREE.Uint16Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead.' );
- return new THREE.BufferAttribute( data, itemSize );
- };
- THREE.Int32Attribute = function ( data, itemSize ) {
- THREE.warn( 'THREE.Int32Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead.' );
- return new THREE.BufferAttribute( data, itemSize );
- };
- THREE.Uint32Attribute = function ( data, itemSize ) {
- THREE.warn( 'THREE.Uint32Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead.' );
- return new THREE.BufferAttribute( data, itemSize );
- };
- THREE.Float32Attribute = function ( data, itemSize ) {
- THREE.warn( 'THREE.Float32Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead.' );
- return new THREE.BufferAttribute( data, itemSize );
- };
- THREE.Float64Attribute = function ( data, itemSize ) {
- THREE.warn( 'THREE.Float64Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead.' );
- return new THREE.BufferAttribute( data, itemSize );
- };
|