Преглед изворни кода

Correct detection of Uint32BufferAttribute for length of verticies

Brian Burke пре 8 година
родитељ
комит
441395277a

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

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

+ 1 - 1
src/geometries/PlaneGeometry.js

@@ -112,7 +112,7 @@ function PlaneBufferGeometry( width, height, widthSegments, heightSegments ) {
 
 	// build geometry
 
-	this.setIndex( new ( Math.max.apply( Math, indices ).length > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
+	this.setIndex( new ( Math.max.apply( Math, indices ) > 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 ) );

+ 1 - 1
src/geometries/TubeGeometry.js

@@ -101,7 +101,7 @@ function TubeBufferGeometry( path, tubularSegments, radius, radialSegments, clos
 
 	// build geometry
 
-	this.setIndex( new ( vertices.length > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 ) );
+	this.setIndex( new ( Math.max.apply( Math, indices ) > 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 ) );

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

@@ -235,7 +235,7 @@ function WebGLObjects( gl, properties, info ) {
 
 		// console.timeEnd( 'wireframe' );
 
-		var TypeArray = position.count > 65535 ? Uint32Array : Uint16Array;
+		var TypeArray = Math.max.apply( Math, indices ) > 65535 ? Uint32Array : Uint16Array;
 		var attribute = new BufferAttribute( new TypeArray( indices ), 1 );
 
 		updateAttribute( attribute, gl.ELEMENT_ARRAY_BUFFER );