瀏覽代碼

Fix OBJLoader not generating normals when the file does not describe any.

Garrett Johnson 4 年之前
父節點
當前提交
3bf981803a
共有 2 個文件被更改,包括 2 次插入16 次删除
  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: [],
 						normals: [],
 						colors: [],
 						colors: [],
 						uvs: [],
 						uvs: [],
-						hasNormalIndices: false,
 						hasUVIndices: false
 						hasUVIndices: false
 					},
 					},
 					materials: [],
 					materials: [],
@@ -340,8 +339,6 @@ THREE.OBJLoader = ( function () {
 
 
 					this.addNormal( ia, ib, ic );
 					this.addNormal( ia, ib, ic );
 
 
-					this.object.geometry.hasNormalIndices = true;
-
 				} else {
 				} else {
 
 
 					this.addFaceNormal( ia, ib, ic );
 					this.addFaceNormal( ia, ib, ic );
@@ -729,11 +726,7 @@ THREE.OBJLoader = ( function () {
 
 
 				buffergeometry.setAttribute( 'position', new THREE.Float32BufferAttribute( geometry.vertices, 3 ) );
 				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 ) {
 				if ( geometry.colors.length > 0 ) {
 
 

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

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