浏览代码

Replaced Math.max.apply( Max, ... ) with setIndexArray(). See #10603.

Mr.doob 8 年之前
父节点
当前提交
0afa7a9363

+ 1 - 1
examples/js/loaders/AssimpJSONLoader.js

@@ -125,7 +125,7 @@ THREE.AssimpJSONLoader.prototype = {
 
 
 		}
 		}
 
 
-		geometry.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? THREE.Uint32BufferAttribute : THREE.Uint16BufferAttribute )( indices, 1 ) );
+		geometry.setIndexArray( indices );
 		geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
 		geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
 
 
 		if ( normals.length > 0 ) {
 		if ( normals.length > 0 ) {

+ 1 - 9
examples/js/loaders/FBXLoader.js

@@ -263,15 +263,7 @@
 
 
 				if ( geoNode.indices !== undefined && geoNode.indices.length > 0 ) {
 				if ( geoNode.indices !== undefined && geoNode.indices.length > 0 ) {
 
 
-					if ( Math.max.apply( Math, geoNode.indices ) > 65535 ) {
-
-						tmpGeo.setIndex( new THREE.BufferAttribute( new Uint32Array( geoNode.indices ), 1 ) );
-
-					} else {
-
-						tmpGeo.setIndex( new THREE.BufferAttribute( new Uint16Array( geoNode.indices ), 1 ) );
-
-					}
+					tmpGeo.setIndexArray( geoNode.indices );
 
 
 				}
 				}
 
 

+ 1 - 1
examples/js/loaders/MMDLoader.js

@@ -1477,7 +1477,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 
 	var initGeometry = function () {
 	var initGeometry = function () {
 
 
-		geometry.setIndex( new ( Math.max.apply( Math, buffer.indices ) > 65535 ? THREE.Uint32BufferAttribute : THREE.Uint16BufferAttribute )( buffer.indices, 1 ) );
+		geometry.setIndexArray( buffer.indices );
 		geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( buffer.vertices, 3 ) );
 		geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( buffer.vertices, 3 ) );
 		geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( buffer.normals, 3 ) );
 		geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( buffer.normals, 3 ) );
 		geometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( buffer.uvs, 2 ) );
 		geometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( buffer.uvs, 2 ) );

+ 4 - 1
examples/js/loaders/PLYLoader.js

@@ -313,8 +313,11 @@ THREE.PLYLoader.prototype = {
 			// mandatory buffer data
 			// mandatory buffer data
 
 
 			if ( buffer.indices.length > 0 ) {
 			if ( buffer.indices.length > 0 ) {
-				geometry.setIndex( new ( Math.max.apply( Math, buffer.indices ) > 65535 ? THREE.Uint32BufferAttribute : THREE.Uint16BufferAttribute )( buffer.indices, 1 ) );
+
+				geometry.setIndexArray( buffer.indices );
+
 			}
 			}
+
 			geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( buffer.vertices, 3 ) );
 			geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( buffer.vertices, 3 ) );
 
 
 			// optional buffer data
 			// optional buffer data

+ 1 - 1
src/core/BufferGeometry.js

@@ -514,7 +514,7 @@ BufferGeometry.prototype = {
 
 
 		if ( geometry.indices.length > 0 ) {
 		if ( geometry.indices.length > 0 ) {
 
 
-			var TypeArray = Math.max.apply( Math, geometry.indices ) > 65535 ? Uint32Array : Uint16Array;
+			var TypeArray = _Math.arrayMax( geometry.indices ) > 65535 ? Uint32Array : Uint16Array;
 			var indices = new TypeArray( geometry.indices.length * 3 );
 			var indices = new TypeArray( geometry.indices.length * 3 );
 			this.setIndex( new BufferAttribute( indices, 1 ).copyIndicesArray( geometry.indices ) );
 			this.setIndex( new BufferAttribute( indices, 1 ).copyIndicesArray( geometry.indices ) );
 
 

+ 2 - 2
src/geometries/BoxGeometry.js

@@ -32,7 +32,7 @@ BoxGeometry.prototype.constructor = BoxGeometry;
  * @author Mugen87 / https://github.com/Mugen87
  * @author Mugen87 / https://github.com/Mugen87
  */
  */
 
 
-import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
+import { Float32BufferAttribute } from '../core/BufferAttribute';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { Vector3 } from '../math/Vector3';
 import { Vector3 } from '../math/Vector3';
 
 
@@ -82,7 +82,7 @@ function BoxBufferGeometry( width, height, depth, widthSegments, heightSegments,
 
 
 	// build geometry
 	// build geometry
 
 
-	this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
+	this.setIndexArray( indices );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );

+ 2 - 2
src/geometries/CircleGeometry.js

@@ -29,7 +29,7 @@ CircleGeometry.prototype.constructor = CircleGeometry;
  * @author Mugen87 / https://github.com/Mugen87
  * @author Mugen87 / https://github.com/Mugen87
  */
  */
 
 
-import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
+import { Float32BufferAttribute } from '../core/BufferAttribute';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { Vector3 } from '../math/Vector3';
 import { Vector3 } from '../math/Vector3';
 import { Vector2 } from '../math/Vector2';
 import { Vector2 } from '../math/Vector2';
@@ -106,7 +106,7 @@ function CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) {
 
 
 	// build geometry
 	// build geometry
 
 
-	this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
+	this.setIndexArray( indices );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );

+ 2 - 2
src/geometries/CylinderGeometry.js

@@ -33,7 +33,7 @@ CylinderGeometry.prototype.constructor = CylinderGeometry;
  * @author Mugen87 / https://github.com/Mugen87
  * @author Mugen87 / https://github.com/Mugen87
  */
  */
 
 
-import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
+import { Float32BufferAttribute } from '../core/BufferAttribute';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { Vector3 } from '../math/Vector3';
 import { Vector3 } from '../math/Vector3';
 import { Vector2 } from '../math/Vector2';
 import { Vector2 } from '../math/Vector2';
@@ -96,7 +96,7 @@ function CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments
 
 
 	// build geometry
 	// build geometry
 
 
-	this.setIndex( new ( Math.max.apply( Math, indices ) ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
+	this.setIndexArray( indices );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );

+ 3 - 3
src/geometries/LatheGeometry.js

@@ -34,7 +34,7 @@ function LatheGeometry( points, segments, phiStart, phiLength ) {
 LatheGeometry.prototype = Object.create( Geometry.prototype );
 LatheGeometry.prototype = Object.create( Geometry.prototype );
 LatheGeometry.prototype.constructor = LatheGeometry;
 LatheGeometry.prototype.constructor = LatheGeometry;
 
 
-import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
+import { Float32BufferAttribute } from '../core/BufferAttribute';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { Vector3 } from '../math/Vector3';
 import { Vector3 } from '../math/Vector3';
 import { Vector2 } from '../math/Vector2';
 import { Vector2 } from '../math/Vector2';
@@ -62,7 +62,7 @@ function LatheBufferGeometry( points, segments, phiStart, phiLength ) {
 	phiLength = phiLength || Math.PI * 2;
 	phiLength = phiLength || Math.PI * 2;
 
 
 	// clamp phiLength so it's in range of [ 0, 2PI ]
 	// clamp phiLength so it's in range of [ 0, 2PI ]
-	
+
 	phiLength = _Math.clamp( phiLength, 0, Math.PI * 2 );
 	phiLength = _Math.clamp( phiLength, 0, Math.PI * 2 );
 
 
 
 
@@ -135,7 +135,7 @@ function LatheBufferGeometry( points, segments, phiStart, phiLength ) {
 
 
 	// build geometry
 	// build geometry
 
 
-	this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
+	this.setIndexArray( indices );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 
 

+ 2 - 2
src/geometries/ParametricGeometry.js

@@ -35,7 +35,7 @@ ParametricGeometry.prototype.constructor = ParametricGeometry;
  */
  */
 
 
 import { BufferGeometry } from '../core/BufferGeometry';
 import { BufferGeometry } from '../core/BufferGeometry';
-import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
+import { Float32BufferAttribute } from '../core/BufferAttribute';
 
 
 function ParametricBufferGeometry( func, slices, stacks ) {
 function ParametricBufferGeometry( func, slices, stacks ) {
 
 
@@ -100,7 +100,7 @@ function ParametricBufferGeometry( func, slices, stacks ) {
 
 
 	// build geometry
 	// build geometry
 
 
-	this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
+	this.setIndexArray( indices );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 
 

+ 2 - 2
src/geometries/PlaneGeometry.js

@@ -32,7 +32,7 @@ PlaneGeometry.prototype.constructor = PlaneGeometry;
  * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
  * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
  */
  */
 
 
-import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
+import { Float32BufferAttribute } from '../core/BufferAttribute';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { BufferGeometry } from '../core/BufferGeometry';
 
 
 function PlaneBufferGeometry( width, height, widthSegments, heightSegments ) {
 function PlaneBufferGeometry( width, height, widthSegments, heightSegments ) {
@@ -112,7 +112,7 @@ function PlaneBufferGeometry( width, height, widthSegments, heightSegments ) {
 
 
 	// build geometry
 	// build geometry
 
 
-	this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
+	this.setIndexArray( indices );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );

+ 3 - 3
src/geometries/RingGeometry.js

@@ -30,7 +30,7 @@ RingGeometry.prototype.constructor = RingGeometry;
  * @author Mugen87 / https://github.com/Mugen87
  * @author Mugen87 / https://github.com/Mugen87
  */
  */
 
 
-import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
+import { Float32BufferAttribute } from '../core/BufferAttribute';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { Vector2 } from '../math/Vector2';
 import { Vector2 } from '../math/Vector2';
 import { Vector3 } from '../math/Vector3';
 import { Vector3 } from '../math/Vector3';
@@ -97,7 +97,7 @@ function RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegment
 			normals.push( 0, 0, 1 );
 			normals.push( 0, 0, 1 );
 
 
 			// uv
 			// uv
-			
+
 			uv.x = ( vertex.x / outerRadius + 1 ) / 2;
 			uv.x = ( vertex.x / outerRadius + 1 ) / 2;
 			uv.y = ( vertex.y / outerRadius + 1 ) / 2;
 			uv.y = ( vertex.y / outerRadius + 1 ) / 2;
 
 
@@ -137,7 +137,7 @@ function RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegment
 
 
 	// build geometry
 	// build geometry
 
 
-	this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
+	this.setIndexArray( indices );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );

+ 2 - 2
src/geometries/ShapeGeometry.js

@@ -35,7 +35,7 @@ ShapeGeometry.prototype.constructor = ShapeGeometry;
  * @author Mugen87 / https://github.com/Mugen87
  * @author Mugen87 / https://github.com/Mugen87
  */
  */
 
 
-import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
+import { Float32BufferAttribute } from '../core/BufferAttribute';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { ShapeUtils } from '../extras/ShapeUtils';
 import { ShapeUtils } from '../extras/ShapeUtils';
 
 
@@ -87,7 +87,7 @@ function ShapeBufferGeometry( shapes, curveSegments ) {
 
 
 	// build geometry
 	// build geometry
 
 
-	this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
+	this.setIndexArray( indices );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );

+ 2 - 2
src/geometries/SphereGeometry.js

@@ -32,7 +32,7 @@ SphereGeometry.prototype.constructor = SphereGeometry;
  * @author Mugen87 / https://github.com/Mugen87
  * @author Mugen87 / https://github.com/Mugen87
  */
  */
 
 
-import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
+import { Float32BufferAttribute } from '../core/BufferAttribute';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { Vector3 } from '../math/Vector3';
 import { Vector3 } from '../math/Vector3';
 
 
@@ -137,7 +137,7 @@ function SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart,
 
 
 	// build geometry
 	// build geometry
 
 
-	this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
+	this.setIndexArray( indices );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );

+ 2 - 2
src/geometries/TorusGeometry.js

@@ -31,7 +31,7 @@ TorusGeometry.prototype.constructor = TorusGeometry;
  * @author Mugen87 / https://github.com/Mugen87
  * @author Mugen87 / https://github.com/Mugen87
  */
  */
 
 
-import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
+import { Float32BufferAttribute } from '../core/BufferAttribute';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { Vector3 } from '../math/Vector3';
 import { Vector3 } from '../math/Vector3';
 
 
@@ -128,7 +128,7 @@ function TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc
 
 
 	// build geometry
 	// build geometry
 
 
-	this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
+	this.setIndexArray( indices );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );

+ 2 - 2
src/geometries/TorusKnotGeometry.js

@@ -34,7 +34,7 @@ TorusKnotGeometry.prototype.constructor = TorusKnotGeometry;
  * see: http://www.blackpawn.com/texts/pqtorus/
  * see: http://www.blackpawn.com/texts/pqtorus/
  */
  */
 
 
-import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
+import { Float32BufferAttribute } from '../core/BufferAttribute';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { Vector3 } from '../math/Vector3';
 import { Vector3 } from '../math/Vector3';
 import { Vector2 } from '../math/Vector2';
 import { Vector2 } from '../math/Vector2';
@@ -166,7 +166,7 @@ function TorusKnotBufferGeometry( radius, tube, tubularSegments, radialSegments,
 
 
 	// build geometry
 	// build geometry
 
 
-	this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
+	this.setIndexArray( indices );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );

+ 2 - 2
src/geometries/TubeGeometry.js

@@ -48,7 +48,7 @@ TubeGeometry.prototype.constructor = TubeGeometry;
  * @author Mugen87 / https://github.com/Mugen87
  * @author Mugen87 / https://github.com/Mugen87
  */
  */
 
 
-import { Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from '../core/BufferAttribute';
+import { Float32BufferAttribute } from '../core/BufferAttribute';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { BufferGeometry } from '../core/BufferGeometry';
 import { Vector2 } from '../math/Vector2';
 import { Vector2 } from '../math/Vector2';
 import { Vector3 } from '../math/Vector3';
 import { Vector3 } from '../math/Vector3';
@@ -101,7 +101,7 @@ function TubeBufferGeometry( path, tubularSegments, radius, radialSegments, clos
 
 
 	// build geometry
 	// build geometry
 
 
-	this.setIndex( new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
+	this.setIndexArray( indices );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );

+ 2 - 1
src/renderers/webgl/WebGLObjects.js

@@ -3,6 +3,7 @@
  */
  */
 
 
 import { Uint16BufferAttribute, Uint32BufferAttribute } from '../../core/BufferAttribute';
 import { Uint16BufferAttribute, Uint32BufferAttribute } from '../../core/BufferAttribute';
+import { _Math } from '../../math/Math';
 import { WebGLGeometries } from './WebGLGeometries';
 import { WebGLGeometries } from './WebGLGeometries';
 
 
 function WebGLObjects( gl, properties, info ) {
 function WebGLObjects( gl, properties, info ) {
@@ -234,7 +235,7 @@ function WebGLObjects( gl, properties, info ) {
 
 
 		// console.timeEnd( 'wireframe' );
 		// console.timeEnd( 'wireframe' );
 
 
-		var attribute = new ( Math.max.apply( Math, indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 );
+		var attribute = new ( _Math.arrayMax( indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 );
 
 
 		updateAttribute( attribute, gl.ELEMENT_ARRAY_BUFFER );
 		updateAttribute( attribute, gl.ELEMENT_ARRAY_BUFFER );