瀏覽代碼

Merge pull request #9331 from aWeirdo/patch-2

Update stlSerializer.ts
David Catuhe 4 年之前
父節點
當前提交
8ea0f3d15e
共有 2 個文件被更改,包括 6 次插入2 次删除
  1. 1 0
      dist/preview release/what's new.md
  2. 5 2
      serializers/src/stl/stlSerializer.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -164,6 +164,7 @@
 - Added support for glTF Skins to glTF serializer ([Drigax](https://github.com/Drigax))
 - Added support for glTF Morph Target serialization ([Drigax](https://github.com/Drigax))
 - Fixed several bugs in stlSerializer ([aWeirdo](https://github.com/aWeirdo))
+- Added param `doNotBakeTransform` to `stlSerializer.CreateSTL` ([aWeirdo](https://github.com/aWeirdo))
 
 ### Navigation
 

+ 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() || [];