Browse Source

Add check for node type when excluding root node in glTF export

noalak 5 years ago
parent
commit
4055d62860
1 changed files with 17 additions and 7 deletions
  1. 17 7
      serializers/src/glTF/2.0/glTFExporter.ts

+ 17 - 7
serializers/src/glTF/2.0/glTFExporter.ts

@@ -1308,15 +1308,25 @@ export class _Exporter {
      * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
      * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
      */
      */
     private isNodeConvertingToLeftHanded(node: Node): boolean {
     private isNodeConvertingToLeftHanded(node: Node): boolean {
-        if (node instanceof TransformNode &&
-            (!node.position.equalsToFloats(0, 0, 0) ||
-            (!node.rotationQuaternion && node.rotation && (node.rotation.x != 0 || node.rotation.z != 0 || Math.abs(node.rotation.y - Math.PI) > Epsilon)) || // rotation Quaternion has priority over Vector3
-            (node.rotationQuaternion && !node.rotationQuaternion.equals(new Quaternion(0, 1, 0, 0))) ||
-            !node.scaling.equalsToFloats(1, 1, -1))) {
+        if (node instanceof TransformNode)
+        {
+            // TRS
+            if (!node.position.equalsToFloats(0, 0, 0) ||
+                (!node.rotationQuaternion && node.rotation && (node.rotation.x != 0 || node.rotation.z != 0 || Math.abs(node.rotation.y - Math.PI) > Epsilon)) || // rotation Quaternion has priority over Vector3
+                (node.rotationQuaternion && !node.rotationQuaternion.equals(new Quaternion(0, 1, 0, 0))) ||
+                !node.scaling.equalsToFloats(1, 1, -1)) {
                 return false;
                 return false;
-        }
+            }
+            
+            // Geometry
+            if ((node instanceof Mesh && node.geometry !== null) ||
+                (node instanceof InstancedMesh && node._masterMesh instanceof Mesh && node._masterMesh.geometry !== null)) {
+                return false;
+            }
 
 
-        return true;
+            return true;
+        }
+        return false;
     }
     }
 
 
     /**
     /**