瀏覽代碼

implement pr feedback

Kyle Belfort 5 年之前
父節點
當前提交
b3b2e9e497

+ 4 - 5
nodeEditor/src/diagram/graphCanvas.tsx

@@ -233,16 +233,15 @@ export class GraphCanvasComponent extends React.Component<IGraphCanvasComponentP
         }, false);     
 
         // Store additional data to serialization object
-        this.props.globalState.storeEditorData = (editorData, frameId) => {
-            editorData.zoom = this.zoom;
+        this.props.globalState.storeEditorData = (editorData, graphFrame) => {
             editorData.x = this.x;
             editorData.y = this.y;
 
             editorData.frames = [];
-            if (typeof(frameId) === "number") {
-                const frame = this._frames.find(frame =>  frame.id === frameId)
-                editorData.frames.push(frame!.serialize());
+            if (graphFrame) {
+                editorData.frames.push(graphFrame!.serialize());
             } else {
+                editorData.zoom = this.zoom;
                 for (var frame of this._frames) {
                     editorData.frames.push(frame.serialize());
                 }

+ 1 - 2
nodeEditor/src/diagram/graphFrame.ts

@@ -1288,7 +1288,6 @@ export class GraphFrame {
 
     public serialize(): IFrameData {
         return {
-            id: this._id,
             x: this._x,
             y: this._y,
             width: this._width,
@@ -1303,7 +1302,7 @@ export class GraphFrame {
 
     public export() {
         const state = this._ownerCanvas.globalState;
-        const json = SerializationTools.Serialize(state.nodeMaterial, state, this.nodes.map(n => n.block), this._id);
+        const json = SerializationTools.Serialize(state.nodeMaterial, state, this.nodes.map(n => n.block), this);
         StringTools.DownloadAsFile(state.hostDocument, json, this._name + ".json");
     }
 

+ 1 - 1
nodeEditor/src/globalState.ts

@@ -56,7 +56,7 @@ export class GlobalState {
     directionalLight0: boolean;
     directionalLight1: boolean;
     controlCamera: boolean;
-    storeEditorData: (serializationObject: any, frameId?: number) => void;
+    storeEditorData: (serializationObject: any, frame?: Nullable<GraphFrame>) => void;
     _mode: NodeMaterialModes;
 
     /** Gets the mode */

+ 0 - 1
nodeEditor/src/nodeLocationInfo.ts

@@ -5,7 +5,6 @@ export interface INodeLocationInfo {
 }
 
 export interface IFrameData {
-    id: number;
     x: number;
     y: number;
     width: number;

+ 6 - 4
nodeEditor/src/serializationTools.ts

@@ -3,10 +3,12 @@ import { GlobalState } from './globalState';
 import { Texture } from 'babylonjs/Materials/Textures/texture';
 import { DataStorage } from 'babylonjs/Misc/dataStorage';
 import { NodeMaterialBlock } from 'babylonjs/Materials/Node/nodeMaterialBlock';
+import { Nullable } from 'babylonjs/types';
+import { GraphFrame } from './diagram/graphFrame';
 
 export class SerializationTools {
 
-    public static UpdateLocations(material: NodeMaterial, globalState: GlobalState, selectedBlocks?: NodeMaterialBlock[], frameId?: number) {
+    public static UpdateLocations(material: NodeMaterial, globalState: GlobalState, selectedBlocks?: NodeMaterialBlock[], frame?: Nullable<GraphFrame>) {
         material.editorData = {
             locations: []
         };
@@ -28,14 +30,14 @@ export class SerializationTools {
             });
         }
 
-        globalState.storeEditorData(material.editorData, frameId);
+        globalState.storeEditorData(material.editorData, frame);
     }
 
-    public static Serialize(material: NodeMaterial, globalState: GlobalState, selectedBlocks?: NodeMaterialBlock[], frameId?: number) {
+    public static Serialize(material: NodeMaterial, globalState: GlobalState, selectedBlocks?: NodeMaterialBlock[], frame?: Nullable<GraphFrame>) {
         let bufferSerializationState = Texture.SerializeBuffers;
         Texture.SerializeBuffers = DataStorage.ReadBoolean("EmbedTextures", true);
 
-        this.UpdateLocations(material, globalState, selectedBlocks, frameId);
+        this.UpdateLocations(material, globalState, selectedBlocks, frame);
 
         let serializationObject = material.serialize(selectedBlocks);