浏览代码

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js into master

David Catuhe 4 年之前
父节点
当前提交
c0c0a5c862

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

@@ -160,6 +160,7 @@
 - Added support for KHR_materials_unlit to glTF serializer ([Popov72](https://github.com/Popov72))
 - Added support for KHR_materials_unlit to glTF serializer ([Popov72](https://github.com/Popov72))
 - Added support for glTF Skins to glTF serializer ([Drigax](https://github.com/Drigax))
 - 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))
 - Added support for glTF Morph Target serialization ([Drigax](https://github.com/Drigax))
+- Fixed several bugs in stlSerializer ([aWeirdo](https://github.com/aWeirdo))
 
 
 ### Navigation
 ### Navigation
 
 

+ 0 - 12
nodeEditor/src/diagram/graphFrame.ts

@@ -1377,18 +1377,6 @@ export class GraphFrame {
     }
     }
 
 
     public dispose() {
     public dispose() {
-        if(this.isCollapsed) {
-            while(this._nodes.length > 0) {
-                this._nodes[0].dispose();
-            }
-            this.isCollapsed = false;
-        }
-        else {
-            this._nodes.forEach(node => {
-                node.enclosingFrameId = -1;
-            });
-        }
-
         if (this._onSelectionChangedObserver) {
         if (this._onSelectionChangedObserver) {
             this._ownerCanvas.globalState.onSelectionChangedObservable.remove(this._onSelectionChangedObserver);
             this._ownerCanvas.globalState.onSelectionChangedObservable.remove(this._onSelectionChangedObserver);
         };
         };

+ 20 - 0
nodeEditor/src/graphEditor.tsx

@@ -202,6 +202,26 @@ export class GraphEditor extends React.Component<IGraphEditorProps, IGraphEditor
                 }
                 }
 
 
                 if (this._graphCanvas.selectedFrame) {
                 if (this._graphCanvas.selectedFrame) {
+                    var frame = this._graphCanvas.selectedFrame;
+                    
+                    if(frame.isCollapsed) {
+                        while(frame.nodes.length > 0) {
+                            let targetBlock = frame.nodes[0].block;
+                            this.props.globalState.nodeMaterial!.removeBlock(targetBlock);
+                            let blockIndex = this._blocks.indexOf(targetBlock);
+        
+                            if (blockIndex > -1) {
+                                this._blocks.splice(blockIndex, 1);
+                            }
+                            frame.nodes[0].dispose();            
+                        }
+                        frame.isCollapsed = false;
+                    }
+                    else {
+                        frame.nodes.forEach(node => {
+                            node.enclosingFrameId = -1;
+                        });
+                    }
                     this._graphCanvas.selectedFrame.dispose();
                     this._graphCanvas.selectedFrame.dispose();
                 }
                 }
 
 

+ 11 - 15
serializers/src/stl/stlSerializer.ts

@@ -12,23 +12,23 @@ export class STLExport {
     * @param download triggers the automatic download of the file.
     * @param download triggers the automatic download of the file.
     * @param fileName changes the downloads fileName.
     * @param fileName changes the downloads fileName.
     * @param binary changes the STL to a binary type.
     * @param binary changes the STL to a binary type.
-	* @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
 
 
         let getFaceData = function(indices: any, vertices: any, i: number) {
         let getFaceData = function(indices: any, vertices: any, i: number) {
             let id = [indices[i] * 3, indices[i + 1] * 3, indices[i + 2] * 3];
             let id = [indices[i] * 3, indices[i + 1] * 3, indices[i + 2] * 3];
             let v = [
             let v = [
-                new Vector3(vertices[id[0]], vertices[id[0] + 1], vertices[id[0] + 2]),
-                new Vector3(vertices[id[1]], vertices[id[1] + 1], vertices[id[1] + 2]),
-                new Vector3(vertices[id[2]], vertices[id[2] + 1], vertices[id[2] + 2])
+                new Vector3(vertices[id[0]], vertices[id[0] + 2], vertices[id[0] + 1]),
+                new Vector3(vertices[id[1]], vertices[id[1] + 2], vertices[id[1] + 1]),
+                new Vector3(vertices[id[2]], vertices[id[2] + 2], vertices[id[2] + 1])
             ];
             ];
             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();
+            let n = (Vector3.Cross(p3p2, p1p2)).normalize();
 
 
             return {v, n};
             return {v, n};
         };
         };
@@ -53,7 +53,7 @@ export class STLExport {
             for (let i = 0; i < meshes.length; i++) {
             for (let i = 0; i < meshes.length; i++) {
                 let mesh = meshes[i];
                 let mesh = meshes[i];
                 let indices = mesh.getIndices();
                 let indices = mesh.getIndices();
-                faceCount += indices ? indices.length : 0;
+                faceCount += indices ? indices.length / 3 : 0;
             }
             }
 
 
             let bufferSize = 84 + (50 * faceCount);
             let bufferSize = 84 + (50 * faceCount);
@@ -64,8 +64,8 @@ export class STLExport {
             data.setUint32(offset, faceCount, isLittleEndian);
             data.setUint32(offset, faceCount, isLittleEndian);
             offset += 4;
             offset += 4;
 
 
-        }else {
-            data = 'solid exportedMesh\r\n';
+        } else {
+            data = 'solid stlmesh\r\n';
         }
         }
 
 
         for (let i = 0; i < meshes.length; i++) {
         for (let i = 0; i < meshes.length; i++) {
@@ -83,7 +83,7 @@ export class STLExport {
                     offset = writeVector(data, offset, fd.v[1], isLittleEndian);
                     offset = writeVector(data, offset, fd.v[1], isLittleEndian);
                     offset = writeVector(data, offset, fd.v[2], isLittleEndian);
                     offset = writeVector(data, offset, fd.v[2], isLittleEndian);
                     offset += 2;
                     offset += 2;
-                }else {
+                } else {
                     data += 'facet normal ' + fd.n.x + ' ' + fd.n.y + ' ' + fd.n.z + '\r\n';
                     data += 'facet normal ' + fd.n.x + ' ' + fd.n.y + ' ' + fd.n.z + '\r\n';
                     data += '\touter loop\r\n';
                     data += '\touter loop\r\n';
                     data += '\t\tvertex ' + fd.v[0].x + ' ' + fd.v[0].y + ' ' + fd.v[0].z + '\r\n';
                     data += '\t\tvertex ' + fd.v[0].x + ' ' + fd.v[0].y + ' ' + fd.v[0].z + '\r\n';
@@ -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();
         }
         }

+ 2 - 2
src/Culling/ray.ts

@@ -696,7 +696,7 @@ Scene.prototype._internalPick = function (rayFunction: (world: Matrix) => Ray, p
 
 
         if (mesh.hasThinInstances && (mesh as Mesh).thinInstanceEnablePicking) {
         if (mesh.hasThinInstances && (mesh as Mesh).thinInstanceEnablePicking) {
             // first check if the ray intersects the whole bounding box/sphere of the mesh
             // first check if the ray intersects the whole bounding box/sphere of the mesh
-            let result = this._internalPickForMesh(pickingInfo, rayFunction, mesh, world, fastCheck, true, trianglePredicate);
+            let result = this._internalPickForMesh(pickingInfo, rayFunction, mesh, world, true, true, trianglePredicate);
             if (result) {
             if (result) {
                 if (onlyBoundingInfo) {
                 if (onlyBoundingInfo) {
                     // the user only asked for a bounding info check so we can return
                     // the user only asked for a bounding info check so we can return
@@ -755,7 +755,7 @@ Scene.prototype._internalMultiPick = function (rayFunction: (world: Matrix) => R
         let world = mesh.skeleton && mesh.skeleton.overrideMesh ? mesh.skeleton.overrideMesh.getWorldMatrix() : mesh.getWorldMatrix();
         let world = mesh.skeleton && mesh.skeleton.overrideMesh ? mesh.skeleton.overrideMesh.getWorldMatrix() : mesh.getWorldMatrix();
 
 
         if (mesh.hasThinInstances && (mesh as Mesh).thinInstanceEnablePicking) {
         if (mesh.hasThinInstances && (mesh as Mesh).thinInstanceEnablePicking) {
-            let result = this._internalPickForMesh(null, rayFunction, mesh, world, false, true, trianglePredicate);
+            let result = this._internalPickForMesh(null, rayFunction, mesh, world, true, true, trianglePredicate);
             if (result) {
             if (result) {
                 const tmpMatrix = TmpVectors.Matrix[1];
                 const tmpMatrix = TmpVectors.Matrix[1];
                 let thinMatrices = (mesh as Mesh).thinInstanceGetWorldMatrices();
                 let thinMatrices = (mesh as Mesh).thinInstanceGetWorldMatrices();