Browse Source

3DMLoader: Clean up (#25423)

* 3DMLoader: Clean up

* Update 3DMLoader.js

* Update 3DMLoader.js

* Revert materials comparison change

* Fix `elements`

* Update 3DMLoader.js

* Update 3DMLoader.js

* Update 3DMLoader.js

---------

Co-authored-by: Michael Herzog <[email protected]>
Levi Pesin 2 năm trước cách đây
mục cha
commit
f5989f759c
1 tập tin đã thay đổi với 8 bổ sung5 xóa
  1. 8 5
      examples/jsm/loaders/3DMLoader.js

+ 8 - 5
examples/jsm/loaders/3DMLoader.js

@@ -21,7 +21,8 @@ import {
 	LinearFilter,
 	ClampToEdgeWrapping,
 	RepeatWrapping,
-	TextureLoader
+	TextureLoader,
+	DoubleSide
 } from 'three';
 
 const _taskCache = new WeakMap();
@@ -189,6 +190,8 @@ class Rhino3dmLoader extends Loader {
 		mat.color.b = material.color.b;
 		mat.type = material.type;
 
+		const json = JSON.stringify( mat );
+
 		for ( let i = 0; i < this.materials.length; i ++ ) {
 
 			const m = this.materials[ i ];
@@ -200,7 +203,7 @@ class Rhino3dmLoader extends Loader {
 			_mat.color.b = m.color.b;
 			_mat.type = m.type;
 
-			if ( JSON.stringify( mat ) === JSON.stringify( _mat ) ) {
+			if ( JSON.stringify( _mat ) === json ) {
 
 				return m;
 
@@ -222,7 +225,7 @@ class Rhino3dmLoader extends Loader {
 				color: new Color( 1, 1, 1 ),
 				metalness: 0.8,
 				name: 'default',
-				side: 2
+				side: DoubleSide
 			} );
 
 		}
@@ -244,7 +247,7 @@ class Rhino3dmLoader extends Loader {
 		const mat = new MeshStandardMaterial( {
 			color: diffusecolor,
 			name: material.name,
-			side: 2,
+			side: DoubleSide,
 			transparent: material.transparency > 0 ? true : false,
 			opacity: 1.0 - material.transparency
 		} );
@@ -418,7 +421,7 @@ class Rhino3dmLoader extends Loader {
 					const xf = iRef.geometry.xform.array;
 
 					const matrix = new Matrix4();
-          			matrix.set( xf[ 0 ], xf[ 1 ], xf[ 2 ], xf[ 3 ], xf[ 4 ], xf[ 5 ], xf[ 6 ], xf[ 7 ], xf[ 8 ], xf[ 9 ], xf[ 10 ], xf[ 11 ], xf[ 12 ], xf[ 13 ], xf[ 14 ], xf[ 15 ] );
+					matrix.set( ...xf );
 
 					iRefObject.applyMatrix4( matrix );