@babylonjs/loaders 9.26.1 → 9.26.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.
Files changed (58) hide show
  1. package/SPLAT/gaussianSplattingStream.d.ts +79 -25
  2. package/SPLAT/gaussianSplattingStream.js +320 -95
  3. package/SPLAT/gaussianSplattingStream.js.map +1 -1
  4. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.d.ts +110 -3
  5. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js +468 -74
  6. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js.map +1 -1
  7. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphEventReferenceBlock.d.ts +47 -0
  8. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphEventReferenceBlock.js +68 -0
  9. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphEventReferenceBlock.js.map +1 -0
  10. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphGLTFDataProvider.d.ts +2 -2
  11. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphGLTFDataProvider.js +1 -1
  12. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphGLTFDataProvider.js.map +1 -1
  13. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphObjectReferenceBlock.d.ts +24 -0
  14. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphObjectReferenceBlock.js +38 -0
  15. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphObjectReferenceBlock.js.map +1 -0
  16. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphUnsupportedInteractivityBlock.d.ts +41 -0
  17. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphUnsupportedInteractivityBlock.js +63 -0
  18. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphUnsupportedInteractivityBlock.js.map +1 -0
  19. package/glTF/2.0/Extensions/KHR_interactivity/index.d.ts +5 -0
  20. package/glTF/2.0/Extensions/KHR_interactivity/index.js +5 -0
  21. package/glTF/2.0/Extensions/KHR_interactivity/index.js.map +1 -1
  22. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphModel.d.ts +112 -0
  23. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphModel.js +773 -0
  24. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphModel.js.map +1 -0
  25. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.d.ts +18 -10
  26. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js +299 -54
  27. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js.map +1 -1
  28. package/glTF/2.0/Extensions/KHR_interactivity/interactivityHostResolver.d.ts +2 -1
  29. package/glTF/2.0/Extensions/KHR_interactivity/interactivityHostResolver.js +7 -2
  30. package/glTF/2.0/Extensions/KHR_interactivity/interactivityHostResolver.js.map +1 -1
  31. package/glTF/2.0/Extensions/KHR_interactivity/interactivityNodeState.d.ts +24 -0
  32. package/glTF/2.0/Extensions/KHR_interactivity/interactivityNodeState.js +89 -0
  33. package/glTF/2.0/Extensions/KHR_interactivity/interactivityNodeState.js.map +1 -0
  34. package/glTF/2.0/Extensions/KHR_interactivity/pure.d.ts +5 -0
  35. package/glTF/2.0/Extensions/KHR_interactivity/pure.js +5 -0
  36. package/glTF/2.0/Extensions/KHR_interactivity/pure.js.map +1 -1
  37. package/glTF/2.0/Extensions/KHR_interactivity.pure.d.ts +55 -1
  38. package/glTF/2.0/Extensions/KHR_interactivity.pure.js +124 -76
  39. package/glTF/2.0/Extensions/KHR_interactivity.pure.js.map +1 -1
  40. package/glTF/2.0/Extensions/KHR_interactivity.types.d.ts +18 -1
  41. package/glTF/2.0/Extensions/KHR_interactivity.types.js.map +1 -1
  42. package/glTF/2.0/Extensions/KHR_node_hoverability.pure.d.ts +2 -0
  43. package/glTF/2.0/Extensions/KHR_node_hoverability.pure.js +114 -56
  44. package/glTF/2.0/Extensions/KHR_node_hoverability.pure.js.map +1 -1
  45. package/glTF/2.0/Extensions/KHR_node_selectability.pure.d.ts +2 -0
  46. package/glTF/2.0/Extensions/KHR_node_selectability.pure.js +80 -35
  47. package/glTF/2.0/Extensions/KHR_node_selectability.pure.js.map +1 -1
  48. package/glTF/2.0/Extensions/interactivityRefPathToObjectConverter.js +3 -2
  49. package/glTF/2.0/Extensions/interactivityRefPathToObjectConverter.js.map +1 -1
  50. package/glTF/2.0/Extensions/objectModelMapping.d.ts +4 -2
  51. package/glTF/2.0/Extensions/objectModelMapping.js +33 -4
  52. package/glTF/2.0/Extensions/objectModelMapping.js.map +1 -1
  53. package/glTF/2.0/glTFLoader.pure.d.ts +1 -1
  54. package/glTF/2.0/glTFLoader.pure.js +9 -4
  55. package/glTF/2.0/glTFLoader.pure.js.map +1 -1
  56. package/glTF/2.0/glTFLoaderExtension.d.ts +2 -1
  57. package/glTF/2.0/glTFLoaderExtension.js.map +1 -1
  58. package/package.json +3 -3
@@ -1,6 +1,7 @@
1
1
  import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry.js";
2
2
  import { addNewInteractivityFlowGraphMapping } from "./KHR_interactivity/declarationMapper.js";
3
3
  import { AddObjectAccessorToKey } from "./objectModelMapping.js";
4
+ import { GetInteractivityNodeState, InitializeInteractivityNodeState, SetInteractivityNodeState } from "./KHR_interactivity/interactivityNodeState.js";
4
5
  const NAME = "KHR_node_hoverability";
5
6
  // interactivity
6
7
  const MeshPointerOverPrefix = "targetMeshPointerOver_";
@@ -19,19 +20,14 @@ export class KHR_node_hoverability {
19
20
  * The name of this extension.
20
21
  */
21
22
  this.name = NAME;
23
+ /** Applies node state before KHR_interactivity graphs start. */
24
+ this.order = 100;
22
25
  this._loader = loader;
23
26
  this.enabled = loader.isExtensionUsed(NAME);
24
27
  }
25
28
  // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-misused-promises
26
29
  async onReady() {
27
- this._loader.gltf.nodes?.forEach((node) => {
28
- // default is true, so only apply if false
29
- if (node.extensions?.KHR_node_hoverability && node.extensions?.KHR_node_hoverability.hoverable === false) {
30
- node._babylonTransformNode?.getChildMeshes().forEach((mesh) => {
31
- mesh.pointerOverDisableMeshTesting = true;
32
- });
33
- }
34
- });
30
+ InitializeInteractivityNodeState(this._loader.gltf.nodes ?? [], "hoverable", (node) => node.extensions?.KHR_node_hoverability?.hoverable);
35
31
  }
36
32
  dispose() {
37
33
  this._loader = null;
@@ -50,12 +46,28 @@ export function _RegisterKHRNodeHoverabilityRuntime() {
50
46
  _RuntimeRegistered = true;
51
47
  addNewInteractivityFlowGraphMapping("event/onHoverIn", NAME, {
52
48
  // using GetVariable as the nodeIndex is a configuration and not a value (i.e. it's not mutable)
53
- blocks: ["FlowGraphPointerOverEventBlock" /* FlowGraphBlockNames.PointerOverEvent */, "FlowGraphGetVariableBlock" /* FlowGraphBlockNames.GetVariable */, "FlowGraphIndexOfBlock" /* FlowGraphBlockNames.IndexOf */, "KHR_interactivity/FlowGraphGLTFDataProvider"],
49
+ blocks: [
50
+ "FlowGraphPointerOverEventBlock" /* FlowGraphBlockNames.PointerOverEvent */,
51
+ "FlowGraphGetVariableBlock" /* FlowGraphBlockNames.GetVariable */,
52
+ "FlowGraphIndexOfBlock" /* FlowGraphBlockNames.IndexOf */,
53
+ "KHR_interactivity/FlowGraphGLTFDataProvider",
54
+ "KHR_interactivity/FlowGraphEventReferenceBlock",
55
+ ],
56
+ declarationSchema: {
57
+ inputValueSockets: {},
58
+ outputValueSockets: {
59
+ hoveredNode: "ref",
60
+ controllerIndex: "int",
61
+ event: "ref",
62
+ },
63
+ },
54
64
  configuration: {
55
- stopPropagation: { name: "stopPropagation" },
56
65
  nodeIndex: {
57
66
  name: "variable",
67
+ configurationType: "int",
58
68
  toBlock: "FlowGraphGetVariableBlock" /* FlowGraphBlockNames.GetVariable */,
69
+ indexSource: "assetNodes",
70
+ invalidUsesDefault: true,
59
71
  dataTransformer(data) {
60
72
  return MeshPointerOverPrefix + data;
61
73
  },
@@ -64,14 +76,12 @@ export function _RegisterKHRNodeHoverabilityRuntime() {
64
76
  outputs: {
65
77
  values: {
66
78
  hoverNodeIndex: { name: "index", toBlock: "FlowGraphIndexOfBlock" /* FlowGraphBlockNames.IndexOf */ },
67
- // `hoveredNode` is the new ref-typed output from the Opaque-Reference
68
- // spec update — the picked Babylon mesh itself, available directly
69
- // from FlowGraphPointerOverEventBlock.meshUnderPointer (no IndexOf).
70
- hoveredNode: { name: "meshUnderPointer", toBlock: "FlowGraphPointerOverEventBlock" /* FlowGraphBlockNames.PointerOverEvent */ },
71
- controllerIndex: { name: "pointerId" },
79
+ hoveredNode: { name: "nodeReference", toBlock: "KHR_interactivity/FlowGraphEventReferenceBlock" },
80
+ controllerIndex: { name: "controllerIndex", toBlock: "KHR_interactivity/FlowGraphEventReferenceBlock" },
81
+ event: { name: "value", toBlock: "KHR_interactivity/FlowGraphEventReferenceBlock" },
72
82
  },
73
83
  flows: {
74
- out: { name: "done" },
84
+ out: { name: "out", toBlock: "KHR_interactivity/FlowGraphEventReferenceBlock" },
75
85
  },
76
86
  },
77
87
  interBlockConnectors: [
@@ -96,36 +106,71 @@ export function _RegisterKHRNodeHoverabilityRuntime() {
96
106
  outputBlockIndex: 0,
97
107
  isVariable: true,
98
108
  },
109
+ {
110
+ input: "node",
111
+ output: "meshUnderPointer",
112
+ inputBlockIndex: 4,
113
+ outputBlockIndex: 0,
114
+ isVariable: true,
115
+ },
116
+ {
117
+ input: "controllerIndexInput",
118
+ output: "pointerId",
119
+ inputBlockIndex: 4,
120
+ outputBlockIndex: 0,
121
+ isVariable: true,
122
+ },
123
+ {
124
+ input: "in",
125
+ output: "done",
126
+ inputBlockIndex: 4,
127
+ outputBlockIndex: 0,
128
+ },
99
129
  ],
100
130
  extraProcessor(gltfBlock, _declaration, _mapping, _arrays, serializedObjects, context, globalGLTF) {
101
- // add the glTF to the configuration of the last serialized object
102
- const serializedObject = serializedObjects[serializedObjects.length - 1];
103
- serializedObject.config = serializedObject.config || {};
104
- serializedObject.config.glTF = globalGLTF;
105
131
  // find the listener nodeIndex value
106
132
  const nodeIndex = gltfBlock.configuration?.["nodeIndex"]?.value?.[0];
107
- if (nodeIndex === undefined || typeof nodeIndex !== "number") {
108
- throw new Error("nodeIndex not found in configuration");
109
- }
110
- const variableName = MeshPointerOverPrefix + nodeIndex;
133
+ const validNodeIndex = typeof nodeIndex === "number" && Number.isInteger(nodeIndex) && nodeIndex >= 0 && nodeIndex < (globalGLTF?.nodes?.length ?? 0);
134
+ const variableName = validNodeIndex ? MeshPointerOverPrefix + nodeIndex : MeshPointerOverPrefix + "unbound";
111
135
  // find the nodeIndex value
112
136
  serializedObjects[1].config.variable = variableName;
113
- context._userVariables[variableName] = {
114
- className: "Mesh",
115
- id: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.id,
116
- uniqueId: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.uniqueId,
117
- };
137
+ context._userVariables[variableName] = validNodeIndex
138
+ ? {
139
+ className: "Mesh",
140
+ id: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.id,
141
+ uniqueId: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.uniqueId,
142
+ }
143
+ : { type: "any" /* FlowGraphTypes.Any */, value: [{}] };
144
+ const eventKey = `${NAME}:event/onHoverIn:${nodeIndex}`;
145
+ serializedObjects[0].config.eventKey = eventKey;
146
+ serializedObjects[4].config.eventKey = eventKey;
118
147
  return serializedObjects;
119
148
  },
120
149
  });
121
150
  addNewInteractivityFlowGraphMapping("event/onHoverOut", NAME, {
122
151
  // using GetVariable as the nodeIndex is a configuration and not a value (i.e. it's not mutable)
123
- blocks: ["FlowGraphPointerOutEventBlock" /* FlowGraphBlockNames.PointerOutEvent */, "FlowGraphGetVariableBlock" /* FlowGraphBlockNames.GetVariable */, "FlowGraphIndexOfBlock" /* FlowGraphBlockNames.IndexOf */, "KHR_interactivity/FlowGraphGLTFDataProvider"],
152
+ blocks: [
153
+ "FlowGraphPointerOutEventBlock" /* FlowGraphBlockNames.PointerOutEvent */,
154
+ "FlowGraphGetVariableBlock" /* FlowGraphBlockNames.GetVariable */,
155
+ "FlowGraphIndexOfBlock" /* FlowGraphBlockNames.IndexOf */,
156
+ "KHR_interactivity/FlowGraphGLTFDataProvider",
157
+ "KHR_interactivity/FlowGraphEventReferenceBlock",
158
+ ],
159
+ declarationSchema: {
160
+ inputValueSockets: {},
161
+ outputValueSockets: {
162
+ hoveredNode: "ref",
163
+ controllerIndex: "int",
164
+ event: "ref",
165
+ },
166
+ },
124
167
  configuration: {
125
- stopPropagation: { name: "stopPropagation" },
126
168
  nodeIndex: {
127
169
  name: "variable",
170
+ configurationType: "int",
128
171
  toBlock: "FlowGraphGetVariableBlock" /* FlowGraphBlockNames.GetVariable */,
172
+ indexSource: "assetNodes",
173
+ invalidUsesDefault: true,
129
174
  dataTransformer(data) {
130
175
  return MeshPointerOutPrefix + data;
131
176
  },
@@ -134,12 +179,12 @@ export function _RegisterKHRNodeHoverabilityRuntime() {
134
179
  outputs: {
135
180
  values: {
136
181
  hoverNodeIndex: { name: "index", toBlock: "FlowGraphIndexOfBlock" /* FlowGraphBlockNames.IndexOf */ },
137
- // Ref-typed output: the mesh that the pointer just left.
138
- hoveredNode: { name: "meshOutOfPointer", toBlock: "FlowGraphPointerOutEventBlock" /* FlowGraphBlockNames.PointerOutEvent */ },
139
- controllerIndex: { name: "pointerId" },
182
+ hoveredNode: { name: "nodeReference", toBlock: "KHR_interactivity/FlowGraphEventReferenceBlock" },
183
+ controllerIndex: { name: "controllerIndex", toBlock: "KHR_interactivity/FlowGraphEventReferenceBlock" },
184
+ event: { name: "value", toBlock: "KHR_interactivity/FlowGraphEventReferenceBlock" },
140
185
  },
141
186
  flows: {
142
- out: { name: "done" },
187
+ out: { name: "out", toBlock: "KHR_interactivity/FlowGraphEventReferenceBlock" },
143
188
  },
144
189
  },
145
190
  interBlockConnectors: [
@@ -164,39 +209,52 @@ export function _RegisterKHRNodeHoverabilityRuntime() {
164
209
  outputBlockIndex: 0,
165
210
  isVariable: true,
166
211
  },
212
+ {
213
+ input: "node",
214
+ output: "meshOutOfPointer",
215
+ inputBlockIndex: 4,
216
+ outputBlockIndex: 0,
217
+ isVariable: true,
218
+ },
219
+ {
220
+ input: "controllerIndexInput",
221
+ output: "pointerId",
222
+ inputBlockIndex: 4,
223
+ outputBlockIndex: 0,
224
+ isVariable: true,
225
+ },
226
+ {
227
+ input: "in",
228
+ output: "done",
229
+ inputBlockIndex: 4,
230
+ outputBlockIndex: 0,
231
+ },
167
232
  ],
168
233
  extraProcessor(gltfBlock, _declaration, _mapping, _arrays, serializedObjects, context, globalGLTF) {
169
- // add the glTF to the configuration of the last serialized object
170
- const serializedObject = serializedObjects[serializedObjects.length - 1];
171
- serializedObject.config = serializedObject.config || {};
172
- serializedObject.config.glTF = globalGLTF;
173
234
  const nodeIndex = gltfBlock.configuration?.["nodeIndex"]?.value?.[0];
174
- if (nodeIndex === undefined || typeof nodeIndex !== "number") {
175
- throw new Error("nodeIndex not found in configuration");
176
- }
177
- const variableName = MeshPointerOutPrefix + nodeIndex;
235
+ const validNodeIndex = typeof nodeIndex === "number" && Number.isInteger(nodeIndex) && nodeIndex >= 0 && nodeIndex < (globalGLTF?.nodes?.length ?? 0);
236
+ const variableName = validNodeIndex ? MeshPointerOutPrefix + nodeIndex : MeshPointerOutPrefix + "unbound";
178
237
  // find the nodeIndex value
179
238
  serializedObjects[1].config.variable = variableName;
180
- context._userVariables[variableName] = {
181
- className: "Mesh",
182
- id: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.id,
183
- uniqueId: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.uniqueId,
184
- };
239
+ context._userVariables[variableName] = validNodeIndex
240
+ ? {
241
+ className: "Mesh",
242
+ id: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.id,
243
+ uniqueId: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.uniqueId,
244
+ }
245
+ : { type: "any" /* FlowGraphTypes.Any */, value: [{}] };
246
+ const eventKey = `${NAME}:event/onHoverOut:${nodeIndex}`;
247
+ serializedObjects[0].config.eventKey = eventKey;
248
+ serializedObjects[4].config.eventKey = eventKey;
185
249
  return serializedObjects;
186
250
  },
187
251
  });
188
252
  AddObjectAccessorToKey("/nodes/{}/extensions/KHR_node_hoverability/hoverable", {
189
253
  get: (node) => {
190
- const tn = node._babylonTransformNode;
191
- if (tn && tn.pointerOverDisableMeshTesting !== undefined) {
192
- return tn.pointerOverDisableMeshTesting;
193
- }
194
- return true;
254
+ return GetInteractivityNodeState(node, "hoverable");
195
255
  },
196
256
  set: (value, node) => {
197
- node._primitiveBabylonMeshes?.forEach((mesh) => {
198
- mesh.pointerOverDisableMeshTesting = !value;
199
- });
257
+ SetInteractivityNodeState(node, "hoverable", value);
200
258
  },
201
259
  getTarget: (node) => node._babylonTransformNode,
202
260
  getPropertyName: [() => "pointerOverDisableMeshTesting"],
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_node_hoverability.pure.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_node_hoverability.pure.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAE5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,MAAM,IAAI,GAAG,uBAAuB,CAAC;AAErC,gBAAgB;AAChB,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAEvD,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AAErD;;;GAGG;AACH,gEAAgE;AAChE,MAAM,OAAO,qBAAqB;IAY9B;;OAEG;IACH,YAAY,MAAkB;QAd9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAYxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GA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Loader.pure\";\r\nimport { type IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\nimport { FlowGraphBlockNames } from \"core/FlowGraph/Blocks/flowGraphBlockNames\";\r\nimport { addNewInteractivityFlowGraphMapping } from \"./KHR_interactivity/declarationMapper\";\r\nimport { type INode } from \"../glTFLoaderInterfaces\";\r\nimport { AddObjectAccessorToKey } from \"./objectModelMapping\";\r\n\r\nconst NAME = \"KHR_node_hoverability\";\r\n\r\n// interactivity\r\nconst MeshPointerOverPrefix = \"targetMeshPointerOver_\";\r\n\r\nconst MeshPointerOutPrefix = \"targetMeshPointerOut_\";\r\n\r\n/**\r\n * Loader extension for KHR_node_hoverability\r\n * @see https://github.com/KhronosGroup/glTF/pull/2426\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_node_hoverability implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = loader.isExtensionUsed(NAME);\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-misused-promises\r\n public async onReady(): Promise<void> {\r\n this._loader.gltf.nodes?.forEach((node) => {\r\n // default is true, so only apply if false\r\n if (node.extensions?.KHR_node_hoverability && node.extensions?.KHR_node_hoverability.hoverable === false) {\r\n node._babylonTransformNode?.getChildMeshes().forEach((mesh) => {\r\n mesh.pointerOverDisableMeshTesting = true;\r\n });\r\n }\r\n });\r\n }\r\n\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n}\r\n\r\nlet _RuntimeRegistered = false;\r\n/**\r\n * @internal\r\n * Registers KHR_node_hoverability runtime dependencies without changing the extension registry.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function _RegisterKHRNodeHoverabilityRuntime(): void {\r\n if (_RuntimeRegistered) {\r\n return;\r\n }\r\n _RuntimeRegistered = true;\r\n\r\n addNewInteractivityFlowGraphMapping(\"event/onHoverIn\", NAME, {\r\n // using GetVariable as the nodeIndex is a configuration and not a value (i.e. it's not mutable)\r\n blocks: [FlowGraphBlockNames.PointerOverEvent, FlowGraphBlockNames.GetVariable, FlowGraphBlockNames.IndexOf, \"KHR_interactivity/FlowGraphGLTFDataProvider\"],\r\n configuration: {\r\n stopPropagation: { name: \"stopPropagation\" },\r\n nodeIndex: {\r\n name: \"variable\",\r\n toBlock: FlowGraphBlockNames.GetVariable,\r\n dataTransformer(data) {\r\n return MeshPointerOverPrefix + data;\r\n },\r\n },\r\n },\r\n outputs: {\r\n values: {\r\n hoverNodeIndex: { name: \"index\", toBlock: FlowGraphBlockNames.IndexOf },\r\n // `hoveredNode` is the new ref-typed output from the Opaque-Reference\r\n // spec update — the picked Babylon mesh itself, available directly\r\n // from FlowGraphPointerOverEventBlock.meshUnderPointer (no IndexOf).\r\n hoveredNode: { name: \"meshUnderPointer\", toBlock: FlowGraphBlockNames.PointerOverEvent },\r\n controllerIndex: { name: \"pointerId\" },\r\n },\r\n flows: {\r\n out: { name: \"done\" },\r\n },\r\n },\r\n interBlockConnectors: [\r\n {\r\n input: \"targetMesh\",\r\n output: \"value\",\r\n inputBlockIndex: 0,\r\n outputBlockIndex: 1,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"array\",\r\n output: \"nodes\",\r\n inputBlockIndex: 2,\r\n outputBlockIndex: 3,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"object\",\r\n output: \"meshUnderPointer\",\r\n inputBlockIndex: 2,\r\n outputBlockIndex: 0,\r\n isVariable: true,\r\n },\r\n ],\r\n extraProcessor(gltfBlock, _declaration, _mapping, _arrays, serializedObjects, context, globalGLTF) {\r\n // add the glTF to the configuration of the last serialized object\r\n const serializedObject = serializedObjects[serializedObjects.length - 1];\r\n serializedObject.config = serializedObject.config || {};\r\n serializedObject.config.glTF = globalGLTF;\r\n // find the listener nodeIndex value\r\n const nodeIndex = gltfBlock.configuration?.[\"nodeIndex\"]?.value?.[0];\r\n if (nodeIndex === undefined || typeof nodeIndex !== \"number\") {\r\n throw new Error(\"nodeIndex not found in configuration\");\r\n }\r\n const variableName = MeshPointerOverPrefix + nodeIndex;\r\n // find the nodeIndex value\r\n serializedObjects[1].config.variable = variableName;\r\n context._userVariables[variableName] = {\r\n className: \"Mesh\",\r\n id: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.id,\r\n uniqueId: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.uniqueId,\r\n };\r\n return serializedObjects;\r\n },\r\n });\r\n\r\n addNewInteractivityFlowGraphMapping(\"event/onHoverOut\", NAME, {\r\n // using GetVariable as the nodeIndex is a configuration and not a value (i.e. it's not mutable)\r\n blocks: [FlowGraphBlockNames.PointerOutEvent, FlowGraphBlockNames.GetVariable, FlowGraphBlockNames.IndexOf, \"KHR_interactivity/FlowGraphGLTFDataProvider\"],\r\n configuration: {\r\n stopPropagation: { name: \"stopPropagation\" },\r\n nodeIndex: {\r\n name: \"variable\",\r\n toBlock: FlowGraphBlockNames.GetVariable,\r\n dataTransformer(data) {\r\n return MeshPointerOutPrefix + data;\r\n },\r\n },\r\n },\r\n outputs: {\r\n values: {\r\n hoverNodeIndex: { name: \"index\", toBlock: FlowGraphBlockNames.IndexOf },\r\n // Ref-typed output: the mesh that the pointer just left.\r\n hoveredNode: { name: \"meshOutOfPointer\", toBlock: FlowGraphBlockNames.PointerOutEvent },\r\n controllerIndex: { name: \"pointerId\" },\r\n },\r\n flows: {\r\n out: { name: \"done\" },\r\n },\r\n },\r\n interBlockConnectors: [\r\n {\r\n input: \"targetMesh\",\r\n output: \"value\",\r\n inputBlockIndex: 0,\r\n outputBlockIndex: 1,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"array\",\r\n output: \"nodes\",\r\n inputBlockIndex: 2,\r\n outputBlockIndex: 3,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"object\",\r\n output: \"meshOutOfPointer\",\r\n inputBlockIndex: 2,\r\n outputBlockIndex: 0,\r\n isVariable: true,\r\n },\r\n ],\r\n extraProcessor(gltfBlock, _declaration, _mapping, _arrays, serializedObjects, context, globalGLTF) {\r\n // add the glTF to the configuration of the last serialized object\r\n const serializedObject = serializedObjects[serializedObjects.length - 1];\r\n serializedObject.config = serializedObject.config || {};\r\n serializedObject.config.glTF = globalGLTF;\r\n\r\n const nodeIndex = gltfBlock.configuration?.[\"nodeIndex\"]?.value?.[0];\r\n if (nodeIndex === undefined || typeof nodeIndex !== \"number\") {\r\n throw new Error(\"nodeIndex not found in configuration\");\r\n }\r\n const variableName = MeshPointerOutPrefix + nodeIndex;\r\n // find the nodeIndex value\r\n serializedObjects[1].config.variable = variableName;\r\n context._userVariables[variableName] = {\r\n className: \"Mesh\",\r\n id: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.id,\r\n uniqueId: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.uniqueId,\r\n };\r\n return serializedObjects;\r\n },\r\n });\r\n\r\n AddObjectAccessorToKey(\"/nodes/{}/extensions/KHR_node_hoverability/hoverable\", {\r\n get: (node: INode) => {\r\n const tn = node._babylonTransformNode as any;\r\n if (tn && tn.pointerOverDisableMeshTesting !== undefined) {\r\n return tn.pointerOverDisableMeshTesting;\r\n }\r\n return true;\r\n },\r\n set: (value: boolean, node: INode) => {\r\n node._primitiveBabylonMeshes?.forEach((mesh) => {\r\n mesh.pointerOverDisableMeshTesting = !value;\r\n });\r\n },\r\n getTarget: (node: INode) => node._babylonTransformNode,\r\n getPropertyName: [() => \"pointerOverDisableMeshTesting\"],\r\n type: \"boolean\",\r\n });\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Registers the KHR_node_hoverability glTF loader extension.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function RegisterKHR_node_hoverability(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n _RegisterKHRNodeHoverabilityRuntime();\r\n\r\n unregisterGLTFExtension(NAME);\r\n\r\n registerGLTFExtension(NAME, true, (loader) => new KHR_node_hoverability(loader));\r\n}\r\n"]}
1
+ {"version":3,"file":"KHR_node_hoverability.pure.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_node_hoverability.pure.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAE5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,gCAAgC,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAGpJ,MAAM,IAAI,GAAG,uBAAuB,CAAC;AAErC,gBAAgB;AAChB,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAEvD,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AAErD;;;GAGG;AACH,gEAAgE;AAChE,MAAM,OAAO,qBAAqB;IAc9B;;OAEG;IACH,YAAY,MAAkB;QAhB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAC5B,gEAAgE;QAChD,UAAK,GAAG,GAAG,CAAC;QAYxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,wGAAwG;IACjG,KAAK,CAAC,OAAO;QAChB,gCAAgC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,EAAE,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE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AE,CAAC,EAAE,CAAC;YAChD,MAAM,QAAQ,GAAG,GAAG,IAAI,qBAAqB,SAAS,EAAE,CAAC;YACzD,iBAAiB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAChD,iBAAiB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAChD,OAAO,iBAAiB,CAAC;QAC7B,CAAC;KACJ,CAAC,CAAC;IAEH,sBAAsB,CAAC,sDAAsD,EAAE;QAC3E,GAAG,EAAE,CAAC,IAAW,EAAE,EAAE;YACjB,OAAO,yBAAyB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QACxD,CAAC;QACD,GAAG,EAAE,CAAC,KAAc,EAAE,IAAW,EAAE,EAAE;YACjC,yBAAyB,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;QACxD,CAAC;QACD,SAAS,EAAE,CAAC,IAAW,EAAE,EAAE,CAAC,IAAI,CAAC,qBAAqB;QACtD,eAAe,EAAE,CAAC,GAAG,EAAE,CAAC,+BAA+B,CAAC;QACxD,IAAI,EAAE,SAAS;KAClB,CAAC,CAAC;AACP,CAAC;AAED,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,gEAAgE;AAChE,MAAM,UAAU,6BAA6B;IACzC,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,mCAAmC,EAAE,CAAC;IAEtC,uBAAuB,CAAC,IAAI,CAAC,CAAC;IAE9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC;AACrF,CAAC","sourcesContent":["import { type GLTFLoader } from \"../glTFLoader.pure\";\r\nimport { type IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\nimport { FlowGraphBlockNames } from \"core/FlowGraph/Blocks/flowGraphBlockNames\";\r\nimport { addNewInteractivityFlowGraphMapping } from \"./KHR_interactivity/declarationMapper\";\r\nimport { type INode } from \"../glTFLoaderInterfaces\";\r\nimport { AddObjectAccessorToKey } from \"./objectModelMapping\";\r\nimport { GetInteractivityNodeState, InitializeInteractivityNodeState, SetInteractivityNodeState } from \"./KHR_interactivity/interactivityNodeState\";\r\nimport { FlowGraphTypes } from \"core/FlowGraph/flowGraphRichTypes.pure\";\r\n\r\nconst NAME = \"KHR_node_hoverability\";\r\n\r\n// interactivity\r\nconst MeshPointerOverPrefix = \"targetMeshPointerOver_\";\r\n\r\nconst MeshPointerOutPrefix = \"targetMeshPointerOut_\";\r\n\r\n/**\r\n * Loader extension for KHR_node_hoverability\r\n * @see https://github.com/KhronosGroup/glTF/pull/2426\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_node_hoverability implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n /** Applies node state before KHR_interactivity graphs start. */\r\n public readonly order = 100;\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = loader.isExtensionUsed(NAME);\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-misused-promises\r\n public async onReady(): Promise<void> {\r\n InitializeInteractivityNodeState(this._loader.gltf.nodes ?? [], \"hoverable\", (node) => node.extensions?.KHR_node_hoverability?.hoverable);\r\n }\r\n\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n}\r\n\r\nlet _RuntimeRegistered = false;\r\n/**\r\n * @internal\r\n * Registers KHR_node_hoverability runtime dependencies without changing the extension registry.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function _RegisterKHRNodeHoverabilityRuntime(): void {\r\n if (_RuntimeRegistered) {\r\n return;\r\n }\r\n _RuntimeRegistered = true;\r\n\r\n addNewInteractivityFlowGraphMapping(\"event/onHoverIn\", NAME, {\r\n // using GetVariable as the nodeIndex is a configuration and not a value (i.e. it's not mutable)\r\n blocks: [\r\n FlowGraphBlockNames.PointerOverEvent,\r\n FlowGraphBlockNames.GetVariable,\r\n FlowGraphBlockNames.IndexOf,\r\n \"KHR_interactivity/FlowGraphGLTFDataProvider\",\r\n \"KHR_interactivity/FlowGraphEventReferenceBlock\",\r\n ],\r\n declarationSchema: {\r\n inputValueSockets: {},\r\n outputValueSockets: {\r\n hoveredNode: \"ref\",\r\n controllerIndex: \"int\",\r\n event: \"ref\",\r\n },\r\n },\r\n configuration: {\r\n nodeIndex: {\r\n name: \"variable\",\r\n configurationType: \"int\",\r\n toBlock: FlowGraphBlockNames.GetVariable,\r\n indexSource: \"assetNodes\",\r\n invalidUsesDefault: true,\r\n dataTransformer(data) {\r\n return MeshPointerOverPrefix + data;\r\n },\r\n },\r\n },\r\n outputs: {\r\n values: {\r\n hoverNodeIndex: { name: \"index\", toBlock: FlowGraphBlockNames.IndexOf },\r\n hoveredNode: { name: \"nodeReference\", toBlock: \"KHR_interactivity/FlowGraphEventReferenceBlock\" },\r\n controllerIndex: { name: \"controllerIndex\", toBlock: \"KHR_interactivity/FlowGraphEventReferenceBlock\" },\r\n event: { name: \"value\", toBlock: \"KHR_interactivity/FlowGraphEventReferenceBlock\" },\r\n },\r\n flows: {\r\n out: { name: \"out\", toBlock: \"KHR_interactivity/FlowGraphEventReferenceBlock\" },\r\n },\r\n },\r\n interBlockConnectors: [\r\n {\r\n input: \"targetMesh\",\r\n output: \"value\",\r\n inputBlockIndex: 0,\r\n outputBlockIndex: 1,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"array\",\r\n output: \"nodes\",\r\n inputBlockIndex: 2,\r\n outputBlockIndex: 3,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"object\",\r\n output: \"meshUnderPointer\",\r\n inputBlockIndex: 2,\r\n outputBlockIndex: 0,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"node\",\r\n output: \"meshUnderPointer\",\r\n inputBlockIndex: 4,\r\n outputBlockIndex: 0,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"controllerIndexInput\",\r\n output: \"pointerId\",\r\n inputBlockIndex: 4,\r\n outputBlockIndex: 0,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"in\",\r\n output: \"done\",\r\n inputBlockIndex: 4,\r\n outputBlockIndex: 0,\r\n },\r\n ],\r\n extraProcessor(gltfBlock, _declaration, _mapping, _arrays, serializedObjects, context, globalGLTF) {\r\n // find the listener nodeIndex value\r\n const nodeIndex = gltfBlock.configuration?.[\"nodeIndex\"]?.value?.[0];\r\n const validNodeIndex = typeof nodeIndex === \"number\" && Number.isInteger(nodeIndex) && nodeIndex >= 0 && nodeIndex < (globalGLTF?.nodes?.length ?? 0);\r\n const variableName = validNodeIndex ? MeshPointerOverPrefix + nodeIndex : MeshPointerOverPrefix + \"unbound\";\r\n // find the nodeIndex value\r\n serializedObjects[1].config.variable = variableName;\r\n context._userVariables[variableName] = validNodeIndex\r\n ? {\r\n className: \"Mesh\",\r\n id: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.id,\r\n uniqueId: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.uniqueId,\r\n }\r\n : { type: FlowGraphTypes.Any, value: [{}] };\r\n const eventKey = `${NAME}:event/onHoverIn:${nodeIndex}`;\r\n serializedObjects[0].config.eventKey = eventKey;\r\n serializedObjects[4].config.eventKey = eventKey;\r\n return serializedObjects;\r\n },\r\n });\r\n\r\n addNewInteractivityFlowGraphMapping(\"event/onHoverOut\", NAME, {\r\n // using GetVariable as the nodeIndex is a configuration and not a value (i.e. it's not mutable)\r\n blocks: [\r\n FlowGraphBlockNames.PointerOutEvent,\r\n FlowGraphBlockNames.GetVariable,\r\n FlowGraphBlockNames.IndexOf,\r\n \"KHR_interactivity/FlowGraphGLTFDataProvider\",\r\n \"KHR_interactivity/FlowGraphEventReferenceBlock\",\r\n ],\r\n declarationSchema: {\r\n inputValueSockets: {},\r\n outputValueSockets: {\r\n hoveredNode: \"ref\",\r\n controllerIndex: \"int\",\r\n event: \"ref\",\r\n },\r\n },\r\n configuration: {\r\n nodeIndex: {\r\n name: \"variable\",\r\n configurationType: \"int\",\r\n toBlock: FlowGraphBlockNames.GetVariable,\r\n indexSource: \"assetNodes\",\r\n invalidUsesDefault: true,\r\n dataTransformer(data) {\r\n return MeshPointerOutPrefix + data;\r\n },\r\n },\r\n },\r\n outputs: {\r\n values: {\r\n hoverNodeIndex: { name: \"index\", toBlock: FlowGraphBlockNames.IndexOf },\r\n hoveredNode: { name: \"nodeReference\", toBlock: \"KHR_interactivity/FlowGraphEventReferenceBlock\" },\r\n controllerIndex: { name: \"controllerIndex\", toBlock: \"KHR_interactivity/FlowGraphEventReferenceBlock\" },\r\n event: { name: \"value\", toBlock: \"KHR_interactivity/FlowGraphEventReferenceBlock\" },\r\n },\r\n flows: {\r\n out: { name: \"out\", toBlock: \"KHR_interactivity/FlowGraphEventReferenceBlock\" },\r\n },\r\n },\r\n interBlockConnectors: [\r\n {\r\n input: \"targetMesh\",\r\n output: \"value\",\r\n inputBlockIndex: 0,\r\n outputBlockIndex: 1,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"array\",\r\n output: \"nodes\",\r\n inputBlockIndex: 2,\r\n outputBlockIndex: 3,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"object\",\r\n output: \"meshOutOfPointer\",\r\n inputBlockIndex: 2,\r\n outputBlockIndex: 0,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"node\",\r\n output: \"meshOutOfPointer\",\r\n inputBlockIndex: 4,\r\n outputBlockIndex: 0,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"controllerIndexInput\",\r\n output: \"pointerId\",\r\n inputBlockIndex: 4,\r\n outputBlockIndex: 0,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"in\",\r\n output: \"done\",\r\n inputBlockIndex: 4,\r\n outputBlockIndex: 0,\r\n },\r\n ],\r\n extraProcessor(gltfBlock, _declaration, _mapping, _arrays, serializedObjects, context, globalGLTF) {\r\n const nodeIndex = gltfBlock.configuration?.[\"nodeIndex\"]?.value?.[0];\r\n const validNodeIndex = typeof nodeIndex === \"number\" && Number.isInteger(nodeIndex) && nodeIndex >= 0 && nodeIndex < (globalGLTF?.nodes?.length ?? 0);\r\n const variableName = validNodeIndex ? MeshPointerOutPrefix + nodeIndex : MeshPointerOutPrefix + \"unbound\";\r\n // find the nodeIndex value\r\n serializedObjects[1].config.variable = variableName;\r\n context._userVariables[variableName] = validNodeIndex\r\n ? {\r\n className: \"Mesh\",\r\n id: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.id,\r\n uniqueId: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.uniqueId,\r\n }\r\n : { type: FlowGraphTypes.Any, value: [{}] };\r\n const eventKey = `${NAME}:event/onHoverOut:${nodeIndex}`;\r\n serializedObjects[0].config.eventKey = eventKey;\r\n serializedObjects[4].config.eventKey = eventKey;\r\n return serializedObjects;\r\n },\r\n });\r\n\r\n AddObjectAccessorToKey(\"/nodes/{}/extensions/KHR_node_hoverability/hoverable\", {\r\n get: (node: INode) => {\r\n return GetInteractivityNodeState(node, \"hoverable\");\r\n },\r\n set: (value: boolean, node: INode) => {\r\n SetInteractivityNodeState(node, \"hoverable\", value);\r\n },\r\n getTarget: (node: INode) => node._babylonTransformNode,\r\n getPropertyName: [() => \"pointerOverDisableMeshTesting\"],\r\n type: \"boolean\",\r\n });\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Registers the KHR_node_hoverability glTF loader extension.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function RegisterKHR_node_hoverability(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n _RegisterKHRNodeHoverabilityRuntime();\r\n\r\n unregisterGLTFExtension(NAME);\r\n\r\n registerGLTFExtension(NAME, true, (loader) => new KHR_node_hoverability(loader));\r\n}\r\n"]}
@@ -8,6 +8,8 @@ export declare class KHR_node_selectability implements IGLTFLoaderExtension {
8
8
  * The name of this extension.
9
9
  */
10
10
  readonly name = "KHR_node_selectability";
11
+ /** Applies node state before KHR_interactivity graphs start. */
12
+ readonly order = 100;
11
13
  /**
12
14
  * Defines whether this extension is enabled.
13
15
  */
@@ -1,6 +1,7 @@
1
1
  import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry.js";
2
2
  import { addNewInteractivityFlowGraphMapping } from "./KHR_interactivity/declarationMapper.js";
3
3
  import { AddObjectAccessorToKey } from "./objectModelMapping.js";
4
+ import { GetInteractivityNodeState, InitializeInteractivityNodeState, SetInteractivityNodeState } from "./KHR_interactivity/interactivityNodeState.js";
4
5
  const NAME = "KHR_node_selectability";
5
6
  // add the interactivity mapping for the onSelect event
6
7
  // object model extension for selectable
@@ -17,18 +18,14 @@ export class KHR_node_selectability {
17
18
  * The name of this extension.
18
19
  */
19
20
  this.name = NAME;
21
+ /** Applies node state before KHR_interactivity graphs start. */
22
+ this.order = 100;
20
23
  this._loader = loader;
21
24
  this.enabled = loader.isExtensionUsed(NAME);
22
25
  }
23
26
  // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-misused-promises
24
27
  async onReady() {
25
- this._loader.gltf.nodes?.forEach((node) => {
26
- if (node.extensions?.KHR_node_selectability && node.extensions?.KHR_node_selectability.selectable === false) {
27
- node._babylonTransformNode?.getChildMeshes().forEach((mesh) => {
28
- mesh.isPickable = false;
29
- });
30
- }
31
- });
28
+ InitializeInteractivityNodeState(this._loader.gltf.nodes ?? [], "selectable", (node) => node.extensions?.KHR_node_selectability?.selectable);
32
29
  }
33
30
  dispose() {
34
31
  this._loader = null;
@@ -47,12 +44,30 @@ export function _RegisterKHRNodeSelectabilityRuntime() {
47
44
  _RuntimeRegistered = true;
48
45
  addNewInteractivityFlowGraphMapping("event/onSelect", NAME, {
49
46
  // using GetVariable as the nodeIndex is a configuration and not a value (i.e. it's not mutable)
50
- blocks: ["FlowGraphMeshPickEventBlock" /* FlowGraphBlockNames.MeshPickEvent */, "FlowGraphGetVariableBlock" /* FlowGraphBlockNames.GetVariable */, "FlowGraphIndexOfBlock" /* FlowGraphBlockNames.IndexOf */, "KHR_interactivity/FlowGraphGLTFDataProvider"],
47
+ blocks: [
48
+ "FlowGraphMeshPickEventBlock" /* FlowGraphBlockNames.MeshPickEvent */,
49
+ "FlowGraphGetVariableBlock" /* FlowGraphBlockNames.GetVariable */,
50
+ "FlowGraphIndexOfBlock" /* FlowGraphBlockNames.IndexOf */,
51
+ "KHR_interactivity/FlowGraphGLTFDataProvider",
52
+ "KHR_interactivity/FlowGraphEventReferenceBlock",
53
+ ],
54
+ declarationSchema: {
55
+ inputValueSockets: {},
56
+ outputValueSockets: {
57
+ selectedNode: "ref",
58
+ selectionRayOrigin: "float3",
59
+ selectionPoint: "float3",
60
+ controllerIndex: "int",
61
+ event: "ref",
62
+ },
63
+ },
51
64
  configuration: {
52
- stopPropagation: { name: "stopPropagation" },
53
65
  nodeIndex: {
54
66
  name: "variable",
67
+ configurationType: "int",
55
68
  toBlock: "FlowGraphGetVariableBlock" /* FlowGraphBlockNames.GetVariable */,
69
+ indexSource: "assetNodes",
70
+ invalidUsesDefault: true,
56
71
  dataTransformer(data) {
57
72
  return "pickedMesh_" + data;
58
73
  },
@@ -64,13 +79,14 @@ export function _RegisterKHRNodeSelectabilityRuntime() {
64
79
  // `selectedNode` is the new ref-typed output from the Opaque-Reference
65
80
  // spec update. It's the picked Babylon mesh itself, available directly
66
81
  // from FlowGraphMeshPickEventBlock.pickedMesh — no IndexOf lookup needed.
67
- selectedNode: { name: "pickedMesh", toBlock: "FlowGraphMeshPickEventBlock" /* FlowGraphBlockNames.MeshPickEvent */ },
68
- controllerIndex: { name: "pointerId" },
69
- selectionPoint: { name: "pickedPoint" },
70
- selectionRayOrigin: { name: "pickOrigin" },
82
+ selectedNode: { name: "nodeReference", toBlock: "KHR_interactivity/FlowGraphEventReferenceBlock" },
83
+ controllerIndex: { name: "controllerIndex", toBlock: "KHR_interactivity/FlowGraphEventReferenceBlock" },
84
+ selectionPoint: { name: "selectionPoint", toBlock: "KHR_interactivity/FlowGraphEventReferenceBlock" },
85
+ selectionRayOrigin: { name: "selectionRayOrigin", toBlock: "KHR_interactivity/FlowGraphEventReferenceBlock" },
86
+ event: { name: "value", toBlock: "KHR_interactivity/FlowGraphEventReferenceBlock" },
71
87
  },
72
88
  flows: {
73
- out: { name: "done" },
89
+ out: { name: "out", toBlock: "KHR_interactivity/FlowGraphEventReferenceBlock" },
74
90
  },
75
91
  },
76
92
  interBlockConnectors: [
@@ -95,40 +111,69 @@ export function _RegisterKHRNodeSelectabilityRuntime() {
95
111
  outputBlockIndex: 0,
96
112
  isVariable: true,
97
113
  },
114
+ {
115
+ input: "node",
116
+ output: "pickedMesh",
117
+ inputBlockIndex: 4,
118
+ outputBlockIndex: 0,
119
+ isVariable: true,
120
+ },
121
+ {
122
+ input: "controllerIndexInput",
123
+ output: "pointerId",
124
+ inputBlockIndex: 4,
125
+ outputBlockIndex: 0,
126
+ isVariable: true,
127
+ },
128
+ {
129
+ input: "selectionPointInput",
130
+ output: "pickedPoint",
131
+ inputBlockIndex: 4,
132
+ outputBlockIndex: 0,
133
+ isVariable: true,
134
+ },
135
+ {
136
+ input: "selectionRayOriginInput",
137
+ output: "pickOrigin",
138
+ inputBlockIndex: 4,
139
+ outputBlockIndex: 0,
140
+ isVariable: true,
141
+ },
142
+ {
143
+ input: "in",
144
+ output: "done",
145
+ inputBlockIndex: 4,
146
+ outputBlockIndex: 0,
147
+ },
98
148
  ],
99
149
  extraProcessor(gltfBlock, _declaration, _mapping, _arrays, serializedObjects, context, globalGLTF) {
100
- // add the glTF to the configuration of the last serialized object
101
- const serializedObject = serializedObjects[serializedObjects.length - 1];
102
- serializedObject.config = serializedObject.config || {};
103
- serializedObject.config.glTF = globalGLTF;
104
150
  // find the listener nodeIndex value
105
151
  const nodeIndex = gltfBlock.configuration?.["nodeIndex"]?.value?.[0];
106
- if (nodeIndex === undefined || typeof nodeIndex !== "number") {
107
- throw new Error("nodeIndex not found in configuration");
108
- }
109
- const variableName = "pickedMesh_" + nodeIndex;
152
+ const validNodeIndex = typeof nodeIndex === "number" && Number.isInteger(nodeIndex) && nodeIndex >= 0 && nodeIndex < (globalGLTF?.nodes?.length ?? 0);
153
+ const variableName = validNodeIndex ? "pickedMesh_" + nodeIndex : "pickedMesh_unbound";
110
154
  // find the nodeIndex value
111
155
  serializedObjects[1].config.variable = variableName;
112
- context._userVariables[variableName] = {
113
- className: "Mesh",
114
- id: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.id,
115
- uniqueId: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.uniqueId,
116
- };
156
+ context._userVariables[variableName] = validNodeIndex
157
+ ? {
158
+ className: "Mesh",
159
+ id: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.id,
160
+ uniqueId: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.uniqueId,
161
+ }
162
+ : { type: "any" /* FlowGraphTypes.Any */, value: [{}] };
163
+ const eventKey = `${NAME}:event/onSelect:${nodeIndex}`;
164
+ serializedObjects[0].config.eventKey = eventKey;
165
+ serializedObjects[0].config.useNaNDefaults = true;
166
+ serializedObjects[0].config.pointerIdDefault = -1;
167
+ serializedObjects[4].config.eventKey = eventKey;
117
168
  return serializedObjects;
118
169
  },
119
170
  });
120
171
  AddObjectAccessorToKey("/nodes/{}/extensions/KHR_node_selectability/selectable", {
121
172
  get: (node) => {
122
- const tn = node._babylonTransformNode;
123
- if (tn && tn.isPickable !== undefined) {
124
- return tn.isPickable;
125
- }
126
- return true;
173
+ return GetInteractivityNodeState(node, "selectable");
127
174
  },
128
175
  set: (value, node) => {
129
- node._primitiveBabylonMeshes?.forEach((mesh) => {
130
- mesh.isPickable = value;
131
- });
176
+ SetInteractivityNodeState(node, "selectable", value);
132
177
  },
133
178
  getTarget: (node) => node._babylonTransformNode,
134
179
  getPropertyName: [() => "isPickable"],
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_node_selectability.pure.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_node_selectability.pure.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAE5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,MAAM,IAAI,GAAG,wBAAwB,CAAC;AAEtC,uDAAuD;AAEvD,wCAAwC;AAExC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,sBAAsB;IAY/B;;OAEG;IACH,YAAY,MAAkB;QAd9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAYxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,wGAAwG;IACjG,KAAK,CAAC,OAAO;QAChB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACtC,IAAI,IAAI,CAAC,UAAU,EAAE,sBAAsB,IAAI,IAAI,CAAC,UAAU,EAAE,sBAAsB,CAAC,UAAU,KAAK,KAAK,EAAE,CAAC;gBAC1G,IAAI,CAAC,qBAAqB,EAAE,cAAc,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;oBAC1D,IAAI,CAAC,UAAU,GAAG,KAAK,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\"../glTFLoaderExtension\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\nimport { FlowGraphBlockNames } from \"core/FlowGraph/Blocks/flowGraphBlockNames\";\r\nimport { addNewInteractivityFlowGraphMapping } from \"./KHR_interactivity/declarationMapper\";\r\nimport { type INode } from \"../glTFLoaderInterfaces\";\r\nimport { AddObjectAccessorToKey } from \"./objectModelMapping\";\r\n\r\nconst NAME = \"KHR_node_selectability\";\r\n\r\n// add the interactivity mapping for the onSelect event\r\n\r\n// object model extension for selectable\r\n\r\n/**\r\n * Loader extension for KHR_selectability\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_node_selectability implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = loader.isExtensionUsed(NAME);\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-misused-promises\r\n public async onReady(): Promise<void> {\r\n this._loader.gltf.nodes?.forEach((node) => {\r\n if (node.extensions?.KHR_node_selectability && node.extensions?.KHR_node_selectability.selectable === false) {\r\n node._babylonTransformNode?.getChildMeshes().forEach((mesh) => {\r\n mesh.isPickable = false;\r\n });\r\n }\r\n });\r\n }\r\n\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n}\r\n\r\nlet _RuntimeRegistered = false;\r\n/**\r\n * @internal\r\n * Registers KHR_node_selectability runtime dependencies without changing the extension registry.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function _RegisterKHRNodeSelectabilityRuntime(): void {\r\n if (_RuntimeRegistered) {\r\n return;\r\n }\r\n _RuntimeRegistered = true;\r\n\r\n addNewInteractivityFlowGraphMapping(\"event/onSelect\", NAME, {\r\n // using GetVariable as the nodeIndex is a configuration and not a value (i.e. it's not mutable)\r\n blocks: [FlowGraphBlockNames.MeshPickEvent, FlowGraphBlockNames.GetVariable, FlowGraphBlockNames.IndexOf, \"KHR_interactivity/FlowGraphGLTFDataProvider\"],\r\n configuration: {\r\n stopPropagation: { name: \"stopPropagation\" },\r\n nodeIndex: {\r\n name: \"variable\",\r\n toBlock: FlowGraphBlockNames.GetVariable,\r\n dataTransformer(data) {\r\n return \"pickedMesh_\" + data;\r\n },\r\n },\r\n },\r\n outputs: {\r\n values: {\r\n selectedNodeIndex: { name: \"index\", toBlock: FlowGraphBlockNames.IndexOf },\r\n // `selectedNode` is the new ref-typed output from the Opaque-Reference\r\n // spec update. It's the picked Babylon mesh itself, available directly\r\n // from FlowGraphMeshPickEventBlock.pickedMesh — no IndexOf lookup needed.\r\n selectedNode: { name: \"pickedMesh\", toBlock: FlowGraphBlockNames.MeshPickEvent },\r\n controllerIndex: { name: \"pointerId\" },\r\n selectionPoint: { name: \"pickedPoint\" },\r\n selectionRayOrigin: { name: \"pickOrigin\" },\r\n },\r\n flows: {\r\n out: { name: \"done\" },\r\n },\r\n },\r\n interBlockConnectors: [\r\n {\r\n input: \"asset\",\r\n output: \"value\",\r\n inputBlockIndex: 0,\r\n outputBlockIndex: 1,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"array\",\r\n output: \"nodes\",\r\n inputBlockIndex: 2,\r\n outputBlockIndex: 3,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"object\",\r\n output: \"pickedMesh\",\r\n inputBlockIndex: 2,\r\n outputBlockIndex: 0,\r\n isVariable: true,\r\n },\r\n ],\r\n extraProcessor(gltfBlock, _declaration, _mapping, _arrays, serializedObjects, context, globalGLTF) {\r\n // add the glTF to the configuration of the last serialized object\r\n const serializedObject = serializedObjects[serializedObjects.length - 1];\r\n serializedObject.config = serializedObject.config || {};\r\n serializedObject.config.glTF = globalGLTF;\r\n // find the listener nodeIndex value\r\n const nodeIndex = gltfBlock.configuration?.[\"nodeIndex\"]?.value?.[0];\r\n if (nodeIndex === undefined || typeof nodeIndex !== \"number\") {\r\n throw new Error(\"nodeIndex not found in configuration\");\r\n }\r\n const variableName = \"pickedMesh_\" + nodeIndex;\r\n // find the nodeIndex value\r\n serializedObjects[1].config.variable = variableName;\r\n context._userVariables[variableName] = {\r\n className: \"Mesh\",\r\n id: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.id,\r\n uniqueId: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.uniqueId,\r\n };\r\n return serializedObjects;\r\n },\r\n });\r\n\r\n AddObjectAccessorToKey(\"/nodes/{}/extensions/KHR_node_selectability/selectable\", {\r\n get: (node: INode) => {\r\n const tn = node._babylonTransformNode as any;\r\n if (tn && tn.isPickable !== undefined) {\r\n return tn.isPickable;\r\n }\r\n return true;\r\n },\r\n set: (value: boolean, node: INode) => {\r\n node._primitiveBabylonMeshes?.forEach((mesh) => {\r\n mesh.isPickable = value;\r\n });\r\n },\r\n getTarget: (node: INode) => node._babylonTransformNode,\r\n getPropertyName: [() => \"isPickable\"],\r\n type: \"boolean\",\r\n });\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Registers the KHR_node_selectability glTF loader extension.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function RegisterKHR_node_selectability(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n _RegisterKHRNodeSelectabilityRuntime();\r\n\r\n unregisterGLTFExtension(NAME);\r\n\r\n registerGLTFExtension(NAME, true, (loader) => new KHR_node_selectability(loader));\r\n}\r\n"]}
1
+ {"version":3,"file":"KHR_node_selectability.pure.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_node_selectability.pure.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,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AE,YAAY,CAAC,CAAC;QACzD,CAAC;QACD,GAAG,EAAE,CAAC,KAAc,EAAE,IAAW,EAAE,EAAE;YACjC,yBAAyB,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;QACzD,CAAC;QACD,SAAS,EAAE,CAAC,IAAW,EAAE,EAAE,CAAC,IAAI,CAAC,qBAAqB;QACtD,eAAe,EAAE,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC;QACrC,IAAI,EAAE,SAAS;KAClB,CAAC,CAAC;AACP,CAAC;AAED,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,gEAAgE;AAChE,MAAM,UAAU,8BAA8B;IAC1C,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,oCAAoC,EAAE,CAAC;IAEvC,uBAAuB,CAAC,IAAI,CAAC,CAAC;IAE9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC;AACtF,CAAC","sourcesContent":["import { type GLTFLoader } from \"../glTFLoader.pure\";\r\nimport { type IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\nimport { FlowGraphBlockNames } from \"core/FlowGraph/Blocks/flowGraphBlockNames\";\r\nimport { addNewInteractivityFlowGraphMapping } from \"./KHR_interactivity/declarationMapper\";\r\nimport { type INode } from \"../glTFLoaderInterfaces\";\r\nimport { AddObjectAccessorToKey } from \"./objectModelMapping\";\r\nimport { GetInteractivityNodeState, InitializeInteractivityNodeState, SetInteractivityNodeState } from \"./KHR_interactivity/interactivityNodeState\";\r\nimport { FlowGraphTypes } from \"core/FlowGraph/flowGraphRichTypes.pure\";\r\n\r\nconst NAME = \"KHR_node_selectability\";\r\n\r\n// add the interactivity mapping for the onSelect event\r\n\r\n// object model extension for selectable\r\n\r\n/**\r\n * Loader extension for KHR_selectability\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_node_selectability implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n /** Applies node state before KHR_interactivity graphs start. */\r\n public readonly order = 100;\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = loader.isExtensionUsed(NAME);\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-misused-promises\r\n public async onReady(): Promise<void> {\r\n InitializeInteractivityNodeState(this._loader.gltf.nodes ?? [], \"selectable\", (node) => node.extensions?.KHR_node_selectability?.selectable);\r\n }\r\n\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n}\r\n\r\nlet _RuntimeRegistered = false;\r\n/**\r\n * @internal\r\n * Registers KHR_node_selectability runtime dependencies without changing the extension registry.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function _RegisterKHRNodeSelectabilityRuntime(): void {\r\n if (_RuntimeRegistered) {\r\n return;\r\n }\r\n _RuntimeRegistered = true;\r\n\r\n addNewInteractivityFlowGraphMapping(\"event/onSelect\", NAME, {\r\n // using GetVariable as the nodeIndex is a configuration and not a value (i.e. it's not mutable)\r\n blocks: [\r\n FlowGraphBlockNames.MeshPickEvent,\r\n FlowGraphBlockNames.GetVariable,\r\n FlowGraphBlockNames.IndexOf,\r\n \"KHR_interactivity/FlowGraphGLTFDataProvider\",\r\n \"KHR_interactivity/FlowGraphEventReferenceBlock\",\r\n ],\r\n declarationSchema: {\r\n inputValueSockets: {},\r\n outputValueSockets: {\r\n selectedNode: \"ref\",\r\n selectionRayOrigin: \"float3\",\r\n selectionPoint: \"float3\",\r\n controllerIndex: \"int\",\r\n event: \"ref\",\r\n },\r\n },\r\n configuration: {\r\n nodeIndex: {\r\n name: \"variable\",\r\n configurationType: \"int\",\r\n toBlock: FlowGraphBlockNames.GetVariable,\r\n indexSource: \"assetNodes\",\r\n invalidUsesDefault: true,\r\n dataTransformer(data) {\r\n return \"pickedMesh_\" + data;\r\n },\r\n },\r\n },\r\n outputs: {\r\n values: {\r\n selectedNodeIndex: { name: \"index\", toBlock: FlowGraphBlockNames.IndexOf },\r\n // `selectedNode` is the new ref-typed output from the Opaque-Reference\r\n // spec update. It's the picked Babylon mesh itself, available directly\r\n // from FlowGraphMeshPickEventBlock.pickedMesh — no IndexOf lookup needed.\r\n selectedNode: { name: \"nodeReference\", toBlock: \"KHR_interactivity/FlowGraphEventReferenceBlock\" },\r\n controllerIndex: { name: \"controllerIndex\", toBlock: \"KHR_interactivity/FlowGraphEventReferenceBlock\" },\r\n selectionPoint: { name: \"selectionPoint\", toBlock: \"KHR_interactivity/FlowGraphEventReferenceBlock\" },\r\n selectionRayOrigin: { name: \"selectionRayOrigin\", toBlock: \"KHR_interactivity/FlowGraphEventReferenceBlock\" },\r\n event: { name: \"value\", toBlock: \"KHR_interactivity/FlowGraphEventReferenceBlock\" },\r\n },\r\n flows: {\r\n out: { name: \"out\", toBlock: \"KHR_interactivity/FlowGraphEventReferenceBlock\" },\r\n },\r\n },\r\n interBlockConnectors: [\r\n {\r\n input: \"asset\",\r\n output: \"value\",\r\n inputBlockIndex: 0,\r\n outputBlockIndex: 1,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"array\",\r\n output: \"nodes\",\r\n inputBlockIndex: 2,\r\n outputBlockIndex: 3,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"object\",\r\n output: \"pickedMesh\",\r\n inputBlockIndex: 2,\r\n outputBlockIndex: 0,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"node\",\r\n output: \"pickedMesh\",\r\n inputBlockIndex: 4,\r\n outputBlockIndex: 0,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"controllerIndexInput\",\r\n output: \"pointerId\",\r\n inputBlockIndex: 4,\r\n outputBlockIndex: 0,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"selectionPointInput\",\r\n output: \"pickedPoint\",\r\n inputBlockIndex: 4,\r\n outputBlockIndex: 0,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"selectionRayOriginInput\",\r\n output: \"pickOrigin\",\r\n inputBlockIndex: 4,\r\n outputBlockIndex: 0,\r\n isVariable: true,\r\n },\r\n {\r\n input: \"in\",\r\n output: \"done\",\r\n inputBlockIndex: 4,\r\n outputBlockIndex: 0,\r\n },\r\n ],\r\n extraProcessor(gltfBlock, _declaration, _mapping, _arrays, serializedObjects, context, globalGLTF) {\r\n // find the listener nodeIndex value\r\n const nodeIndex = gltfBlock.configuration?.[\"nodeIndex\"]?.value?.[0];\r\n const validNodeIndex = typeof nodeIndex === \"number\" && Number.isInteger(nodeIndex) && nodeIndex >= 0 && nodeIndex < (globalGLTF?.nodes?.length ?? 0);\r\n const variableName = validNodeIndex ? \"pickedMesh_\" + nodeIndex : \"pickedMesh_unbound\";\r\n // find the nodeIndex value\r\n serializedObjects[1].config.variable = variableName;\r\n context._userVariables[variableName] = validNodeIndex\r\n ? {\r\n className: \"Mesh\",\r\n id: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.id,\r\n uniqueId: globalGLTF?.nodes?.[nodeIndex]._babylonTransformNode?.uniqueId,\r\n }\r\n : { type: FlowGraphTypes.Any, value: [{}] };\r\n const eventKey = `${NAME}:event/onSelect:${nodeIndex}`;\r\n serializedObjects[0].config.eventKey = eventKey;\r\n serializedObjects[0].config.useNaNDefaults = true;\r\n serializedObjects[0].config.pointerIdDefault = -1;\r\n serializedObjects[4].config.eventKey = eventKey;\r\n return serializedObjects;\r\n },\r\n });\r\n\r\n AddObjectAccessorToKey(\"/nodes/{}/extensions/KHR_node_selectability/selectable\", {\r\n get: (node: INode) => {\r\n return GetInteractivityNodeState(node, \"selectable\");\r\n },\r\n set: (value: boolean, node: INode) => {\r\n SetInteractivityNodeState(node, \"selectable\", value);\r\n },\r\n getTarget: (node: INode) => node._babylonTransformNode,\r\n getPropertyName: [() => \"isPickable\"],\r\n type: \"boolean\",\r\n });\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Registers the KHR_node_selectability glTF loader extension.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function RegisterKHR_node_selectability(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n _RegisterKHRNodeSelectabilityRuntime();\r\n\r\n unregisterGLTFExtension(NAME);\r\n\r\n registerGLTFExtension(NAME, true, (loader) => new KHR_node_selectability(loader));\r\n}\r\n"]}
@@ -32,8 +32,9 @@ export class InteractivityRefPathToObjectConverter {
32
32
  * @returns an object accessor whose `get` validates the reference
33
33
  */
34
34
  convert(path) {
35
+ const isEmptyEventReference = path === EventReferencePrefix;
35
36
  const normalized = path.endsWith("/") ? path.slice(0, -1) : path;
36
- if (normalized.startsWith(EventReferencePrefix)) {
37
+ if (isEmptyEventReference || normalized.startsWith(EventReferencePrefix)) {
37
38
  const key = normalized.substring(EventReferencePrefix.length);
38
39
  return {
39
40
  object: RefValidityTarget,
@@ -42,7 +43,7 @@ export class InteractivityRefPathToObjectConverter {
42
43
  isReadOnly: true,
43
44
  // A non-empty key means a real event reference was supplied (the
44
45
  // template substitution rejects null refs before we get here).
45
- get: () => (key.length > 0 ? normalized : undefined),
46
+ get: () => (isEmptyEventReference ? path : key.length > 0 ? normalized : undefined),
46
47
  getTarget: () => RefValidityTarget,
47
48
  },
48
49
  };