Browse Source

Update stlSerializer.ts

aWeirdo 4 years ago
parent
commit
5ce679aa95
1 changed files with 5 additions and 2 deletions
  1. 5 2
      serializers/src/stl/stlSerializer.ts

+ 5 - 2
serializers/src/stl/stlSerializer.ts

@@ -13,9 +13,10 @@ export class STLExport {
     * @param fileName changes the downloads fileName.
     * @param binary changes the STL to a binary type.
     * @param isLittleEndian toggle for binary type exporter.
+    * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
     * @returns the STL as UTF8 string
     */
-    public static CreateSTL(meshes: Mesh[], download: boolean = true, fileName: string = 'stlmesh', binary: boolean = false, isLittleEndian: boolean = true): any {
+    public static CreateSTL(meshes: Mesh[], download: boolean = true, fileName: string = 'stlmesh', binary: boolean = false, isLittleEndian: boolean = true, doNotBakeTransform: boolean = false): any {
 
         //Binary support adapted from https://gist.github.com/paulkaplan/6d5f0ab2c7e8fdc68a61
 
@@ -70,7 +71,9 @@ export class STLExport {
 
         for (let i = 0; i < meshes.length; i++) {
             let mesh = meshes[i];
-            mesh.bakeCurrentTransformIntoVertices();
+            if (!doNotBakeTransform) {
+                mesh.bakeCurrentTransformIntoVertices();
+            }
             let vertices = mesh.getVerticesData(VertexBuffer.PositionKind) || [];
             let indices = mesh.getIndices() || [];