|
@@ -159,14 +159,13 @@ export class GraphEditor extends React.Component<IGraphEditorProps, IGraphEditor
|
|
|
});
|
|
|
|
|
|
this.props.globalState.onImportFrameObservable.add((source: any) => {
|
|
|
- let editorData = this.props.globalState.nodeMaterial.editorData;
|
|
|
-
|
|
|
- if (editorData instanceof Array) {
|
|
|
- editorData = {
|
|
|
- locations: editorData
|
|
|
- }
|
|
|
- }
|
|
|
- this.addFrameFromSerialization(editorData, source, "");
|
|
|
+ const frameData = source.editorData.frames[0];
|
|
|
+
|
|
|
+ // create new graph nodes for only blocks from frame (last blocks added)
|
|
|
+ this.props.globalState.nodeMaterial.attachedBlocks.slice(-(frameData.blocks.length)).forEach((block: NodeMaterialBlock) => {
|
|
|
+ this.createNodeFromObject(block);
|
|
|
+ });
|
|
|
+ this._graphCanvas.addFrame(frameData);
|
|
|
this.reOrganize(this.props.globalState.nodeMaterial.editorData, true);
|
|
|
})
|
|
|
|
|
@@ -480,9 +479,8 @@ export class GraphEditor extends React.Component<IGraphEditorProps, IGraphEditor
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (isImportingAFrame) {
|
|
|
- this._graphCanvas.addFrame(editorData);
|
|
|
- } else {
|
|
|
+
|
|
|
+ if (!isImportingAFrame){
|
|
|
this._graphCanvas.processEditorData(editorData);
|
|
|
}
|
|
|
}
|
|
@@ -495,47 +493,6 @@ export class GraphEditor extends React.Component<IGraphEditorProps, IGraphEditor
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- addFrameFromSerialization(editorData: IEditorData , source: any, rootUrl: string = "") {
|
|
|
- let map: {[key: number]: NodeMaterialBlock} = {};
|
|
|
-
|
|
|
- // Create blocks
|
|
|
- for (var parsedBlock of source.blocks) {
|
|
|
- let blockType = _TypeStore.GetClass(parsedBlock.customType);
|
|
|
- if (blockType) {
|
|
|
- let block: NodeMaterialBlock = new blockType();
|
|
|
- block._deserialize(parsedBlock, this.props.globalState.nodeMaterial.getScene(), rootUrl);
|
|
|
- map[parsedBlock.id] = block;
|
|
|
-
|
|
|
- this.createNodeFromObject(block);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (source.locations || source.editorData && source.editorData.locations) {
|
|
|
- let locations: {
|
|
|
- blockId: number;
|
|
|
- x: number;
|
|
|
- y: number;
|
|
|
- }[] = source.locations || source.editorData.locations;
|
|
|
-
|
|
|
- for (var location of locations) {
|
|
|
- if (map[location.blockId]) {
|
|
|
- location.blockId = map[location.blockId].uniqueId;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- editorData.locations = editorData.locations.concat(locations);
|
|
|
- editorData.frames = editorData.frames ? editorData.frames.concat(source.editorData.frames) : source.editorData.frames;
|
|
|
-
|
|
|
- let blockMap: number[] = [];
|
|
|
-
|
|
|
- for (var key in map) {
|
|
|
- blockMap[key] = map[key].uniqueId;
|
|
|
- }
|
|
|
-
|
|
|
- editorData.map = blockMap;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
onPointerDown(evt: React.PointerEvent<HTMLDivElement>) {
|
|
|
this._startX = evt.clientX;
|
|
|
this._moveInProgress = true;
|