Ver Fonte

Merge pull request #20498 from gkjohnson/obj-loader-normals-fix

Fix OBJLoader not generating normals when the file does not describe …
Mr.doob há 4 anos atrás
pai
commit
62389f26f9
2 ficheiros alterados com 2 adições e 16 exclusões
  1. 1 8
      examples/js/loaders/OBJLoader.js
  2. 1 8
      examples/jsm/loaders/OBJLoader.js

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

@@ -61,7 +61,6 @@ THREE.OBJLoader = ( function () {
 						normals: [],
 						colors: [],
 						uvs: [],
-						hasNormalIndices: false,
 						hasUVIndices: false
 					},
 					materials: [],
@@ -340,8 +339,6 @@ THREE.OBJLoader = ( function () {
 
 					this.addNormal( ia, ib, ic );
 
-					this.object.geometry.hasNormalIndices = true;
-
 				} else {
 
 					this.addFaceNormal( ia, ib, ic );
@@ -729,11 +726,7 @@ THREE.OBJLoader = ( function () {
 
 				buffergeometry.setAttribute( 'position', new THREE.Float32BufferAttribute( geometry.vertices, 3 ) );
 
-				if ( geometry.hasNormalIndices === true ) {
-
-					buffergeometry.setAttribute( 'normal', new THREE.Float32BufferAttribute( geometry.normals, 3 ) );
-
-				}
+				buffergeometry.setAttribute( 'normal', new THREE.Float32BufferAttribute( geometry.normals, 3 ) );
 
 				if ( geometry.colors.length > 0 ) {
 

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

@@ -75,7 +75,6 @@ var OBJLoader = ( function () {
 						normals: [],
 						colors: [],
 						uvs: [],
-						hasNormalIndices: false,
 						hasUVIndices: false
 					},
 					materials: [],
@@ -354,8 +353,6 @@ var OBJLoader = ( function () {
 
 					this.addNormal( ia, ib, ic );
 
-					this.object.geometry.hasNormalIndices = true;
-
 				} else {
 
 					this.addFaceNormal( ia, ib, ic );
@@ -743,11 +740,7 @@ var OBJLoader = ( function () {
 
 				buffergeometry.setAttribute( 'position', new Float32BufferAttribute( geometry.vertices, 3 ) );
 
-				if ( geometry.hasNormalIndices === true ) {
-
-					buffergeometry.setAttribute( 'normal', new Float32BufferAttribute( geometry.normals, 3 ) );
-
-				}
+				buffergeometry.setAttribute( 'normal', new Float32BufferAttribute( geometry.normals, 3 ) );
 
 				if ( geometry.colors.length > 0 ) {