|
@@ -3,16 +3,20 @@ import { GlobalState } from './globalState';
|
|
import { Texture } from 'babylonjs/Materials/Textures/texture';
|
|
import { Texture } from 'babylonjs/Materials/Textures/texture';
|
|
import { DataStorage } from 'babylonjs/Misc/dataStorage';
|
|
import { DataStorage } from 'babylonjs/Misc/dataStorage';
|
|
import { NodeMaterialBlock } from 'babylonjs/Materials/Node/nodeMaterialBlock';
|
|
import { NodeMaterialBlock } from 'babylonjs/Materials/Node/nodeMaterialBlock';
|
|
|
|
+import { Nullable } from 'babylonjs/types';
|
|
|
|
+import { GraphFrame } from './diagram/graphFrame';
|
|
|
|
|
|
export class SerializationTools {
|
|
export class SerializationTools {
|
|
|
|
|
|
- public static UpdateLocations(material: NodeMaterial, globalState: GlobalState) {
|
|
|
|
|
|
+ public static UpdateLocations(material: NodeMaterial, globalState: GlobalState, frame?: Nullable<GraphFrame>) {
|
|
material.editorData = {
|
|
material.editorData = {
|
|
locations: []
|
|
locations: []
|
|
};
|
|
};
|
|
|
|
|
|
// Store node locations
|
|
// Store node locations
|
|
- for (var block of material.attachedBlocks) {
|
|
|
|
|
|
+ const blocks: NodeMaterialBlock[] = frame ? frame.nodes.map(n => n.block) : material.attachedBlocks;
|
|
|
|
+
|
|
|
|
+ for (var block of blocks) {
|
|
let node = globalState.onGetNodeFromBlock(block);
|
|
let node = globalState.onGetNodeFromBlock(block);
|
|
|
|
|
|
material.editorData.locations.push({
|
|
material.editorData.locations.push({
|
|
@@ -22,14 +26,16 @@ export class SerializationTools {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- globalState.storeEditorData(material.editorData);
|
|
|
|
|
|
+ globalState.storeEditorData(material.editorData, frame);
|
|
}
|
|
}
|
|
|
|
|
|
- public static Serialize(material: NodeMaterial, globalState: GlobalState, selectedBlocks?: NodeMaterialBlock[]) {
|
|
|
|
|
|
+ public static Serialize(material: NodeMaterial, globalState: GlobalState, frame?: Nullable<GraphFrame>) {
|
|
let bufferSerializationState = Texture.SerializeBuffers;
|
|
let bufferSerializationState = Texture.SerializeBuffers;
|
|
Texture.SerializeBuffers = DataStorage.ReadBoolean("EmbedTextures", true);
|
|
Texture.SerializeBuffers = DataStorage.ReadBoolean("EmbedTextures", true);
|
|
|
|
|
|
- this.UpdateLocations(material, globalState);
|
|
|
|
|
|
+ this.UpdateLocations(material, globalState, frame);
|
|
|
|
+
|
|
|
|
+ const selectedBlocks = frame ? frame.nodes.map(n => n.block) : undefined;
|
|
|
|
|
|
let serializationObject = material.serialize(selectedBlocks);
|
|
let serializationObject = material.serialize(selectedBlocks);
|
|
|
|
|