浏览代码

Refactored BufferAttribute shortcuts. See #10055.

Mr.doob 8 年之前
父节点
当前提交
33bfe1b393

+ 64 - 1
src/Three.Legacy.js

@@ -6,7 +6,18 @@ import { Audio } from './audio/Audio.js';
 import { AudioAnalyser } from './audio/AudioAnalyser.js';
 import { PerspectiveCamera } from './cameras/PerspectiveCamera.js';
 import { CullFaceFront, CullFaceBack } from './constants.js';
-import { BufferAttribute } from './core/BufferAttribute.js';
+import {
+	Float64BufferAttribute,
+	Float32BufferAttribute,
+	Uint32BufferAttribute,
+	Int32BufferAttribute,
+	Uint16BufferAttribute,
+	Int16BufferAttribute,
+	Uint8ClampedBufferAttribute,
+	Uint8BufferAttribute,
+	Int8BufferAttribute,
+	BufferAttribute
+} from './core/BufferAttribute.js';
 import { BufferGeometry } from './core/BufferGeometry.js';
 import { EventDispatcher } from './core/EventDispatcher.js';
 import { Face3 } from './core/Face3.js';
@@ -94,6 +105,58 @@ export function Vertex ( x, y, z ) {
 
 //
 
+export function DynamicBufferAttribute( array, itemSize ) {
+	console.warn( 'THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead.' );
+	return new BufferAttribute( array, itemSize ).setDynamic( true );
+}
+
+export function Int8Attribute( array, itemSize ) {
+	console.warn( 'THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead.' );
+	return new Int8BufferAttribute( array, itemSize );
+}
+
+export function Uint8Attribute( array, itemSize ) {
+	console.warn( 'THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead.' );
+	return new Uint8BufferAttribute( array, itemSize );
+}
+
+export function Uint8ClampedAttribute( array, itemSize ) {
+	console.warn( 'THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead.' );
+	return new Uint8ClampedBufferAttribute( array, itemSize );
+}
+
+export function Int16Attribute( array, itemSize ) {
+	console.warn( 'THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead.' );
+	return new Int16BufferAttribute( array, itemSize );
+}
+
+export function Uint16Attribute( array, itemSize ) {
+	console.warn( 'THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead.' );
+	return new Uint16BufferAttribute( array, itemSize );
+}
+
+export function Int32Attribute( array, itemSize ) {
+	console.warn( 'THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead.' );
+	return new Int32BufferAttribute( array, itemSize );
+}
+
+export function Uint32Attribute( array, itemSize ) {
+	console.warn( 'THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead.' );
+	return new Uint32BufferAttribute( array, itemSize );
+}
+
+export function Float32Attribute( array, itemSize ) {
+	console.warn( 'THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead.' );
+	return new Float32BufferAttribute( array, itemSize );
+}
+
+export function Float64Attribute( array, itemSize ) {
+	console.warn( 'THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead.' );
+	return new Float64BufferAttribute( array, itemSize );
+}
+
+//
+
 export function EdgesHelper( object, hex ) {
 	console.warn( 'THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead.' );
 	return new LineSegments( new EdgesGeometry( object.geometry ), new LineBasicMaterial( { color: hex !== undefined ? hex : 0xffffff } ) );

+ 10 - 11
src/Three.js

@@ -88,17 +88,16 @@ export { InstancedInterleavedBuffer } from './core/InstancedInterleavedBuffer.js
 export { InterleavedBuffer } from './core/InterleavedBuffer.js';
 export { InstancedBufferAttribute } from './core/InstancedBufferAttribute.js';
 export {
-  DynamicBufferAttribute,
-  Float64Attribute,
-  Float32Attribute,
-  Uint32Attribute,
-  Int32Attribute,
-  Uint16Attribute,
-  Int16Attribute,
-  Uint8ClampedAttribute,
-  Uint8Attribute,
-  Int8Attribute,
-  BufferAttribute
+	Float64BufferAttribute,
+	Float32BufferAttribute,
+	Uint32BufferAttribute,
+	Int32BufferAttribute,
+	Uint16BufferAttribute,
+	Int16BufferAttribute,
+	Uint8ClampedBufferAttribute,
+	Uint8BufferAttribute,
+	Int8BufferAttribute,
+	BufferAttribute
 } from './core/BufferAttribute.js';
 export { Face3 } from './core/Face3.js';
 export { Object3DIdCount, Object3D } from './core/Object3D.js';

+ 61 - 35
src/core/BufferAttribute.js

@@ -339,80 +339,106 @@ BufferAttribute.prototype = {
 
 //
 
-function Int8Attribute( array, itemSize ) {
+function Int8BufferAttribute( array, itemSize ) {
 
-	return new BufferAttribute( new Int8Array( array ), itemSize );
+	BufferAttribute.call( this, new Int8Array( array ), itemSize );
 
 }
 
-function Uint8Attribute( array, itemSize ) {
+Int8BufferAttribute.prototype = Object.create( BufferAttribute.prototype );
+Int8BufferAttribute.prototype.constructor = Int8BufferAttribute;
 
-	return new BufferAttribute( new Uint8Array( array ), itemSize );
 
-}
-
-function Uint8ClampedAttribute( array, itemSize ) {
+function Uint8BufferAttribute( array, itemSize ) {
 
-	return new BufferAttribute( new Uint8ClampedArray( array ), itemSize );
+	BufferAttribute.call( this, new Uint8Array( array ), itemSize );
 
 }
 
-function Int16Attribute( array, itemSize ) {
+Uint8BufferAttribute.prototype = Object.create( BufferAttribute.prototype );
+Uint8BufferAttribute.prototype.constructor = Uint8BufferAttribute;
+
 
-	return new BufferAttribute( new Int16Array( array ), itemSize );
+function Uint8ClampedBufferAttribute( array, itemSize ) {
+
+	BufferAttribute.call( this, new Uint8ClampedArray( array ), itemSize );
 
 }
 
-function Uint16Attribute( array, itemSize ) {
+Uint8ClampedBufferAttribute.prototype = Object.create( BufferAttribute.prototype );
+Uint8ClampedBufferAttribute.prototype.constructor = Uint8ClampedBufferAttribute;
+
 
-	return new BufferAttribute( new Uint16Array( array ), itemSize );
+function Int16BufferAttribute( array, itemSize ) {
+
+	BufferAttribute.call( this, new Int16Array( array ), itemSize );
 
 }
 
-function Int32Attribute( array, itemSize ) {
+Int16BufferAttribute.prototype = Object.create( BufferAttribute.prototype );
+Int16BufferAttribute.prototype.constructor = Int16BufferAttribute;
+
 
-	return new BufferAttribute( new Int32Array( array ), itemSize );
+function Uint16BufferAttribute( array, itemSize ) {
+
+	BufferAttribute.call( this, new Uint16Array( array ), itemSize );
 
 }
 
-function Uint32Attribute( array, itemSize ) {
+Uint16BufferAttribute.prototype = Object.create( BufferAttribute.prototype );
+Uint16BufferAttribute.prototype.constructor = Uint16BufferAttribute;
+
 
-	return new BufferAttribute( new Uint32Array( array ), itemSize );
+function Int32BufferAttribute( array, itemSize ) {
+
+	BufferAttribute.call( this, new Int32Array( array ), itemSize );
 
 }
 
-function Float32Attribute( array, itemSize ) {
+Int32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );
+Int32BufferAttribute.prototype.constructor = Int32BufferAttribute;
+
 
-	return new BufferAttribute( new Float32Array( array ), itemSize );
+function Uint32BufferAttribute( array, itemSize ) {
+
+	BufferAttribute.call( this, new Uint32Array( array ), itemSize );
 
 }
 
-function Float64Attribute( array, itemSize ) {
+Uint32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );
+Uint32BufferAttribute.prototype.constructor = Uint32BufferAttribute;
+
 
-	return new BufferAttribute( new Float64Array( array ), itemSize );
+function Float32BufferAttribute( array, itemSize ) {
+
+	BufferAttribute.call( this, new Float32Array( array ), itemSize );
 
 }
 
-// Deprecated
+Float32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );
+Float32BufferAttribute.prototype.constructor = Float32BufferAttribute;
+
 
-function DynamicBufferAttribute( array, itemSize ) {
+function Float64BufferAttribute( array, itemSize ) {
 
-	console.warn( 'THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead.' );
-	return new BufferAttribute( array, itemSize ).setDynamic( true );
+	BufferAttribute.call( this, new Float64Array( array ), itemSize );
 
 }
 
+Float64BufferAttribute.prototype = Object.create( BufferAttribute.prototype );
+Float64BufferAttribute.prototype.constructor = Float64BufferAttribute;
+
+//
 
 export {
-  DynamicBufferAttribute,
-  Float64Attribute,
-  Float32Attribute,
-  Uint32Attribute,
-  Int32Attribute,
-  Uint16Attribute,
-  Int16Attribute,
-  Uint8ClampedAttribute,
-  Uint8Attribute,
-  Int8Attribute,
-  BufferAttribute
+	Float64BufferAttribute,
+	Float32BufferAttribute,
+	Uint32BufferAttribute,
+	Int32BufferAttribute,
+	Uint16BufferAttribute,
+	Int16BufferAttribute,
+	Uint8ClampedBufferAttribute,
+	Uint8BufferAttribute,
+	Int8BufferAttribute,
+	BufferAttribute
 };

+ 7 - 7
src/core/BufferGeometry.js

@@ -1,7 +1,7 @@
 import { Vector3 } from '../math/Vector3';
 import { Box3 } from '../math/Box3';
 import { EventDispatcher } from './EventDispatcher';
-import { BufferAttribute, Float32Attribute } from './BufferAttribute';
+import { BufferAttribute, Float32BufferAttribute } from './BufferAttribute';
 import { Sphere } from '../math/Sphere';
 import { DirectGeometry } from './DirectGeometry';
 import { Object3D } from './Object3D';
@@ -296,15 +296,15 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
 
 		if ( object.isPoints || object.isLine ) {
 
-			var positions = new Float32Attribute( geometry.vertices.length * 3, 3 );
-			var colors = new Float32Attribute( geometry.colors.length * 3, 3 );
+			var positions = new Float32BufferAttribute( geometry.vertices.length * 3, 3 );
+			var colors = new Float32BufferAttribute( geometry.colors.length * 3, 3 );
 
 			this.addAttribute( 'position', positions.copyVector3sArray( geometry.vertices ) );
 			this.addAttribute( 'color', colors.copyColorsArray( geometry.colors ) );
 
 			if ( geometry.lineDistances && geometry.lineDistances.length === geometry.vertices.length ) {
 
-				var lineDistances = new Float32Attribute( geometry.lineDistances.length, 1 );
+				var lineDistances = new Float32BufferAttribute( geometry.lineDistances.length, 1 );
 
 				this.addAttribute( 'lineDistance', lineDistances.copyArray( geometry.lineDistances ) );
 
@@ -527,7 +527,7 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
 
 				var morphTarget = morphTargets[ i ];
 
-				var attribute = new Float32Attribute( morphTarget.length * 3, 3 );
+				var attribute = new Float32BufferAttribute( morphTarget.length * 3, 3 );
 
 				array.push( attribute.copyVector3sArray( morphTarget ) );
 
@@ -541,14 +541,14 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
 
 		if ( geometry.skinIndices.length > 0 ) {
 
-			var skinIndices = new Float32Attribute( geometry.skinIndices.length * 4, 4 );
+			var skinIndices = new Float32BufferAttribute( geometry.skinIndices.length * 4, 4 );
 			this.addAttribute( 'skinIndex', skinIndices.copyVector4sArray( geometry.skinIndices ) );
 
 		}
 
 		if ( geometry.skinWeights.length > 0 ) {
 
-			var skinWeights = new Float32Attribute( geometry.skinWeights.length * 4, 4 );
+			var skinWeights = new Float32BufferAttribute( geometry.skinWeights.length * 4, 4 );
 			this.addAttribute( 'skinWeight', skinWeights.copyVector4sArray( geometry.skinWeights ) );
 
 		}

+ 2 - 2
src/extras/helpers/ArrowHelper.js

@@ -17,7 +17,7 @@
 import { Vector3 } from '../../math/Vector3';
 import { Object3D } from '../../core/Object3D';
 import { CylinderBufferGeometry } from '../../geometries/CylinderBufferGeometry';
-import { Float32Attribute } from '../../core/BufferAttribute';
+import { Float32BufferAttribute } from '../../core/BufferAttribute';
 import { BufferGeometry } from '../../core/BufferGeometry';
 import { MeshBasicMaterial } from '../../materials/MeshBasicMaterial';
 import { Mesh } from '../../objects/Mesh';
@@ -25,7 +25,7 @@ import { LineBasicMaterial } from '../../materials/LineBasicMaterial';
 import { Line } from '../../objects/Line';
 
 var lineGeometry = new BufferGeometry();
-lineGeometry.addAttribute( 'position', new Float32Attribute( [ 0, 0, 0, 0, 1, 0 ], 3 ) );
+lineGeometry.addAttribute( 'position', new Float32BufferAttribute( [ 0, 0, 0, 0, 1, 0 ], 3 ) );
 
 var coneGeometry = new CylinderBufferGeometry( 0, 0.5, 1, 5, 1 );
 coneGeometry.translate( 0, - 0.5, 0 );

+ 3 - 3
src/extras/helpers/DirectionalLightHelper.js

@@ -1,7 +1,7 @@
 import { Vector3 } from '../../math/Vector3';
 import { Object3D } from '../../core/Object3D';
 import { Line } from '../../objects/Line';
-import { Float32Attribute } from '../../core/BufferAttribute';
+import { Float32BufferAttribute } from '../../core/BufferAttribute';
 import { BufferGeometry } from '../../core/BufferGeometry';
 import { LineBasicMaterial } from '../../materials/LineBasicMaterial';
 
@@ -24,7 +24,7 @@ function DirectionalLightHelper( light, size ) {
 	if ( size === undefined ) size = 1;
 
 	var geometry = new BufferGeometry();
-	geometry.addAttribute( 'position', new Float32Attribute( [
+	geometry.addAttribute( 'position', new Float32BufferAttribute( [
 		- size,   size, 0,
 		  size,   size, 0,
 		  size, - size, 0,
@@ -37,7 +37,7 @@ function DirectionalLightHelper( light, size ) {
 	this.add( new Line( geometry, material ) );
 
 	geometry = new BufferGeometry();
-	geometry.addAttribute( 'position', new Float32Attribute( [ 0, 0, 0, 0, 0, 1 ], 3 ) );
+	geometry.addAttribute( 'position', new Float32BufferAttribute( [ 0, 0, 0, 0, 0, 1 ], 3 ) );
 
 	this.add( new Line( geometry, material ));
 

+ 2 - 2
src/extras/helpers/FaceNormalsHelper.js

@@ -2,7 +2,7 @@ import { Matrix3 } from '../../math/Matrix3';
 import { Vector3 } from '../../math/Vector3';
 import { LineSegments } from '../../objects/LineSegments';
 import { LineBasicMaterial } from '../../materials/LineBasicMaterial';
-import { Float32Attribute } from '../../core/BufferAttribute';
+import { Float32BufferAttribute } from '../../core/BufferAttribute';
 import { BufferGeometry } from '../../core/BufferGeometry';
 
 /**
@@ -42,7 +42,7 @@ function FaceNormalsHelper( object, size, hex, linewidth ) {
 
 	var geometry = new BufferGeometry();
 
-	var positions = new Float32Attribute( nNormals * 2 * 3, 3 );
+	var positions = new Float32BufferAttribute( nNormals * 2 * 3, 3 );
 
 	geometry.addAttribute( 'position', positions );
 

+ 3 - 3
src/extras/helpers/GridHelper.js

@@ -1,7 +1,7 @@
 import { LineSegments } from '../../objects/LineSegments';
 import { VertexColors } from '../../constants';
 import { LineBasicMaterial } from '../../materials/LineBasicMaterial';
-import { Float32Attribute } from '../../core/BufferAttribute';
+import { Float32BufferAttribute } from '../../core/BufferAttribute';
 import { BufferGeometry } from '../../core/BufferGeometry';
 import { Color } from '../../math/Color';
 
@@ -34,8 +34,8 @@ function GridHelper( size, divisions, color1, color2 ) {
 	}
 
 	var geometry = new BufferGeometry();
-	geometry.addAttribute( 'position', new Float32Attribute( vertices, 3 ) );
-	geometry.addAttribute( 'color', new Float32Attribute( colors, 3 ) );
+	geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+	geometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );
 
 	var material = new LineBasicMaterial( { vertexColors: VertexColors } );
 

+ 2 - 2
src/extras/helpers/SpotLightHelper.js

@@ -2,7 +2,7 @@ import { Vector3 } from '../../math/Vector3';
 import { Object3D } from '../../core/Object3D';
 import { LineSegments } from '../../objects/LineSegments';
 import { LineBasicMaterial } from '../../materials/LineBasicMaterial';
-import { Float32Attribute } from '../../core/BufferAttribute';
+import { Float32BufferAttribute } from '../../core/BufferAttribute';
 import { BufferGeometry } from '../../core/BufferGeometry';
 
 /**
@@ -43,7 +43,7 @@ function SpotLightHelper( light ) {
 
 	}
 
-	geometry.addAttribute( 'position', new Float32Attribute( positions, 3 ) );
+	geometry.addAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
 
 	var material = new LineBasicMaterial( { fog: false } );
 

+ 2 - 2
src/extras/helpers/VertexNormalsHelper.js

@@ -2,7 +2,7 @@ import { Matrix3 } from '../../math/Matrix3';
 import { Vector3 } from '../../math/Vector3';
 import { LineSegments } from '../../objects/LineSegments';
 import { LineBasicMaterial } from '../../materials/LineBasicMaterial';
-import { Float32Attribute } from '../../core/BufferAttribute';
+import { Float32BufferAttribute } from '../../core/BufferAttribute';
 import { BufferGeometry } from '../../core/BufferGeometry';
 
 /**
@@ -40,7 +40,7 @@ function VertexNormalsHelper( object, size, hex, linewidth ) {
 
 	var geometry = new BufferGeometry();
 
-	var positions = new Float32Attribute( nNormals * 2 * 3, 3 );
+	var positions = new Float32BufferAttribute( nNormals * 2 * 3, 3 );
 
 	geometry.addAttribute( 'position', positions );
 

+ 4 - 4
src/geometries/ParametricBufferGeometry.js

@@ -1,5 +1,5 @@
 import { BufferGeometry } from '../core/BufferGeometry';
-import { Float32Attribute, Uint16Attribute, Uint32Attribute } from '../core/BufferAttribute';
+import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
 
 /**
  * @author Mugen87 / https://github.com/Mugen87
@@ -72,9 +72,9 @@ function ParametricBufferGeometry( func, slices, stacks ) {
 
 	// build geometry
 
-	this.setIndex( ( indices.length > 65535 ? Uint32Attribute : Uint16Attribute )( indices, 1 ) );
-	this.addAttribute( 'position', Float32Attribute( vertices, 3 ) );
-	this.addAttribute( 'uv', Float32Attribute( uvs, 2 ) );
+	this.setIndex( new ( indices.length > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
+	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 
 	// generate normals
 

+ 4 - 4
src/geometries/PolyhedronBufferGeometry.js

@@ -1,5 +1,5 @@
 import { BufferGeometry } from '../core/BufferGeometry';
-import { Float32Attribute } from '../core/BufferAttribute';
+import { Float32BufferAttribute } from '../core/BufferAttribute';
 import { Vector3 } from '../math/Vector3';
 import { Vector2 } from '../math/Vector2';
 import { Sphere } from '../math/Sphere';
@@ -43,9 +43,9 @@ function PolyhedronBufferGeometry( vertices, indices, radius, detail ) {
 
 	// build non-indexed geometry
 
-	this.addAttribute( 'position', Float32Attribute( vertexBuffer, 3 ) );
-	this.addAttribute( 'normal', Float32Attribute( vertexBuffer.slice(), 3 ) );
-	this.addAttribute( 'uv', Float32Attribute( uvBuffer, 2 ) );
+	this.addAttribute( 'position', new Float32BufferAttribute( vertexBuffer, 3 ) );
+	this.addAttribute( 'normal', new Float32BufferAttribute( vertexBuffer.slice(), 3 ) );
+	this.addAttribute( 'uv', new Float32BufferAttribute( uvBuffer, 2 ) );
 	this.normalizeNormals();
 
 	this.boundingSphere = new Sphere( new Vector3(), radius );

+ 5 - 5
src/geometries/ShapeBufferGeometry.js

@@ -1,5 +1,5 @@
 import { BufferGeometry } from '../core/BufferGeometry';
-import { Float32Attribute, Uint16Attribute, Uint32Attribute } from '../core/BufferAttribute';
+import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
 import { ShapeUtils } from '../extras/ShapeUtils';
 
 /**
@@ -53,10 +53,10 @@ function ShapeBufferGeometry( shapes, curveSegments ) {
 
 	// build geometry
 
-	this.setIndex( ( indices.length > 65535 ? Uint32Attribute : Uint16Attribute )( indices, 1 ) );
-	this.addAttribute( 'position', Float32Attribute( vertices, 3 ) );
-	this.addAttribute( 'normal', Float32Attribute( normals, 3 ) );
-	this.addAttribute( 'uv', Float32Attribute( uvs, 2 ) );
+	this.setIndex( new ( indices.length > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
+	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
+	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 
 
 	// helper functions

+ 2 - 2
src/geometries/SphereBufferGeometry.js

@@ -1,7 +1,7 @@
 import { BufferGeometry } from '../core/BufferGeometry';
 import { Vector3 } from '../math/Vector3';
 import { Sphere } from '../math/Sphere';
-import { Uint16Attribute, Uint32Attribute, BufferAttribute } from '../core/BufferAttribute';
+import { Uint16BufferAttribute, Uint32BufferAttribute, BufferAttribute } from '../core/BufferAttribute';
 
 /**
  * @author benaadams / https://twitter.com/ben_a_adams
@@ -93,7 +93,7 @@ function SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart,
 
 	}
 
-	this.setIndex( new ( positions.count > 65535 ? Uint32Attribute : Uint16Attribute )( indices, 1 ) );
+	this.setIndex( new ( positions.count > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
 	this.addAttribute( 'position', positions );
 	this.addAttribute( 'normal', normals );
 	this.addAttribute( 'uv', uvs );

+ 5 - 5
src/geometries/TubeBufferGeometry.js

@@ -1,5 +1,5 @@
 import { BufferGeometry } from '../core/BufferGeometry';
-import { Float32Attribute, Uint16Attribute, Uint32Attribute } from '../core/BufferAttribute';
+import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
 import { Vector2 } from '../math/Vector2';
 import { Vector3 } from '../math/Vector3';
 
@@ -58,10 +58,10 @@ function TubeBufferGeometry( path, tubularSegments, radius, radialSegments, clos
 
 	// build geometry
 
-	this.setIndex( ( indices.length > 65535 ? Uint32Attribute : Uint16Attribute )( indices, 1 ) );
-	this.addAttribute( 'position', Float32Attribute( vertices, 3 ) );
-	this.addAttribute( 'normal', Float32Attribute( normals, 3 ) );
-	this.addAttribute( 'uv', Float32Attribute( uvs, 2 ) );
+	this.setIndex( new ( indices.length > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
+	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
+	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
+	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 
 	// functions