@babylonjs/loaders 9.19.1 → 9.20.1

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.
Files changed (52) hide show
  1. package/SPLAT/gaussianSplattingStream.d.ts +170 -1
  2. package/SPLAT/gaussianSplattingStream.js +516 -40
  3. package/SPLAT/gaussianSplattingStream.js.map +1 -1
  4. package/SPLAT/gaussianSplattingWorkBuffer.d.ts +163 -4
  5. package/SPLAT/gaussianSplattingWorkBuffer.js +683 -35
  6. package/SPLAT/gaussianSplattingWorkBuffer.js.map +1 -1
  7. package/SPLAT/gaussianSplattingWorkBufferShaders.d.ts +70 -2
  8. package/SPLAT/gaussianSplattingWorkBufferShaders.js +465 -4
  9. package/SPLAT/gaussianSplattingWorkBufferShaders.js.map +1 -1
  10. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.d.ts +16 -1
  11. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js +232 -25
  12. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js.map +1 -1
  13. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.d.ts +52 -2
  14. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js +108 -7
  15. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js.map +1 -1
  16. package/glTF/2.0/Extensions/KHR_interactivity/interactivityHostResolver.d.ts +37 -0
  17. package/glTF/2.0/Extensions/KHR_interactivity/interactivityHostResolver.js +69 -0
  18. package/glTF/2.0/Extensions/KHR_interactivity/interactivityHostResolver.js.map +1 -0
  19. package/glTF/2.0/Extensions/KHR_interactivity/interactivityReferences.d.ts +44 -0
  20. package/glTF/2.0/Extensions/KHR_interactivity/interactivityReferences.js +51 -0
  21. package/glTF/2.0/Extensions/KHR_interactivity/interactivityReferences.js.map +1 -0
  22. package/glTF/2.0/Extensions/KHR_interactivity.pure.d.ts +1 -0
  23. package/glTF/2.0/Extensions/KHR_interactivity.pure.js +143 -12
  24. package/glTF/2.0/Extensions/KHR_interactivity.pure.js.map +1 -1
  25. package/glTF/2.0/Extensions/KHR_node_hoverability.pure.js +6 -0
  26. package/glTF/2.0/Extensions/KHR_node_hoverability.pure.js.map +1 -1
  27. package/glTF/2.0/Extensions/KHR_node_selectability.pure.js +4 -0
  28. package/glTF/2.0/Extensions/KHR_node_selectability.pure.js.map +1 -1
  29. package/glTF/2.0/Extensions/KHR_node_visibility.pure.js +11 -0
  30. package/glTF/2.0/Extensions/KHR_node_visibility.pure.js.map +1 -1
  31. package/glTF/2.0/Extensions/babylonScenePathToObjectConverter.d.ts +126 -0
  32. package/glTF/2.0/Extensions/babylonScenePathToObjectConverter.js +251 -0
  33. package/glTF/2.0/Extensions/babylonScenePathToObjectConverter.js.map +1 -0
  34. package/glTF/2.0/Extensions/compositePathToObjectConverter.d.ts +51 -0
  35. package/glTF/2.0/Extensions/compositePathToObjectConverter.js +51 -0
  36. package/glTF/2.0/Extensions/compositePathToObjectConverter.js.map +1 -0
  37. package/glTF/2.0/Extensions/gltfPathToObjectConverter.js +69 -7
  38. package/glTF/2.0/Extensions/gltfPathToObjectConverter.js.map +1 -1
  39. package/glTF/2.0/Extensions/interactivityAssetPathToObjectConverter.d.ts +41 -0
  40. package/glTF/2.0/Extensions/interactivityAssetPathToObjectConverter.js +108 -0
  41. package/glTF/2.0/Extensions/interactivityAssetPathToObjectConverter.js.map +1 -0
  42. package/glTF/2.0/Extensions/interactivityRefPathToObjectConverter.d.ts +28 -0
  43. package/glTF/2.0/Extensions/interactivityRefPathToObjectConverter.js +71 -0
  44. package/glTF/2.0/Extensions/interactivityRefPathToObjectConverter.js.map +1 -0
  45. package/glTF/2.0/Extensions/objectModelMapping.d.ts +118 -30
  46. package/glTF/2.0/Extensions/objectModelMapping.js +472 -70
  47. package/glTF/2.0/Extensions/objectModelMapping.js.map +1 -1
  48. package/glTF/2.0/Extensions/transmissionHelper.js +4 -0
  49. package/glTF/2.0/Extensions/transmissionHelper.js.map +1 -1
  50. package/glTF/2.0/glTFLoader.pure.js +2 -1
  51. package/glTF/2.0/glTFLoader.pure.js.map +1 -1
  52. package/package.json +3 -3
@@ -3,8 +3,20 @@ import { type IGLTF } from "../../glTFLoaderInterfaces.js";
3
3
  import { type IGLTFToFlowGraphMapping } from "./declarationMapper.js";
4
4
  import { type ISerializedFlowGraph, type ISerializedFlowGraphBlock } from "@babylonjs/core/FlowGraph/typeDefinitions.js";
5
5
  import { FlowGraphTypes } from "@babylonjs/core/FlowGraph/flowGraphRichTypes.js";
6
+ /**
7
+ * Description of a KHR_interactivity custom event, as parsed from the
8
+ * glTF `events` array. Used by the importer to register the event with the
9
+ * FlowGraph send/receive event blocks.
10
+ */
6
11
  export interface InteractivityEvent {
12
+ /** Identifier of the event, used to match send and receive blocks. */
7
13
  eventId: string;
14
+ /**
15
+ * Optional payload schema for the event. Each entry describes one
16
+ * value carried by the event: an `id` (the FlowGraph data socket name),
17
+ * a `type` (glTF interactivity type name) and an optional default
18
+ * `value`. `eventData` (the boolean) is currently unused.
19
+ */
8
20
  eventData?: {
9
21
  eventData: boolean;
10
22
  id: string;
@@ -16,9 +28,17 @@ export declare const gltfTypeToBabylonType: {
16
28
  [key: string]: {
17
29
  length: number;
18
30
  flowGraphType: FlowGraphTypes;
19
- elementType: "number" | "boolean";
31
+ elementType: "number" | "boolean" | "string";
20
32
  };
21
33
  };
34
+ /**
35
+ * Parses a KHR_interactivity graph definition (the raw glTF JSON object) into
36
+ * the serialized FlowGraph form consumed by {@link ParseFlowGraphAsync}.
37
+ *
38
+ * The class walks the interactivity types, declarations, variables, events
39
+ * and nodes in order and emits an {@link ISerializedFlowGraph} via
40
+ * {@link serializeToFlowGraph}.
41
+ */
22
42
  export declare class InteractivityGraphToFlowGraphParser {
23
43
  private _interactivityGraph;
24
44
  private _gltf;
@@ -33,12 +53,19 @@ export declare class InteractivityGraphToFlowGraphParser {
33
53
  private _events;
34
54
  private _internalEventsCounter;
35
55
  private _nodes;
56
+ /**
57
+ * Extra blocks the parser inserts between existing nodes (e.g. the seconds→frames multiply for
58
+ * connected animation-time inputs). Kept separate from any node's `blocks` array so per-node
59
+ * post-processing that indexes into that array (such as the animation extraProcessors targeting
60
+ * the last block) is not disturbed, then concatenated into the serialized graph.
61
+ */
62
+ private _insertedBlocks;
36
63
  constructor(_interactivityGraph: IKHRInteractivity_Graph, _gltf: IGLTF, _animationTargetFps?: number);
37
64
  get arrays(): {
38
65
  types: {
39
66
  length: number;
40
67
  flowGraphType: FlowGraphTypes;
41
- elementType: "number" | "boolean";
68
+ elementType: "number" | "boolean" | "string";
42
69
  }[];
43
70
  mappings: {
44
71
  flowGraphMapping: IGLTFToFlowGraphMapping;
@@ -64,7 +91,30 @@ export declare class InteractivityGraphToFlowGraphParser {
64
91
  private _parseNodeConfiguration;
65
92
  private _parseNodeConnections;
66
93
  private _createNewSocketConnection;
94
+ /**
95
+ * Wires an upstream data output into a downstream data input through a runtime multiply block that
96
+ * scales the value by the animation target fps. This converts a KHR animation time (seconds),
97
+ * delivered by a connection (e.g. a `pointer/get` on the `maxTime` animation pointer), into the
98
+ * Babylon animation frames expected by the play/stop-animation blocks. Literal times are already
99
+ * converted at parse time by the input's `dataTransformer`, so this is only used for connections.
100
+ * @param context the serialized flow graph context that stores literal socket values
101
+ * @param upstreamOutput the data output socket providing the time value (in seconds)
102
+ * @param downstreamInput the data input socket that expects the time in frames
103
+ */
104
+ private _connectWithSecondsToFramesConversion;
67
105
  private _connectFlowGraphNodes;
106
+ /**
107
+ * Returns the deterministic FlowGraph user-variable name used for the
108
+ * static variable at the given declaration index.
109
+ * @param index zero-based index into the interactivity graph's `variables` array.
110
+ * @returns the FlowGraph variable name (e.g. `staticVariable_3`).
111
+ */
68
112
  getVariableName(index: number): string;
113
+ /**
114
+ * Serializes the parsed interactivity graph into the {@link ISerializedFlowGraph}
115
+ * payload consumed by `ParseFlowGraphAsync`. Performs node-connection wiring
116
+ * and seeds the execution context with the graph's static variables.
117
+ * @returns the serialized FlowGraph for the parsed KHR_interactivity graph.
118
+ */
69
119
  serializeToFlowGraph(): ISerializedFlowGraph;
70
120
  }
@@ -12,7 +12,19 @@ export const gltfTypeToBabylonType = {
12
12
  float2x2: { length: 4, flowGraphType: "Matrix2D" /* FlowGraphTypes.Matrix2D */, elementType: "number" },
13
13
  float3x3: { length: 9, flowGraphType: "Matrix3D" /* FlowGraphTypes.Matrix3D */, elementType: "number" },
14
14
  int: { length: 1, flowGraphType: "FlowGraphInteger" /* FlowGraphTypes.Integer */, elementType: "number" },
15
+ // KHR_interactivity opaque reference type. Represented as a JSON Pointer string
16
+ // (e.g. "/nodes/17/") that addresses a glTF object. The empty string is the
17
+ // canonical "null reference" sentinel used by the parser.
18
+ ref: { length: 1, flowGraphType: "string" /* FlowGraphTypes.String */, elementType: "string" },
15
19
  };
20
+ /**
21
+ * Parses a KHR_interactivity graph definition (the raw glTF JSON object) into
22
+ * the serialized FlowGraph form consumed by {@link ParseFlowGraphAsync}.
23
+ *
24
+ * The class walks the interactivity types, declarations, variables, events
25
+ * and nodes in order and emits an {@link ISerializedFlowGraph} via
26
+ * {@link serializeToFlowGraph}.
27
+ */
16
28
  export class InteractivityGraphToFlowGraphParser {
17
29
  constructor(_interactivityGraph, _gltf, _animationTargetFps = 60) {
18
30
  this._interactivityGraph = _interactivityGraph;
@@ -28,6 +40,13 @@ export class InteractivityGraphToFlowGraphParser {
28
40
  this._events = [];
29
41
  this._internalEventsCounter = 0;
30
42
  this._nodes = [];
43
+ /**
44
+ * Extra blocks the parser inserts between existing nodes (e.g. the seconds→frames multiply for
45
+ * connected animation-time inputs). Kept separate from any node's `blocks` array so per-node
46
+ * post-processing that indexes into that array (such as the animation extraProcessors targeting
47
+ * the last block) is not disturbed, then concatenated into the serialized graph.
48
+ */
49
+ this._insertedBlocks = [];
31
50
  // start with types
32
51
  this._parseTypes();
33
52
  // continue with declarations
@@ -105,6 +124,10 @@ export class InteractivityGraphToFlowGraphParser {
105
124
  case "number" /* FlowGraphTypes.Number */:
106
125
  value.push(NaN);
107
126
  break;
127
+ case "string" /* FlowGraphTypes.String */:
128
+ // Default for a `ref`-typed value is the null reference, encoded as the empty string.
129
+ value.push("");
130
+ break;
108
131
  case "Vector2" /* FlowGraphTypes.Vector2 */:
109
132
  value.push(NaN, NaN);
110
133
  break;
@@ -258,6 +281,17 @@ export class InteractivityGraphToFlowGraphParser {
258
281
  Logger.Error(["No mapping found for node", gltfNode]);
259
282
  throw new Error("Error parsing node connections");
260
283
  }
284
+ // KHR_interactivity spec section 3.2.4 "Unsupported Operations":
285
+ // nodes referring to unsupported operations are demoted to no-ops.
286
+ // Activations of their input flow sockets are ignored, their output
287
+ // flow sockets are never activated, and their output value sockets
288
+ // return constant type-default values. They have no backing
289
+ // FlowGraph blocks (blocks.length === 0), so there is nothing to
290
+ // wire for this node — skip all of its connections.
291
+ if (flowGraphBlocks.blocks.length === 0) {
292
+ Logger.Warn(`Skipping connections for no-op node #${i} (unsupported operation: ${flowGraphBlocks.fullOperationName})`);
293
+ continue;
294
+ }
261
295
  const flowsFromGLTF = gltfNode.flows || {};
262
296
  const flowsKeys = Object.keys(flowsFromGLTF).sort(); // sorting as some operations require sorted keys
263
297
  // connect the flows
@@ -265,10 +299,6 @@ export class InteractivityGraphToFlowGraphParser {
265
299
  const flow = flowsFromGLTF[flowKey];
266
300
  const flowMapping = outputMapper.flowGraphMapping.outputs?.flows?.[flowKey];
267
301
  const socketOutName = flowMapping?.name || flowKey;
268
- // create a serialized socket
269
- const socketOut = this._createNewSocketConnection(socketOutName, true);
270
- const block = (flowMapping && flowMapping.toBlock && flowGraphBlocks.blocks.find((b) => b.className === flowMapping.toBlock)) || flowGraphBlocks.blocks[0];
271
- block.signalOutputs.push(socketOut);
272
302
  // get the input node of this block
273
303
  const inputNodeId = flow.node;
274
304
  const nodeIn = this._nodes[inputNodeId];
@@ -276,6 +306,17 @@ export class InteractivityGraphToFlowGraphParser {
276
306
  Logger.Error(["No node found for input node id", inputNodeId]);
277
307
  throw new Error("Error parsing node connections");
278
308
  }
309
+ // Spec 3.2.4: input flow activations on no-op nodes are ignored,
310
+ // so a flow connection into a no-op target is itself a no-op.
311
+ // Drop it instead of crashing on the missing target block.
312
+ if (nodeIn.blocks.length === 0) {
313
+ Logger.Warn(`Dropping flow connection from node #${i} "${flowKey}" to no-op node #${inputNodeId} (unsupported operation: ${nodeIn.fullOperationName})`);
314
+ continue;
315
+ }
316
+ // create a serialized socket
317
+ const socketOut = this._createNewSocketConnection(socketOutName, true);
318
+ const block = (flowMapping && flowMapping.toBlock && flowGraphBlocks.blocks.find((b) => b.className === flowMapping.toBlock)) || flowGraphBlocks.blocks[0];
319
+ block.signalOutputs.push(socketOut);
279
320
  // get the mapper for the input node - in case it mapped to multiple blocks
280
321
  const inputMapper = getMappingForFullOperationName(nodeIn.fullOperationName);
281
322
  if (!inputMapper) {
@@ -325,6 +366,10 @@ export class InteractivityGraphToFlowGraphParser {
325
366
  const socketIn = this._createNewSocketConnection(socketInName);
326
367
  const block = (valueMapping && valueMapping.toBlock && flowGraphBlocks.blocks.find((b) => b.className === valueMapping.toBlock)) || flowGraphBlocks.blocks[0];
327
368
  block.dataInputs.push(socketIn);
369
+ // Captured before the connected branch below shadows `valueMapping`. When set and the
370
+ // value is supplied by a connection, the seconds→frames `dataTransformer` cannot run
371
+ // (it is parse-time only), so the raw connected value is scaled by a runtime multiply.
372
+ const convertConnectedTimeToFrames = !!valueMapping?.convertConnectedTimeToFrames;
328
373
  if (value.value !== undefined) {
329
374
  const convertedValue = this._parseVariable(value, valueMapping && valueMapping.dataTransformer);
330
375
  context._connectionValues[socketIn.uniqueId] = convertedValue;
@@ -337,6 +382,14 @@ export class InteractivityGraphToFlowGraphParser {
337
382
  Logger.Error(["No node found for output socket reference", value]);
338
383
  throw new Error("Error parsing node connections");
339
384
  }
385
+ // Spec 3.2.4: output value sockets of no-op nodes return
386
+ // constant type-default values. Leave the consumer's
387
+ // dataInput unconnected (no connectedPointIds) so the
388
+ // FlowGraph runtime falls back to the RichType default.
389
+ if (nodeOut.blocks.length === 0) {
390
+ Logger.Warn(`Dropping value connection from no-op node #${nodeOutId} (unsupported operation: ${nodeOut.fullOperationName}) into node #${i} "${valueKey}"; consumer will use type-default value`);
391
+ continue;
392
+ }
340
393
  const outputMapper = getMappingForFullOperationName(nodeOut.fullOperationName);
341
394
  if (!outputMapper) {
342
395
  Logger.Error(["No mapping found for output socket reference", value]);
@@ -363,8 +416,13 @@ export class InteractivityGraphToFlowGraphParser {
363
416
  outBlock.dataOutputs.push(socketOut);
364
417
  }
365
418
  // connect the sockets
366
- socketIn.connectedPointIds.push(socketOut.uniqueId);
367
- socketOut.connectedPointIds.push(socketIn.uniqueId);
419
+ if (convertConnectedTimeToFrames) {
420
+ this._connectWithSecondsToFramesConversion(context, socketOut, socketIn);
421
+ }
422
+ else {
423
+ socketIn.connectedPointIds.push(socketOut.uniqueId);
424
+ socketOut.connectedPointIds.push(socketIn.uniqueId);
425
+ }
368
426
  }
369
427
  else {
370
428
  Logger.Error(["Invalid value for value connection", value]);
@@ -398,6 +456,37 @@ export class InteractivityGraphToFlowGraphParser {
398
456
  connectedPointIds: [],
399
457
  };
400
458
  }
459
+ /**
460
+ * Wires an upstream data output into a downstream data input through a runtime multiply block that
461
+ * scales the value by the animation target fps. This converts a KHR animation time (seconds),
462
+ * delivered by a connection (e.g. a `pointer/get` on the `maxTime` animation pointer), into the
463
+ * Babylon animation frames expected by the play/stop-animation blocks. Literal times are already
464
+ * converted at parse time by the input's `dataTransformer`, so this is only used for connections.
465
+ * @param context the serialized flow graph context that stores literal socket values
466
+ * @param upstreamOutput the data output socket providing the time value (in seconds)
467
+ * @param downstreamInput the data input socket that expects the time in frames
468
+ */
469
+ _connectWithSecondsToFramesConversion(context, upstreamOutput, downstreamInput) {
470
+ const multiplyBlock = this._getEmptyBlock("FlowGraphMultiplyBlock" /* FlowGraphBlockNames.Multiply */, "FlowGraphMultiplyBlock" /* FlowGraphBlockNames.Multiply */);
471
+ // Scalar (float) multiply; matches how the `math/mul` mapping configures the block.
472
+ multiplyBlock.config = { type: "number" /* FlowGraphTypes.Number */ };
473
+ const inputA = this._createNewSocketConnection("a");
474
+ const inputB = this._createNewSocketConnection("b");
475
+ const output = this._createNewSocketConnection("value", true);
476
+ multiplyBlock.dataInputs.push(inputA, inputB);
477
+ multiplyBlock.dataOutputs.push(output);
478
+ // The second factor is the constant animation target fps.
479
+ context._connectionValues[inputB.uniqueId] = { type: "number" /* FlowGraphTypes.Number */, value: [this._animationTargetFps] };
480
+ // upstream time output -> multiply.a
481
+ inputA.connectedPointIds.push(upstreamOutput.uniqueId);
482
+ upstreamOutput.connectedPointIds.push(inputA.uniqueId);
483
+ // multiply.value (frames) -> downstream time input
484
+ downstreamInput.connectedPointIds.push(output.uniqueId);
485
+ output.connectedPointIds.push(downstreamInput.uniqueId);
486
+ // Register the inserted block separately so serializeToFlowGraph picks it up without
487
+ // appending to any node's block list (which would break per-node extraProcessors).
488
+ this._insertedBlocks.push(multiplyBlock);
489
+ }
401
490
  _connectFlowGraphNodes(input, output, serializedInput, serializedOutput, isVariable) {
402
491
  const inputArray = isVariable ? serializedInput.dataInputs : serializedInput.signalInputs;
403
492
  const outputArray = isVariable ? serializedOutput.dataOutputs : serializedOutput.signalOutputs;
@@ -414,9 +503,21 @@ export class InteractivityGraphToFlowGraphParser {
414
503
  inputConnection.connectedPointIds.push(outputConnection.uniqueId);
415
504
  outputConnection.connectedPointIds.push(inputConnection.uniqueId);
416
505
  }
506
+ /**
507
+ * Returns the deterministic FlowGraph user-variable name used for the
508
+ * static variable at the given declaration index.
509
+ * @param index zero-based index into the interactivity graph's `variables` array.
510
+ * @returns the FlowGraph variable name (e.g. `staticVariable_3`).
511
+ */
417
512
  getVariableName(index) {
418
513
  return "staticVariable_" + index;
419
514
  }
515
+ /**
516
+ * Serializes the parsed interactivity graph into the {@link ISerializedFlowGraph}
517
+ * payload consumed by `ParseFlowGraphAsync`. Performs node-connection wiring
518
+ * and seeds the execution context with the graph's static variables.
519
+ * @returns the serialized FlowGraph for the parsed KHR_interactivity graph.
520
+ */
420
521
  serializeToFlowGraph() {
421
522
  const context = {
422
523
  uniqueId: RandomGUID(),
@@ -428,7 +529,7 @@ export class InteractivityGraphToFlowGraphParser {
428
529
  const variable = this._staticVariables[i];
429
530
  context._userVariables[this.getVariableName(i)] = variable;
430
531
  }
431
- const allBlocks = this._nodes.reduce((acc, val) => acc.concat(val.blocks), []);
532
+ const allBlocks = this._nodes.reduce((acc, val) => acc.concat(val.blocks), []).concat(this._insertedBlocks);
432
533
  return {
433
534
  rightHanded: true,
434
535
  allBlocks,
@@ -1 +1 @@
1
- {"version":3,"file":"interactivityGraphParser.js","sourceRoot":"","sources":["../../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgC,wBAAwB,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAC7H,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAe5C,gEAAgE;AAChE,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,EAA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AC,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, type IKHRInteractivity_Node, type IKHRInteractivity_OutputSocketReference, type IKHRInteractivity_Variable } from \"babylonjs-gltf2interface\";\nimport { type IGLTF } from \"../../glTFLoaderInterfaces\";\nimport { type IGLTFToFlowGraphMapping, getMappingForDeclaration, getMappingForFullOperationName } from \"./declarationMapper\";\nimport { Logger } from \"core/Misc/logger\";\nimport { type ISerializedFlowGraph, type ISerializedFlowGraphBlock, type ISerializedFlowGraphConnection, type ISerializedFlowGraphContext } from \"core/FlowGraph/typeDefinitions\";\nimport { RandomGUID } from \"core/Misc/guid\";\nimport { type FlowGraphBlockNames } from \"core/FlowGraph/Blocks/flowGraphBlockNames\";\nimport { FlowGraphConnectionType } from \"core/FlowGraph/flowGraphConnection\";\nimport { FlowGraphTypes } from \"core/FlowGraph/flowGraphRichTypes\";\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface InteractivityEvent {\n eventId: string;\n eventData?: {\n eventData: boolean;\n id: string;\n type: string;\n value?: any;\n }[];\n}\n// eslint-disable-next-line @typescript-eslint/naming-convention\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 _animationTargetFps: number = 60\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 case FlowGraphTypes.Quaternion:\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 // in case of NaN, Infinity, we need to parse the string to the object itself\n if (type.elementType === \"number\" && typeof value[0] === \"string\") {\n value[0] = parseFloat(value[0]);\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 const validationResult = mapping.flowGraphMapping.validation(node, this._interactivityGraph, this._gltf);\n if (!validationResult.valid) {\n throw new Error(`Error validating interactivity node ${this._interactivityGraph.declarations?.[node.declaration].op} - ${validationResult.error}`);\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 return {\n uniqueId: RandomGUID(),\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 gltfConfiguration = node.configuration;\n if (gltfConfiguration) {\n for (const key in gltfConfiguration) {\n const gltfProperty = gltfConfiguration[key];\n if (!gltfProperty) {\n throw new Error(\"Error parsing node configuration\");\n }\n\n const propertyMapping = nodeMapping.configuration?.[key];\n const belongsToBlock = propertyMapping && propertyMapping.toBlock ? propertyMapping.toBlock === blockType : nodeMapping.blocks.indexOf(blockType) === 0;\n if (belongsToBlock) {\n let value = propertyMapping?.defaultValue;\n if (gltfProperty?.value) {\n value = gltfProperty.value;\n }\n\n if (!propertyMapping?.isArray) {\n if (value.length !== 1) {\n Logger.Warn(`Invalid non-array value length: ${value.length}`);\n }\n\n value = value[0];\n }\n\n if (propertyMapping?.dataTransformer) {\n value = propertyMapping.dataTransformer(value, this);\n }\n\n if (value !== undefined) {\n // Update the flow graph block config.\n block.config[propertyMapping?.name || key] = {\n value: value,\n };\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
+ {"version":3,"file":"interactivityGraphParser.js","sourceRoot":"","sources":["../../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgC,wBAAwB,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAC7H,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AA2B5C,gEAAgE;AAChE,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,EAA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cAAc,EAAE,EAAE;YAClB,iBAAiB,EAAE,EAAE;SACxB,CAAC;QACF,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;YAC1C,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,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAE3I,OAAO;YACH,WAAW,EAAE,IAAI;YACjB,SAAS;YACT,iBAAiB,EAAE,CAAC,OAAO,CAAC;SAC/B,CAAC;IACN,CAAC;CACJ","sourcesContent":["import { type IKHRInteractivity_Graph, type IKHRInteractivity_Node, type IKHRInteractivity_OutputSocketReference, type IKHRInteractivity_Variable } from \"babylonjs-gltf2interface\";\nimport { type IGLTF } from \"../../glTFLoaderInterfaces\";\nimport { type IGLTFToFlowGraphMapping, getMappingForDeclaration, getMappingForFullOperationName } from \"./declarationMapper\";\nimport { Logger } from \"core/Misc/logger\";\nimport { type ISerializedFlowGraph, type ISerializedFlowGraphBlock, type ISerializedFlowGraphConnection, type ISerializedFlowGraphContext } from \"core/FlowGraph/typeDefinitions\";\nimport { RandomGUID } from \"core/Misc/guid\";\nimport { FlowGraphBlockNames } from \"core/FlowGraph/Blocks/flowGraphBlockNames\";\nimport { FlowGraphConnectionType } from \"core/FlowGraph/flowGraphConnection\";\nimport { FlowGraphTypes } from \"core/FlowGraph/flowGraphRichTypes\";\n\n/**\n * Description of a KHR_interactivity custom event, as parsed from the\n * glTF `events` array. Used by the importer to register the event with the\n * FlowGraph send/receive event blocks.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface InteractivityEvent {\n /** Identifier of the event, used to match send and receive blocks. */\n eventId: string;\n /**\n * Optional payload schema for the event. Each entry describes one\n * value carried by the event: an `id` (the FlowGraph data socket name),\n * a `type` (glTF interactivity type name) and an optional default\n * `value`. `eventData` (the boolean) is currently unused.\n */\n eventData?: {\n eventData: boolean;\n id: string;\n type: string;\n value?: any;\n }[];\n}\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const gltfTypeToBabylonType: {\n [key: string]: { length: number; flowGraphType: FlowGraphTypes; elementType: \"number\" | \"boolean\" | \"string\" };\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 // KHR_interactivity opaque reference type. Represented as a JSON Pointer string\n // (e.g. \"/nodes/17/\") that addresses a glTF object. The empty string is the\n // canonical \"null reference\" sentinel used by the parser.\n ref: { length: 1, flowGraphType: FlowGraphTypes.String, elementType: \"string\" },\n};\n\n/**\n * Parses a KHR_interactivity graph definition (the raw glTF JSON object) into\n * the serialized FlowGraph form consumed by {@link ParseFlowGraphAsync}.\n *\n * The class walks the interactivity types, declarations, variables, events\n * and nodes in order and emits an {@link ISerializedFlowGraph} via\n * {@link serializeToFlowGraph}.\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\" | \"string\" }[] = [];\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 * Extra blocks the parser inserts between existing nodes (e.g. the seconds→frames multiply for\n * connected animation-time inputs). Kept separate from any node's `blocks` array so per-node\n * post-processing that indexes into that array (such as the animation extraProcessors targeting\n * the last block) is not disturbed, then concatenated into the serialized graph.\n */\n private _insertedBlocks: ISerializedFlowGraphBlock[] = [];\n\n constructor(\n private _interactivityGraph: IKHRInteractivity_Graph,\n private _gltf: IGLTF,\n public _animationTargetFps: number = 60\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.String:\n // Default for a `ref`-typed value is the null reference, encoded as the empty string.\n value.push(\"\" as any);\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 case FlowGraphTypes.Quaternion:\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 // in case of NaN, Infinity, we need to parse the string to the object itself\n if (type.elementType === \"number\" && typeof value[0] === \"string\") {\n value[0] = parseFloat(value[0]);\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 const validationResult = mapping.flowGraphMapping.validation(node, this._interactivityGraph, this._gltf);\n if (!validationResult.valid) {\n throw new Error(`Error validating interactivity node ${this._interactivityGraph.declarations?.[node.declaration].op} - ${validationResult.error}`);\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 return {\n uniqueId: RandomGUID(),\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 gltfConfiguration = node.configuration;\n if (gltfConfiguration) {\n for (const key in gltfConfiguration) {\n const gltfProperty = gltfConfiguration[key];\n if (!gltfProperty) {\n throw new Error(\"Error parsing node configuration\");\n }\n\n const propertyMapping = nodeMapping.configuration?.[key];\n const belongsToBlock = propertyMapping && propertyMapping.toBlock ? propertyMapping.toBlock === blockType : nodeMapping.blocks.indexOf(blockType) === 0;\n if (belongsToBlock) {\n let value = propertyMapping?.defaultValue;\n if (gltfProperty?.value) {\n value = gltfProperty.value;\n }\n\n if (!propertyMapping?.isArray) {\n if (value.length !== 1) {\n Logger.Warn(`Invalid non-array value length: ${value.length}`);\n }\n\n value = value[0];\n }\n\n if (propertyMapping?.dataTransformer) {\n value = propertyMapping.dataTransformer(value, this);\n }\n\n if (value !== undefined) {\n // Update the flow graph block config.\n block.config[propertyMapping?.name || key] = {\n value: value,\n };\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 // KHR_interactivity spec section 3.2.4 \"Unsupported Operations\":\n // nodes referring to unsupported operations are demoted to no-ops.\n // Activations of their input flow sockets are ignored, their output\n // flow sockets are never activated, and their output value sockets\n // return constant type-default values. They have no backing\n // FlowGraph blocks (blocks.length === 0), so there is nothing to\n // wire for this node — skip all of its connections.\n if (flowGraphBlocks.blocks.length === 0) {\n Logger.Warn(`Skipping connections for no-op node #${i} (unsupported operation: ${flowGraphBlocks.fullOperationName})`);\n continue;\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 // 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 // Spec 3.2.4: input flow activations on no-op nodes are ignored,\n // so a flow connection into a no-op target is itself a no-op.\n // Drop it instead of crashing on the missing target block.\n if (nodeIn.blocks.length === 0) {\n Logger.Warn(`Dropping flow connection from node #${i} \"${flowKey}\" to no-op node #${inputNodeId} (unsupported operation: ${nodeIn.fullOperationName})`);\n continue;\n }\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 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 // Captured before the connected branch below shadows `valueMapping`. When set and the\n // value is supplied by a connection, the seconds→frames `dataTransformer` cannot run\n // (it is parse-time only), so the raw connected value is scaled by a runtime multiply.\n const convertConnectedTimeToFrames = !!valueMapping?.convertConnectedTimeToFrames;\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 // Spec 3.2.4: output value sockets of no-op nodes return\n // constant type-default values. Leave the consumer's\n // dataInput unconnected (no connectedPointIds) so the\n // FlowGraph runtime falls back to the RichType default.\n if (nodeOut.blocks.length === 0) {\n Logger.Warn(\n `Dropping value connection from no-op node #${nodeOutId} (unsupported operation: ${nodeOut.fullOperationName}) into node #${i} \"${valueKey}\"; consumer will use type-default value`\n );\n continue;\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 if (convertConnectedTimeToFrames) {\n this._connectWithSecondsToFramesConversion(context, socketOut, socketIn);\n } else {\n socketIn.connectedPointIds.push(socketOut.uniqueId);\n socketOut.connectedPointIds.push(socketIn.uniqueId);\n }\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 /**\n * Wires an upstream data output into a downstream data input through a runtime multiply block that\n * scales the value by the animation target fps. This converts a KHR animation time (seconds),\n * delivered by a connection (e.g. a `pointer/get` on the `maxTime` animation pointer), into the\n * Babylon animation frames expected by the play/stop-animation blocks. Literal times are already\n * converted at parse time by the input's `dataTransformer`, so this is only used for connections.\n * @param context the serialized flow graph context that stores literal socket values\n * @param upstreamOutput the data output socket providing the time value (in seconds)\n * @param downstreamInput the data input socket that expects the time in frames\n */\n private _connectWithSecondsToFramesConversion(\n context: ISerializedFlowGraphContext,\n upstreamOutput: ISerializedFlowGraphConnection,\n downstreamInput: ISerializedFlowGraphConnection\n ): void {\n const multiplyBlock = this._getEmptyBlock(FlowGraphBlockNames.Multiply, FlowGraphBlockNames.Multiply);\n // Scalar (float) multiply; matches how the `math/mul` mapping configures the block.\n multiplyBlock.config = { type: FlowGraphTypes.Number };\n const inputA = this._createNewSocketConnection(\"a\");\n const inputB = this._createNewSocketConnection(\"b\");\n const output = this._createNewSocketConnection(\"value\", true);\n multiplyBlock.dataInputs.push(inputA, inputB);\n multiplyBlock.dataOutputs.push(output);\n // The second factor is the constant animation target fps.\n context._connectionValues[inputB.uniqueId] = { type: FlowGraphTypes.Number, value: [this._animationTargetFps] };\n // upstream time output -> multiply.a\n inputA.connectedPointIds.push(upstreamOutput.uniqueId);\n upstreamOutput.connectedPointIds.push(inputA.uniqueId);\n // multiply.value (frames) -> downstream time input\n downstreamInput.connectedPointIds.push(output.uniqueId);\n output.connectedPointIds.push(downstreamInput.uniqueId);\n // Register the inserted block separately so serializeToFlowGraph picks it up without\n // appending to any node's block list (which would break per-node extraProcessors).\n this._insertedBlocks.push(multiplyBlock);\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 /**\n * Returns the deterministic FlowGraph user-variable name used for the\n * static variable at the given declaration index.\n * @param index zero-based index into the interactivity graph's `variables` array.\n * @returns the FlowGraph variable name (e.g. `staticVariable_3`).\n */\n public getVariableName(index: number) {\n return \"staticVariable_\" + index;\n }\n\n /**\n * Serializes the parsed interactivity graph into the {@link ISerializedFlowGraph}\n * payload consumed by `ParseFlowGraphAsync`. Performs node-connection wiring\n * and seeds the execution context with the graph's static variables.\n * @returns the serialized FlowGraph for the parsed KHR_interactivity graph.\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[]).concat(this._insertedBlocks);\n\n return {\n rightHanded: true,\n allBlocks,\n executionContexts: [context],\n };\n }\n}\n"]}
@@ -0,0 +1,37 @@
1
+ import { type IFlowGraphHostResolver } from "@babylonjs/core/FlowGraph/flowGraphHostResolver.js";
2
+ /**
3
+ * Supplies the KHR_interactivity representation of opaque `ref` values to the FlowGraph engine.
4
+ *
5
+ * The engine itself has no notion of the glTF object model: it asks this resolver how to represent
6
+ * event sources and runtime objects as references, and how to read one back.
7
+ */
8
+ export declare class InteractivityHostResolver implements IFlowGraphHostResolver {
9
+ /**
10
+ * @param key the FlowGraph event source key
11
+ * @returns the KHR_interactivity event reference
12
+ */
13
+ encodeEventReference(key: string): string;
14
+ /**
15
+ * @param reference the value to decode
16
+ * @returns the FlowGraph event source key, or `undefined` when the value is not an event reference
17
+ */
18
+ decodeEventReference(reference: string): string | undefined;
19
+ /**
20
+ * @param reference the reference to decode
21
+ * @returns the index the reference denotes, or `undefined` when it is not an indexed JSON Pointer
22
+ */
23
+ decodeIndexReference(reference: string): number | undefined;
24
+ /**
25
+ * Maps a Babylon object loaded from the glTF back to a JSON Pointer addressing it.
26
+ *
27
+ * The glTF loader stamps `_internalMetadata.gltf.pointers` with one entry per JSON Pointer the
28
+ * object can be addressed by; a single-primitive mesh, for example, holds both `/nodes/<i>` and
29
+ * `/meshes/<j>/primitives/<k>`. The hint is the path segment preceding the template parameter
30
+ * being resolved, so a template like `/nodes/{nodeRef}/globalMatrix` picks the `/nodes/<i>`
31
+ * pointer even when another pointer was added to the object first.
32
+ * @param object the Babylon object to address
33
+ * @param hint the expected root segment of the pointer, when known
34
+ * @returns the JSON Pointer for the object, or `undefined` when it is not addressable
35
+ */
36
+ getObjectReference(object: object, hint?: string): string | undefined;
37
+ }
@@ -0,0 +1,69 @@
1
+ import { GetEventReference, GetEventReferenceKey } from "./interactivityReferences.js";
2
+ /**
3
+ * Supplies the KHR_interactivity representation of opaque `ref` values to the FlowGraph engine.
4
+ *
5
+ * The engine itself has no notion of the glTF object model: it asks this resolver how to represent
6
+ * event sources and runtime objects as references, and how to read one back.
7
+ */
8
+ export class InteractivityHostResolver {
9
+ /**
10
+ * @param key the FlowGraph event source key
11
+ * @returns the KHR_interactivity event reference
12
+ */
13
+ encodeEventReference(key) {
14
+ return GetEventReference(key);
15
+ }
16
+ /**
17
+ * @param reference the value to decode
18
+ * @returns the FlowGraph event source key, or `undefined` when the value is not an event reference
19
+ */
20
+ decodeEventReference(reference) {
21
+ return GetEventReferenceKey(reference);
22
+ }
23
+ /**
24
+ * @param reference the reference to decode
25
+ * @returns the index the reference denotes, or `undefined` when it is not an indexed JSON Pointer
26
+ */
27
+ decodeIndexReference(reference) {
28
+ if (reference.length === 0 || reference[0] !== "/") {
29
+ return undefined;
30
+ }
31
+ const tail = reference.substring(reference.lastIndexOf("/") + 1);
32
+ // RFC 6901 array indices are unsigned decimal integers with no leading zeros, so reject
33
+ // anything else rather than letting `Number` accept "0x2", "1e1" or " 3".
34
+ if (!/^(0|[1-9]\d*)$/.test(tail)) {
35
+ return undefined;
36
+ }
37
+ return parseInt(tail, 10);
38
+ }
39
+ /**
40
+ * Maps a Babylon object loaded from the glTF back to a JSON Pointer addressing it.
41
+ *
42
+ * The glTF loader stamps `_internalMetadata.gltf.pointers` with one entry per JSON Pointer the
43
+ * object can be addressed by; a single-primitive mesh, for example, holds both `/nodes/<i>` and
44
+ * `/meshes/<j>/primitives/<k>`. The hint is the path segment preceding the template parameter
45
+ * being resolved, so a template like `/nodes/{nodeRef}/globalMatrix` picks the `/nodes/<i>`
46
+ * pointer even when another pointer was added to the object first.
47
+ * @param object the Babylon object to address
48
+ * @param hint the expected root segment of the pointer, when known
49
+ * @returns the JSON Pointer for the object, or `undefined` when it is not addressable
50
+ */
51
+ getObjectReference(object, hint) {
52
+ const pointers = object._internalMetadata?.gltf?.pointers;
53
+ if (!Array.isArray(pointers)) {
54
+ return undefined;
55
+ }
56
+ const stringPointers = pointers.filter((pointer) => typeof pointer === "string");
57
+ if (stringPointers.length === 0) {
58
+ return undefined;
59
+ }
60
+ if (hint) {
61
+ const match = stringPointers.find((pointer) => pointer.split("/")[1] === hint);
62
+ if (match) {
63
+ return match;
64
+ }
65
+ }
66
+ return stringPointers[0];
67
+ }
68
+ }
69
+ //# sourceMappingURL=interactivityHostResolver.js.map