Browse Source

Fix: use mesh[0].getScene to avoid passing useless extra parameter

Thibault Durand 5 years ago
parent
commit
8782290555
1 changed files with 4 additions and 5 deletions
  1. 4 5
      serializers/src/OBJ/objSerializer.ts

+ 4 - 5
serializers/src/OBJ/objSerializer.ts

@@ -16,10 +16,9 @@ export class OBJExport {
      * @param materials defines if materials should be exported
      * @param materials defines if materials should be exported
      * @param matlibname defines the name of the associated mtl file
      * @param matlibname defines the name of the associated mtl file
      * @param globalposition defines if the exported positions are globals or local to the exported mesh
      * @param globalposition defines if the exported positions are globals or local to the exported mesh
-     * @param sceneUsesRightHandedSystem defines if the babylon scene is right handed, in this case the exported obj X vertices won't be inverted
      * @returns the OBJ content
      * @returns the OBJ content
      */
      */
-    public static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean, sceneUsesRightHandedSystem?: boolean): string {
+    public static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string {
         const output: string[] = [];
         const output: string[] = [];
         let v = 1;
         let v = 1;
         if (materials) {
         if (materials) {
@@ -68,9 +67,9 @@ export class OBJExport {
             }
             }
 
 
             for (var i = 0; i < trunkVerts.length; i += 3) {
             for (var i = 0; i < trunkVerts.length; i += 3) {
-                // Babylon default is left handed, while OBJ default is right handed
-                // By default we serialize in OBJ inverting the X vertices
-                if (sceneUsesRightHandedSystem) {
+                // Babylon.js default is left handed, while OBJ default is right handed
+                // Need to invert X vertices unless Babylon is set to use a right handed system
+                if (mesh[0].getScene().useRightHandedSystem) {
                     output.push("v " + trunkVerts[i] + " " + trunkVerts[i + 1] + " " + trunkVerts[i + 2]);
                     output.push("v " + trunkVerts[i] + " " + trunkVerts[i + 1] + " " + trunkVerts[i + 2]);
                 } else {
                 } else {
                     output.push("v " + -trunkVerts[i] + " " + trunkVerts[i + 1] + " " + trunkVerts[i + 2]);
                     output.push("v " + -trunkVerts[i] + " " + trunkVerts[i + 1] + " " + trunkVerts[i + 2]);