浏览代码

OBJLoader: Only add color attribute if necessary.

Mugen87 4 年之前
父节点
当前提交
e72497fbad
共有 2 个文件被更改,包括 2 次插入2 次删除
  1. 1 1
      examples/js/loaders/OBJLoader.js
  2. 1 1
      examples/jsm/loaders/OBJLoader.js

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

@@ -875,7 +875,7 @@ THREE.OBJLoader = ( function () {
 
 
 					buffergeometry.setAttribute( 'position', new THREE.Float32BufferAttribute( state.vertices, 3 ) );
 					buffergeometry.setAttribute( 'position', new THREE.Float32BufferAttribute( state.vertices, 3 ) );
 
 
-					if ( state.colors.length > 0 ) {
+					if ( state.colors.length > 0 && state.colors[ 0 ] !== undefined ) {
 
 
 						buffergeometry.setAttribute( 'color', new THREE.Float32BufferAttribute( state.colors, 3 ) );
 						buffergeometry.setAttribute( 'color', new THREE.Float32BufferAttribute( state.colors, 3 ) );
 						material.vertexColors = true;
 						material.vertexColors = true;

+ 1 - 1
examples/jsm/loaders/OBJLoader.js

@@ -891,7 +891,7 @@ var OBJLoader = ( function () {
 
 
 					buffergeometry.setAttribute( 'position', new Float32BufferAttribute( state.vertices, 3 ) );
 					buffergeometry.setAttribute( 'position', new Float32BufferAttribute( state.vertices, 3 ) );
 
 
-					if ( state.colors.length > 0 ) {
+					if ( state.colors.length > 0 && state.colors[ 0 ] !== undefined ) {
 
 
 						buffergeometry.setAttribute( 'color', new Float32BufferAttribute( state.colors, 3 ) );
 						buffergeometry.setAttribute( 'color', new Float32BufferAttribute( state.colors, 3 ) );
 						material.vertexColors = true;
 						material.vertexColors = true;