Kaynağa Gözat

fix the problem of CMPT file loaded incorrectly

fwang 3 yıl önce
ebeveyn
işleme
5ac46b9bca
1 değiştirilmiş dosya ile 11 ekleme ve 2 silme
  1. 11 2
      src/three/I3DMLoader.js

+ 11 - 2
src/three/I3DMLoader.js

@@ -1,5 +1,5 @@
 import { I3DMLoaderBase } from '../base/I3DMLoaderBase.js';
-import { DefaultLoadingManager, Matrix4, InstancedMesh, Vector3, Quaternion } from 'three';
+import { DefaultLoadingManager, Matrix4, InstancedMesh, Vector3, Quaternion,Euler } from 'three';
 import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
 
 const tempFwd = new Vector3();
@@ -201,7 +201,14 @@ export class I3DMLoader extends I3DMLoaderBase {
 
 							}
 
-							tempMat.compose( tempPos, tempQuat, tempSca );
+
+							const m = new Matrix4();
+							m.set(1.0, 0.0,  0.0, 0.0,
+								0.0, 0.0, -1.0, 0.0,
+								0.0, 1.0,  0.0, 0.0,
+								0.0, 0.0,  0.0, 1.0);
+							tempMat.compose( tempPos, tempQuat, tempSca ).multiply(m);
+							// tempMat.compose( tempPos, tempQuat, tempSca );
 
 							for ( let j = 0, l = instances.length; j < l; j ++ ) {
 
@@ -212,6 +219,8 @@ export class I3DMLoader extends I3DMLoaderBase {
 
 						}
 
+						model.scene.rotation.copy(new Euler(model.scene.rotation.x - Math.PI/2,model.scene.rotation.y,model.scene.rotation.z,'XYZ'))
+
 						model.batchTable = batchTable;
 						model.featureTable = featureTable;