Browse Source

OBJLoader & OBJMTLLoader: Fixed sharing of Vector2 & Vector3 objects by UVs & normals.

Should bring the OBJ(MTL)Loader into compliance with #3762.
Alex Weiss 11 years ago
parent
commit
ca89f4654b
2 changed files with 12 additions and 12 deletions
  1. 6 6
      examples/js/loaders/OBJLoader.js
  2. 6 6
      examples/js/loaders/OBJMTLLoader.js

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

@@ -63,9 +63,9 @@ THREE.OBJLoader.prototype = {
   				parseInt( b ) - (face_offset + 1),
   				parseInt( c ) - (face_offset + 1),
   				[
-  					normals[ parseInt( normals_inds[ 0 ] ) - 1 ],
-  					normals[ parseInt( normals_inds[ 1 ] ) - 1 ],
-  					normals[ parseInt( normals_inds[ 2 ] ) - 1 ]
+  					normals[ parseInt( normals_inds[ 0 ] ) - 1 ].clone(),
+  					normals[ parseInt( normals_inds[ 1 ] ) - 1 ].clone(),
+  					normals[ parseInt( normals_inds[ 2 ] ) - 1 ].clone()
   				]
   			) );
       }
@@ -73,9 +73,9 @@ THREE.OBJLoader.prototype = {
     
     function add_uvs( a, b, c ) {
 			geometry.faceVertexUvs[ 0 ].push( [
-				uvs[ parseInt( a ) - 1 ],
-				uvs[ parseInt( b ) - 1 ],
-				uvs[ parseInt( c ) - 1 ]
+				uvs[ parseInt( a ) - 1 ].clone(),
+				uvs[ parseInt( b ) - 1 ].clone(),
+				uvs[ parseInt( c ) - 1 ].clone()
 			] );
     }
     

+ 6 - 6
examples/js/loaders/OBJMTLLoader.js

@@ -133,9 +133,9 @@ THREE.OBJMTLLoader.prototype = {
   				parseInt( b ) - (face_offset + 1),
   				parseInt( c ) - (face_offset + 1),
   				[
-  					normals[ parseInt( normals_inds[ 0 ] ) - 1 ],
-  					normals[ parseInt( normals_inds[ 1 ] ) - 1 ],
-  					normals[ parseInt( normals_inds[ 2 ] ) - 1 ]
+  					normals[ parseInt( normals_inds[ 0 ] ) - 1 ].clone(),
+  					normals[ parseInt( normals_inds[ 1 ] ) - 1 ].clone(),
+  					normals[ parseInt( normals_inds[ 2 ] ) - 1 ].clone()
   				]
   			) );
       }
@@ -143,9 +143,9 @@ THREE.OBJMTLLoader.prototype = {
     
     function add_uvs( a, b, c ) {
 			geometry.faceVertexUvs[ 0 ].push( [
-				uvs[ parseInt( a ) - 1 ],
-				uvs[ parseInt( b ) - 1 ],
-				uvs[ parseInt( c ) - 1 ]
+				uvs[ parseInt( a ) - 1 ].clone(),
+				uvs[ parseInt( b ) - 1 ].clone(),
+				uvs[ parseInt( c ) - 1 ].clone()
 			] );
     }