@babylonjs/loaders 7.51.1 → 7.51.2
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/glTF/2.0/Extensions/KHR_animation_pointer.d.ts +1 -0
- package/glTF/2.0/Extensions/KHR_animation_pointer.data.d.ts +0 -299
- package/glTF/2.0/Extensions/KHR_animation_pointer.data.js +190 -224
- package/glTF/2.0/Extensions/KHR_animation_pointer.data.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_animation_pointer.js +11 -14
- package/glTF/2.0/Extensions/KHR_animation_pointer.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.d.ts +339 -0
- package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js +1507 -0
- package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_interactivity/flowGraphGLTFDataProvider.d.ts +33 -0
- package/glTF/2.0/Extensions/KHR_interactivity/flowGraphGLTFDataProvider.js +20 -0
- package/glTF/2.0/Extensions/KHR_interactivity/flowGraphGLTFDataProvider.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_interactivity/index.d.ts +3 -0
- package/glTF/2.0/Extensions/KHR_interactivity/index.js +4 -0
- package/glTF/2.0/Extensions/KHR_interactivity/index.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.d.ts +71 -0
- package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js +442 -0
- package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_interactivity.d.ts +7 -1
- package/glTF/2.0/Extensions/KHR_interactivity.js +105 -7
- package/glTF/2.0/Extensions/KHR_interactivity.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_node_hoverability.js +153 -0
- package/glTF/2.0/Extensions/KHR_node_hoverability.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_node_selectability.d.ts +30 -0
- package/glTF/2.0/Extensions/KHR_node_selectability.js +123 -0
- package/glTF/2.0/Extensions/KHR_node_selectability.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_node_visibility.js +25 -0
- package/glTF/2.0/Extensions/KHR_node_visibility.js.map +1 -1
- package/glTF/2.0/Extensions/gltfPathToObjectConverter.d.ts +5 -2
- package/glTF/2.0/Extensions/gltfPathToObjectConverter.js +26 -5
- package/glTF/2.0/Extensions/gltfPathToObjectConverter.js.map +1 -1
- package/glTF/2.0/Extensions/index.d.ts +4 -0
- package/glTF/2.0/Extensions/index.js +5 -0
- package/glTF/2.0/Extensions/index.js.map +1 -1
- package/glTF/2.0/Extensions/objectModelMapping.d.ts +289 -0
- package/glTF/2.0/Extensions/objectModelMapping.js +801 -0
- package/glTF/2.0/Extensions/objectModelMapping.js.map +1 -0
- package/glTF/2.0/glTFLoader.d.ts +4 -1
- package/glTF/2.0/glTFLoader.js +22 -11
- package/glTF/2.0/glTFLoader.js.map +1 -1
- package/glTF/2.0/glTFLoaderAnimation.d.ts +12 -10
- package/glTF/2.0/glTFLoaderAnimation.js +13 -11
- package/glTF/2.0/glTFLoaderAnimation.js.map +1 -1
- package/glTF/2.0/index.d.ts +1 -0
- package/glTF/2.0/index.js +1 -0
- package/glTF/2.0/index.js.map +1 -1
- package/package.json +3 -3
- package/glTF/2.0/Extensions/interactivityFunctions.d.ts +0 -9
- package/glTF/2.0/Extensions/interactivityFunctions.js +0 -198
- package/glTF/2.0/Extensions/interactivityFunctions.js.map +0 -1
- package/glTF/2.0/Extensions/interactivityPathToObjectConverter.d.ts +0 -9
- package/glTF/2.0/Extensions/interactivityPathToObjectConverter.js +0 -32
- package/glTF/2.0/Extensions/interactivityPathToObjectConverter.js.map +0 -1
- package/glTF/2.0/Extensions/interactivityUtils.d.ts +0 -4
- package/glTF/2.0/Extensions/interactivityUtils.js +0 -108
- package/glTF/2.0/Extensions/interactivityUtils.js.map +0 -1
@@ -0,0 +1,442 @@
|
|
1
|
+
import { getMappingForDeclaration, getMappingForFullOperationName } from "./declarationMapper.js";
|
2
|
+
import { Logger } from "@babylonjs/core/Misc/logger.js";
|
3
|
+
import { RandomGUID } from "@babylonjs/core/Misc/guid.js";
|
4
|
+
export const gltfTypeToBabylonType = {
|
5
|
+
float: { length: 1, flowGraphType: "number" /* FlowGraphTypes.Number */, elementType: "number" },
|
6
|
+
bool: { length: 1, flowGraphType: "boolean" /* FlowGraphTypes.Boolean */, elementType: "boolean" },
|
7
|
+
float2: { length: 2, flowGraphType: "Vector2" /* FlowGraphTypes.Vector2 */, elementType: "number" },
|
8
|
+
float3: { length: 3, flowGraphType: "Vector3" /* FlowGraphTypes.Vector3 */, elementType: "number" },
|
9
|
+
float4: { length: 4, flowGraphType: "Vector4" /* FlowGraphTypes.Vector4 */, elementType: "number" },
|
10
|
+
float4x4: { length: 16, flowGraphType: "Matrix" /* FlowGraphTypes.Matrix */, elementType: "number" },
|
11
|
+
float2x2: { length: 4, flowGraphType: "Matrix2D" /* FlowGraphTypes.Matrix2D */, elementType: "number" },
|
12
|
+
float3x3: { length: 9, flowGraphType: "Matrix3D" /* FlowGraphTypes.Matrix3D */, elementType: "number" },
|
13
|
+
int: { length: 1, flowGraphType: "FlowGraphInteger" /* FlowGraphTypes.Integer */, elementType: "number" },
|
14
|
+
};
|
15
|
+
export class InteractivityGraphToFlowGraphParser {
|
16
|
+
constructor(_interactivityGraph, _gltf, _loader) {
|
17
|
+
this._interactivityGraph = _interactivityGraph;
|
18
|
+
this._gltf = _gltf;
|
19
|
+
this._loader = _loader;
|
20
|
+
/**
|
21
|
+
* Note - the graph should be rejected if the same type is defined twice.
|
22
|
+
* We currently don't validate that.
|
23
|
+
*/
|
24
|
+
this._types = [];
|
25
|
+
this._mappings = [];
|
26
|
+
this._staticVariables = [];
|
27
|
+
this._events = [];
|
28
|
+
this._internalEventsCounter = 0;
|
29
|
+
this._nodes = [];
|
30
|
+
// start with types
|
31
|
+
this._parseTypes();
|
32
|
+
// continue with declarations
|
33
|
+
this._parseDeclarations();
|
34
|
+
this._parseVariables();
|
35
|
+
this._parseEvents();
|
36
|
+
this._parseNodes();
|
37
|
+
}
|
38
|
+
get arrays() {
|
39
|
+
return {
|
40
|
+
types: this._types,
|
41
|
+
mappings: this._mappings,
|
42
|
+
staticVariables: this._staticVariables,
|
43
|
+
events: this._events,
|
44
|
+
nodes: this._nodes,
|
45
|
+
};
|
46
|
+
}
|
47
|
+
_parseTypes() {
|
48
|
+
if (!this._interactivityGraph.types) {
|
49
|
+
return;
|
50
|
+
}
|
51
|
+
for (const type of this._interactivityGraph.types) {
|
52
|
+
this._types.push(gltfTypeToBabylonType[type.signature]);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
_parseDeclarations() {
|
56
|
+
if (!this._interactivityGraph.declarations) {
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
for (const declaration of this._interactivityGraph.declarations) {
|
60
|
+
// make sure we have the mapping for this operation
|
61
|
+
const mapping = getMappingForDeclaration(declaration);
|
62
|
+
// mapping is defined, because we generate an empty mapping if it's not found
|
63
|
+
if (!mapping) {
|
64
|
+
Logger.Error(["No mapping found for declaration", declaration]);
|
65
|
+
throw new Error("Error parsing declarations");
|
66
|
+
}
|
67
|
+
this._mappings.push({
|
68
|
+
flowGraphMapping: mapping,
|
69
|
+
fullOperationName: declaration.extension ? declaration.op + ":" + declaration.extension : declaration.op,
|
70
|
+
});
|
71
|
+
}
|
72
|
+
}
|
73
|
+
_parseVariables() {
|
74
|
+
if (!this._interactivityGraph.variables) {
|
75
|
+
return;
|
76
|
+
}
|
77
|
+
for (const variable of this._interactivityGraph.variables) {
|
78
|
+
const parsed = this._parseVariable(variable);
|
79
|
+
// set the default values here
|
80
|
+
this._staticVariables.push(parsed);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
_parseVariable(variable, dataTransform) {
|
84
|
+
const type = this._types[variable.type];
|
85
|
+
if (!type) {
|
86
|
+
Logger.Error(["No type found for variable", variable]);
|
87
|
+
throw new Error("Error parsing variables");
|
88
|
+
}
|
89
|
+
if (variable.value) {
|
90
|
+
if (variable.value.length !== type.length) {
|
91
|
+
Logger.Error(["Invalid value length for variable", variable, type]);
|
92
|
+
throw new Error("Error parsing variables");
|
93
|
+
}
|
94
|
+
}
|
95
|
+
const value = variable.value || [];
|
96
|
+
if (!value.length) {
|
97
|
+
switch (type.flowGraphType) {
|
98
|
+
case "boolean" /* FlowGraphTypes.Boolean */:
|
99
|
+
value.push(false);
|
100
|
+
break;
|
101
|
+
case "FlowGraphInteger" /* FlowGraphTypes.Integer */:
|
102
|
+
value.push(0);
|
103
|
+
break;
|
104
|
+
case "number" /* FlowGraphTypes.Number */:
|
105
|
+
value.push(NaN);
|
106
|
+
break;
|
107
|
+
case "Vector2" /* FlowGraphTypes.Vector2 */:
|
108
|
+
value.push(NaN, NaN);
|
109
|
+
break;
|
110
|
+
case "Vector3" /* FlowGraphTypes.Vector3 */:
|
111
|
+
value.push(NaN, NaN, NaN);
|
112
|
+
break;
|
113
|
+
case "Vector4" /* FlowGraphTypes.Vector4 */:
|
114
|
+
case "Matrix2D" /* FlowGraphTypes.Matrix2D */:
|
115
|
+
value.fill(NaN, 0, 4);
|
116
|
+
break;
|
117
|
+
case "Matrix" /* FlowGraphTypes.Matrix */:
|
118
|
+
value.fill(NaN, 0, 16);
|
119
|
+
break;
|
120
|
+
case "Matrix3D" /* FlowGraphTypes.Matrix3D */:
|
121
|
+
value.fill(NaN, 0, 9);
|
122
|
+
break;
|
123
|
+
default:
|
124
|
+
break;
|
125
|
+
}
|
126
|
+
}
|
127
|
+
return { type: type.flowGraphType, value: dataTransform ? dataTransform(value, this) : value };
|
128
|
+
}
|
129
|
+
_parseEvents() {
|
130
|
+
if (!this._interactivityGraph.events) {
|
131
|
+
return;
|
132
|
+
}
|
133
|
+
for (const event of this._interactivityGraph.events) {
|
134
|
+
const converted = {
|
135
|
+
eventId: event.id || "internalEvent_" + this._internalEventsCounter++,
|
136
|
+
};
|
137
|
+
if (event.values) {
|
138
|
+
converted.eventData = Object.keys(event.values).map((key) => {
|
139
|
+
const eventValue = event.values?.[key];
|
140
|
+
if (!eventValue) {
|
141
|
+
Logger.Error(["No value found for event key", key]);
|
142
|
+
throw new Error("Error parsing events");
|
143
|
+
}
|
144
|
+
const type = this._types[eventValue.type];
|
145
|
+
if (!type) {
|
146
|
+
Logger.Error(["No type found for event value", eventValue]);
|
147
|
+
throw new Error("Error parsing events");
|
148
|
+
}
|
149
|
+
const value = typeof eventValue.value !== "undefined" ? this._parseVariable(eventValue) : undefined;
|
150
|
+
return {
|
151
|
+
id: key,
|
152
|
+
type: type.flowGraphType,
|
153
|
+
eventData: true,
|
154
|
+
value,
|
155
|
+
};
|
156
|
+
});
|
157
|
+
}
|
158
|
+
this._events.push(converted);
|
159
|
+
}
|
160
|
+
}
|
161
|
+
_parseNodes() {
|
162
|
+
if (!this._interactivityGraph.nodes) {
|
163
|
+
return;
|
164
|
+
}
|
165
|
+
for (const node of this._interactivityGraph.nodes) {
|
166
|
+
// some validation
|
167
|
+
if (typeof node.declaration !== "number") {
|
168
|
+
Logger.Error(["No declaration found for node", node]);
|
169
|
+
throw new Error("Error parsing nodes");
|
170
|
+
}
|
171
|
+
const mapping = this._mappings[node.declaration];
|
172
|
+
if (!mapping) {
|
173
|
+
Logger.Error(["No mapping found for node", node]);
|
174
|
+
throw new Error("Error parsing nodes");
|
175
|
+
}
|
176
|
+
if (mapping.flowGraphMapping.validation) {
|
177
|
+
if (!mapping.flowGraphMapping.validation(node, this._interactivityGraph, this._gltf)) {
|
178
|
+
throw new Error(`Error validating interactivity node ${node}`);
|
179
|
+
}
|
180
|
+
}
|
181
|
+
const blocks = [];
|
182
|
+
// create block(s) for this node using the mapping
|
183
|
+
for (const blockType of mapping.flowGraphMapping.blocks) {
|
184
|
+
const block = this._getEmptyBlock(blockType, mapping.fullOperationName);
|
185
|
+
this._parseNodeConfiguration(node, block, mapping.flowGraphMapping, blockType);
|
186
|
+
blocks.push(block);
|
187
|
+
}
|
188
|
+
this._nodes.push({ blocks, fullOperationName: mapping.fullOperationName });
|
189
|
+
}
|
190
|
+
}
|
191
|
+
_getEmptyBlock(className, type) {
|
192
|
+
const uniqueId = RandomGUID();
|
193
|
+
const dataInputs = [];
|
194
|
+
const dataOutputs = [];
|
195
|
+
const signalInputs = [];
|
196
|
+
const signalOutputs = [];
|
197
|
+
const config = {};
|
198
|
+
const metadata = {};
|
199
|
+
return {
|
200
|
+
uniqueId,
|
201
|
+
className,
|
202
|
+
dataInputs,
|
203
|
+
dataOutputs,
|
204
|
+
signalInputs,
|
205
|
+
signalOutputs,
|
206
|
+
config,
|
207
|
+
type,
|
208
|
+
metadata,
|
209
|
+
};
|
210
|
+
}
|
211
|
+
_parseNodeConfiguration(node, block, nodeMapping, blockType) {
|
212
|
+
const configuration = block.config;
|
213
|
+
if (node.configuration) {
|
214
|
+
Object.keys(node.configuration).forEach((key) => {
|
215
|
+
const value = node.configuration?.[key];
|
216
|
+
// value is always an array, never a number or string
|
217
|
+
if (!value) {
|
218
|
+
Logger.Error(["No value found for node configuration", key]);
|
219
|
+
throw new Error("Error parsing node configuration");
|
220
|
+
}
|
221
|
+
const configMapping = nodeMapping.configuration?.[key];
|
222
|
+
const belongsToBlock = configMapping && configMapping.toBlock ? configMapping.toBlock === blockType : nodeMapping.blocks.indexOf(blockType) === 0;
|
223
|
+
if (belongsToBlock) {
|
224
|
+
// get the right name for the configuration key
|
225
|
+
const configKey = configMapping?.name || key;
|
226
|
+
if ((!value || typeof value.value === "undefined") && typeof configMapping?.defaultValue !== "undefined") {
|
227
|
+
configuration[configKey] = {
|
228
|
+
value: configMapping.defaultValue,
|
229
|
+
};
|
230
|
+
}
|
231
|
+
else if (value.value.length >= 1) {
|
232
|
+
// supporting int[] and int/boolean/string
|
233
|
+
configuration[configKey] = {
|
234
|
+
value: value.value.length === 1 ? value.value[0] : value.value,
|
235
|
+
};
|
236
|
+
}
|
237
|
+
else {
|
238
|
+
Logger.Warn(["Invalid value for node configuration", value]);
|
239
|
+
}
|
240
|
+
// make sure we transform the data if needed
|
241
|
+
if (configMapping && configMapping.dataTransformer) {
|
242
|
+
configuration[configKey].value = configMapping.dataTransformer([configuration[configKey].value], this)[0];
|
243
|
+
}
|
244
|
+
}
|
245
|
+
});
|
246
|
+
}
|
247
|
+
}
|
248
|
+
_parseNodeConnections(context) {
|
249
|
+
for (let i = 0; i < this._nodes.length; i++) {
|
250
|
+
// get the corresponding gltf node
|
251
|
+
const gltfNode = this._interactivityGraph.nodes?.[i];
|
252
|
+
if (!gltfNode) {
|
253
|
+
// should never happen but let's still check
|
254
|
+
Logger.Error(["No node found for interactivity node", this._nodes[i]]);
|
255
|
+
throw new Error("Error parsing node connections");
|
256
|
+
}
|
257
|
+
const flowGraphBlocks = this._nodes[i];
|
258
|
+
const outputMapper = this._mappings[gltfNode.declaration];
|
259
|
+
// validate
|
260
|
+
if (!outputMapper) {
|
261
|
+
Logger.Error(["No mapping found for node", gltfNode]);
|
262
|
+
throw new Error("Error parsing node connections");
|
263
|
+
}
|
264
|
+
const flowsFromGLTF = gltfNode.flows || {};
|
265
|
+
const flowsKeys = Object.keys(flowsFromGLTF).sort(); // sorting as some operations require sorted keys
|
266
|
+
// connect the flows
|
267
|
+
for (const flowKey of flowsKeys) {
|
268
|
+
const flow = flowsFromGLTF[flowKey];
|
269
|
+
const flowMapping = outputMapper.flowGraphMapping.outputs?.flows?.[flowKey];
|
270
|
+
const socketOutName = flowMapping?.name || flowKey;
|
271
|
+
// create a serialized socket
|
272
|
+
const socketOut = this._createNewSocketConnection(socketOutName, true);
|
273
|
+
const block = (flowMapping && flowMapping.toBlock && flowGraphBlocks.blocks.find((b) => b.className === flowMapping.toBlock)) || flowGraphBlocks.blocks[0];
|
274
|
+
block.signalOutputs.push(socketOut);
|
275
|
+
// get the input node of this block
|
276
|
+
const inputNodeId = flow.node;
|
277
|
+
const nodeIn = this._nodes[inputNodeId];
|
278
|
+
if (!nodeIn) {
|
279
|
+
Logger.Error(["No node found for input node id", inputNodeId]);
|
280
|
+
throw new Error("Error parsing node connections");
|
281
|
+
}
|
282
|
+
// get the mapper for the input node - in case it mapped to multiple blocks
|
283
|
+
const inputMapper = getMappingForFullOperationName(nodeIn.fullOperationName);
|
284
|
+
if (!inputMapper) {
|
285
|
+
Logger.Error(["No mapping found for input node", nodeIn]);
|
286
|
+
throw new Error("Error parsing node connections");
|
287
|
+
}
|
288
|
+
let flowInMapping = inputMapper.inputs?.flows?.[flow.socket || "in"];
|
289
|
+
let arrayMapping = false;
|
290
|
+
if (!flowInMapping) {
|
291
|
+
for (const key in inputMapper.inputs?.flows) {
|
292
|
+
if (key.startsWith("[") && key.endsWith("]")) {
|
293
|
+
arrayMapping = true;
|
294
|
+
flowInMapping = inputMapper.inputs?.flows?.[key];
|
295
|
+
}
|
296
|
+
}
|
297
|
+
}
|
298
|
+
const nodeInSocketName = flowInMapping ? (arrayMapping ? flowInMapping.name.replace("$1", flow.socket || "") : flowInMapping.name) : flow.socket || "in";
|
299
|
+
const inputBlock = (flowInMapping && flowInMapping.toBlock && nodeIn.blocks.find((b) => b.className === flowInMapping.toBlock)) || nodeIn.blocks[0];
|
300
|
+
// in all of the flow graph input connections, find the one with the same name as the socket
|
301
|
+
let socketIn = inputBlock.signalInputs.find((s) => s.name === nodeInSocketName);
|
302
|
+
// if the socket doesn't exist, create the input socket for the connection
|
303
|
+
if (!socketIn) {
|
304
|
+
socketIn = this._createNewSocketConnection(nodeInSocketName);
|
305
|
+
inputBlock.signalInputs.push(socketIn);
|
306
|
+
}
|
307
|
+
// connect the sockets
|
308
|
+
socketIn.connectedPointIds.push(socketOut.uniqueId);
|
309
|
+
socketOut.connectedPointIds.push(socketIn.uniqueId);
|
310
|
+
}
|
311
|
+
// connect the values
|
312
|
+
const valuesFromGLTF = gltfNode.values || {};
|
313
|
+
const valuesKeys = Object.keys(valuesFromGLTF);
|
314
|
+
for (const valueKey of valuesKeys) {
|
315
|
+
const value = valuesFromGLTF[valueKey];
|
316
|
+
let valueMapping = outputMapper.flowGraphMapping.inputs?.values?.[valueKey];
|
317
|
+
let arrayMapping = false;
|
318
|
+
if (!valueMapping) {
|
319
|
+
for (const key in outputMapper.flowGraphMapping.inputs?.values) {
|
320
|
+
if (key.startsWith("[") && key.endsWith("]")) {
|
321
|
+
arrayMapping = true;
|
322
|
+
valueMapping = outputMapper.flowGraphMapping.inputs?.values?.[key];
|
323
|
+
}
|
324
|
+
}
|
325
|
+
}
|
326
|
+
const socketInName = valueMapping ? (arrayMapping ? valueMapping.name.replace("$1", valueKey) : valueMapping.name) : valueKey;
|
327
|
+
// create a serialized socket
|
328
|
+
const socketIn = this._createNewSocketConnection(socketInName);
|
329
|
+
const block = (valueMapping && valueMapping.toBlock && flowGraphBlocks.blocks.find((b) => b.className === valueMapping.toBlock)) || flowGraphBlocks.blocks[0];
|
330
|
+
block.dataInputs.push(socketIn);
|
331
|
+
if (value.value !== undefined) {
|
332
|
+
const convertedValue = this._parseVariable(value, valueMapping && valueMapping.dataTransformer);
|
333
|
+
context._connectionValues[socketIn.uniqueId] = convertedValue;
|
334
|
+
}
|
335
|
+
else if (typeof value.node !== "undefined") {
|
336
|
+
const nodeOutId = value.node;
|
337
|
+
const nodeOutSocketName = value.socket || "value";
|
338
|
+
const nodeOut = this._nodes[nodeOutId];
|
339
|
+
if (!nodeOut) {
|
340
|
+
Logger.Error(["No node found for output socket reference", value]);
|
341
|
+
throw new Error("Error parsing node connections");
|
342
|
+
}
|
343
|
+
const outputMapper = getMappingForFullOperationName(nodeOut.fullOperationName);
|
344
|
+
if (!outputMapper) {
|
345
|
+
Logger.Error(["No mapping found for output socket reference", value]);
|
346
|
+
throw new Error("Error parsing node connections");
|
347
|
+
}
|
348
|
+
let valueMapping = outputMapper.outputs?.values?.[nodeOutSocketName];
|
349
|
+
let arrayMapping = false;
|
350
|
+
// check if there is an array mapping defined
|
351
|
+
if (!valueMapping) {
|
352
|
+
// search for a value mapping that has an array mapping
|
353
|
+
for (const key in outputMapper.outputs?.values) {
|
354
|
+
if (key.startsWith("[") && key.endsWith("]")) {
|
355
|
+
arrayMapping = true;
|
356
|
+
valueMapping = outputMapper.outputs?.values?.[key];
|
357
|
+
}
|
358
|
+
}
|
359
|
+
}
|
360
|
+
const socketOutName = valueMapping ? (arrayMapping ? valueMapping.name.replace("$1", nodeOutSocketName) : valueMapping?.name) : nodeOutSocketName;
|
361
|
+
const outBlock = (valueMapping && valueMapping.toBlock && nodeOut.blocks.find((b) => b.className === valueMapping.toBlock)) || nodeOut.blocks[0];
|
362
|
+
let socketOut = outBlock.dataOutputs.find((s) => s.name === socketOutName);
|
363
|
+
// if the socket doesn't exist, create it
|
364
|
+
if (!socketOut) {
|
365
|
+
socketOut = this._createNewSocketConnection(socketOutName, true);
|
366
|
+
outBlock.dataOutputs.push(socketOut);
|
367
|
+
}
|
368
|
+
// connect the sockets
|
369
|
+
socketIn.connectedPointIds.push(socketOut.uniqueId);
|
370
|
+
socketOut.connectedPointIds.push(socketIn.uniqueId);
|
371
|
+
}
|
372
|
+
else {
|
373
|
+
Logger.Error(["Invalid value for value connection", value]);
|
374
|
+
throw new Error("Error parsing node connections");
|
375
|
+
}
|
376
|
+
}
|
377
|
+
// inter block connections
|
378
|
+
if (outputMapper.flowGraphMapping.interBlockConnectors) {
|
379
|
+
for (const connector of outputMapper.flowGraphMapping.interBlockConnectors) {
|
380
|
+
const input = connector.input;
|
381
|
+
const output = connector.output;
|
382
|
+
const isVariable = connector.isVariable;
|
383
|
+
this._connectFlowGraphNodes(input, output, flowGraphBlocks.blocks[connector.inputBlockIndex], flowGraphBlocks.blocks[connector.outputBlockIndex], isVariable);
|
384
|
+
}
|
385
|
+
}
|
386
|
+
if (outputMapper.flowGraphMapping.extraProcessor) {
|
387
|
+
const declaration = this._interactivityGraph.declarations?.[gltfNode.declaration];
|
388
|
+
if (!declaration) {
|
389
|
+
Logger.Error(["No declaration found for extra processor", gltfNode]);
|
390
|
+
throw new Error("Error parsing node connections");
|
391
|
+
}
|
392
|
+
flowGraphBlocks.blocks = outputMapper.flowGraphMapping.extraProcessor(gltfNode, declaration, outputMapper.flowGraphMapping, this, flowGraphBlocks.blocks, context, this._gltf);
|
393
|
+
}
|
394
|
+
}
|
395
|
+
}
|
396
|
+
_createNewSocketConnection(name, isOutput) {
|
397
|
+
return {
|
398
|
+
uniqueId: RandomGUID(),
|
399
|
+
name,
|
400
|
+
_connectionType: isOutput ? 1 /* FlowGraphConnectionType.Output */ : 0 /* FlowGraphConnectionType.Input */,
|
401
|
+
connectedPointIds: [],
|
402
|
+
};
|
403
|
+
}
|
404
|
+
_connectFlowGraphNodes(input, output, serializedInput, serializedOutput, isVariable) {
|
405
|
+
const inputArray = isVariable ? serializedInput.dataInputs : serializedInput.signalInputs;
|
406
|
+
const outputArray = isVariable ? serializedOutput.dataOutputs : serializedOutput.signalOutputs;
|
407
|
+
const inputConnection = inputArray.find((s) => s.name === input) || this._createNewSocketConnection(input);
|
408
|
+
const outputConnection = outputArray.find((s) => s.name === output) || this._createNewSocketConnection(output, true);
|
409
|
+
// of not found add it to the array
|
410
|
+
if (!inputArray.find((s) => s.name === input)) {
|
411
|
+
inputArray.push(inputConnection);
|
412
|
+
}
|
413
|
+
if (!outputArray.find((s) => s.name === output)) {
|
414
|
+
outputArray.push(outputConnection);
|
415
|
+
}
|
416
|
+
// connect the sockets
|
417
|
+
inputConnection.connectedPointIds.push(outputConnection.uniqueId);
|
418
|
+
outputConnection.connectedPointIds.push(inputConnection.uniqueId);
|
419
|
+
}
|
420
|
+
getVariableName(index) {
|
421
|
+
return "staticVariable_" + index;
|
422
|
+
}
|
423
|
+
serializeToFlowGraph() {
|
424
|
+
const context = {
|
425
|
+
uniqueId: RandomGUID(),
|
426
|
+
_userVariables: {},
|
427
|
+
_connectionValues: {},
|
428
|
+
};
|
429
|
+
this._parseNodeConnections(context);
|
430
|
+
for (let i = 0; i < this._staticVariables.length; i++) {
|
431
|
+
const variable = this._staticVariables[i];
|
432
|
+
context._userVariables[this.getVariableName(i)] = variable;
|
433
|
+
}
|
434
|
+
const allBlocks = this._nodes.reduce((acc, val) => acc.concat(val.blocks), []);
|
435
|
+
return {
|
436
|
+
rightHanded: true,
|
437
|
+
allBlocks,
|
438
|
+
executionContexts: [context],
|
439
|
+
};
|
440
|
+
}
|
441
|
+
}
|
442
|
+
//# sourceMappingURL=interactivityGraphParser.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"interactivityGraphParser.js","sourceRoot":"","sources":["../../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAE1C,OAAO,EAAE,UAAU,EAAE,qCAAuB;AAgB5C,MAAM,CAAC,MAAM,qBAAqB,GAE9B;IACA,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,sCAAuB,EAAE,WAAW,EAAE,QAAQ,EAAE;IACjF,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,wCAAwB,EAAE,WAAW,EAAE,SAAS,EAAE;IAClF,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,wCAAwB,EAAE,WAAW,EAAE,QAAQ,EAAE;IACnF,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,wCAAwB,EAAE,WAAW,EAAE,QAAQ,EAAE;IACnF,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,wCAAwB,EAAE,WAAW,EAAE,QAAQ,EAAE;IACnF,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,sCAAuB,EAAE,WAAW,EAAE,QAAQ,EAAE;IACrF,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,0CAAyB,EAAE,WAAW,EAAE,QAAQ,EAAE;IACtF,Q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1C,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC;QAC/D,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAiC,CAAC,CAAC;QAE9G,OAAO;YACH,WAAW,EAAE,IAAI;YACjB,SAAS;YACT,iBAAiB,EAAE,CAAC,OAAO,CAAC;SAC/B,CAAC;IACN,CAAC;CACJ","sourcesContent":["import type { IKHRInteractivity_Graph, IKHRInteractivity_Node, IKHRInteractivity_OutputSocketReference, IKHRInteractivity_Variable } from \"babylonjs-gltf2interface\";\nimport type { IGLTF } from \"../../glTFLoaderInterfaces\";\nimport type { IGLTFToFlowGraphMapping } from \"./declarationMapper\";\nimport { getMappingForDeclaration, getMappingForFullOperationName } from \"./declarationMapper\";\nimport { Logger } from \"core/Misc/logger\";\nimport type { ISerializedFlowGraph, ISerializedFlowGraphBlock, ISerializedFlowGraphConnection, ISerializedFlowGraphContext } from \"core/FlowGraph/typeDefinitions\";\nimport { RandomGUID } from \"core/Misc/guid\";\nimport type { IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\nimport type { FlowGraphBlockNames } from \"core/FlowGraph/Blocks/flowGraphBlockNames\";\nimport { FlowGraphConnectionType } from \"core/FlowGraph/flowGraphConnection\";\nimport { FlowGraphTypes } from \"core/FlowGraph/flowGraphRichTypes\";\nimport type { GLTFLoader } from \"../../glTFLoader\";\n\nexport interface InteractivityEvent {\n eventId: string;\n eventData?: {\n eventData: boolean;\n id: string;\n type: string;\n value?: any;\n }[];\n}\nexport const gltfTypeToBabylonType: {\n [key: string]: { length: number; flowGraphType: FlowGraphTypes; elementType: \"number\" | \"boolean\" };\n} = {\n float: { length: 1, flowGraphType: FlowGraphTypes.Number, elementType: \"number\" },\n bool: { length: 1, flowGraphType: FlowGraphTypes.Boolean, elementType: \"boolean\" },\n float2: { length: 2, flowGraphType: FlowGraphTypes.Vector2, elementType: \"number\" },\n float3: { length: 3, flowGraphType: FlowGraphTypes.Vector3, elementType: \"number\" },\n float4: { length: 4, flowGraphType: FlowGraphTypes.Vector4, elementType: \"number\" },\n float4x4: { length: 16, flowGraphType: FlowGraphTypes.Matrix, elementType: \"number\" },\n float2x2: { length: 4, flowGraphType: FlowGraphTypes.Matrix2D, elementType: \"number\" },\n float3x3: { length: 9, flowGraphType: FlowGraphTypes.Matrix3D, elementType: \"number\" },\n int: { length: 1, flowGraphType: FlowGraphTypes.Integer, elementType: \"number\" },\n};\n\nexport class InteractivityGraphToFlowGraphParser {\n /**\n * Note - the graph should be rejected if the same type is defined twice.\n * We currently don't validate that.\n */\n private _types: { length: number; flowGraphType: FlowGraphTypes; elementType: \"number\" | \"boolean\" }[] = [];\n private _mappings: { flowGraphMapping: IGLTFToFlowGraphMapping; fullOperationName: string }[] = [];\n private _staticVariables: { type: FlowGraphTypes; value: any[] }[] = [];\n private _events: InteractivityEvent[] = [];\n private _internalEventsCounter: number = 0;\n private _nodes: { blocks: ISerializedFlowGraphBlock[]; fullOperationName: string }[] = [];\n\n constructor(\n private _interactivityGraph: IKHRInteractivity_Graph,\n private _gltf: IGLTF,\n public _loader: GLTFLoader\n ) {\n // start with types\n this._parseTypes();\n // continue with declarations\n this._parseDeclarations();\n this._parseVariables();\n this._parseEvents();\n this._parseNodes();\n }\n\n public get arrays() {\n return {\n types: this._types,\n mappings: this._mappings,\n staticVariables: this._staticVariables,\n events: this._events,\n nodes: this._nodes,\n };\n }\n\n private _parseTypes() {\n if (!this._interactivityGraph.types) {\n return;\n }\n for (const type of this._interactivityGraph.types) {\n this._types.push(gltfTypeToBabylonType[type.signature]);\n }\n }\n\n private _parseDeclarations() {\n if (!this._interactivityGraph.declarations) {\n return;\n }\n for (const declaration of this._interactivityGraph.declarations) {\n // make sure we have the mapping for this operation\n const mapping = getMappingForDeclaration(declaration);\n // mapping is defined, because we generate an empty mapping if it's not found\n if (!mapping) {\n Logger.Error([\"No mapping found for declaration\", declaration]);\n throw new Error(\"Error parsing declarations\");\n }\n this._mappings.push({\n flowGraphMapping: mapping,\n fullOperationName: declaration.extension ? declaration.op + \":\" + declaration.extension : declaration.op,\n });\n }\n }\n\n private _parseVariables() {\n if (!this._interactivityGraph.variables) {\n return;\n }\n for (const variable of this._interactivityGraph.variables) {\n const parsed = this._parseVariable(variable);\n // set the default values here\n this._staticVariables.push(parsed);\n }\n }\n\n private _parseVariable(variable: IKHRInteractivity_Variable, dataTransform?: (value: any, parser: InteractivityGraphToFlowGraphParser) => any) {\n const type = this._types[variable.type];\n if (!type) {\n Logger.Error([\"No type found for variable\", variable]);\n throw new Error(\"Error parsing variables\");\n }\n if (variable.value) {\n if (variable.value.length !== type.length) {\n Logger.Error([\"Invalid value length for variable\", variable, type]);\n throw new Error(\"Error parsing variables\");\n }\n }\n const value = variable.value || [];\n if (!value.length) {\n switch (type.flowGraphType) {\n case FlowGraphTypes.Boolean:\n value.push(false);\n break;\n case FlowGraphTypes.Integer:\n value.push(0);\n break;\n case FlowGraphTypes.Number:\n value.push(NaN);\n break;\n case FlowGraphTypes.Vector2:\n value.push(NaN, NaN);\n break;\n case FlowGraphTypes.Vector3:\n value.push(NaN, NaN, NaN);\n break;\n case FlowGraphTypes.Vector4:\n case FlowGraphTypes.Matrix2D:\n value.fill(NaN, 0, 4);\n break;\n case FlowGraphTypes.Matrix:\n value.fill(NaN, 0, 16);\n break;\n case FlowGraphTypes.Matrix3D:\n value.fill(NaN, 0, 9);\n break;\n default:\n break;\n }\n }\n return { type: type.flowGraphType, value: dataTransform ? dataTransform(value, this) : value };\n }\n\n private _parseEvents() {\n if (!this._interactivityGraph.events) {\n return;\n }\n for (const event of this._interactivityGraph.events) {\n const converted: InteractivityEvent = {\n eventId: event.id || \"internalEvent_\" + this._internalEventsCounter++,\n };\n if (event.values) {\n converted.eventData = Object.keys(event.values).map((key) => {\n const eventValue = event.values?.[key];\n if (!eventValue) {\n Logger.Error([\"No value found for event key\", key]);\n throw new Error(\"Error parsing events\");\n }\n const type = this._types[eventValue.type];\n if (!type) {\n Logger.Error([\"No type found for event value\", eventValue]);\n throw new Error(\"Error parsing events\");\n }\n const value = typeof eventValue.value !== \"undefined\" ? this._parseVariable(eventValue) : undefined;\n return {\n id: key,\n type: type.flowGraphType,\n eventData: true,\n value,\n };\n });\n }\n this._events.push(converted);\n }\n }\n\n private _parseNodes() {\n if (!this._interactivityGraph.nodes) {\n return;\n }\n for (const node of this._interactivityGraph.nodes) {\n // some validation\n if (typeof node.declaration !== \"number\") {\n Logger.Error([\"No declaration found for node\", node]);\n throw new Error(\"Error parsing nodes\");\n }\n const mapping = this._mappings[node.declaration];\n if (!mapping) {\n Logger.Error([\"No mapping found for node\", node]);\n throw new Error(\"Error parsing nodes\");\n }\n if (mapping.flowGraphMapping.validation) {\n if (!mapping.flowGraphMapping.validation(node, this._interactivityGraph, this._gltf)) {\n throw new Error(`Error validating interactivity node ${node}`);\n }\n }\n const blocks: ISerializedFlowGraphBlock[] = [];\n // create block(s) for this node using the mapping\n for (const blockType of mapping.flowGraphMapping.blocks) {\n const block = this._getEmptyBlock(blockType, mapping.fullOperationName);\n this._parseNodeConfiguration(node, block, mapping.flowGraphMapping, blockType);\n blocks.push(block);\n }\n this._nodes.push({ blocks, fullOperationName: mapping.fullOperationName });\n }\n }\n\n private _getEmptyBlock(className: string, type: string): ISerializedFlowGraphBlock {\n const uniqueId = RandomGUID();\n const dataInputs: ISerializedFlowGraphConnection[] = [];\n const dataOutputs: ISerializedFlowGraphConnection[] = [];\n const signalInputs: ISerializedFlowGraphConnection[] = [];\n const signalOutputs: ISerializedFlowGraphConnection[] = [];\n const config: IFlowGraphBlockConfiguration = {};\n const metadata = {};\n return {\n uniqueId,\n className,\n dataInputs,\n dataOutputs,\n signalInputs,\n signalOutputs,\n config,\n type,\n metadata,\n };\n }\n\n private _parseNodeConfiguration(node: IKHRInteractivity_Node, block: ISerializedFlowGraphBlock, nodeMapping: IGLTFToFlowGraphMapping, blockType: FlowGraphBlockNames | string) {\n const configuration = block.config;\n if (node.configuration) {\n Object.keys(node.configuration).forEach((key) => {\n const value = node.configuration?.[key];\n // value is always an array, never a number or string\n if (!value) {\n Logger.Error([\"No value found for node configuration\", key]);\n throw new Error(\"Error parsing node configuration\");\n }\n const configMapping = nodeMapping.configuration?.[key];\n const belongsToBlock = configMapping && configMapping.toBlock ? configMapping.toBlock === blockType : nodeMapping.blocks.indexOf(blockType) === 0;\n if (belongsToBlock) {\n // get the right name for the configuration key\n const configKey = configMapping?.name || key;\n if ((!value || typeof value.value === \"undefined\") && typeof configMapping?.defaultValue !== \"undefined\") {\n configuration[configKey] = {\n value: configMapping.defaultValue,\n };\n } else if (value.value.length >= 1) {\n // supporting int[] and int/boolean/string\n configuration[configKey] = {\n value: value.value.length === 1 ? value.value[0] : value.value,\n };\n } else {\n Logger.Warn([\"Invalid value for node configuration\", value]);\n }\n // make sure we transform the data if needed\n if (configMapping && configMapping.dataTransformer) {\n configuration[configKey].value = configMapping.dataTransformer([configuration[configKey].value], this)[0];\n }\n }\n });\n }\n }\n\n private _parseNodeConnections(context: ISerializedFlowGraphContext) {\n for (let i = 0; i < this._nodes.length; i++) {\n // get the corresponding gltf node\n const gltfNode = this._interactivityGraph.nodes?.[i];\n if (!gltfNode) {\n // should never happen but let's still check\n Logger.Error([\"No node found for interactivity node\", this._nodes[i]]);\n throw new Error(\"Error parsing node connections\");\n }\n const flowGraphBlocks = this._nodes[i];\n const outputMapper = this._mappings[gltfNode.declaration];\n // validate\n if (!outputMapper) {\n Logger.Error([\"No mapping found for node\", gltfNode]);\n throw new Error(\"Error parsing node connections\");\n }\n const flowsFromGLTF = gltfNode.flows || {};\n const flowsKeys = Object.keys(flowsFromGLTF).sort(); // sorting as some operations require sorted keys\n // connect the flows\n for (const flowKey of flowsKeys) {\n const flow = flowsFromGLTF[flowKey];\n const flowMapping = outputMapper.flowGraphMapping.outputs?.flows?.[flowKey];\n const socketOutName = flowMapping?.name || flowKey;\n // create a serialized socket\n const socketOut = this._createNewSocketConnection(socketOutName, true);\n const block = (flowMapping && flowMapping.toBlock && flowGraphBlocks.blocks.find((b) => b.className === flowMapping.toBlock)) || flowGraphBlocks.blocks[0];\n block.signalOutputs.push(socketOut);\n // get the input node of this block\n const inputNodeId = flow.node;\n const nodeIn = this._nodes[inputNodeId];\n if (!nodeIn) {\n Logger.Error([\"No node found for input node id\", inputNodeId]);\n throw new Error(\"Error parsing node connections\");\n }\n // get the mapper for the input node - in case it mapped to multiple blocks\n const inputMapper = getMappingForFullOperationName(nodeIn.fullOperationName);\n if (!inputMapper) {\n Logger.Error([\"No mapping found for input node\", nodeIn]);\n throw new Error(\"Error parsing node connections\");\n }\n let flowInMapping = inputMapper.inputs?.flows?.[flow.socket || \"in\"];\n let arrayMapping = false;\n if (!flowInMapping) {\n for (const key in inputMapper.inputs?.flows) {\n if (key.startsWith(\"[\") && key.endsWith(\"]\")) {\n arrayMapping = true;\n flowInMapping = inputMapper.inputs?.flows?.[key];\n }\n }\n }\n const nodeInSocketName = flowInMapping ? (arrayMapping ? flowInMapping.name.replace(\"$1\", flow.socket || \"\") : flowInMapping.name) : flow.socket || \"in\";\n const inputBlock = (flowInMapping && flowInMapping.toBlock && nodeIn.blocks.find((b) => b.className === flowInMapping.toBlock)) || nodeIn.blocks[0];\n // in all of the flow graph input connections, find the one with the same name as the socket\n let socketIn = inputBlock.signalInputs.find((s) => s.name === nodeInSocketName);\n // if the socket doesn't exist, create the input socket for the connection\n if (!socketIn) {\n socketIn = this._createNewSocketConnection(nodeInSocketName);\n inputBlock.signalInputs.push(socketIn);\n }\n // connect the sockets\n socketIn.connectedPointIds.push(socketOut.uniqueId);\n socketOut.connectedPointIds.push(socketIn.uniqueId);\n }\n // connect the values\n const valuesFromGLTF = gltfNode.values || {};\n const valuesKeys = Object.keys(valuesFromGLTF);\n for (const valueKey of valuesKeys) {\n const value = valuesFromGLTF[valueKey];\n let valueMapping = outputMapper.flowGraphMapping.inputs?.values?.[valueKey];\n let arrayMapping = false;\n if (!valueMapping) {\n for (const key in outputMapper.flowGraphMapping.inputs?.values) {\n if (key.startsWith(\"[\") && key.endsWith(\"]\")) {\n arrayMapping = true;\n valueMapping = outputMapper.flowGraphMapping.inputs?.values?.[key];\n }\n }\n }\n const socketInName = valueMapping ? (arrayMapping ? valueMapping.name.replace(\"$1\", valueKey) : valueMapping.name) : valueKey;\n // create a serialized socket\n const socketIn = this._createNewSocketConnection(socketInName);\n const block = (valueMapping && valueMapping.toBlock && flowGraphBlocks.blocks.find((b) => b.className === valueMapping!.toBlock)) || flowGraphBlocks.blocks[0];\n block.dataInputs.push(socketIn);\n if ((value as IKHRInteractivity_Variable).value !== undefined) {\n const convertedValue = this._parseVariable(value as IKHRInteractivity_Variable, valueMapping && valueMapping.dataTransformer);\n context._connectionValues[socketIn.uniqueId] = convertedValue;\n } else if (typeof (value as IKHRInteractivity_OutputSocketReference).node !== \"undefined\") {\n const nodeOutId = (value as IKHRInteractivity_OutputSocketReference).node;\n const nodeOutSocketName = (value as IKHRInteractivity_OutputSocketReference).socket || \"value\";\n const nodeOut = this._nodes[nodeOutId];\n if (!nodeOut) {\n Logger.Error([\"No node found for output socket reference\", value]);\n throw new Error(\"Error parsing node connections\");\n }\n const outputMapper = getMappingForFullOperationName(nodeOut.fullOperationName);\n if (!outputMapper) {\n Logger.Error([\"No mapping found for output socket reference\", value]);\n throw new Error(\"Error parsing node connections\");\n }\n let valueMapping = outputMapper.outputs?.values?.[nodeOutSocketName];\n let arrayMapping = false;\n // check if there is an array mapping defined\n if (!valueMapping) {\n // search for a value mapping that has an array mapping\n for (const key in outputMapper.outputs?.values) {\n if (key.startsWith(\"[\") && key.endsWith(\"]\")) {\n arrayMapping = true;\n valueMapping = outputMapper.outputs?.values?.[key];\n }\n }\n }\n const socketOutName = valueMapping ? (arrayMapping ? valueMapping.name.replace(\"$1\", nodeOutSocketName) : valueMapping?.name) : nodeOutSocketName;\n const outBlock = (valueMapping && valueMapping.toBlock && nodeOut.blocks.find((b) => b.className === valueMapping!.toBlock)) || nodeOut.blocks[0];\n let socketOut = outBlock.dataOutputs.find((s) => s.name === socketOutName);\n // if the socket doesn't exist, create it\n if (!socketOut) {\n socketOut = this._createNewSocketConnection(socketOutName, true);\n outBlock.dataOutputs.push(socketOut);\n }\n // connect the sockets\n socketIn.connectedPointIds.push(socketOut.uniqueId);\n socketOut.connectedPointIds.push(socketIn.uniqueId);\n } else {\n Logger.Error([\"Invalid value for value connection\", value]);\n throw new Error(\"Error parsing node connections\");\n }\n }\n\n // inter block connections\n if (outputMapper.flowGraphMapping.interBlockConnectors) {\n for (const connector of outputMapper.flowGraphMapping.interBlockConnectors) {\n const input = connector.input;\n const output = connector.output;\n const isVariable = connector.isVariable;\n this._connectFlowGraphNodes(input, output, flowGraphBlocks.blocks[connector.inputBlockIndex], flowGraphBlocks.blocks[connector.outputBlockIndex], isVariable);\n }\n }\n\n if (outputMapper.flowGraphMapping.extraProcessor) {\n const declaration = this._interactivityGraph.declarations?.[gltfNode.declaration];\n if (!declaration) {\n Logger.Error([\"No declaration found for extra processor\", gltfNode]);\n throw new Error(\"Error parsing node connections\");\n }\n flowGraphBlocks.blocks = outputMapper.flowGraphMapping.extraProcessor(\n gltfNode,\n declaration,\n outputMapper.flowGraphMapping,\n this,\n flowGraphBlocks.blocks,\n context,\n this._gltf\n );\n }\n }\n }\n\n private _createNewSocketConnection(name: string, isOutput?: boolean): ISerializedFlowGraphConnection {\n return {\n uniqueId: RandomGUID(),\n name,\n _connectionType: isOutput ? FlowGraphConnectionType.Output : FlowGraphConnectionType.Input,\n connectedPointIds: [],\n };\n }\n\n private _connectFlowGraphNodes(input: string, output: string, serializedInput: ISerializedFlowGraphBlock, serializedOutput: ISerializedFlowGraphBlock, isVariable?: boolean) {\n const inputArray = isVariable ? serializedInput.dataInputs : serializedInput.signalInputs;\n const outputArray = isVariable ? serializedOutput.dataOutputs : serializedOutput.signalOutputs;\n const inputConnection = inputArray.find((s) => s.name === input) || this._createNewSocketConnection(input);\n const outputConnection = outputArray.find((s) => s.name === output) || this._createNewSocketConnection(output, true);\n // of not found add it to the array\n if (!inputArray.find((s) => s.name === input)) {\n inputArray.push(inputConnection);\n }\n if (!outputArray.find((s) => s.name === output)) {\n outputArray.push(outputConnection);\n }\n // connect the sockets\n inputConnection.connectedPointIds.push(outputConnection.uniqueId);\n outputConnection.connectedPointIds.push(inputConnection.uniqueId);\n }\n\n public getVariableName(index: number) {\n return \"staticVariable_\" + index;\n }\n\n public serializeToFlowGraph(): ISerializedFlowGraph {\n const context: ISerializedFlowGraphContext = {\n uniqueId: RandomGUID(),\n _userVariables: {},\n _connectionValues: {},\n };\n this._parseNodeConnections(context);\n for (let i = 0; i < this._staticVariables.length; i++) {\n const variable = this._staticVariables[i];\n context._userVariables[this.getVariableName(i)] = variable;\n }\n\n const allBlocks = this._nodes.reduce((acc, val) => acc.concat(val.blocks), [] as ISerializedFlowGraphBlock[]);\n\n return {\n rightHanded: true,\n allBlocks,\n executionContexts: [context],\n };\n }\n}\n"]}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { GLTFLoader } from "../glTFLoader";
|
2
2
|
import type { IGLTFLoaderExtension } from "../glTFLoaderExtension";
|
3
|
+
import type { Scene } from "@babylonjs/core/scene.js";
|
3
4
|
declare module "../../glTFFileLoader" {
|
4
5
|
interface GLTFLoaderExtensionOptions {
|
5
6
|
/**
|
@@ -28,5 +29,10 @@ export declare class KHR_interactivity implements IGLTFLoaderExtension {
|
|
28
29
|
*/
|
29
30
|
constructor(_loader: GLTFLoader);
|
30
31
|
dispose(): void;
|
31
|
-
onReady(): void
|
32
|
+
onReady(): Promise<void>;
|
32
33
|
}
|
34
|
+
/**
|
35
|
+
* @internal
|
36
|
+
* populates the object model with the interactivity extension
|
37
|
+
*/
|
38
|
+
export declare function _AddInteractivityObjectModel(scene: Scene): void;
|