|
@@ -30,7 +30,7 @@ interface IGraphEditorProps {
|
|
globalState: GlobalState;
|
|
globalState: GlobalState;
|
|
}
|
|
}
|
|
|
|
|
|
-type State = {
|
|
|
|
|
|
+interface IGraphEditorState {
|
|
showPreviewPopUp: boolean;
|
|
showPreviewPopUp: boolean;
|
|
};
|
|
};
|
|
|
|
|
|
@@ -42,7 +42,7 @@ interface IInternalPreviewAreaOptions extends IInspectorOptions {
|
|
embedHostWidth?: string;
|
|
embedHostWidth?: string;
|
|
}
|
|
}
|
|
|
|
|
|
-export class GraphEditor extends React.Component<IGraphEditorProps, State> {
|
|
|
|
|
|
+export class GraphEditor extends React.Component<IGraphEditorProps, IGraphEditorState> {
|
|
private readonly NodeWidth = 100;
|
|
private readonly NodeWidth = 100;
|
|
private _graphCanvas: GraphCanvasComponent;
|
|
private _graphCanvas: GraphCanvasComponent;
|
|
|
|
|
|
@@ -64,11 +64,6 @@ export class GraphEditor extends React.Component<IGraphEditorProps, State> {
|
|
private _previewHost: Nullable<HTMLElement>;
|
|
private _previewHost: Nullable<HTMLElement>;
|
|
private _popUpWindow: Window;
|
|
private _popUpWindow: Window;
|
|
|
|
|
|
-
|
|
|
|
- public readonly state: State = {
|
|
|
|
- showPreviewPopUp: false
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Creates a node and recursivly creates its parent nodes from it's input
|
|
* Creates a node and recursivly creates its parent nodes from it's input
|
|
* @param nodeMaterialBlock
|
|
* @param nodeMaterialBlock
|
|
@@ -387,7 +382,8 @@ export class GraphEditor extends React.Component<IGraphEditorProps, State> {
|
|
}
|
|
}
|
|
|
|
|
|
build() {
|
|
build() {
|
|
- let editorData = this.props.globalState.nodeMaterial.editorData;
|
|
|
|
|
|
+ let editorData = this.props.globalState.nodeMaterial.editorData;
|
|
|
|
+ this._graphCanvas._isLoading = true; // Will help loading large graphes
|
|
|
|
|
|
if (editorData instanceof Array) {
|
|
if (editorData instanceof Array) {
|
|
editorData = {
|
|
editorData = {
|
|
@@ -428,24 +424,43 @@ export class GraphEditor extends React.Component<IGraphEditorProps, State> {
|
|
this.reOrganize(editorData);
|
|
this.reOrganize(editorData);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ showWaitScreen() {
|
|
|
|
+ this.props.globalState.hostDocument.querySelector(".wait-screen")?.classList.remove("hidden");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ hideWaitScreen() {
|
|
|
|
+ this.props.globalState.hostDocument.querySelector(".wait-screen")?.classList.add("hidden");
|
|
|
|
+ }
|
|
|
|
+
|
|
reOrganize(editorData: Nullable<IEditorData> = null) {
|
|
reOrganize(editorData: Nullable<IEditorData> = null) {
|
|
- if (!editorData || !editorData.locations) {
|
|
|
|
- this._graphCanvas.distributeGraph();
|
|
|
|
- } else {
|
|
|
|
- // Locations
|
|
|
|
- for (var location of editorData.locations) {
|
|
|
|
- for (var node of this._graphCanvas.nodes) {
|
|
|
|
- if (node.block && node.block.uniqueId === location.blockId) {
|
|
|
|
- node.x = location.x;
|
|
|
|
- node.y = location.y;
|
|
|
|
- node.cleanAccumulation();
|
|
|
|
- break;
|
|
|
|
|
|
+ this.showWaitScreen();
|
|
|
|
+ this._graphCanvas._isLoading = true; // Will help loading large graphes
|
|
|
|
+
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ if (!editorData || !editorData.locations) {
|
|
|
|
+ this._graphCanvas.distributeGraph();
|
|
|
|
+ } else {
|
|
|
|
+ // Locations
|
|
|
|
+ for (var location of editorData.locations) {
|
|
|
|
+ for (var node of this._graphCanvas.nodes) {
|
|
|
|
+ if (node.block && node.block.uniqueId === location.blockId) {
|
|
|
|
+ node.x = location.x;
|
|
|
|
+ node.y = location.y;
|
|
|
|
+ node.cleanAccumulation();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ this._graphCanvas.processEditorData(editorData);
|
|
}
|
|
}
|
|
|
|
|
|
- this._graphCanvas.processEditorData(editorData);
|
|
|
|
- }
|
|
|
|
|
|
+ this._graphCanvas._isLoading = false;
|
|
|
|
+ for (var node of this._graphCanvas.nodes) {
|
|
|
|
+ node._refreshLinks();
|
|
|
|
+ }
|
|
|
|
+ this.hideWaitScreen();
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
onPointerDown(evt: React.PointerEvent<HTMLDivElement>) {
|
|
onPointerDown(evt: React.PointerEvent<HTMLDivElement>) {
|
|
@@ -762,7 +777,7 @@ export class GraphEditor extends React.Component<IGraphEditorProps, State> {
|
|
onDragOver={event => {
|
|
onDragOver={event => {
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
}}
|
|
}}
|
|
- >
|
|
|
|
|
|
+ >
|
|
<GraphCanvasComponent ref={"graphCanvas"} globalState={this.props.globalState}/>
|
|
<GraphCanvasComponent ref={"graphCanvas"} globalState={this.props.globalState}/>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@@ -785,6 +800,9 @@ export class GraphEditor extends React.Component<IGraphEditorProps, State> {
|
|
<div className="blocker">
|
|
<div className="blocker">
|
|
Node Material Editor runs only on desktop
|
|
Node Material Editor runs only on desktop
|
|
</div>
|
|
</div>
|
|
|
|
+ <div className="wait-screen hidden">
|
|
|
|
+ Processing...please wait
|
|
|
|
+ </div>
|
|
</Portal>
|
|
</Portal>
|
|
);
|
|
);
|
|
}
|
|
}
|