@onerjs/core 8.51.2 → 8.51.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animationGroup.d.ts +2 -1
- package/Animations/animationGroup.js +3 -2
- package/Animations/animationGroup.js.map +1 -1
- package/Engines/WebGPU/webgpuSnapshotRendering.js +7 -3
- package/Engines/WebGPU/webgpuSnapshotRendering.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Events/deviceInputEvents.d.ts +5 -0
- package/Events/deviceInputEvents.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphIsKeyPressedBlock.d.ts +65 -0
- package/FlowGraph/Blocks/Data/flowGraphIsKeyPressedBlock.js +74 -0
- package/FlowGraph/Blocks/Data/flowGraphIsKeyPressedBlock.js.map +1 -0
- package/FlowGraph/Blocks/Data/index.d.ts +1 -0
- package/FlowGraph/Blocks/Data/index.js +1 -0
- package/FlowGraph/Blocks/Data/index.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphKeyDownEventBlock.d.ts +39 -0
- package/FlowGraph/Blocks/Event/flowGraphKeyDownEventBlock.js +42 -0
- package/FlowGraph/Blocks/Event/flowGraphKeyDownEventBlock.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphKeyUpEventBlock.d.ts +19 -0
- package/FlowGraph/Blocks/Event/flowGraphKeyUpEventBlock.js +25 -0
- package/FlowGraph/Blocks/Event/flowGraphKeyUpEventBlock.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphKeyboardEventBlock.d.ts +64 -0
- package/FlowGraph/Blocks/Event/flowGraphKeyboardEventBlock.js +50 -0
- package/FlowGraph/Blocks/Event/flowGraphKeyboardEventBlock.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphPointerDownEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphPointerMoveEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphPointerUpEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/index.d.ts +3 -0
- package/FlowGraph/Blocks/Event/index.js +3 -0
- package/FlowGraph/Blocks/Event/index.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockFactory.js +7 -0
- package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +3 -0
- package/FlowGraph/Blocks/flowGraphBlockNames.js +3 -0
- package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -1
- package/FlowGraph/flowGraph.d.ts +6 -0
- package/FlowGraph/flowGraph.js +10 -1
- package/FlowGraph/flowGraph.js.map +1 -1
- package/FlowGraph/flowGraphContext.d.ts +8 -0
- package/FlowGraph/flowGraphContext.js.map +1 -1
- package/FlowGraph/flowGraphCoordinator.d.ts +1 -1
- package/FlowGraph/flowGraphCoordinator.js.map +1 -1
- package/FlowGraph/flowGraphEventType.d.ts +2 -0
- package/FlowGraph/flowGraphEventType.js +2 -0
- package/FlowGraph/flowGraphEventType.js.map +1 -1
- package/FlowGraph/flowGraphParser.d.ts +15 -0
- package/FlowGraph/flowGraphParser.js +101 -14
- package/FlowGraph/flowGraphParser.js.map +1 -1
- package/FlowGraph/flowGraphSceneEventCoordinator.d.ts +14 -0
- package/FlowGraph/flowGraphSceneEventCoordinator.js +56 -0
- package/FlowGraph/flowGraphSceneEventCoordinator.js.map +1 -1
- package/FlowGraph/serialization.js +16 -18
- package/FlowGraph/serialization.js.map +1 -1
- package/FlowGraph/utils.d.ts +7 -0
- package/FlowGraph/utils.js +8 -0
- package/FlowGraph/utils.js.map +1 -1
- package/Lights/Clustered/clusteredLightContainer.js +1 -1
- package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
- package/Materials/Background/backgroundMaterial.js +1 -0
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +6 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Dual/imageSourceBlock.d.ts +2 -0
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js +14 -0
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.js +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.d.ts +2 -0
- package/Materials/Node/Blocks/Dual/textureBlock.js +19 -4
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +11 -6
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.js +9 -0
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/openpbrMaterial.js +1 -0
- package/Materials/PBR/openpbrMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +1 -0
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +2 -1
- package/Materials/materialHelper.functions.js +8 -3
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/standardMaterial.js +1 -0
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js +30 -8
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js.map +1 -1
- package/Misc/snapshotRenderingHelper.d.ts +4 -2
- package/Misc/snapshotRenderingHelper.js +33 -22
- package/Misc/snapshotRenderingHelper.js.map +1 -1
- package/Misc/tools.js +1 -1
- package/Misc/tools.js.map +1 -1
- package/Particles/thinParticleSystem.d.ts +6 -1
- package/Particles/thinParticleSystem.js +23 -6
- package/Particles/thinParticleSystem.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,6 +4,32 @@ import { FlowGraphEventBlock } from "./flowGraphEventBlock.js";
|
|
|
4
4
|
import { FlowGraphExecutionBlock } from "./flowGraphExecutionBlock.js";
|
|
5
5
|
import { defaultValueParseFunction, needsPathConverter } from "./serialization.js";
|
|
6
6
|
import { getRichTypeByFlowGraphType, RichType } from "./flowGraphRichTypes.js";
|
|
7
|
+
|
|
8
|
+
import { WebRequest } from "../Misc/webRequest.js";
|
|
9
|
+
async function GetSerializedFlowGraphFromSnippetAsync(snippetId) {
|
|
10
|
+
const response = await WebRequest.FetchAsync(`https://snippet.babylonjs.com` + "/" + snippetId.replace(/#/g, "/"));
|
|
11
|
+
if (!response.ok) {
|
|
12
|
+
throw new Error("Unable to load the snippet " + snippetId);
|
|
13
|
+
}
|
|
14
|
+
const text = new TextDecoder().decode(await response.arrayBuffer());
|
|
15
|
+
const snippet = JSON.parse(text);
|
|
16
|
+
const snippetPayload = JSON.parse(snippet.jsonPayload);
|
|
17
|
+
const flowGraphPayload = snippetPayload.flowGraph;
|
|
18
|
+
if (!flowGraphPayload) {
|
|
19
|
+
throw new Error("Snippet " + snippetId + " does not contain a flow graph");
|
|
20
|
+
}
|
|
21
|
+
return typeof flowGraphPayload === "string" ? JSON.parse(flowGraphPayload) : flowGraphPayload;
|
|
22
|
+
}
|
|
23
|
+
function ApplyCoordinatorSerializationSettings(serializedObject, coordinator) {
|
|
24
|
+
if (serializedObject.dispatchEventsSynchronously !== undefined) {
|
|
25
|
+
coordinator.dispatchEventsSynchronously = serializedObject.dispatchEventsSynchronously;
|
|
26
|
+
}
|
|
27
|
+
if (serializedObject._defaultValues) {
|
|
28
|
+
for (const key in serializedObject._defaultValues) {
|
|
29
|
+
getRichTypeByFlowGraphType(key).defaultValue = serializedObject._defaultValues[key];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
7
33
|
/**
|
|
8
34
|
* Given a list of blocks, find an output data connection that has a specific unique id
|
|
9
35
|
* @param blocks a list of flow graph blocks
|
|
@@ -47,22 +73,51 @@ export function GetSignalInConnectionByUniqueId(blocks, uniqueId) {
|
|
|
47
73
|
export async function ParseCoordinatorAsync(serializedObject, options) {
|
|
48
74
|
const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;
|
|
49
75
|
const coordinator = new FlowGraphCoordinator({ scene: options.scene });
|
|
50
|
-
|
|
51
|
-
coordinator.dispatchEventsSynchronously = serializedObject.dispatchEventsSynchronously;
|
|
52
|
-
}
|
|
76
|
+
ApplyCoordinatorSerializationSettings(serializedObject, coordinator);
|
|
53
77
|
await options.scene.whenReadyAsync();
|
|
54
|
-
// if custom default values are defined, set them in the global context
|
|
55
|
-
if (serializedObject._defaultValues) {
|
|
56
|
-
for (const key in serializedObject._defaultValues) {
|
|
57
|
-
// key is the FlowGraphType, value is the default value
|
|
58
|
-
const value = serializedObject._defaultValues[key];
|
|
59
|
-
getRichTypeByFlowGraphType(key).defaultValue = value;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
78
|
// async-parse the flow graphs. This can be done in parallel
|
|
63
79
|
await Promise.all(serializedObject._flowGraphs?.map(async (serializedGraph) => await ParseFlowGraphAsync(serializedGraph, { coordinator, valueParseFunction, pathConverter: options.pathConverter })));
|
|
64
80
|
return coordinator;
|
|
65
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Parses a flow graph coordinator from a snippet saved by the Flow Graph Editor.
|
|
84
|
+
* @param snippetId the snippet id to load. Versioned ids such as "ABC123#4" are supported.
|
|
85
|
+
* @param options options for parsing the coordinator.
|
|
86
|
+
* @returns the parsed flow graph coordinator.
|
|
87
|
+
*/
|
|
88
|
+
export async function ParseFlowGraphCoordinatorFromSnippetAsync(snippetId, options) {
|
|
89
|
+
const serializedObject = await GetSerializedFlowGraphFromSnippetAsync(snippetId);
|
|
90
|
+
if (serializedObject._flowGraphs) {
|
|
91
|
+
return await ParseCoordinatorAsync(serializedObject, options);
|
|
92
|
+
}
|
|
93
|
+
const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;
|
|
94
|
+
const coordinator = new FlowGraphCoordinator({ scene: options.scene });
|
|
95
|
+
await options.scene.whenReadyAsync();
|
|
96
|
+
await ParseFlowGraphAsync(serializedObject, { coordinator, valueParseFunction, pathConverter: options.pathConverter });
|
|
97
|
+
return coordinator;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Parses a flow graph from a snippet saved by the Flow Graph Editor.
|
|
101
|
+
* If the snippet contains multiple graphs, all graphs are parsed into the provided coordinator and the active graph is returned.
|
|
102
|
+
* @param snippetId the snippet id to load. Versioned ids such as "ABC123#4" are supported.
|
|
103
|
+
* @param options options for parsing the graph.
|
|
104
|
+
* @returns the parsed flow graph.
|
|
105
|
+
*/
|
|
106
|
+
export async function ParseFlowGraphFromSnippetAsync(snippetId, options) {
|
|
107
|
+
const serializedObject = await GetSerializedFlowGraphFromSnippetAsync(snippetId);
|
|
108
|
+
const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;
|
|
109
|
+
if (!serializedObject._flowGraphs) {
|
|
110
|
+
return await ParseFlowGraphAsync(serializedObject, options);
|
|
111
|
+
}
|
|
112
|
+
ApplyCoordinatorSerializationSettings(serializedObject, options.coordinator);
|
|
113
|
+
const parsedGraphs = [];
|
|
114
|
+
for (const serializedGraph of serializedObject._flowGraphs) {
|
|
115
|
+
// eslint-disable-next-line no-await-in-loop -- graph order matters for the active graph index.
|
|
116
|
+
parsedGraphs.push(await ParseFlowGraphAsync(serializedGraph, { coordinator: options.coordinator, valueParseFunction, pathConverter: options.pathConverter }));
|
|
117
|
+
}
|
|
118
|
+
const activeGraphIndex = serializedObject.activeGraphIndex ?? 0;
|
|
119
|
+
return parsedGraphs[activeGraphIndex] ?? parsedGraphs[0];
|
|
120
|
+
}
|
|
66
121
|
/**
|
|
67
122
|
* Parses a graph from a given serialization object
|
|
68
123
|
* @param serializationObject the object where the values are written
|
|
@@ -109,9 +164,14 @@ export function ParseFlowGraph(serializationObject, options, resolvedClasses) {
|
|
|
109
164
|
}
|
|
110
165
|
// After parsing all blocks, connect them.
|
|
111
166
|
// Build lookup maps for O(1) connection resolution instead of O(B*P) linear scans.
|
|
167
|
+
const dataInMap = new Map();
|
|
112
168
|
const dataOutMap = new Map();
|
|
113
169
|
const signalInMap = new Map();
|
|
170
|
+
const signalOutMap = new Map();
|
|
114
171
|
for (const block of blocks) {
|
|
172
|
+
for (const dataIn of block.dataInputs) {
|
|
173
|
+
dataInMap.set(dataIn.uniqueId, dataIn);
|
|
174
|
+
}
|
|
115
175
|
for (const dataOut of block.dataOutputs) {
|
|
116
176
|
dataOutMap.set(dataOut.uniqueId, dataOut);
|
|
117
177
|
}
|
|
@@ -119,8 +179,17 @@ export function ParseFlowGraph(serializationObject, options, resolvedClasses) {
|
|
|
119
179
|
for (const signalIn of block.signalInputs) {
|
|
120
180
|
signalInMap.set(signalIn.uniqueId, signalIn);
|
|
121
181
|
}
|
|
182
|
+
for (const signalOut of block.signalOutputs) {
|
|
183
|
+
signalOutMap.set(signalOut.uniqueId, signalOut);
|
|
184
|
+
}
|
|
122
185
|
}
|
|
123
186
|
}
|
|
187
|
+
const connectIfNeeded = (connection, connectedConnection) => {
|
|
188
|
+
if (connection._connectedPoint.indexOf(connectedConnection) !== -1) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
connection.connectTo(connectedConnection);
|
|
192
|
+
};
|
|
124
193
|
for (const block of blocks) {
|
|
125
194
|
for (const dataIn of block.dataInputs) {
|
|
126
195
|
for (const serializedConnection of dataIn.connectedPointIds) {
|
|
@@ -128,7 +197,16 @@ export function ParseFlowGraph(serializationObject, options, resolvedClasses) {
|
|
|
128
197
|
if (!connection) {
|
|
129
198
|
throw new Error("Could not find data out connection with unique id " + serializedConnection);
|
|
130
199
|
}
|
|
131
|
-
dataIn
|
|
200
|
+
connectIfNeeded(dataIn, connection);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
for (const dataOut of block.dataOutputs) {
|
|
204
|
+
for (const serializedConnection of dataOut.connectedPointIds) {
|
|
205
|
+
const connection = dataInMap.get(serializedConnection);
|
|
206
|
+
if (!connection) {
|
|
207
|
+
throw new Error("Could not find data in connection with unique id " + serializedConnection);
|
|
208
|
+
}
|
|
209
|
+
connectIfNeeded(dataOut, connection);
|
|
132
210
|
}
|
|
133
211
|
}
|
|
134
212
|
if (block instanceof FlowGraphExecutionBlock) {
|
|
@@ -138,12 +216,21 @@ export function ParseFlowGraph(serializationObject, options, resolvedClasses) {
|
|
|
138
216
|
if (!connection) {
|
|
139
217
|
throw new Error("Could not find signal in connection with unique id " + serializedConnection);
|
|
140
218
|
}
|
|
141
|
-
signalOut
|
|
219
|
+
connectIfNeeded(signalOut, connection);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
for (const signalIn of block.signalInputs) {
|
|
223
|
+
for (const serializedConnection of signalIn.connectedPointIds) {
|
|
224
|
+
const connection = signalOutMap.get(serializedConnection);
|
|
225
|
+
if (!connection) {
|
|
226
|
+
throw new Error("Could not find signal out connection with unique id " + serializedConnection);
|
|
227
|
+
}
|
|
228
|
+
connectIfNeeded(connection, signalIn);
|
|
142
229
|
}
|
|
143
230
|
}
|
|
144
231
|
}
|
|
145
232
|
}
|
|
146
|
-
for (const serializedContext of serializationObject.executionContexts) {
|
|
233
|
+
for (const serializedContext of serializationObject.executionContexts ?? []) {
|
|
147
234
|
ParseFlowGraphContext(serializedContext, { graph, valueParseFunction }, serializationObject.rightHanded);
|
|
148
235
|
}
|
|
149
236
|
return graph;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphParser.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAK9D,OAAO,EAA0C,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEtG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,C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,GAAG,CAAC,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAC;IAC5C,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;IACxD,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iCAAiC,CAAgC,sBAA2B,EAAE,EAAE,UAAkB,EAAE,SAAqC;IACrK,MAAM,UAAU,GAAG,IAAI,SAAS,CAAC,mBAAmB,CAAC,IAAI,EAAE,mBAAmB,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IAC5G,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;IAC5C,OAAO,UAAU,CAAC;AACtB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,mBAAwB,EAAE,UAA0B,EAAE,SAAyC;IACpI,MAAM,QAAQ,GAAG,aAAa,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAC7D,MAAM,YAAY,GAAG,mBAAmB,CAAC,YAAY,CAAC;IACtD,MAAM,UAAU,GAAG,IAAI,SAAS,CAAC,mBAAmB,CAAC,IAAI,EAAE,mBAAmB,CAAC,eAAe,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACrK,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;IAC5C,OAAO,UAAU,CAAC;AACtB,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,mBAAwB;IAC3C,OAAO,IAAI,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;AACxF,CAAC","sourcesContent":["import { type IAssetContainer } from \"core/IAssetContainer\";\nimport { blockFactory } from \"./Blocks/flowGraphBlockFactory\";\nimport { type FlowGraphBlockNames } from \"./Blocks/flowGraphBlockNames\";\nimport { type FlowGraph, type IFlowGraphParseOptions } from \"./flowGraph\";\nimport { type FlowGraphBlock, type IFlowGraphBlockParseOptions } from \"./flowGraphBlock\";\nimport { type FlowGraphContext, type IFlowGraphContextParseOptions } from \"./flowGraphContext\";\nimport { type IFlowGraphCoordinatorParseOptions, FlowGraphCoordinator } from \"./flowGraphCoordinator\";\nimport { type FlowGraphDataConnection } from \"./flowGraphDataConnection\";\nimport { FlowGraphEventBlock } from \"./flowGraphEventBlock\";\nimport { FlowGraphExecutionBlock } from \"./flowGraphExecutionBlock\";\nimport { type FlowGraphSignalConnection } from \"./flowGraphSignalConnection\";\nimport { defaultValueParseFunction, needsPathConverter } from \"./serialization\";\nimport { type ISerializedFlowGraph, type ISerializedFlowGraphBlock, type ISerializedFlowGraphContext } from \"./typeDefinitions\";\nimport { type Node } from \"core/node\";\nimport { getRichTypeByFlowGraphType, RichType } from \"./flowGraphRichTypes\";\nimport { type FlowGraphConnection } from \"./flowGraphConnection\";\n\n/**\n * Given a list of blocks, find an output data connection that has a specific unique id\n * @param blocks a list of flow graph blocks\n * @param uniqueId the unique id of a connection\n * @returns the connection that has this unique id. throws an error if none was found\n */\nexport function GetDataOutConnectionByUniqueId(blocks: FlowGraphBlock[], uniqueId: string): FlowGraphDataConnection<any> {\n for (const block of blocks) {\n for (const dataOut of block.dataOutputs) {\n if (dataOut.uniqueId === uniqueId) {\n return dataOut;\n }\n }\n }\n throw new Error(\"Could not find data out connection with unique id \" + uniqueId);\n}\n\n/**\n * Given a list of blocks, find an input signal connection that has a specific unique id\n * @param blocks a list of flow graph blocks\n * @param uniqueId the unique id of a connection\n * @returns the connection that has this unique id. throws an error if none was found\n */\nexport function GetSignalInConnectionByUniqueId(blocks: FlowGraphBlock[], uniqueId: string): FlowGraphSignalConnection {\n for (const block of blocks) {\n if (block instanceof FlowGraphExecutionBlock) {\n for (const signalIn of block.signalInputs) {\n if (signalIn.uniqueId === uniqueId) {\n return signalIn;\n }\n }\n }\n }\n throw new Error(\"Could not find signal in connection with unique id \" + uniqueId);\n}\n\n/**\n * Parses a serialized coordinator.\n * @param serializedObject the object to parse\n * @param options the options to use when parsing\n * @returns the parsed coordinator\n */\nexport async function ParseCoordinatorAsync(serializedObject: any, options: IFlowGraphCoordinatorParseOptions) {\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n const coordinator = new FlowGraphCoordinator({ scene: options.scene });\n\n if (serializedObject.dispatchEventsSynchronously) {\n coordinator.dispatchEventsSynchronously = serializedObject.dispatchEventsSynchronously;\n }\n\n await options.scene.whenReadyAsync();\n // if custom default values are defined, set them in the global context\n if (serializedObject._defaultValues) {\n for (const key in serializedObject._defaultValues) {\n // key is the FlowGraphType, value is the default value\n const value = serializedObject._defaultValues[key];\n getRichTypeByFlowGraphType(key).defaultValue = value;\n }\n }\n // async-parse the flow graphs. This can be done in parallel\n await Promise.all(\n serializedObject._flowGraphs?.map(\n async (serializedGraph: any) => await ParseFlowGraphAsync(serializedGraph, { coordinator, valueParseFunction, pathConverter: options.pathConverter })\n )\n );\n return coordinator;\n}\n\n/**\n * Parses a graph from a given serialization object\n * @param serializationObject the object where the values are written\n * @param options options for parsing the graph\n * @returns the parsed graph\n */\nexport async function ParseFlowGraphAsync(serializationObject: ISerializedFlowGraph, options: IFlowGraphParseOptions): Promise<FlowGraph> {\n // get all classes types needed for the blocks using the block factory\n const resolvedClasses = await Promise.all(\n serializationObject.allBlocks.map(async (serializedBlock) => {\n const classFactory = blockFactory(serializedBlock.className as FlowGraphBlockNames);\n return await classFactory();\n })\n );\n // async will be used when we start using the block async factory\n return ParseFlowGraph(serializationObject, options, resolvedClasses);\n}\n\n/**\n * Parses a graph from a given serialization object\n * @param serializationObject the object where the values are written\n * @param options options for parsing the graph\n * @param resolvedClasses the resolved classes for the blocks\n * @returns the parsed graph\n */\nexport function ParseFlowGraph(serializationObject: ISerializedFlowGraph, options: IFlowGraphParseOptions, resolvedClasses: (typeof FlowGraphBlock)[]) {\n const graph = options.coordinator.createGraph();\n // Restore graph identity from serialized data\n if (serializationObject.name) {\n graph.name = serializationObject.name;\n }\n if (serializationObject.uniqueId) {\n graph.uniqueId = serializationObject.uniqueId;\n }\n const blocks: FlowGraphBlock[] = [];\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n // Parse all blocks\n // for (const serializedBlock of serializationObject.allBlocks) {\n for (let i = 0; i < serializationObject.allBlocks.length; i++) {\n const serializedBlock = serializationObject.allBlocks[i];\n const block = ParseFlowGraphBlockWithClassType(\n serializedBlock,\n { scene: options.coordinator.config.scene, pathConverter: options.pathConverter, assetsContainer: options.coordinator.config.scene, valueParseFunction },\n resolvedClasses[i]\n );\n blocks.push(block);\n graph.addBlock(block);\n if (block instanceof FlowGraphEventBlock) {\n graph.addEventBlock(block);\n }\n }\n // After parsing all blocks, connect them.\n // Build lookup maps for O(1) connection resolution instead of O(B*P) linear scans.\n const dataOutMap = new Map<string, FlowGraphDataConnection<any>>();\n const signalInMap = new Map<string, FlowGraphSignalConnection>();\n for (const block of blocks) {\n for (const dataOut of block.dataOutputs) {\n dataOutMap.set(dataOut.uniqueId, dataOut);\n }\n if (block instanceof FlowGraphExecutionBlock) {\n for (const signalIn of block.signalInputs) {\n signalInMap.set(signalIn.uniqueId, signalIn);\n }\n }\n }\n for (const block of blocks) {\n for (const dataIn of block.dataInputs) {\n for (const serializedConnection of dataIn.connectedPointIds) {\n const connection = dataOutMap.get(serializedConnection);\n if (!connection) {\n throw new Error(\"Could not find data out connection with unique id \" + serializedConnection);\n }\n dataIn.connectTo(connection);\n }\n }\n if (block instanceof FlowGraphExecutionBlock) {\n for (const signalOut of block.signalOutputs) {\n for (const serializedConnection of signalOut.connectedPointIds) {\n const connection = signalInMap.get(serializedConnection);\n if (!connection) {\n throw new Error(\"Could not find signal in connection with unique id \" + serializedConnection);\n }\n signalOut.connectTo(connection);\n }\n }\n }\n }\n for (const serializedContext of serializationObject.executionContexts) {\n ParseFlowGraphContext(serializedContext, { graph, valueParseFunction }, serializationObject.rightHanded);\n }\n return graph;\n}\n\n/**\n * Parses a context\n * @param serializationObject the object containing the context serialization values\n * @param options the options for parsing the context\n * @param rightHanded whether the serialized data is right handed\n * @returns\n */\nexport function ParseFlowGraphContext(serializationObject: ISerializedFlowGraphContext, options: IFlowGraphContextParseOptions, rightHanded?: boolean): FlowGraphContext {\n const result = options.graph.createContext();\n if (serializationObject.enableLogging) {\n result.enableLogging = true;\n }\n result.treatDataAsRightHanded = rightHanded || false;\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n result.uniqueId = serializationObject.uniqueId;\n result.name = serializationObject.name ?? \"\";\n const scene = result.getScene();\n // check if assets context is available\n if (serializationObject._assetsContext) {\n const ac = serializationObject._assetsContext;\n const assetsContext: IAssetContainer = {\n meshes: ac.meshes?.map((m: string) => scene.getMeshById(m)),\n lights: ac.lights?.map((l: string) => scene.getLightByName(l)),\n cameras: ac.cameras?.map((c: string) => scene.getCameraByName(c)),\n materials: ac.materials?.map((m: string) => scene.getMaterialById(m)),\n textures: ac.textures?.map((t: string) => scene.getTextureByName(t)),\n animations: ac.animations?.map((a: string) => scene.animations.find((anim) => anim.name === a)),\n skeletons: ac.skeletons?.map((s: string) => scene.getSkeletonByName(s)),\n particleSystems: ac.particleSystems?.map((ps: string) => scene.getParticleSystemById(ps)),\n animationGroups: ac.animationGroups?.map((ag: string) => scene.getAnimationGroupByName(ag)),\n transformNodes: ac.transformNodes?.map((tn: string) => scene.getTransformNodeById(tn)),\n rootNodes: [],\n multiMaterials: [],\n morphTargetManagers: [],\n geometries: [],\n actionManagers: [],\n environmentTexture: null,\n postProcesses: [],\n sounds: null,\n effectLayers: [],\n layers: [],\n reflectionProbes: [],\n lensFlareSystems: [],\n proceduralTextures: [],\n getNodes: function (): Array<Node> {\n throw new Error(\"Function not implemented.\");\n },\n };\n result.assetsContext = assetsContext;\n }\n for (const key in serializationObject._userVariables) {\n const value = valueParseFunction(key, serializationObject._userVariables, result.assetsContext, scene);\n result.userVariables[key] = value;\n }\n // Restore variable type annotations\n if (serializationObject._variableTypes) {\n for (const key in serializationObject._variableTypes) {\n result.setVariableType(key, serializationObject._variableTypes[key]);\n }\n }\n for (const key in serializationObject._connectionValues) {\n const value = valueParseFunction(key, serializationObject._connectionValues, result.assetsContext, scene);\n result._setConnectionValueByKey(key, value);\n }\n\n return result;\n}\n\n/**\n * Parses a block from a serialization object\n * This function is async due to the factory method that is used to create the block's class. If you load the class externally use ParseBlockWithClassType\n * @param serializationObject the object to parse from\n * @param parseOptions options for parsing the block\n * @returns the parsed block\n */\nexport async function ParseBlockAsync(serializationObject: ISerializedFlowGraphBlock, parseOptions: IFlowGraphBlockParseOptions): Promise<FlowGraphBlock> {\n const classFactory = blockFactory(serializationObject.className as FlowGraphBlockNames);\n const classType = await classFactory();\n return ParseFlowGraphBlockWithClassType(serializationObject, parseOptions, classType);\n}\n\n/**\n * Parses a block from a serialization object\n * @param serializationObject the object to parse from\n * @param parseOptions options for parsing the block\n * @param classType the class type of the block. This is used when the class is not loaded asynchronously\n * @returns the parsed block\n */\nexport function ParseFlowGraphBlockWithClassType(\n serializationObject: ISerializedFlowGraphBlock,\n parseOptions: IFlowGraphBlockParseOptions,\n classType: typeof FlowGraphBlock\n): FlowGraphBlock {\n const parsedConfig: any = {};\n const valueParseFunction = parseOptions.valueParseFunction ?? defaultValueParseFunction;\n if (serializationObject.config) {\n for (const key in serializationObject.config) {\n parsedConfig[key] = valueParseFunction(key, serializationObject.config, parseOptions.assetsContainer || parseOptions.scene, parseOptions.scene);\n }\n }\n if (needsPathConverter(serializationObject.className)) {\n if (!parseOptions.pathConverter) {\n throw new Error(\"Block \" + serializationObject.className + \" requires a path converter to be provided in parse options.\");\n }\n parsedConfig.pathConverter = parseOptions.pathConverter;\n }\n const obj = new classType(parsedConfig);\n obj.uniqueId = serializationObject.uniqueId;\n for (let i = 0; i < serializationObject.dataInputs.length; i++) {\n const dataInput = obj.getDataInput(serializationObject.dataInputs[i].name);\n if (dataInput) {\n dataInput.deserialize(serializationObject.dataInputs[i]);\n // Restore _defaultValue if it was serialized. Without this, the\n // user-set inline value (e.g. \"2\" on an Add input, or \"position\"\n // on a GetProperty's propertyName) is lost during round-trips.\n if (serializationObject.dataInputs[i].defaultValue !== undefined) {\n (dataInput as any)._defaultValue = valueParseFunction(\n \"defaultValue\",\n serializationObject.dataInputs[i],\n parseOptions.assetsContainer || parseOptions.scene,\n parseOptions.scene\n );\n }\n } else {\n throw new Error(\"Could not find data input with name \" + serializationObject.dataInputs[i].name + \" in block \" + serializationObject.className);\n }\n }\n for (let i = 0; i < serializationObject.dataOutputs.length; i++) {\n const dataOutput = obj.getDataOutput(serializationObject.dataOutputs[i].name);\n if (dataOutput) {\n dataOutput.deserialize(serializationObject.dataOutputs[i]);\n } else {\n throw new Error(\"Could not find data output with name \" + serializationObject.dataOutputs[i].name + \" in block \" + serializationObject.className);\n }\n }\n obj.metadata = serializationObject.metadata;\n obj.deserialize && obj.deserialize(serializationObject);\n return obj;\n}\n\n/**\n * Parses a connection from an object\n * @param serializationObject the object to parse from.\n * @param ownerBlock the block that owns the connection.\n * @param classType the class type of the connection.\n * @returns the parsed connection.\n */\nexport function ParseGraphConnectionWithClassType<BlockT extends FlowGraphBlock>(serializationObject: any = {}, ownerBlock: BlockT, classType: typeof FlowGraphConnection) {\n const connection = new classType(serializationObject.name, serializationObject._connectionType, ownerBlock);\n connection.deserialize(serializationObject);\n return connection;\n}\n\n/**\n * Parses a data connection from a serialized object.\n * @param serializationObject the object to parse from\n * @param ownerBlock the block that owns the connection\n * @param classType the class type of the data connection\n * @returns the parsed connection\n */\nexport function ParseGraphDataConnection(serializationObject: any, ownerBlock: FlowGraphBlock, classType: typeof FlowGraphDataConnection): FlowGraphDataConnection<any> {\n const richType = ParseRichType(serializationObject.richType);\n const defaultValue = serializationObject.defaultValue;\n const connection = new classType(serializationObject.name, serializationObject._connectionType, ownerBlock, richType, defaultValue, !!serializationObject._optional);\n connection.deserialize(serializationObject);\n return connection;\n}\n\n/**\n * Parses a rich type from a serialization object.\n * @param serializationObject a serialization object\n * @returns the parsed rich type\n */\nfunction ParseRichType(serializationObject: any): RichType<any> {\n return new RichType(serializationObject.typeName, serializationObject.defaultValue);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraphParser.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAK9D,OAAO,EAA0C,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEtG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGhF,OAAO,EAAE,0BAA0B,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE5E,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,KAAK,UAAU,sCAAsC,CAAC,SAAiB;IACnE,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,GAAG,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IACxG,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,6BAA6B,GAAG,SAAS,CAAC,CAAC;IAC/D,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IACpE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACv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C;IACpI,MAAM,QAAQ,GAAG,aAAa,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAC7D,MAAM,YAAY,GAAG,mBAAmB,CAAC,YAAY,CAAC;IACtD,MAAM,UAAU,GAAG,IAAI,SAAS,CAAC,mBAAmB,CAAC,IAAI,EAAE,mBAAmB,CAAC,eAAe,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACrK,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;IAC5C,OAAO,UAAU,CAAC;AACtB,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,mBAAwB;IAC3C,OAAO,IAAI,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;AACxF,CAAC","sourcesContent":["import { type IAssetContainer } from \"core/IAssetContainer\";\nimport { blockFactory } from \"./Blocks/flowGraphBlockFactory\";\nimport { type FlowGraphBlockNames } from \"./Blocks/flowGraphBlockNames\";\nimport { type FlowGraph, type IFlowGraphParseOptions } from \"./flowGraph\";\nimport { type FlowGraphBlock, type IFlowGraphBlockParseOptions } from \"./flowGraphBlock\";\nimport { type FlowGraphContext, type IFlowGraphContextParseOptions } from \"./flowGraphContext\";\nimport { type IFlowGraphCoordinatorParseOptions, FlowGraphCoordinator } from \"./flowGraphCoordinator\";\nimport { type FlowGraphDataConnection } from \"./flowGraphDataConnection\";\nimport { FlowGraphEventBlock } from \"./flowGraphEventBlock\";\nimport { FlowGraphExecutionBlock } from \"./flowGraphExecutionBlock\";\nimport { type FlowGraphSignalConnection } from \"./flowGraphSignalConnection\";\nimport { defaultValueParseFunction, needsPathConverter } from \"./serialization\";\nimport { type ISerializedFlowGraph, type ISerializedFlowGraphBlock, type ISerializedFlowGraphContext } from \"./typeDefinitions\";\nimport { type Node } from \"core/node\";\nimport { getRichTypeByFlowGraphType, RichType } from \"./flowGraphRichTypes\";\nimport { type FlowGraphConnection } from \"./flowGraphConnection\";\nimport { Constants } from \"core/Engines/constants\";\nimport { WebRequest } from \"core/Misc/webRequest\";\n\nasync function GetSerializedFlowGraphFromSnippetAsync(snippetId: string): Promise<any> {\n const response = await WebRequest.FetchAsync(Constants.SnippetUrl + \"/\" + snippetId.replace(/#/g, \"/\"));\n if (!response.ok) {\n throw new Error(\"Unable to load the snippet \" + snippetId);\n }\n\n const text = new TextDecoder().decode(await response.arrayBuffer());\n const snippet = JSON.parse(text);\n const snippetPayload = JSON.parse(snippet.jsonPayload);\n const flowGraphPayload = snippetPayload.flowGraph;\n if (!flowGraphPayload) {\n throw new Error(\"Snippet \" + snippetId + \" does not contain a flow graph\");\n }\n\n return typeof flowGraphPayload === \"string\" ? JSON.parse(flowGraphPayload) : flowGraphPayload;\n}\n\nfunction ApplyCoordinatorSerializationSettings(serializedObject: any, coordinator: FlowGraphCoordinator): void {\n if (serializedObject.dispatchEventsSynchronously !== undefined) {\n coordinator.dispatchEventsSynchronously = serializedObject.dispatchEventsSynchronously;\n }\n\n if (serializedObject._defaultValues) {\n for (const key in serializedObject._defaultValues) {\n getRichTypeByFlowGraphType(key).defaultValue = serializedObject._defaultValues[key];\n }\n }\n}\n\n/**\n * Given a list of blocks, find an output data connection that has a specific unique id\n * @param blocks a list of flow graph blocks\n * @param uniqueId the unique id of a connection\n * @returns the connection that has this unique id. throws an error if none was found\n */\nexport function GetDataOutConnectionByUniqueId(blocks: FlowGraphBlock[], uniqueId: string): FlowGraphDataConnection<any> {\n for (const block of blocks) {\n for (const dataOut of block.dataOutputs) {\n if (dataOut.uniqueId === uniqueId) {\n return dataOut;\n }\n }\n }\n throw new Error(\"Could not find data out connection with unique id \" + uniqueId);\n}\n\n/**\n * Given a list of blocks, find an input signal connection that has a specific unique id\n * @param blocks a list of flow graph blocks\n * @param uniqueId the unique id of a connection\n * @returns the connection that has this unique id. throws an error if none was found\n */\nexport function GetSignalInConnectionByUniqueId(blocks: FlowGraphBlock[], uniqueId: string): FlowGraphSignalConnection {\n for (const block of blocks) {\n if (block instanceof FlowGraphExecutionBlock) {\n for (const signalIn of block.signalInputs) {\n if (signalIn.uniqueId === uniqueId) {\n return signalIn;\n }\n }\n }\n }\n throw new Error(\"Could not find signal in connection with unique id \" + uniqueId);\n}\n\n/**\n * Parses a serialized coordinator.\n * @param serializedObject the object to parse\n * @param options the options to use when parsing\n * @returns the parsed coordinator\n */\nexport async function ParseCoordinatorAsync(serializedObject: any, options: IFlowGraphCoordinatorParseOptions) {\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n const coordinator = new FlowGraphCoordinator({ scene: options.scene });\n\n ApplyCoordinatorSerializationSettings(serializedObject, coordinator);\n\n await options.scene.whenReadyAsync();\n // async-parse the flow graphs. This can be done in parallel\n await Promise.all(\n serializedObject._flowGraphs?.map(\n async (serializedGraph: any) => await ParseFlowGraphAsync(serializedGraph, { coordinator, valueParseFunction, pathConverter: options.pathConverter })\n )\n );\n return coordinator;\n}\n\n/**\n * Parses a flow graph coordinator from a snippet saved by the Flow Graph Editor.\n * @param snippetId the snippet id to load. Versioned ids such as \"ABC123#4\" are supported.\n * @param options options for parsing the coordinator.\n * @returns the parsed flow graph coordinator.\n */\nexport async function ParseFlowGraphCoordinatorFromSnippetAsync(snippetId: string, options: IFlowGraphCoordinatorParseOptions): Promise<FlowGraphCoordinator> {\n const serializedObject = await GetSerializedFlowGraphFromSnippetAsync(snippetId);\n if (serializedObject._flowGraphs) {\n return await ParseCoordinatorAsync(serializedObject, options);\n }\n\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n const coordinator = new FlowGraphCoordinator({ scene: options.scene });\n await options.scene.whenReadyAsync();\n await ParseFlowGraphAsync(serializedObject, { coordinator, valueParseFunction, pathConverter: options.pathConverter });\n return coordinator;\n}\n\n/**\n * Parses a flow graph from a snippet saved by the Flow Graph Editor.\n * If the snippet contains multiple graphs, all graphs are parsed into the provided coordinator and the active graph is returned.\n * @param snippetId the snippet id to load. Versioned ids such as \"ABC123#4\" are supported.\n * @param options options for parsing the graph.\n * @returns the parsed flow graph.\n */\nexport async function ParseFlowGraphFromSnippetAsync(snippetId: string, options: IFlowGraphParseOptions): Promise<FlowGraph> {\n const serializedObject = await GetSerializedFlowGraphFromSnippetAsync(snippetId);\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n\n if (!serializedObject._flowGraphs) {\n return await ParseFlowGraphAsync(serializedObject, options);\n }\n\n ApplyCoordinatorSerializationSettings(serializedObject, options.coordinator);\n const parsedGraphs: FlowGraph[] = [];\n for (const serializedGraph of serializedObject._flowGraphs) {\n // eslint-disable-next-line no-await-in-loop -- graph order matters for the active graph index.\n parsedGraphs.push(await ParseFlowGraphAsync(serializedGraph, { coordinator: options.coordinator, valueParseFunction, pathConverter: options.pathConverter }));\n }\n\n const activeGraphIndex = serializedObject.activeGraphIndex ?? 0;\n return parsedGraphs[activeGraphIndex] ?? parsedGraphs[0];\n}\n\n/**\n * Parses a graph from a given serialization object\n * @param serializationObject the object where the values are written\n * @param options options for parsing the graph\n * @returns the parsed graph\n */\nexport async function ParseFlowGraphAsync(serializationObject: ISerializedFlowGraph, options: IFlowGraphParseOptions): Promise<FlowGraph> {\n // get all classes types needed for the blocks using the block factory\n const resolvedClasses = await Promise.all(\n serializationObject.allBlocks.map(async (serializedBlock) => {\n const classFactory = blockFactory(serializedBlock.className as FlowGraphBlockNames);\n return await classFactory();\n })\n );\n // async will be used when we start using the block async factory\n return ParseFlowGraph(serializationObject, options, resolvedClasses);\n}\n\n/**\n * Parses a graph from a given serialization object\n * @param serializationObject the object where the values are written\n * @param options options for parsing the graph\n * @param resolvedClasses the resolved classes for the blocks\n * @returns the parsed graph\n */\nexport function ParseFlowGraph(serializationObject: ISerializedFlowGraph, options: IFlowGraphParseOptions, resolvedClasses: (typeof FlowGraphBlock)[]) {\n const graph = options.coordinator.createGraph();\n // Restore graph identity from serialized data\n if (serializationObject.name) {\n graph.name = serializationObject.name;\n }\n if (serializationObject.uniqueId) {\n graph.uniqueId = serializationObject.uniqueId;\n }\n const blocks: FlowGraphBlock[] = [];\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n // Parse all blocks\n // for (const serializedBlock of serializationObject.allBlocks) {\n for (let i = 0; i < serializationObject.allBlocks.length; i++) {\n const serializedBlock = serializationObject.allBlocks[i];\n const block = ParseFlowGraphBlockWithClassType(\n serializedBlock,\n { scene: options.coordinator.config.scene, pathConverter: options.pathConverter, assetsContainer: options.coordinator.config.scene, valueParseFunction },\n resolvedClasses[i]\n );\n blocks.push(block);\n graph.addBlock(block);\n if (block instanceof FlowGraphEventBlock) {\n graph.addEventBlock(block);\n }\n }\n // After parsing all blocks, connect them.\n // Build lookup maps for O(1) connection resolution instead of O(B*P) linear scans.\n const dataInMap = new Map<string, FlowGraphDataConnection<any>>();\n const dataOutMap = new Map<string, FlowGraphDataConnection<any>>();\n const signalInMap = new Map<string, FlowGraphSignalConnection>();\n const signalOutMap = new Map<string, FlowGraphSignalConnection>();\n for (const block of blocks) {\n for (const dataIn of block.dataInputs) {\n dataInMap.set(dataIn.uniqueId, dataIn);\n }\n for (const dataOut of block.dataOutputs) {\n dataOutMap.set(dataOut.uniqueId, dataOut);\n }\n if (block instanceof FlowGraphExecutionBlock) {\n for (const signalIn of block.signalInputs) {\n signalInMap.set(signalIn.uniqueId, signalIn);\n }\n for (const signalOut of block.signalOutputs) {\n signalOutMap.set(signalOut.uniqueId, signalOut);\n }\n }\n }\n const connectIfNeeded = <ConnectionT extends FlowGraphConnection<any, any>>(connection: ConnectionT, connectedConnection: ConnectionT) => {\n if (connection._connectedPoint.indexOf(connectedConnection) !== -1) {\n return;\n }\n connection.connectTo(connectedConnection);\n };\n for (const block of blocks) {\n for (const dataIn of block.dataInputs) {\n for (const serializedConnection of dataIn.connectedPointIds) {\n const connection = dataOutMap.get(serializedConnection);\n if (!connection) {\n throw new Error(\"Could not find data out connection with unique id \" + serializedConnection);\n }\n connectIfNeeded(dataIn, connection);\n }\n }\n for (const dataOut of block.dataOutputs) {\n for (const serializedConnection of dataOut.connectedPointIds) {\n const connection = dataInMap.get(serializedConnection);\n if (!connection) {\n throw new Error(\"Could not find data in connection with unique id \" + serializedConnection);\n }\n connectIfNeeded(dataOut, connection);\n }\n }\n if (block instanceof FlowGraphExecutionBlock) {\n for (const signalOut of block.signalOutputs) {\n for (const serializedConnection of signalOut.connectedPointIds) {\n const connection = signalInMap.get(serializedConnection);\n if (!connection) {\n throw new Error(\"Could not find signal in connection with unique id \" + serializedConnection);\n }\n connectIfNeeded(signalOut, connection);\n }\n }\n for (const signalIn of block.signalInputs) {\n for (const serializedConnection of signalIn.connectedPointIds) {\n const connection = signalOutMap.get(serializedConnection);\n if (!connection) {\n throw new Error(\"Could not find signal out connection with unique id \" + serializedConnection);\n }\n connectIfNeeded(connection, signalIn);\n }\n }\n }\n }\n for (const serializedContext of serializationObject.executionContexts ?? []) {\n ParseFlowGraphContext(serializedContext, { graph, valueParseFunction }, serializationObject.rightHanded);\n }\n return graph;\n}\n\n/**\n * Parses a context\n * @param serializationObject the object containing the context serialization values\n * @param options the options for parsing the context\n * @param rightHanded whether the serialized data is right handed\n * @returns\n */\nexport function ParseFlowGraphContext(serializationObject: ISerializedFlowGraphContext, options: IFlowGraphContextParseOptions, rightHanded?: boolean): FlowGraphContext {\n const result = options.graph.createContext();\n if (serializationObject.enableLogging) {\n result.enableLogging = true;\n }\n result.treatDataAsRightHanded = rightHanded || false;\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n result.uniqueId = serializationObject.uniqueId;\n result.name = serializationObject.name ?? \"\";\n const scene = result.getScene();\n // check if assets context is available\n if (serializationObject._assetsContext) {\n const ac = serializationObject._assetsContext;\n const assetsContext: IAssetContainer = {\n meshes: ac.meshes?.map((m: string) => scene.getMeshById(m)),\n lights: ac.lights?.map((l: string) => scene.getLightByName(l)),\n cameras: ac.cameras?.map((c: string) => scene.getCameraByName(c)),\n materials: ac.materials?.map((m: string) => scene.getMaterialById(m)),\n textures: ac.textures?.map((t: string) => scene.getTextureByName(t)),\n animations: ac.animations?.map((a: string) => scene.animations.find((anim) => anim.name === a)),\n skeletons: ac.skeletons?.map((s: string) => scene.getSkeletonByName(s)),\n particleSystems: ac.particleSystems?.map((ps: string) => scene.getParticleSystemById(ps)),\n animationGroups: ac.animationGroups?.map((ag: string) => scene.getAnimationGroupByName(ag)),\n transformNodes: ac.transformNodes?.map((tn: string) => scene.getTransformNodeById(tn)),\n rootNodes: [],\n multiMaterials: [],\n morphTargetManagers: [],\n geometries: [],\n actionManagers: [],\n environmentTexture: null,\n postProcesses: [],\n sounds: null,\n effectLayers: [],\n layers: [],\n reflectionProbes: [],\n lensFlareSystems: [],\n proceduralTextures: [],\n getNodes: function (): Array<Node> {\n throw new Error(\"Function not implemented.\");\n },\n };\n result.assetsContext = assetsContext;\n }\n for (const key in serializationObject._userVariables) {\n const value = valueParseFunction(key, serializationObject._userVariables, result.assetsContext, scene);\n result.userVariables[key] = value;\n }\n // Restore variable type annotations\n if (serializationObject._variableTypes) {\n for (const key in serializationObject._variableTypes) {\n result.setVariableType(key, serializationObject._variableTypes[key]);\n }\n }\n for (const key in serializationObject._connectionValues) {\n const value = valueParseFunction(key, serializationObject._connectionValues, result.assetsContext, scene);\n result._setConnectionValueByKey(key, value);\n }\n\n return result;\n}\n\n/**\n * Parses a block from a serialization object\n * This function is async due to the factory method that is used to create the block's class. If you load the class externally use ParseBlockWithClassType\n * @param serializationObject the object to parse from\n * @param parseOptions options for parsing the block\n * @returns the parsed block\n */\nexport async function ParseBlockAsync(serializationObject: ISerializedFlowGraphBlock, parseOptions: IFlowGraphBlockParseOptions): Promise<FlowGraphBlock> {\n const classFactory = blockFactory(serializationObject.className as FlowGraphBlockNames);\n const classType = await classFactory();\n return ParseFlowGraphBlockWithClassType(serializationObject, parseOptions, classType);\n}\n\n/**\n * Parses a block from a serialization object\n * @param serializationObject the object to parse from\n * @param parseOptions options for parsing the block\n * @param classType the class type of the block. This is used when the class is not loaded asynchronously\n * @returns the parsed block\n */\nexport function ParseFlowGraphBlockWithClassType(\n serializationObject: ISerializedFlowGraphBlock,\n parseOptions: IFlowGraphBlockParseOptions,\n classType: typeof FlowGraphBlock\n): FlowGraphBlock {\n const parsedConfig: any = {};\n const valueParseFunction = parseOptions.valueParseFunction ?? defaultValueParseFunction;\n if (serializationObject.config) {\n for (const key in serializationObject.config) {\n parsedConfig[key] = valueParseFunction(key, serializationObject.config, parseOptions.assetsContainer || parseOptions.scene, parseOptions.scene);\n }\n }\n if (needsPathConverter(serializationObject.className)) {\n if (!parseOptions.pathConverter) {\n throw new Error(\"Block \" + serializationObject.className + \" requires a path converter to be provided in parse options.\");\n }\n parsedConfig.pathConverter = parseOptions.pathConverter;\n }\n const obj = new classType(parsedConfig);\n obj.uniqueId = serializationObject.uniqueId;\n for (let i = 0; i < serializationObject.dataInputs.length; i++) {\n const dataInput = obj.getDataInput(serializationObject.dataInputs[i].name);\n if (dataInput) {\n dataInput.deserialize(serializationObject.dataInputs[i]);\n // Restore _defaultValue if it was serialized. Without this, the\n // user-set inline value (e.g. \"2\" on an Add input, or \"position\"\n // on a GetProperty's propertyName) is lost during round-trips.\n if (serializationObject.dataInputs[i].defaultValue !== undefined) {\n (dataInput as any)._defaultValue = valueParseFunction(\n \"defaultValue\",\n serializationObject.dataInputs[i],\n parseOptions.assetsContainer || parseOptions.scene,\n parseOptions.scene\n );\n }\n } else {\n throw new Error(\"Could not find data input with name \" + serializationObject.dataInputs[i].name + \" in block \" + serializationObject.className);\n }\n }\n for (let i = 0; i < serializationObject.dataOutputs.length; i++) {\n const dataOutput = obj.getDataOutput(serializationObject.dataOutputs[i].name);\n if (dataOutput) {\n dataOutput.deserialize(serializationObject.dataOutputs[i]);\n } else {\n throw new Error(\"Could not find data output with name \" + serializationObject.dataOutputs[i].name + \" in block \" + serializationObject.className);\n }\n }\n obj.metadata = serializationObject.metadata;\n obj.deserialize && obj.deserialize(serializationObject);\n return obj;\n}\n\n/**\n * Parses a connection from an object\n * @param serializationObject the object to parse from.\n * @param ownerBlock the block that owns the connection.\n * @param classType the class type of the connection.\n * @returns the parsed connection.\n */\nexport function ParseGraphConnectionWithClassType<BlockT extends FlowGraphBlock>(serializationObject: any = {}, ownerBlock: BlockT, classType: typeof FlowGraphConnection) {\n const connection = new classType(serializationObject.name, serializationObject._connectionType, ownerBlock);\n connection.deserialize(serializationObject);\n return connection;\n}\n\n/**\n * Parses a data connection from a serialized object.\n * @param serializationObject the object to parse from\n * @param ownerBlock the block that owns the connection\n * @param classType the class type of the data connection\n * @returns the parsed connection\n */\nexport function ParseGraphDataConnection(serializationObject: any, ownerBlock: FlowGraphBlock, classType: typeof FlowGraphDataConnection): FlowGraphDataConnection<any> {\n const richType = ParseRichType(serializationObject.richType);\n const defaultValue = serializationObject.defaultValue;\n const connection = new classType(serializationObject.name, serializationObject._connectionType, ownerBlock, richType, defaultValue, !!serializationObject._optional);\n connection.deserialize(serializationObject);\n return connection;\n}\n\n/**\n * Parses a rich type from a serialization object.\n * @param serializationObject a serialization object\n * @returns the parsed rich type\n */\nfunction ParseRichType(serializationObject: any): RichType<any> {\n return new RichType(serializationObject.typeName, serializationObject.defaultValue);\n}\n"]}
|
|
@@ -41,6 +41,20 @@ export declare class FlowGraphSceneEventCoordinator {
|
|
|
41
41
|
private _pointerUpObserver;
|
|
42
42
|
private _pointerMoveObserver;
|
|
43
43
|
private _pointerUnderMeshState;
|
|
44
|
+
private _keyDownObserver;
|
|
45
|
+
private _keyUpObserver;
|
|
46
|
+
private _onBlurHandler;
|
|
47
|
+
/**
|
|
48
|
+
* The set of keys currently pressed, keyed by `event.code`.
|
|
49
|
+
* Keyboard event blocks use this to determine whether a key is held.
|
|
50
|
+
*
|
|
51
|
+
* In addition to physical key codes, a virtual `"CommandOrControl"` entry
|
|
52
|
+
* is maintained: it tracks Meta (Cmd) on macOS and Ctrl on Windows/Linux,
|
|
53
|
+
* enabling platform-agnostic shortcut checks via the IsKeyPressed block.
|
|
54
|
+
*/
|
|
55
|
+
readonly pressedKeys: Set<string>;
|
|
56
|
+
/** The physical key codes that map to the virtual CommandOrControl key on this platform. */
|
|
57
|
+
private static readonly _COMMAND_OR_CTRL_CODES;
|
|
44
58
|
private _startingTime;
|
|
45
59
|
constructor(scene: Scene);
|
|
46
60
|
private _initialize;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { PointerEventTypes } from "../Events/pointerEvents.js";
|
|
2
|
+
import { KeyboardEventTypes } from "../Events/keyboardEvents.js";
|
|
2
3
|
import { Observable } from "../Misc/observable.js";
|
|
4
|
+
import { _IsMacPlatform } from "./utils.js";
|
|
3
5
|
/**
|
|
4
6
|
* This class is responsible for coordinating the events that are triggered in the scene.
|
|
5
7
|
* It registers all observers needed to track certain events and triggers the blocks that are listening to them.
|
|
@@ -16,6 +18,16 @@ export class FlowGraphSceneEventCoordinator {
|
|
|
16
18
|
*/
|
|
17
19
|
this.sceneReadyTriggered = false;
|
|
18
20
|
this._pointerUnderMeshState = {};
|
|
21
|
+
this._onBlurHandler = null;
|
|
22
|
+
/**
|
|
23
|
+
* The set of keys currently pressed, keyed by `event.code`.
|
|
24
|
+
* Keyboard event blocks use this to determine whether a key is held.
|
|
25
|
+
*
|
|
26
|
+
* In addition to physical key codes, a virtual `"CommandOrControl"` entry
|
|
27
|
+
* is maintained: it tracks Meta (Cmd) on macOS and Ctrl on Windows/Linux,
|
|
28
|
+
* enabling platform-agnostic shortcut checks via the IsKeyPressed block.
|
|
29
|
+
*/
|
|
30
|
+
this.pressedKeys = new Set();
|
|
19
31
|
this._startingTime = 0;
|
|
20
32
|
this._scene = scene;
|
|
21
33
|
this._initialize();
|
|
@@ -73,6 +85,40 @@ export class FlowGraphSceneEventCoordinator {
|
|
|
73
85
|
}
|
|
74
86
|
this._pointerUnderMeshState[pointerId] = mesh;
|
|
75
87
|
}, PointerEventTypes.POINTERMOVE);
|
|
88
|
+
this._keyDownObserver = this._scene.onKeyboardObservable.add((keyboardInfo) => {
|
|
89
|
+
const code = keyboardInfo.event.code;
|
|
90
|
+
this.pressedKeys.add(code);
|
|
91
|
+
if (FlowGraphSceneEventCoordinator._COMMAND_OR_CTRL_CODES.has(code)) {
|
|
92
|
+
this.pressedKeys.add("CommandOrControl");
|
|
93
|
+
}
|
|
94
|
+
this.onEventTriggeredObservable.notifyObservers({ type: "KeyDown" /* FlowGraphEventType.KeyDown */, payload: keyboardInfo });
|
|
95
|
+
}, KeyboardEventTypes.KEYDOWN);
|
|
96
|
+
this._keyUpObserver = this._scene.onKeyboardObservable.add((keyboardInfo) => {
|
|
97
|
+
const code = keyboardInfo.event.code;
|
|
98
|
+
this.pressedKeys.delete(code);
|
|
99
|
+
if (FlowGraphSceneEventCoordinator._COMMAND_OR_CTRL_CODES.has(code)) {
|
|
100
|
+
// Only remove CommandOrControl if neither left nor right is still held
|
|
101
|
+
let stillHeld = false;
|
|
102
|
+
for (const c of Array.from(FlowGraphSceneEventCoordinator._COMMAND_OR_CTRL_CODES)) {
|
|
103
|
+
if (c !== code && this.pressedKeys.has(c)) {
|
|
104
|
+
stillHeld = true;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (!stillHeld) {
|
|
109
|
+
this.pressedKeys.delete("CommandOrControl");
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
this.onEventTriggeredObservable.notifyObservers({ type: "KeyUp" /* FlowGraphEventType.KeyUp */, payload: keyboardInfo });
|
|
113
|
+
}, KeyboardEventTypes.KEYUP);
|
|
114
|
+
// Clear all tracked keys when the window/tab loses focus.
|
|
115
|
+
// Without this, held keys would appear "stuck" after an Alt-Tab
|
|
116
|
+
// because the keyup event fires in the other window.
|
|
117
|
+
const canvas = this._scene.getEngine().getRenderingCanvas();
|
|
118
|
+
if (canvas) {
|
|
119
|
+
this._onBlurHandler = () => this.pressedKeys.clear();
|
|
120
|
+
canvas.addEventListener("blur", this._onBlurHandler);
|
|
121
|
+
}
|
|
76
122
|
}
|
|
77
123
|
dispose() {
|
|
78
124
|
this._sceneDisposeObserver?.remove();
|
|
@@ -83,7 +129,17 @@ export class FlowGraphSceneEventCoordinator {
|
|
|
83
129
|
this._pointerDownObserver?.remove();
|
|
84
130
|
this._pointerUpObserver?.remove();
|
|
85
131
|
this._pointerMoveObserver?.remove();
|
|
132
|
+
this._keyDownObserver?.remove();
|
|
133
|
+
this._keyUpObserver?.remove();
|
|
134
|
+
if (this._onBlurHandler) {
|
|
135
|
+
const canvas = this._scene.getEngine().getRenderingCanvas();
|
|
136
|
+
canvas?.removeEventListener("blur", this._onBlurHandler);
|
|
137
|
+
this._onBlurHandler = null;
|
|
138
|
+
}
|
|
139
|
+
this.pressedKeys.clear();
|
|
86
140
|
this.onEventTriggeredObservable.clear();
|
|
87
141
|
}
|
|
88
142
|
}
|
|
143
|
+
/** The physical key codes that map to the virtual CommandOrControl key on this platform. */
|
|
144
|
+
FlowGraphSceneEventCoordinator._COMMAND_OR_CTRL_CODES = _IsMacPlatform ? new Set(["MetaLeft", "MetaRight"]) : new Set(["ControlLeft", "ControlRight"]);
|
|
89
145
|
//# sourceMappingURL=flowGraphSceneEventCoordinator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphSceneEventCoordinator.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphSceneEventCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEhF,OAAO,EAAiB,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAmBjE;;;;GAIG;AACH,MAAM,OAAO,8BAA8B;IA4BvC,YAAY,KAAY;QAtBxB;;WAEG;QACI,+BAA0B,GAAuC,IAAI,UAAU,EAAE,CAAC;QAEzF;;WAEG;QACI,wBAAmB,GAAY,KAAK,CAAC;QAUpC,2BAAsB,GAAoD,EAAE,CAAC;QAE7E,kBAAa,GAAW,CAAC,CAAC;QAG9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AAE,CAAC;QACpC,IAAI,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC;QAClC,IAAI,CAAC,oBAAoB,EAAE,MAAM,EAAE,CAAC;QACpC,IAAI,CAAC,0BAA0B,CAAC,KAAK,EAAE,CAAC;IAC5C,CAAC;CACJ","sourcesContent":["import { type PointerInfo, PointerEventTypes } from \"core/Events/pointerEvents\";\nimport { type AbstractMesh } from \"core/Meshes/abstractMesh\";\nimport { type Observer, Observable } from \"core/Misc/observable\";\nimport { type Scene } from \"core/scene\";\nimport { type Nullable } from \"core/types\";\nimport { FlowGraphEventType } from \"./flowGraphEventType\";\n\n/**\n * the interface of the object the scene event coordinator will trigger.\n */\nexport interface IFlowGraphEventTrigger {\n /**\n * The type of the event\n */\n type: FlowGraphEventType;\n /**\n * The data of the event\n */\n payload?: any;\n}\n\n/**\n * This class is responsible for coordinating the events that are triggered in the scene.\n * It registers all observers needed to track certain events and triggers the blocks that are listening to them.\n * Abstracting the events from the class will allow us to easily change the events that are being listened to, and trigger them in any order.\n */\nexport class FlowGraphSceneEventCoordinator {\n /**\n * @internal\n */\n public readonly _scene: Scene;\n\n /**\n * register to this observable to get flow graph event notifications.\n */\n public onEventTriggeredObservable: Observable<IFlowGraphEventTrigger> = new Observable();\n\n /**\n * Was scene-ready already triggered?\n */\n public sceneReadyTriggered: boolean = false;\n\n private _sceneDisposeObserver: Nullable<Observer<Scene>>;\n private _sceneReadyObserver: Nullable<Observer<Scene>>;\n private _sceneOnBeforeRenderObserver: Nullable<Observer<Scene>>;\n private _meshPickedObserver: Nullable<Observer<PointerInfo>>;\n private _meshUnderPointerObserver: Nullable<Observer<{ mesh: Nullable<AbstractMesh>; pointerId: number }>>;\n private _pointerDownObserver: Nullable<Observer<PointerInfo>>;\n private _pointerUpObserver: Nullable<Observer<PointerInfo>>;\n private _pointerMoveObserver: Nullable<Observer<PointerInfo>>;\n private _pointerUnderMeshState: { [pointerId: number]: Nullable<AbstractMesh> } = {};\n\n private _startingTime: number = 0;\n\n constructor(scene: Scene) {\n this._scene = scene;\n this._initialize();\n }\n\n private _initialize() {\n this._sceneReadyObserver = this._scene.onReadyObservable.addOnce(() => {\n if (!this.sceneReadyTriggered) {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.SceneReady });\n this.sceneReadyTriggered = true;\n }\n });\n\n this._sceneDisposeObserver = this._scene.onDisposeObservable.add(() => {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.SceneDispose });\n });\n this._sceneOnBeforeRenderObserver = this._scene.onBeforeRenderObservable.add(() => {\n const deltaTime = this._scene.getEngine().getDeltaTime() / 1000; // set in seconds\n this.onEventTriggeredObservable.notifyObservers({\n type: FlowGraphEventType.SceneBeforeRender,\n payload: {\n timeSinceStart: this._startingTime,\n deltaTime,\n },\n });\n this._startingTime += deltaTime;\n });\n\n this._meshPickedObserver = this._scene.onPointerObservable.add((pointerInfo) => {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.MeshPick, payload: pointerInfo });\n }, PointerEventTypes.POINTERPICK); // should it be pointerdown?\n\n this._pointerDownObserver = this._scene.onPointerObservable.add((pointerInfo) => {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerDown, payload: pointerInfo });\n }, PointerEventTypes.POINTERDOWN);\n\n this._pointerUpObserver = this._scene.onPointerObservable.add((pointerInfo) => {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerUp, payload: pointerInfo });\n }, PointerEventTypes.POINTERUP);\n\n this._pointerMoveObserver = this._scene.onPointerObservable.add((pointerInfo) => {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerMove, payload: pointerInfo });\n }, PointerEventTypes.POINTERMOVE);\n\n this._meshUnderPointerObserver = this._scene.onMeshUnderPointerUpdatedObservable.add((data) => {\n // check if the data has changed. Check the state of the last change and see if it is a mesh or null.\n // if it is a mesh and the previous state was null, trigger over event. If it is null and the previous state was a mesh, trigger out event.\n // if it is a mesh and the previous state was a mesh, trigger out from the old mesh and over the new mesh\n // if it is null and the previous state was null, do nothing.\n const pointerId = data.pointerId;\n const mesh = data.mesh;\n const previousState = this._pointerUnderMeshState[pointerId];\n if (!previousState && mesh) {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerOver, payload: { pointerId, mesh } });\n } else if (previousState && !mesh) {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerOut, payload: { pointerId, mesh: previousState } });\n } else if (previousState && mesh && previousState !== mesh) {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerOut, payload: { pointerId, mesh: previousState, over: mesh } });\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerOver, payload: { pointerId, mesh, out: previousState } });\n }\n this._pointerUnderMeshState[pointerId] = mesh;\n }, PointerEventTypes.POINTERMOVE);\n }\n\n public dispose() {\n this._sceneDisposeObserver?.remove();\n this._sceneReadyObserver?.remove();\n this._sceneOnBeforeRenderObserver?.remove();\n this._meshPickedObserver?.remove();\n this._meshUnderPointerObserver?.remove();\n this._pointerDownObserver?.remove();\n this._pointerUpObserver?.remove();\n this._pointerMoveObserver?.remove();\n this.onEventTriggeredObservable.clear();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraphSceneEventCoordinator.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphSceneEventCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAqB,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEnF,OAAO,EAAiB,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIjE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAgBzC;;;;GAIG;AACH,MAAM,OAAO,8BAA8B;IA4CvC,YAAY,KAAY;QAtCxB;;WAEG;QACI,+BAA0B,GAAuC,IAAI,UAAU,EAAE,CAAC;Q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QACD,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,0BAA0B,CAAC,KAAK,EAAE,CAAC;IAC5C,CAAC;;AA5HD,4FAA4F;AACpE,qDAAsB,GAAwB,cAAc,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC,AAAtH,CAAuH","sourcesContent":["import { type PointerInfo, PointerEventTypes } from \"core/Events/pointerEvents\";\nimport { type KeyboardInfo, KeyboardEventTypes } from \"core/Events/keyboardEvents\";\nimport { type AbstractMesh } from \"core/Meshes/abstractMesh\";\nimport { type Observer, Observable } from \"core/Misc/observable\";\nimport { type Scene } from \"core/scene\";\nimport { type Nullable } from \"core/types\";\nimport { FlowGraphEventType } from \"./flowGraphEventType\";\nimport { _IsMacPlatform } from \"./utils\";\n\n/**\n * the interface of the object the scene event coordinator will trigger.\n */\nexport interface IFlowGraphEventTrigger {\n /**\n * The type of the event\n */\n type: FlowGraphEventType;\n /**\n * The data of the event\n */\n payload?: any;\n}\n\n/**\n * This class is responsible for coordinating the events that are triggered in the scene.\n * It registers all observers needed to track certain events and triggers the blocks that are listening to them.\n * Abstracting the events from the class will allow us to easily change the events that are being listened to, and trigger them in any order.\n */\nexport class FlowGraphSceneEventCoordinator {\n /**\n * @internal\n */\n public readonly _scene: Scene;\n\n /**\n * register to this observable to get flow graph event notifications.\n */\n public onEventTriggeredObservable: Observable<IFlowGraphEventTrigger> = new Observable();\n\n /**\n * Was scene-ready already triggered?\n */\n public sceneReadyTriggered: boolean = false;\n\n private _sceneDisposeObserver: Nullable<Observer<Scene>>;\n private _sceneReadyObserver: Nullable<Observer<Scene>>;\n private _sceneOnBeforeRenderObserver: Nullable<Observer<Scene>>;\n private _meshPickedObserver: Nullable<Observer<PointerInfo>>;\n private _meshUnderPointerObserver: Nullable<Observer<{ mesh: Nullable<AbstractMesh>; pointerId: number }>>;\n private _pointerDownObserver: Nullable<Observer<PointerInfo>>;\n private _pointerUpObserver: Nullable<Observer<PointerInfo>>;\n private _pointerMoveObserver: Nullable<Observer<PointerInfo>>;\n private _pointerUnderMeshState: { [pointerId: number]: Nullable<AbstractMesh> } = {};\n private _keyDownObserver: Nullable<Observer<KeyboardInfo>>;\n private _keyUpObserver: Nullable<Observer<KeyboardInfo>>;\n private _onBlurHandler: (() => void) | null = null;\n\n /**\n * The set of keys currently pressed, keyed by `event.code`.\n * Keyboard event blocks use this to determine whether a key is held.\n *\n * In addition to physical key codes, a virtual `\"CommandOrControl\"` entry\n * is maintained: it tracks Meta (Cmd) on macOS and Ctrl on Windows/Linux,\n * enabling platform-agnostic shortcut checks via the IsKeyPressed block.\n */\n public readonly pressedKeys: Set<string> = new Set<string>();\n\n /** The physical key codes that map to the virtual CommandOrControl key on this platform. */\n private static readonly _COMMAND_OR_CTRL_CODES: ReadonlySet<string> = _IsMacPlatform ? new Set([\"MetaLeft\", \"MetaRight\"]) : new Set([\"ControlLeft\", \"ControlRight\"]);\n\n private _startingTime: number = 0;\n\n constructor(scene: Scene) {\n this._scene = scene;\n this._initialize();\n }\n\n private _initialize() {\n this._sceneReadyObserver = this._scene.onReadyObservable.addOnce(() => {\n if (!this.sceneReadyTriggered) {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.SceneReady });\n this.sceneReadyTriggered = true;\n }\n });\n\n this._sceneDisposeObserver = this._scene.onDisposeObservable.add(() => {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.SceneDispose });\n });\n this._sceneOnBeforeRenderObserver = this._scene.onBeforeRenderObservable.add(() => {\n const deltaTime = this._scene.getEngine().getDeltaTime() / 1000; // set in seconds\n this.onEventTriggeredObservable.notifyObservers({\n type: FlowGraphEventType.SceneBeforeRender,\n payload: {\n timeSinceStart: this._startingTime,\n deltaTime,\n },\n });\n this._startingTime += deltaTime;\n });\n\n this._meshPickedObserver = this._scene.onPointerObservable.add((pointerInfo) => {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.MeshPick, payload: pointerInfo });\n }, PointerEventTypes.POINTERPICK); // should it be pointerdown?\n\n this._pointerDownObserver = this._scene.onPointerObservable.add((pointerInfo) => {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerDown, payload: pointerInfo });\n }, PointerEventTypes.POINTERDOWN);\n\n this._pointerUpObserver = this._scene.onPointerObservable.add((pointerInfo) => {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerUp, payload: pointerInfo });\n }, PointerEventTypes.POINTERUP);\n\n this._pointerMoveObserver = this._scene.onPointerObservable.add((pointerInfo) => {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerMove, payload: pointerInfo });\n }, PointerEventTypes.POINTERMOVE);\n\n this._meshUnderPointerObserver = this._scene.onMeshUnderPointerUpdatedObservable.add((data) => {\n // check if the data has changed. Check the state of the last change and see if it is a mesh or null.\n // if it is a mesh and the previous state was null, trigger over event. If it is null and the previous state was a mesh, trigger out event.\n // if it is a mesh and the previous state was a mesh, trigger out from the old mesh and over the new mesh\n // if it is null and the previous state was null, do nothing.\n const pointerId = data.pointerId;\n const mesh = data.mesh;\n const previousState = this._pointerUnderMeshState[pointerId];\n if (!previousState && mesh) {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerOver, payload: { pointerId, mesh } });\n } else if (previousState && !mesh) {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerOut, payload: { pointerId, mesh: previousState } });\n } else if (previousState && mesh && previousState !== mesh) {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerOut, payload: { pointerId, mesh: previousState, over: mesh } });\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerOver, payload: { pointerId, mesh, out: previousState } });\n }\n this._pointerUnderMeshState[pointerId] = mesh;\n }, PointerEventTypes.POINTERMOVE);\n\n this._keyDownObserver = this._scene.onKeyboardObservable.add((keyboardInfo) => {\n const code = keyboardInfo.event.code;\n this.pressedKeys.add(code);\n if (FlowGraphSceneEventCoordinator._COMMAND_OR_CTRL_CODES.has(code)) {\n this.pressedKeys.add(\"CommandOrControl\");\n }\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.KeyDown, payload: keyboardInfo });\n }, KeyboardEventTypes.KEYDOWN);\n\n this._keyUpObserver = this._scene.onKeyboardObservable.add((keyboardInfo) => {\n const code = keyboardInfo.event.code;\n this.pressedKeys.delete(code);\n if (FlowGraphSceneEventCoordinator._COMMAND_OR_CTRL_CODES.has(code)) {\n // Only remove CommandOrControl if neither left nor right is still held\n let stillHeld = false;\n for (const c of Array.from(FlowGraphSceneEventCoordinator._COMMAND_OR_CTRL_CODES)) {\n if (c !== code && this.pressedKeys.has(c)) {\n stillHeld = true;\n break;\n }\n }\n if (!stillHeld) {\n this.pressedKeys.delete(\"CommandOrControl\");\n }\n }\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.KeyUp, payload: keyboardInfo });\n }, KeyboardEventTypes.KEYUP);\n\n // Clear all tracked keys when the window/tab loses focus.\n // Without this, held keys would appear \"stuck\" after an Alt-Tab\n // because the keyup event fires in the other window.\n const canvas = this._scene.getEngine().getRenderingCanvas();\n if (canvas) {\n this._onBlurHandler = () => this.pressedKeys.clear();\n canvas.addEventListener(\"blur\", this._onBlurHandler);\n }\n }\n\n public dispose() {\n this._sceneDisposeObserver?.remove();\n this._sceneReadyObserver?.remove();\n this._sceneOnBeforeRenderObserver?.remove();\n this._meshPickedObserver?.remove();\n this._meshUnderPointerObserver?.remove();\n this._pointerDownObserver?.remove();\n this._pointerUpObserver?.remove();\n this._pointerMoveObserver?.remove();\n this._keyDownObserver?.remove();\n this._keyUpObserver?.remove();\n if (this._onBlurHandler) {\n const canvas = this._scene.getEngine().getRenderingCanvas();\n canvas?.removeEventListener(\"blur\", this._onBlurHandler);\n this._onBlurHandler = null;\n }\n this.pressedKeys.clear();\n this.onEventTriggeredObservable.clear();\n }\n}\n"]}
|
|
@@ -4,18 +4,6 @@ import { Matrix, Quaternion, Vector2, Vector3, Vector4 } from "../Maths/math.vec
|
|
|
4
4
|
import { FlowGraphInteger } from "./CustomTypes/flowGraphInteger.js";
|
|
5
5
|
import { getRichTypeByFlowGraphType } from "./flowGraphRichTypes.js";
|
|
6
6
|
import { FlowGraphMatrix2D, FlowGraphMatrix3D } from "./CustomTypes/flowGraphMatrix.js";
|
|
7
|
-
function IsMeshClassName(className) {
|
|
8
|
-
return (className === "Mesh" ||
|
|
9
|
-
className === "AbstractMesh" ||
|
|
10
|
-
className === "TransformNode" ||
|
|
11
|
-
className === "GroundMesh" ||
|
|
12
|
-
className === "InstancedMesh" ||
|
|
13
|
-
className === "InstanceMesh" ||
|
|
14
|
-
className === "LinesMesh" ||
|
|
15
|
-
className === "GoldbergMesh" ||
|
|
16
|
-
className === "GreasedLineMesh" ||
|
|
17
|
-
className === "TrailMesh");
|
|
18
|
-
}
|
|
19
7
|
function IsVectorClassName(className) {
|
|
20
8
|
return (className === "Vector2" /* FlowGraphTypes.Vector2 */ ||
|
|
21
9
|
className === "Vector3" /* FlowGraphTypes.Vector3 */ ||
|
|
@@ -30,6 +18,19 @@ function IsMatrixClassName(className) {
|
|
|
30
18
|
function IsAnimationGroupClassName(className) {
|
|
31
19
|
return className === "AnimationGroup";
|
|
32
20
|
}
|
|
21
|
+
function GetSceneNodeFromSerializedReference(serializedReference, scene) {
|
|
22
|
+
if (!serializedReference || (!serializedReference.id && !serializedReference.name)) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
const nodes = scene.getNodes().filter((node) => (serializedReference.id ? node.id === serializedReference.id : node.name === serializedReference.name));
|
|
26
|
+
if (nodes.length === 0) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
const className = serializedReference.type ?? serializedReference.className;
|
|
30
|
+
const classMatches = className ? nodes.filter((node) => node.getClassName() === className) : [];
|
|
31
|
+
const candidates = classMatches.length > 0 ? classMatches : nodes;
|
|
32
|
+
return (serializedReference.uniqueId ? candidates.find((node) => node.uniqueId === serializedReference.uniqueId) : undefined) ?? candidates[0];
|
|
33
|
+
}
|
|
33
34
|
function ParseVector(className, value, flipHandedness = false) {
|
|
34
35
|
if (className === "Vector2" /* FlowGraphTypes.Vector2 */) {
|
|
35
36
|
return Vector2.FromArray(value);
|
|
@@ -131,12 +132,9 @@ export function defaultValueParseFunction(key, serializationObject, assetsContai
|
|
|
131
132
|
const intermediateValue = serializationObject[key];
|
|
132
133
|
let finalValue;
|
|
133
134
|
const className = intermediateValue?.type ?? intermediateValue?.className;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
nodes = scene.transformNodes.filter((m) => (intermediateValue.id ? m.id === intermediateValue.id : m.name === intermediateValue.name));
|
|
138
|
-
}
|
|
139
|
-
finalValue = intermediateValue.uniqueId ? nodes.find((m) => m.uniqueId === intermediateValue.uniqueId) : nodes[0];
|
|
135
|
+
const sceneNode = GetSceneNodeFromSerializedReference(intermediateValue, scene);
|
|
136
|
+
if (sceneNode) {
|
|
137
|
+
finalValue = sceneNode;
|
|
140
138
|
}
|
|
141
139
|
else if (IsVectorClassName(className)) {
|
|
142
140
|
finalValue = ParseVector(className, intermediateValue.value);
|