@babylonjs/loaders 9.31.0 → 9.31.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 (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
@@ -4,13 +4,14 @@ import { type Scene } from "@babylonjs/core/scene.js";
4
4
  import { type Nullable } from "@babylonjs/core/types.js";
5
5
  import { Camera } from "@babylonjs/core/Cameras/camera.js";
6
6
  import { BoundingInfo } from "@babylonjs/core/Culling/boundingInfo.js";
7
+ import { type SOGRootData } from "./sog.pure.js";
7
8
  /**
8
9
  * A single LOD variant of a tree node: a contiguous splat range inside one streamed SOG file.
9
10
  */
10
11
  interface ISOGLODEntry {
11
- /** Index into {@link ISOGLODMetadata.filenames}. */
12
+ /** Initially an index into {@link ISOGLODMetadata.filenames}; remapped to a residency page ID when range residency is enabled. */
12
13
  file: number;
13
- /** First splat index inside that file. */
14
+ /** First splat index inside the source file, or relative to the residency page after remapping. */
14
15
  offset: number;
15
16
  /** Number of splats. */
16
17
  count: number;
@@ -47,11 +48,11 @@ interface ISOGLODNode {
47
48
  inFrustum?: boolean;
48
49
  /** Cached local-space bounding info used for the per-node frustum test (created once per leaf). */
49
50
  cullBounds?: BoundingInfo;
50
- /** File index this node currently has an in-flight/queued decode request for (its not-yet-decoded target),
51
+ /** Allocation ID (source file or residency page) this node has an in-flight/queued decode request for,
51
52
  * or undefined when the node's target is already decoded. Drives pending-download reference counting. */
52
53
  pendingFile?: number;
53
- /** File index this node's current {@link activeLod} renders from, or undefined before any LOD is active.
54
- * Drives the resident reference count that keeps a file in the work buffer. */
54
+ /** Allocation ID (source file or residency page) this node's current {@link activeLod} renders from,
55
+ * or undefined before any LOD is active. Drives the work-buffer resident reference count. */
55
56
  activeFile?: number;
56
57
  }
57
58
  /**
@@ -60,7 +61,7 @@ interface ISOGLODNode {
60
61
  export interface ISOGLODMetadata {
61
62
  /** Number of LOD levels (0 = highest detail). */
62
63
  lodLevels: number;
63
- /** SOG `meta.json` paths, relative to the metadata file, indexed by `ISOGLODEntry.file`. */
64
+ /** SOG `meta.json` paths, relative to the metadata file, indexed by the original source file ID of each LOD entry. */
64
65
  filenames: string[];
65
66
  /** Optional always-on environment `.sog` bundle, relative to the metadata file. */
66
67
  environment?: string;
@@ -83,6 +84,46 @@ export type GaussianSplattingStreamLod0SplatCount = Readonly<{
83
84
  }> | Readonly<{
84
85
  status: "unavailable";
85
86
  }>;
87
+ /**
88
+ * A contiguous splat interval inside one streamed source file.
89
+ * @experimental
90
+ */
91
+ export interface IGaussianSplattingStreamSourceRange {
92
+ /** Index of the source file in the LOD metadata `filenames`. */
93
+ file: number;
94
+ /** First splat of the interval inside the source file. */
95
+ offset: number;
96
+ /** Number of splats in the interval. */
97
+ count: number;
98
+ }
99
+ /**
100
+ * A separately packed copy of exactly one residency page interval, see {@link IGaussianSplattingStreamOptions.rangePack}.
101
+ * @experimental
102
+ */
103
+ export interface IGaussianSplattingStreamRangePack {
104
+ /** SOG metadata of the split pack; its splat count must equal the page interval count. */
105
+ sogData: SOGRootData;
106
+ /** URL prefix prepended to every image file name listed in {@link sogData}. */
107
+ subRootUrl: string;
108
+ }
109
+ /**
110
+ * Counters describing range residency activity. They are not memory measurements.
111
+ * @experimental
112
+ */
113
+ export interface IGaussianSplattingStreamRangeResidencyStats {
114
+ /** Whether range residency is enabled for the stream. */
115
+ enabled: boolean;
116
+ /** Number of residency pages created. */
117
+ pages: number;
118
+ /** Number of source packs downloaded and cached for source pages. */
119
+ sourcePackLoads: number;
120
+ /** Number of times a cached source pack served another page of the same source. */
121
+ sourcePackReuses: number;
122
+ /** Number of split packs loaded successfully. */
123
+ splitPackLoads: number;
124
+ /** Splat count of the currently cached source pack, or 0 when none is cached. */
125
+ cachedSourceSplats: number;
126
+ }
86
127
  /**
87
128
  * Options for {@link GaussianSplattingStream}.
88
129
  */
@@ -185,6 +226,24 @@ export interface IGaussianSplattingStreamOptions {
185
226
  * the stream decodes into. Defaults to `false`.
186
227
  */
187
228
  needsRotationScale?: boolean;
229
+ /**
230
+ * When true, finer (non-coarse) source files are split into residency pages: each LOD leaf's interval becomes its
231
+ * own work-buffer allocation, sized to the interval rather than the whole source file. Overlapping intervals share
232
+ * a page; adjacent ones do not. Files of the pinned coarse layer stay whole. Pages of the same source share one
233
+ * download of the source textures, cached until no page needs it, so source pages load one at a time.
234
+ * Defaults to `false` (whole-file residency, unchanged behavior).
235
+ * Playground example: https://playground.babylonjs.com/#7AZH52#1
236
+ * @experimental
237
+ */
238
+ rangeResidency?: boolean;
239
+ /**
240
+ * Optional resolver returning a separately packed copy of exactly one residency page interval, so the page downloads
241
+ * and decodes only its own textures instead of its whole source pack. Called at most once per page, when the page
242
+ * is created. Return `null` to use the source pack. A result whose splat count differs from `source.count`, or a
243
+ * resolver that throws, is ignored with a warning. Requires {@link rangeResidency}.
244
+ * @experimental
245
+ */
246
+ rangePack?: (source: Readonly<IGaussianSplattingStreamSourceRange>, sourceData: SOGRootData) => Nullable<IGaussianSplattingStreamRangePack>;
188
247
  }
189
248
  /**
190
249
  * Streams a PlayCanvas-style SOG LOD scene (`lod-meta.json`) into a single Gaussian Splatting mesh.
@@ -234,6 +293,14 @@ export declare class GaussianSplattingStream extends GaussianSplattingMesh imple
234
293
  private _residency;
235
294
  private readonly _fileCounts;
236
295
  private readonly _fileMeta;
296
+ private readonly _residencyPages;
297
+ private readonly _splitPacks;
298
+ private _nextPageId;
299
+ private _rangeSourcePack;
300
+ private _activeRangeSource;
301
+ private _rangeSourcePackLoads;
302
+ private _rangeSourcePackReuses;
303
+ private _rangeSplitPackLoads;
237
304
  private readonly _baseFileIds;
238
305
  private readonly _decodedFiles;
239
306
  private readonly _loadingFiles;
@@ -396,6 +463,35 @@ export declare class GaussianSplattingStream extends GaussianSplattingMesh imple
396
463
  * @experimental
397
464
  */
398
465
  get lod0SplatCount(): GaussianSplattingStreamLod0SplatCount;
466
+ /**
467
+ * The source interval represented by a residency page allocation.
468
+ * @param fileId allocation ID as used for LOD entries (a source file index or a page ID)
469
+ * @returns the page's source interval, or null when the ID is a whole source file or range residency is off
470
+ * @experimental
471
+ */
472
+ getSourceRange(fileId: number): Nullable<Readonly<IGaussianSplattingStreamSourceRange>>;
473
+ /**
474
+ * Whether a residency page loads from its own split pack, see {@link IGaussianSplattingStreamOptions.rangePack}.
475
+ * @param fileId allocation ID
476
+ * @returns true when the page downloads only its own textures
477
+ * @experimental
478
+ */
479
+ isSplitPage(fileId: number): boolean;
480
+ /**
481
+ * Cancels in-flight residency page loads, e.g. pages that lost priority. Only pages currently loading are affected,
482
+ * queued pages are untouched. A split page's own downloads are aborted. A shared source download is aborted only
483
+ * when no other non-cancelled, non-split loading page of that source and no entry of `keepSources` still needs it.
484
+ * Cancelled pages that are still referenced by a node are re-queued at the end of the decode queue.
485
+ * @param files allocation IDs to cancel; whole-file IDs and IDs that are not loading are ignored
486
+ * @param keepSources source file indices whose download must be kept (e.g. needed by queued pages), defaults to none
487
+ * @experimental
488
+ */
489
+ cancelRangeLoads(files: readonly number[], keepSources?: readonly number[]): void;
490
+ /**
491
+ * Range residency counters for diagnostics. A new object is created on each call, so avoid reading it every frame.
492
+ * @experimental
493
+ */
494
+ get rangeResidencyStats(): Readonly<IGaussianSplattingStreamRangeResidencyStats>;
399
495
  /**
400
496
  * Resolves the raw {@link splatBudget} option to a concrete cap: `undefined` ⇒ 0 (disabled), `"auto"` ⇒ a
401
497
  * device-tiered default, a positive number ⇒ itself (floored).
@@ -570,8 +666,9 @@ export declare class GaussianSplattingStream extends GaussianSplattingMesh imple
570
666
  */
571
667
  private _bytesPerResidentSplat;
572
668
  /**
573
- * Collects the unique set of source file indices referenced by any LOD of any leaf, sorted ascending.
574
- * @returns sorted unique file indices
669
+ * Collects sorted allocation IDs referenced by leaf LODs: source file IDs before range remapping, and
670
+ * source file or residency page IDs afterwards.
671
+ * @returns sorted unique allocation IDs
575
672
  */
576
673
  private _collectAllFileIds;
577
674
  /**
@@ -598,6 +695,46 @@ export declare class GaussianSplattingStream extends GaussianSplattingMesh imple
598
695
  * @returns the environment splat count (0 when there is no environment)
599
696
  */
600
697
  private _gatherCountsAsync;
698
+ /**
699
+ * Splits the gathered source files into residency pages sized to the LOD leaf intervals they serve, and rewrites
700
+ * those leaf entries to point at the pages. Pinned coarse files, files without metadata and files with invalid
701
+ * intervals stay whole.
702
+ * @param fileIds source file indices whose metadata was just gathered
703
+ */
704
+ private _initializeResidencyPages;
705
+ /**
706
+ * Asks the {@link IGaussianSplattingStreamOptions.rangePack} resolver for the split pack of one page.
707
+ * @param pageId page allocation ID
708
+ * @param source the page's source interval
709
+ * @param sourceData SOG metadata of the page's source file
710
+ * @returns the split pack, or null when the page decodes from its source pack
711
+ */
712
+ private _resolveSplitPack;
713
+ /**
714
+ * Downloads every image of a pack through the download manager, then creates its textures. The cancellable
715
+ * network phase completes before any GPU texture exists, so a cancelled or failed download cannot leave textures
716
+ * allocated by sibling image promises behind.
717
+ * @param meta SOG metadata and image URL prefix of the pack
718
+ * @param groupId download group, so the downloads can be cancelled together
719
+ * @returns the texture pack, or null when the stream was disposed meanwhile
720
+ */
721
+ private _loadPrefetchedPackAsync;
722
+ /**
723
+ * Returns the cached source pack of a file, loading it (and dropping any other cached source pack) when needed.
724
+ * @param file source file index
725
+ * @param meta SOG metadata and image URL prefix of the source file
726
+ * @returns the shared source pack, which the caller must not dispose
727
+ */
728
+ private _getRangeSourcePackAsync;
729
+ private _disposeRangeSourcePack;
730
+ /**
731
+ * Copies the parts of the LOD metadata a stream mutates (tree nodes and LOD entries), so a range-residency stream
732
+ * can rewrite entries without affecting the caller's object or another stream built from it.
733
+ * @param metadata caller metadata
734
+ * @returns metadata sharing every field except a freshly copied tree
735
+ */
736
+ private static _CloneLodMetadata;
737
+ private static _CloneLodNode;
601
738
  /**
602
739
  * Queues a file for on-demand decode if it isn't already decoded, in flight, or already queued.
603
740
  * @param fileId file index to decode
@@ -649,6 +786,7 @@ export declare class GaussianSplattingStream extends GaussianSplattingMesh imple
649
786
  * @param pack the parsed SOG pack (its `positions` is populated only on the CPU path)
650
787
  * @param base first splat index of the range in the work buffer
651
788
  * @param count number of splats in the range
789
+ * @param sourceOffset first splat of the range inside the pack, defaults to 0
652
790
  * @returns whether positions were applied
653
791
  */
654
792
  private _applyDecodedPositionsAsync;
@@ -657,12 +795,13 @@ export declare class GaussianSplattingStream extends GaussianSplattingMesh imple
657
795
  */
658
796
  private _decodeEnvironmentAsync;
659
797
  /**
660
- * Loads one LOD source file as GPU textures, decodes it into its fixed work-buffer block, records its
661
- * CPU centers for sorting, frees the source textures, then promotes any nodes that were waiting for it.
662
- * Concurrent or repeat requests for the same file are ignored. If the file is cancelled mid-flight
798
+ * Loads one LOD source file or residency page, decodes it into its work-buffer block, records CPU
799
+ * centers for sorting, then promotes waiting nodes. Whole-file and split-page textures are freed
800
+ * after decoding; unsplit pages can reuse a cached source pack until no page needs it.
801
+ * Concurrent or repeat requests for the same allocation are ignored. If it is cancelled mid-flight
663
802
  * (because every node that wanted it retargeted), the decode bails cooperatively at the next checkpoint.
664
- * @param fileId file index to decode
665
- * @returns whether the file was decoded and published successfully
803
+ * @param fileId source file or residency page allocation ID to decode
804
+ * @returns whether the allocation was decoded and published successfully
666
805
  */
667
806
  private _decodeFileAsync;
668
807
  /**
@@ -784,14 +923,14 @@ export declare class GaussianSplattingStream extends GaussianSplattingMesh imple
784
923
  private _acquireFileRef;
785
924
  /**
786
925
  * Records that a node needs a not-yet-decoded file, bumping its reference count and queueing the decode.
787
- * @param fileId file index the node now targets
926
+ * @param fileId source file or residency page allocation ID the node now targets
788
927
  */
789
928
  private _acquirePendingFile;
790
929
  /**
791
930
  * Releases a node's reference to a file. When the last reference is dropped: a decoded file is scheduled
792
931
  * for eviction (when streaming under a budget), and a still-downloading file has its queued decode dropped
793
932
  * and any in-flight download cancelled.
794
- * @param fileId file index the node no longer references
933
+ * @param fileId source file or residency page allocation ID the node no longer references
795
934
  */
796
935
  private _releaseFileRef;
797
936
  /**