@babylonjs/loaders 9.31.0 → 9.31.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 (59) hide show
  1. package/SPLAT/gaussianSplattingDownloadManager.d.ts +10 -9
  2. package/SPLAT/gaussianSplattingDownloadManager.js +64 -53
  3. package/SPLAT/gaussianSplattingDownloadManager.js.map +1 -1
  4. package/SPLAT/gaussianSplattingResidencyPages.d.ts +49 -0
  5. package/SPLAT/gaussianSplattingResidencyPages.js +93 -0
  6. package/SPLAT/gaussianSplattingResidencyPages.js.map +1 -0
  7. package/SPLAT/gaussianSplattingStream.d.ts +154 -15
  8. package/SPLAT/gaussianSplattingStream.js +407 -25
  9. package/SPLAT/gaussianSplattingStream.js.map +1 -1
  10. package/SPLAT/gaussianSplattingWorkBuffer.d.ts +3 -1
  11. package/SPLAT/gaussianSplattingWorkBuffer.js +51 -14
  12. package/SPLAT/gaussianSplattingWorkBuffer.js.map +1 -1
  13. package/SPLAT/gaussianSplattingWorkBufferShaders.d.ts +6 -6
  14. package/SPLAT/gaussianSplattingWorkBufferShaders.js +12 -6
  15. package/SPLAT/gaussianSplattingWorkBufferShaders.js.map +1 -1
  16. package/glTF/2.0/Extensions/KHR_animation_pointer.data.pure.js +24 -9
  17. package/glTF/2.0/Extensions/KHR_animation_pointer.data.pure.js.map +1 -1
  18. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.d.ts +6 -1
  19. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js +66 -40
  20. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js.map +1 -1
  21. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphDelayReferenceBlock.d.ts +26 -0
  22. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphDelayReferenceBlock.js +44 -0
  23. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphDelayReferenceBlock.js.map +1 -0
  24. package/glTF/2.0/Extensions/KHR_interactivity/index.d.ts +1 -0
  25. package/glTF/2.0/Extensions/KHR_interactivity/index.js +1 -0
  26. package/glTF/2.0/Extensions/KHR_interactivity/index.js.map +1 -1
  27. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphExporter.js +7 -1
  28. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphExporter.js.map +1 -1
  29. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphModel.d.ts +2 -1
  30. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphModel.js +75 -6
  31. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphModel.js.map +1 -1
  32. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.d.ts +9 -0
  33. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js +35 -5
  34. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js.map +1 -1
  35. package/glTF/2.0/Extensions/KHR_interactivity/pure.d.ts +1 -0
  36. package/glTF/2.0/Extensions/KHR_interactivity/pure.js +1 -0
  37. package/glTF/2.0/Extensions/KHR_interactivity/pure.js.map +1 -1
  38. package/glTF/2.0/Extensions/KHR_interactivity.pure.js +27 -6
  39. package/glTF/2.0/Extensions/KHR_interactivity.pure.js.map +1 -1
  40. package/glTF/2.0/Extensions/KHR_node_hoverability.pure.js +2 -0
  41. package/glTF/2.0/Extensions/KHR_node_hoverability.pure.js.map +1 -1
  42. package/glTF/2.0/Extensions/KHR_node_selectability.pure.js +11 -0
  43. package/glTF/2.0/Extensions/KHR_node_selectability.pure.js.map +1 -1
  44. package/glTF/2.0/Extensions/gltfAreaLightDimensions.d.ts +26 -0
  45. package/glTF/2.0/Extensions/gltfAreaLightDimensions.js +49 -0
  46. package/glTF/2.0/Extensions/gltfAreaLightDimensions.js.map +1 -0
  47. package/glTF/2.0/Extensions/gltfPathToObjectConverter.js +3 -0
  48. package/glTF/2.0/Extensions/gltfPathToObjectConverter.js.map +1 -1
  49. package/glTF/2.0/Extensions/interactivityAssetPathToObjectConverter.d.ts +1 -1
  50. package/glTF/2.0/Extensions/interactivityAssetPathToObjectConverter.js +5 -2
  51. package/glTF/2.0/Extensions/interactivityAssetPathToObjectConverter.js.map +1 -1
  52. package/glTF/2.0/Extensions/interactivityRefPathToObjectConverter.js +1 -2
  53. package/glTF/2.0/Extensions/interactivityRefPathToObjectConverter.js.map +1 -1
  54. package/glTF/2.0/Extensions/objectModelMapping.d.ts +16 -13
  55. package/glTF/2.0/Extensions/objectModelMapping.js +157 -108
  56. package/glTF/2.0/Extensions/objectModelMapping.js.map +1 -1
  57. package/glTF/2.0/glTFLoaderInterfaces.d.ts +2 -0
  58. package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
  59. package/package.json +3 -3
@@ -171,9 +171,10 @@ export declare function CloneKHRInteractivityGraph(graph: IKHRInteractivity_Grap
171
171
  * @param graph source graph
172
172
  * @param declarations canonical declarations
173
173
  * @param assetNodeCount number of glTF nodes in the containing asset
174
+ * @param preserveCompatibilityConfiguration allow independent optional configuration properties and legacy fractional for-loop initial indices
174
175
  * @returns normalized executable graph
175
176
  */
176
- export declare function CreateEffectiveKHRInteractivityGraph(graph: IKHRInteractivity_Graph, declarations: readonly IKHRInteractivityDeclarationModel[], assetNodeCount?: number): IKHRInteractivity_Graph;
177
+ export declare function CreateEffectiveKHRInteractivityGraph(graph: IKHRInteractivity_Graph, declarations: readonly IKHRInteractivityDeclarationModel[], assetNodeCount?: number, preserveCompatibilityConfiguration?: boolean): IKHRInteractivity_Graph;
177
178
  /**
178
179
  * Creates and validates a canonical copy of one KHR_interactivity graph.
179
180
  * @param graph source graph
@@ -223,7 +223,9 @@ function _getDeclarationMapping(declaration, graph, supportedExtensions) {
223
223
  const extensionEnabled = !declaration.extension || !supportedExtensions || supportedExtensions.has(declaration.extension);
224
224
  const mapping = extensionEnabled ? getMappingForDeclaration(declaration, false) : undefined;
225
225
  if (mapping) {
226
- if (declaration.extension && mapping.declarationSchema && !_isCompatibleExtensionDeclaration(declaration, graph, mapping.declarationSchema)) {
226
+ if (declaration.extension &&
227
+ mapping.declarationSchema &&
228
+ ![mapping.declarationSchema, ...(mapping.declarationSchemaVariants ?? [])].some((schema) => schema && _isCompatibleExtensionDeclaration(declaration, graph, schema))) {
227
229
  return { mapping: undefined, support: "unsupported-extension" };
228
230
  }
229
231
  return { mapping, support: declaration.extension ? "extension" : "core" };
@@ -318,9 +320,10 @@ function _isEffectiveConfigurationValue(configuration, property, graph, assetNod
318
320
  * @param graph source graph
319
321
  * @param declarations canonical declarations
320
322
  * @param assetNodeCount number of glTF nodes in the containing asset
323
+ * @param preserveCompatibilityConfiguration allow independent optional configuration properties and legacy fractional for-loop initial indices
321
324
  * @returns normalized executable graph
322
325
  */
323
- export function CreateEffectiveKHRInteractivityGraph(graph, declarations, assetNodeCount) {
326
+ export function CreateEffectiveKHRInteractivityGraph(graph, declarations, assetNodeCount, preserveCompatibilityConfiguration = false) {
324
327
  const effective = CloneKHRInteractivityGraph(graph);
325
328
  for (let nodeIndex = 0; nodeIndex < (effective.nodes?.length ?? 0); nodeIndex++) {
326
329
  const node = effective.nodes[nodeIndex];
@@ -335,11 +338,20 @@ export function CreateEffectiveKHRInteractivityGraph(graph, declarations, assetN
335
338
  const groupedValidity = new Map();
336
339
  for (const [key, property] of Object.entries(mapping.configuration)) {
337
340
  if (property.configurationGroup) {
338
- const valid = _isEffectiveConfigurationValue(node.configuration?.[key], property, effective, assetNodeCount);
341
+ const valid = (preserveCompatibilityConfiguration && node.configuration?.[key] === undefined) ||
342
+ _isEffectiveConfigurationValue(node.configuration?.[key], property, effective, assetNodeCount);
339
343
  groupedValidity.set(property.configurationGroup, (groupedValidity.get(property.configurationGroup) ?? true) && valid);
340
344
  }
341
345
  }
342
346
  for (const [key, property] of Object.entries(mapping.configuration)) {
347
+ if (preserveCompatibilityConfiguration &&
348
+ declaration.operation === "flow/for" &&
349
+ key === "initialIndex" &&
350
+ node.configuration?.[key]?.value?.length === 1 &&
351
+ typeof node.configuration[key].value[0] === "number" &&
352
+ Number.isFinite(node.configuration[key].value[0])) {
353
+ continue;
354
+ }
343
355
  const valid = (!property.configurationGroup || groupedValidity.get(property.configurationGroup) === true) &&
344
356
  _isEffectiveConfigurationValue(node.configuration?.[key], property, effective, assetNodeCount);
345
357
  if (!valid && property.defaultValue !== undefined) {
@@ -370,6 +382,9 @@ function _getPointerTemplateSockets(pointer) {
370
382
  return sockets;
371
383
  }
372
384
  function _resolveValueTypeIndex(value, graph, declarations, visited = new Set()) {
385
+ if (!_isRecord(value)) {
386
+ return undefined;
387
+ }
373
388
  if ("node" in value) {
374
389
  return _resolveOutputTypeIndex(value.node, value.socket ?? "value", graph, declarations, visited);
375
390
  }
@@ -480,6 +495,11 @@ function _getFixedOutputSignature(operation, socket) {
480
495
  }
481
496
  function _validateNode(node, nodeIndex, graph, declarations, diagnostics, graphPath, assetNodeCount) {
482
497
  const path = `${graphPath}/nodes/${nodeIndex}`;
498
+ for (const [key, value] of Object.entries(node.values ?? {})) {
499
+ if (!_isRecord(value)) {
500
+ _addError(diagnostics, `${path}/values/${key}`, `Input value socket "${key}" must be an object.`);
501
+ }
502
+ }
483
503
  if (!_isValidIndex(node.declaration, declarations.length)) {
484
504
  _addError(diagnostics, `${path}/declaration`, `Declaration index ${String(node.declaration)} is out of range.`);
485
505
  return;
@@ -600,6 +620,9 @@ function _validateNode(node, nodeIndex, graph, declarations, diagnostics, graphP
600
620
  }
601
621
  }
602
622
  for (const [key, property] of Object.entries(mapping.inputs?.values ?? {})) {
623
+ if (property.compatibilityOnly) {
624
+ continue;
625
+ }
603
626
  if (!key.startsWith("[") && !node.values?.[key]) {
604
627
  _addError(diagnostics, `${path}/values/${key}`, `Required input value socket "${key}" is missing.`);
605
628
  }
@@ -618,6 +641,13 @@ function _validateNode(node, nodeIndex, graph, declarations, diagnostics, graphP
618
641
  }
619
642
  const expectedSignature = property.gltfType === "number" ? "float" : property.gltfType === "boolean" ? "bool" : property.gltfType;
620
643
  const source = node.values?.[key];
644
+ if (source && property.allowedSignatures) {
645
+ const typeIndex = _resolveValueTypeIndex(source, graph, declarations);
646
+ const signature = typeIndex !== undefined ? graph.types?.[typeIndex]?.signature : undefined;
647
+ if (signature !== undefined && !property.allowedSignatures.includes(signature)) {
648
+ _addError(diagnostics, `${path}/values/${key}/type`, `Input value socket "${key}" must have one of the types ${property.allowedSignatures.join(", ")}.`);
649
+ }
650
+ }
621
651
  if (source && expectedSignature && expectedSignature in gltfTypeToBabylonType) {
622
652
  const typeIndex = _resolveValueTypeIndex(source, graph, declarations);
623
653
  if (typeIndex !== undefined && graph.types?.[typeIndex]?.signature !== expectedSignature) {
@@ -625,11 +655,27 @@ function _validateNode(node, nodeIndex, graph, declarations, diagnostics, graphP
625
655
  }
626
656
  }
627
657
  }
658
+ if (["variable/interpolate", "pointer/interpolate", "pointer/set"].includes(declarationModel.operation)) {
659
+ const configuredIndex = node.configuration?.[declarationModel.operation === "variable/interpolate" ? "variable" : "type"]?.value?.[0];
660
+ const targetType = typeof configuredIndex === "number" ? (declarationModel.operation === "variable/interpolate" ? graph.variables?.[configuredIndex]?.type : configuredIndex) : undefined;
661
+ const signature = targetType !== undefined ? graph.types?.[targetType]?.signature : undefined;
662
+ if (declarationModel.operation === "variable/interpolate") {
663
+ if (signature === "int" || signature === "bool") {
664
+ _addError(diagnostics, `${path}/configuration/variable`, `Variables of type "${signature}" cannot be interpolated.`);
665
+ }
666
+ if (node.configuration?.useSlerp?.value?.[0] === true && signature !== "float4") {
667
+ _addError(diagnostics, `${path}/configuration/useSlerp`, "Spherical interpolation requires a float4 variable.");
668
+ }
669
+ }
670
+ if (targetType !== undefined && node.values?.value && _resolveValueTypeIndex(node.values.value, graph, declarations) !== targetType) {
671
+ _addError(diagnostics, `${path}/values/value/type`, "Input value type must match the configured variable or pointer type.");
672
+ }
673
+ }
628
674
  if (mapping.validation) {
629
675
  try {
630
676
  const validationNode = _cloneJson(node);
631
677
  for (const value of Object.values(validationNode.values ?? {})) {
632
- if (value.type === undefined) {
678
+ if (_isRecord(value) && value.type === undefined) {
633
679
  value.type = _resolveValueTypeIndex(value, graph, declarations);
634
680
  }
635
681
  }
@@ -644,7 +690,6 @@ function _validateNode(node, nodeIndex, graph, declarations, diagnostics, graphP
644
690
  }
645
691
  for (const [key, value] of Object.entries(node.values ?? {})) {
646
692
  if (!_isRecord(value)) {
647
- _addError(diagnostics, `${path}/values/${key}`, `Input value socket "${key}" must be an object.`);
648
693
  continue;
649
694
  }
650
695
  if (declarationModel.support === "unsupported-extension" && !declarationModel.source.inputValueSockets?.[key]) {
@@ -664,6 +709,10 @@ function _validateNode(node, nodeIndex, graph, declarations, diagnostics, graphP
664
709
  if (value.type !== undefined) {
665
710
  _validateTypeIndex(value.type, graph, diagnostics, `${path}/values/${key}/type`);
666
711
  }
712
+ if (value.socket !== undefined && typeof value.socket !== "string") {
713
+ _addError(diagnostics, `${path}/values/${key}/socket`, "Socket id must be a string.");
714
+ continue;
715
+ }
667
716
  const sourceNode = graph.nodes[value.node];
668
717
  if (_isValidIndex(sourceNode.declaration, declarations.length)) {
669
718
  const sourceDeclaration = declarations[sourceNode.declaration];
@@ -715,6 +764,9 @@ function _validateNode(node, nodeIndex, graph, declarations, diagnostics, graphP
715
764
  _addError(diagnostics, `${path}/flows/${key}/node`, `Node index ${String(flow.node)} is out of range.`);
716
765
  continue;
717
766
  }
767
+ if (flow.socket !== undefined && typeof flow.socket !== "string") {
768
+ _addError(diagnostics, `${path}/flows/${key}/socket`, "Socket id must be a string.");
769
+ }
718
770
  if (flow.node <= nodeIndex) {
719
771
  _addError(diagnostics, `${path}/flows/${key}/node`, "Flow connections must reference a later node.");
720
772
  }
@@ -776,6 +828,12 @@ export function CreateKHRInteractivityGraphModel(graph, index = 0, supportedExte
776
828
  }
777
829
  for (let declarationIndex = 0; declarationIndex < (graph.declarations?.length ?? 0); declarationIndex++) {
778
830
  const declaration = graph.declarations[declarationIndex];
831
+ if (typeof declaration.op !== "string") {
832
+ _addError(diagnostics, `${path}/declarations/${declarationIndex}/op`, '"op" must be a string.');
833
+ }
834
+ if (declaration.extension !== undefined && typeof declaration.extension !== "string") {
835
+ _addError(diagnostics, `${path}/declarations/${declarationIndex}/extension`, '"extension" must be a string when present.');
836
+ }
779
837
  for (const key of ["inputValueSockets", "outputValueSockets"]) {
780
838
  if (declaration[key] !== undefined && !_isRecord(declaration[key])) {
781
839
  _addError(diagnostics, `${path}/declarations/${declarationIndex}/${key}`, `"${key}" must be an object when present.`);
@@ -852,10 +910,18 @@ export function CreateKHRInteractivityGraphModel(graph, index = 0, supportedExte
852
910
  }
853
911
  }
854
912
  for (let variableIndex = 0; variableIndex < (graph.variables?.length ?? 0); variableIndex++) {
913
+ if (graph.variables[variableIndex].name !== undefined && typeof graph.variables[variableIndex].name !== "string") {
914
+ _addError(diagnostics, `${path}/variables/${variableIndex}/name`, '"name" must be a string when present.');
915
+ }
855
916
  _validateValue(graph.variables[variableIndex], graph, diagnostics, `${path}/variables/${variableIndex}`);
856
917
  }
857
918
  for (let eventIndex = 0; eventIndex < (graph.events?.length ?? 0); eventIndex++) {
858
919
  const eventId = graph.events[eventIndex].id;
920
+ for (const key of ["id", "name"]) {
921
+ if (graph.events[eventIndex][key] !== undefined && typeof graph.events[eventIndex][key] !== "string") {
922
+ _addError(diagnostics, `${path}/events/${eventIndex}/${key}`, `"${key}" must be a string when present.`);
923
+ }
924
+ }
859
925
  if (eventId !== undefined && graph.events.slice(0, eventIndex).some((event) => event.id === eventId)) {
860
926
  _addError(diagnostics, `${path}/events/${eventIndex}/id`, `Duplicate event id "${eventId}".`);
861
927
  }
@@ -892,8 +958,11 @@ export function CreateKHRInteractivityGraphModel(graph, index = 0, supportedExte
892
958
  * @returns the canonical document
893
959
  */
894
960
  export function CreateKHRInteractivityDocument(extension, supportedExtensions, assetNodeCount) {
895
- const source = _cloneJson(extension);
896
961
  const diagnostics = [];
962
+ const source = _isRecord(extension) ? _cloneJson(extension) : { graphs: [] };
963
+ if (!_isRecord(extension)) {
964
+ _addError(diagnostics, "/extensions/KHR_interactivity", "Extension must be an object.");
965
+ }
897
966
  if (!Array.isArray(source.graphs)) {
898
967
  _addError(diagnostics, "/extensions/KHR_interactivity/graphs", '"graphs" must be an array.');
899
968
  source.graphs = [];