Browse Source

Update stlSerializer.ts

Last minute changes..
Removed n vector3 negating & switched the input values as suggested.
Updated default fileName to match binary mesh name (which is always 'stlmesh')
Updated ASCII mesh name to match binary mesh name for consistency
And removed fileName check in download code as it is defaulted at beginning.
aWeirdo 4 năm trước cách đây
mục cha
commit
5c623a0e94

+ 4 - 8
serializers/src/stl/stlSerializer.ts

@@ -15,7 +15,7 @@ export class STLExport {
     * @param isLittleEndian toggle for binary type exporter.
     * @param isLittleEndian toggle for binary type exporter.
     * @returns the STL as UTF8 string
     * @returns the STL as UTF8 string
     */
     */
-    public static CreateSTL(meshes: Mesh[], download: boolean = true, fileName: string = 'STL_Mesh', binary: boolean = false, isLittleEndian: boolean = true): any {
+    public static CreateSTL(meshes: Mesh[], download: boolean = true, fileName: string = 'stlmesh', binary: boolean = false, isLittleEndian: boolean = true): any {
 
 
         //Binary support adapted from https://gist.github.com/paulkaplan/6d5f0ab2c7e8fdc68a61
         //Binary support adapted from https://gist.github.com/paulkaplan/6d5f0ab2c7e8fdc68a61
 
 
@@ -28,7 +28,7 @@ export class STLExport {
             ];
             ];
             let p1p2 = v[0].subtract(v[1]);
             let p1p2 = v[0].subtract(v[1]);
             let p3p2 = v[2].subtract(v[1]);
             let p3p2 = v[2].subtract(v[1]);
-            let n = (Vector3.Cross(p1p2, p3p2)).normalize().negateInPlace();
+            let n = (Vector3.Cross(p3p2, p1p2)).normalize();
 
 
             return {v, n};
             return {v, n};
         };
         };
@@ -65,7 +65,7 @@ export class STLExport {
             offset += 4;
             offset += 4;
 
 
         } else {
         } else {
-            data = 'solid exportedMesh\r\n';
+            data = 'solid stlmesh\r\n';
         }
         }
 
 
         for (let i = 0; i < meshes.length; i++) {
         for (let i = 0; i < meshes.length; i++) {
@@ -97,17 +97,13 @@ export class STLExport {
         }
         }
 
 
         if (!binary) {
         if (!binary) {
-            data += 'endsolid exportedMesh';
+            data += 'endsolid stlmesh';
         }
         }
 
 
         if (download) {
         if (download) {
             let a = document.createElement('a');
             let a = document.createElement('a');
             let blob = new Blob([data], {'type': 'application/octet-stream'});
             let blob = new Blob([data], {'type': 'application/octet-stream'});
             a.href = window.URL.createObjectURL(blob);
             a.href = window.URL.createObjectURL(blob);
-
-            if (!fileName) {
-                fileName = "STL_Mesh";
-            }
             a.download = fileName + ".stl";
             a.download = fileName + ".stl";
             a.click();
             a.click();
         }
         }