|
@@ -7,53 +7,47 @@ import { StaticDrawUsage } from '../constants.js';
|
|
const _vector = new Vector3();
|
|
const _vector = new Vector3();
|
|
const _vector2 = new Vector2();
|
|
const _vector2 = new Vector2();
|
|
|
|
|
|
-function BufferAttribute( array, itemSize, normalized ) {
|
|
|
|
|
|
+class BufferAttribute {
|
|
|
|
|
|
- if ( Array.isArray( array ) ) {
|
|
|
|
|
|
+ constructor( array, itemSize, normalized ) {
|
|
|
|
|
|
- throw new TypeError( 'THREE.BufferAttribute: array should be a Typed Array.' );
|
|
|
|
|
|
+ if ( Array.isArray( array ) ) {
|
|
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- this.name = '';
|
|
|
|
|
|
+ throw new TypeError( 'THREE.BufferAttribute: array should be a Typed Array.' );
|
|
|
|
|
|
- this.array = array;
|
|
|
|
- this.itemSize = itemSize;
|
|
|
|
- this.count = array !== undefined ? array.length / itemSize : 0;
|
|
|
|
- this.normalized = normalized === true;
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- this.usage = StaticDrawUsage;
|
|
|
|
- this.updateRange = { offset: 0, count: - 1 };
|
|
|
|
|
|
+ this.name = '';
|
|
|
|
|
|
- this.version = 0;
|
|
|
|
|
|
+ this.array = array;
|
|
|
|
+ this.itemSize = itemSize;
|
|
|
|
+ this.count = array !== undefined ? array.length / itemSize : 0;
|
|
|
|
+ this.normalized = normalized === true;
|
|
|
|
|
|
-}
|
|
|
|
|
|
+ this.usage = StaticDrawUsage;
|
|
|
|
+ this.updateRange = { offset: 0, count: - 1 };
|
|
|
|
|
|
-Object.defineProperty( BufferAttribute.prototype, 'needsUpdate', {
|
|
|
|
|
|
+ this.version = 0;
|
|
|
|
|
|
- set: function ( value ) {
|
|
|
|
-
|
|
|
|
- if ( value === true ) this.version ++;
|
|
|
|
|
|
+ this.onUploadCallback = function () {};
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-} );
|
|
|
|
-
|
|
|
|
-Object.assign( BufferAttribute.prototype, {
|
|
|
|
|
|
+ set needsUpdate( value ) {
|
|
|
|
|
|
- isBufferAttribute: true,
|
|
|
|
|
|
+ if ( value === true ) this.version ++;
|
|
|
|
|
|
- onUploadCallback: function () {},
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- setUsage: function ( value ) {
|
|
|
|
|
|
+ setUsage( value ) {
|
|
|
|
|
|
this.usage = value;
|
|
this.usage = value;
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- copy: function ( source ) {
|
|
|
|
|
|
+ copy( source ) {
|
|
|
|
|
|
this.name = source.name;
|
|
this.name = source.name;
|
|
this.array = new source.array.constructor( source.array );
|
|
this.array = new source.array.constructor( source.array );
|
|
@@ -65,9 +59,9 @@ Object.assign( BufferAttribute.prototype, {
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- copyAt: function ( index1, attribute, index2 ) {
|
|
|
|
|
|
+ copyAt( index1, attribute, index2 ) {
|
|
|
|
|
|
index1 *= this.itemSize;
|
|
index1 *= this.itemSize;
|
|
index2 *= attribute.itemSize;
|
|
index2 *= attribute.itemSize;
|
|
@@ -80,17 +74,17 @@ Object.assign( BufferAttribute.prototype, {
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- copyArray: function ( array ) {
|
|
|
|
|
|
+ copyArray( array ) {
|
|
|
|
|
|
this.array.set( array );
|
|
this.array.set( array );
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- copyColorsArray: function ( colors ) {
|
|
|
|
|
|
+ copyColorsArray( colors ) {
|
|
|
|
|
|
const array = this.array;
|
|
const array = this.array;
|
|
let offset = 0;
|
|
let offset = 0;
|
|
@@ -114,9 +108,9 @@ Object.assign( BufferAttribute.prototype, {
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- copyVector2sArray: function ( vectors ) {
|
|
|
|
|
|
+ copyVector2sArray( vectors ) {
|
|
|
|
|
|
const array = this.array;
|
|
const array = this.array;
|
|
let offset = 0;
|
|
let offset = 0;
|
|
@@ -139,9 +133,9 @@ Object.assign( BufferAttribute.prototype, {
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- copyVector3sArray: function ( vectors ) {
|
|
|
|
|
|
+ copyVector3sArray( vectors ) {
|
|
|
|
|
|
const array = this.array;
|
|
const array = this.array;
|
|
let offset = 0;
|
|
let offset = 0;
|
|
@@ -165,9 +159,9 @@ Object.assign( BufferAttribute.prototype, {
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- copyVector4sArray: function ( vectors ) {
|
|
|
|
|
|
+ copyVector4sArray( vectors ) {
|
|
|
|
|
|
const array = this.array;
|
|
const array = this.array;
|
|
let offset = 0;
|
|
let offset = 0;
|
|
@@ -192,9 +186,9 @@ Object.assign( BufferAttribute.prototype, {
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- applyMatrix3: function ( m ) {
|
|
|
|
|
|
+ applyMatrix3( m ) {
|
|
|
|
|
|
if ( this.itemSize === 2 ) {
|
|
if ( this.itemSize === 2 ) {
|
|
|
|
|
|
@@ -222,9 +216,9 @@ Object.assign( BufferAttribute.prototype, {
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- applyMatrix4: function ( m ) {
|
|
|
|
|
|
+ applyMatrix4( m ) {
|
|
|
|
|
|
for ( let i = 0, l = this.count; i < l; i ++ ) {
|
|
for ( let i = 0, l = this.count; i < l; i ++ ) {
|
|
|
|
|
|
@@ -240,9 +234,9 @@ Object.assign( BufferAttribute.prototype, {
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- applyNormalMatrix: function ( m ) {
|
|
|
|
|
|
+ applyNormalMatrix( m ) {
|
|
|
|
|
|
for ( let i = 0, l = this.count; i < l; i ++ ) {
|
|
for ( let i = 0, l = this.count; i < l; i ++ ) {
|
|
|
|
|
|
@@ -258,9 +252,9 @@ Object.assign( BufferAttribute.prototype, {
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- transformDirection: function ( m ) {
|
|
|
|
|
|
+ transformDirection( m ) {
|
|
|
|
|
|
for ( let i = 0, l = this.count; i < l; i ++ ) {
|
|
for ( let i = 0, l = this.count; i < l; i ++ ) {
|
|
|
|
|
|
@@ -276,73 +270,73 @@ Object.assign( BufferAttribute.prototype, {
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- set: function ( value, offset = 0 ) {
|
|
|
|
|
|
+ set( value, offset = 0 ) {
|
|
|
|
|
|
this.array.set( value, offset );
|
|
this.array.set( value, offset );
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- getX: function ( index ) {
|
|
|
|
|
|
+ getX( index ) {
|
|
|
|
|
|
return this.array[ index * this.itemSize ];
|
|
return this.array[ index * this.itemSize ];
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- setX: function ( index, x ) {
|
|
|
|
|
|
+ setX( index, x ) {
|
|
|
|
|
|
this.array[ index * this.itemSize ] = x;
|
|
this.array[ index * this.itemSize ] = x;
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- getY: function ( index ) {
|
|
|
|
|
|
+ getY( index ) {
|
|
|
|
|
|
return this.array[ index * this.itemSize + 1 ];
|
|
return this.array[ index * this.itemSize + 1 ];
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- setY: function ( index, y ) {
|
|
|
|
|
|
+ setY( index, y ) {
|
|
|
|
|
|
this.array[ index * this.itemSize + 1 ] = y;
|
|
this.array[ index * this.itemSize + 1 ] = y;
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- getZ: function ( index ) {
|
|
|
|
|
|
+ getZ( index ) {
|
|
|
|
|
|
return this.array[ index * this.itemSize + 2 ];
|
|
return this.array[ index * this.itemSize + 2 ];
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- setZ: function ( index, z ) {
|
|
|
|
|
|
+ setZ( index, z ) {
|
|
|
|
|
|
this.array[ index * this.itemSize + 2 ] = z;
|
|
this.array[ index * this.itemSize + 2 ] = z;
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- getW: function ( index ) {
|
|
|
|
|
|
+ getW( index ) {
|
|
|
|
|
|
return this.array[ index * this.itemSize + 3 ];
|
|
return this.array[ index * this.itemSize + 3 ];
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- setW: function ( index, w ) {
|
|
|
|
|
|
+ setW( index, w ) {
|
|
|
|
|
|
this.array[ index * this.itemSize + 3 ] = w;
|
|
this.array[ index * this.itemSize + 3 ] = w;
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- setXY: function ( index, x, y ) {
|
|
|
|
|
|
+ setXY( index, x, y ) {
|
|
|
|
|
|
index *= this.itemSize;
|
|
index *= this.itemSize;
|
|
|
|
|
|
@@ -351,9 +345,9 @@ Object.assign( BufferAttribute.prototype, {
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- setXYZ: function ( index, x, y, z ) {
|
|
|
|
|
|
+ setXYZ( index, x, y, z ) {
|
|
|
|
|
|
index *= this.itemSize;
|
|
index *= this.itemSize;
|
|
|
|
|
|
@@ -363,9 +357,9 @@ Object.assign( BufferAttribute.prototype, {
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- setXYZW: function ( index, x, y, z, w ) {
|
|
|
|
|
|
+ setXYZW( index, x, y, z, w ) {
|
|
|
|
|
|
index *= this.itemSize;
|
|
index *= this.itemSize;
|
|
|
|
|
|
@@ -376,23 +370,23 @@ Object.assign( BufferAttribute.prototype, {
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- onUpload: function ( callback ) {
|
|
|
|
|
|
+ onUpload( callback ) {
|
|
|
|
|
|
this.onUploadCallback = callback;
|
|
this.onUploadCallback = callback;
|
|
|
|
|
|
return this;
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- clone: function () {
|
|
|
|
|
|
+ clone() {
|
|
|
|
|
|
return new this.constructor( this.array, this.itemSize ).copy( this );
|
|
return new this.constructor( this.array, this.itemSize ).copy( this );
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- toJSON: function () {
|
|
|
|
|
|
+ toJSON() {
|
|
|
|
|
|
const data = {
|
|
const data = {
|
|
itemSize: this.itemSize,
|
|
itemSize: this.itemSize,
|
|
@@ -409,108 +403,114 @@ Object.assign( BufferAttribute.prototype, {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-} );
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+BufferAttribute.prototype.isBufferAttribute = true;
|
|
|
|
|
|
//
|
|
//
|
|
|
|
|
|
-function Int8BufferAttribute( array, itemSize, normalized ) {
|
|
|
|
|
|
+class Int8BufferAttribute extends BufferAttribute {
|
|
|
|
|
|
- BufferAttribute.call( this, new Int8Array( array ), itemSize, normalized );
|
|
|
|
|
|
+ constructor( array, itemSize, normalized ) {
|
|
|
|
+
|
|
|
|
+ super( new Int8Array( array ), itemSize, normalized );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-Int8BufferAttribute.prototype = Object.create( BufferAttribute.prototype );
|
|
|
|
-Int8BufferAttribute.prototype.constructor = Int8BufferAttribute;
|
|
|
|
|
|
+class Uint8BufferAttribute extends BufferAttribute {
|
|
|
|
|
|
|
|
+ constructor( array, itemSize, normalized ) {
|
|
|
|
|
|
-function Uint8BufferAttribute( array, itemSize, normalized ) {
|
|
|
|
|
|
+ super( new Uint8Array( array ), itemSize, normalized );
|
|
|
|
|
|
- BufferAttribute.call( this, new Uint8Array( array ), itemSize, normalized );
|
|
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-Uint8BufferAttribute.prototype = Object.create( BufferAttribute.prototype );
|
|
|
|
-Uint8BufferAttribute.prototype.constructor = Uint8BufferAttribute;
|
|
|
|
|
|
+class Uint8ClampedBufferAttribute extends BufferAttribute {
|
|
|
|
|
|
|
|
+ constructor( array, itemSize, normalized ) {
|
|
|
|
|
|
-function Uint8ClampedBufferAttribute( array, itemSize, normalized ) {
|
|
|
|
|
|
+ super( new Uint8ClampedArray( array ), itemSize, normalized );
|
|
|
|
|
|
- BufferAttribute.call( this, new Uint8ClampedArray( array ), itemSize, normalized );
|
|
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-Uint8ClampedBufferAttribute.prototype = Object.create( BufferAttribute.prototype );
|
|
|
|
-Uint8ClampedBufferAttribute.prototype.constructor = Uint8ClampedBufferAttribute;
|
|
|
|
|
|
+class Int16BufferAttribute extends BufferAttribute {
|
|
|
|
|
|
|
|
+ constructor( array, itemSize, normalized ) {
|
|
|
|
|
|
-function Int16BufferAttribute( array, itemSize, normalized ) {
|
|
|
|
|
|
+ super( new Int16Array( array ), itemSize, normalized );
|
|
|
|
|
|
- BufferAttribute.call( this, new Int16Array( array ), itemSize, normalized );
|
|
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-Int16BufferAttribute.prototype = Object.create( BufferAttribute.prototype );
|
|
|
|
-Int16BufferAttribute.prototype.constructor = Int16BufferAttribute;
|
|
|
|
|
|
+class Uint16BufferAttribute extends BufferAttribute {
|
|
|
|
|
|
|
|
+ constructor( array, itemSize, normalized ) {
|
|
|
|
|
|
-function Uint16BufferAttribute( array, itemSize, normalized ) {
|
|
|
|
|
|
+ super( new Uint16Array( array ), itemSize, normalized );
|
|
|
|
|
|
- BufferAttribute.call( this, new Uint16Array( array ), itemSize, normalized );
|
|
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-Uint16BufferAttribute.prototype = Object.create( BufferAttribute.prototype );
|
|
|
|
-Uint16BufferAttribute.prototype.constructor = Uint16BufferAttribute;
|
|
|
|
|
|
+class Int32BufferAttribute extends BufferAttribute {
|
|
|
|
|
|
|
|
+ constructor( array, itemSize, normalized ) {
|
|
|
|
|
|
-function Int32BufferAttribute( array, itemSize, normalized ) {
|
|
|
|
|
|
+ super( new Int32Array( array ), itemSize, normalized );
|
|
|
|
|
|
- BufferAttribute.call( this, new Int32Array( array ), itemSize, normalized );
|
|
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-Int32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );
|
|
|
|
-Int32BufferAttribute.prototype.constructor = Int32BufferAttribute;
|
|
|
|
|
|
+class Uint32BufferAttribute extends BufferAttribute {
|
|
|
|
|
|
|
|
+ constructor( array, itemSize, normalized ) {
|
|
|
|
|
|
-function Uint32BufferAttribute( array, itemSize, normalized ) {
|
|
|
|
|
|
+ super( new Uint32Array( array ), itemSize, normalized );
|
|
|
|
|
|
- BufferAttribute.call( this, new Uint32Array( array ), itemSize, normalized );
|
|
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-Uint32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );
|
|
|
|
-Uint32BufferAttribute.prototype.constructor = Uint32BufferAttribute;
|
|
|
|
|
|
+class Float16BufferAttribute extends BufferAttribute {
|
|
|
|
|
|
-function Float16BufferAttribute( array, itemSize, normalized ) {
|
|
|
|
|
|
+ constructor( array, itemSize, normalized ) {
|
|
|
|
|
|
- BufferAttribute.call( this, new Uint16Array( array ), itemSize, normalized );
|
|
|
|
|
|
+ super( new Uint16Array( array ), itemSize, normalized );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-Float16BufferAttribute.prototype = Object.create( BufferAttribute.prototype );
|
|
|
|
-Float16BufferAttribute.prototype.constructor = Float16BufferAttribute;
|
|
|
|
Float16BufferAttribute.prototype.isFloat16BufferAttribute = true;
|
|
Float16BufferAttribute.prototype.isFloat16BufferAttribute = true;
|
|
|
|
|
|
-function Float32BufferAttribute( array, itemSize, normalized ) {
|
|
|
|
|
|
+class Float32BufferAttribute extends BufferAttribute {
|
|
|
|
+
|
|
|
|
+ constructor( array, itemSize, normalized ) {
|
|
|
|
+
|
|
|
|
+ super( new Float32Array( array ), itemSize, normalized );
|
|
|
|
|
|
- BufferAttribute.call( this, new Float32Array( array ), itemSize, normalized );
|
|
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-Float32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );
|
|
|
|
-Float32BufferAttribute.prototype.constructor = Float32BufferAttribute;
|
|
|
|
|
|
+class Float64BufferAttribute extends BufferAttribute {
|
|
|
|
|
|
|
|
+ constructor( array, itemSize, normalized ) {
|
|
|
|
|
|
-function Float64BufferAttribute( array, itemSize, normalized ) {
|
|
|
|
|
|
+ super( new Float64Array( array ), itemSize, normalized );
|
|
|
|
|
|
- BufferAttribute.call( this, new Float64Array( array ), itemSize, normalized );
|
|
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-Float64BufferAttribute.prototype = Object.create( BufferAttribute.prototype );
|
|
|
|
-Float64BufferAttribute.prototype.constructor = Float64BufferAttribute;
|
|
|
|
-
|
|
|
|
//
|
|
//
|
|
|
|
|
|
export {
|
|
export {
|