babylonjs-loaders 9.25.0 → 9.26.0

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.
@@ -7,6 +7,7 @@ export * from "babylonjs-loaders/glTF/pure";
7
7
  export * from "babylonjs-loaders/OBJ/pure";
8
8
  export * from "babylonjs-loaders/STL/pure";
9
9
  export * from "babylonjs-loaders/SPLAT/pure";
10
+ export * from "babylonjs-loaders/USD/pure";
10
11
  export * from "babylonjs-loaders/dynamic";
11
12
 
12
13
  }
@@ -17,6 +18,7 @@ export * from "babylonjs-loaders/glTF/index";
17
18
  export * from "babylonjs-loaders/OBJ/index";
18
19
  export * from "babylonjs-loaders/STL/index";
19
20
  export * from "babylonjs-loaders/SPLAT/index";
21
+ export * from "babylonjs-loaders/USD/index";
20
22
  export * from "babylonjs-loaders/dynamic";
21
23
 
22
24
  }
@@ -8731,6 +8733,436 @@ declare module "babylonjs-loaders/glTF/1.0/glTFBinaryExtension" {
8731
8733
  export * from "babylonjs-loaders/glTF/1.0/glTFBinaryExtension.pure";
8732
8734
  import "babylonjs-loaders/glTF/1.0/glTFLoader";
8733
8735
 
8736
+ }
8737
+ declare module "babylonjs-loaders/USD/usdWorkerMessages" {
8738
+ import { USDLoadProgress } from "babylonjs-loaders/USD/usdLoadingOptions";
8739
+ export interface WorkerAsset {
8740
+ bytes: Uint8Array;
8741
+ fileName: string;
8742
+ files?: Record<string, Uint8Array>;
8743
+ resolveByFileName: boolean;
8744
+ glueUrl?: string;
8745
+ wasmUrl?: string;
8746
+ dataUrl?: string;
8747
+ }
8748
+ export interface ExtractRequest {
8749
+ type: "extract";
8750
+ requestId: number;
8751
+ asset: WorkerAsset;
8752
+ }
8753
+ export interface WorkerTimings {
8754
+ totalMs: number;
8755
+ stageOpenMs: number;
8756
+ stageReadMs: number;
8757
+ preparationMs: number;
8758
+ packingMs: number;
8759
+ heapCopyMs: number;
8760
+ }
8761
+ export interface WorkerStatistics {
8762
+ nodes: number;
8763
+ meshes: number;
8764
+ analyticPrimitives: number;
8765
+ instances: number;
8766
+ materials: number;
8767
+ vertices: number;
8768
+ triangles: number;
8769
+ commandBytes: number;
8770
+ dataBytes: number;
8771
+ }
8772
+ export type WorkerResponse = {
8773
+ type: "progress";
8774
+ requestId: number;
8775
+ progress: USDLoadProgress;
8776
+ } | {
8777
+ type: "log";
8778
+ requestId: number;
8779
+ level: number;
8780
+ message: string;
8781
+ } | {
8782
+ type: "result";
8783
+ requestId: number;
8784
+ commands: ArrayBuffer;
8785
+ data: ArrayBuffer;
8786
+ timings: WorkerTimings;
8787
+ statistics: WorkerStatistics;
8788
+ missingAssets: string[];
8789
+ } | {
8790
+ type: "error";
8791
+ requestId: number;
8792
+ message: string;
8793
+ stack?: string;
8794
+ };
8795
+
8796
+ }
8797
+ declare module "babylonjs-loaders/USD/usdSceneMaterializer" {
8798
+ import { AbstractAssetContainer } from "babylonjs/assetContainer";
8799
+ import { Scene } from "babylonjs/scene.pure";
8800
+ export interface MaterializationResult {
8801
+ container: AbstractAssetContainer & {
8802
+ dispose(): void;
8803
+ };
8804
+ materializeMs: number;
8805
+ }
8806
+ export function materializeCommandBuffers(scene: Scene, commandBuffer: ArrayBuffer, dataBuffer: ArrayBuffer, addToScene: boolean, signal?: AbortSignal): Promise<MaterializationResult>;
8807
+
8808
+ }
8809
+ declare module "babylonjs-loaders/USD/usdLoadingOptions" {
8810
+ /**
8811
+ * Binary input accepted for supporting USD layers and assets.
8812
+ */
8813
+ export type USDBinaryInput = ArrayBuffer | ArrayBufferView;
8814
+ /**
8815
+ * Virtual files supplied alongside the root USD layer, keyed by their path relative to the
8816
+ * root layer.
8817
+ */
8818
+ export type USDVirtualFiles = Readonly<Record<string, USDBinaryInput>>;
8819
+ /**
8820
+ * Progress phases reported by the USD worker and Babylon materializer.
8821
+ */
8822
+ export interface USDLoadProgress {
8823
+ /**
8824
+ * Current importer phase.
8825
+ */
8826
+ phase: "initializing" | "staging" | "extracting" | "materializing";
8827
+ /**
8828
+ * Human-readable phase description.
8829
+ */
8830
+ message: string;
8831
+ }
8832
+ /**
8833
+ * Options for the OpenUSD scene loader.
8834
+ */
8835
+ export interface USDFileLoaderOptions {
8836
+ /**
8837
+ * Virtual path used to stage the root layer. Set this when supporting files need
8838
+ * to resolve relative to a directory hierarchy.
8839
+ */
8840
+ rootFileName?: string;
8841
+ /**
8842
+ * Supporting layers, payloads, and textures keyed by virtual path in the same
8843
+ * virtual file system as `rootFileName`.
8844
+ */
8845
+ files?: USDVirtualFiles;
8846
+ /**
8847
+ * Enables conservative file-name fallback for unresolved absolute references.
8848
+ * Defaults to true.
8849
+ */
8850
+ resolveByFileName?: boolean;
8851
+ /**
8852
+ * URL of the module worker. Defaults to the protocol-versioned worker hosted on the Babylon.js CDN.
8853
+ */
8854
+ workerUrl?: string | URL;
8855
+ /**
8856
+ * URL of the generated Emscripten JavaScript module.
8857
+ */
8858
+ glueUrl?: string;
8859
+ /**
8860
+ * URL of the OpenUSD WebAssembly binary.
8861
+ */
8862
+ wasmUrl?: string;
8863
+ /**
8864
+ * URL of the OpenUSD preloaded resource bundle.
8865
+ */
8866
+ dataUrl?: string;
8867
+ /**
8868
+ * Called when the importer moves to a new processing phase.
8869
+ */
8870
+ onProgress?: (progress: USDLoadProgress) => void;
8871
+ /**
8872
+ * Called for OpenUSD diagnostic messages.
8873
+ */
8874
+ onLog?: (level: "info" | "warning" | "error", message: string) => void;
8875
+ /**
8876
+ * Called after extraction and Babylon.js object creation complete.
8877
+ */
8878
+ onComplete?: (diagnostics: USDImportDiagnostics) => void;
8879
+ }
8880
+ /**
8881
+ * Timing data measured by the OpenUSD worker and Babylon materializer.
8882
+ */
8883
+ export interface USDImportTimings {
8884
+ /** Total extraction time, including the final Wasm heap copy. */
8885
+ totalMs: number;
8886
+ /** Time spent opening and composing the USD stage. */
8887
+ stageOpenMs: number;
8888
+ /** Time spent traversing the composed stage. */
8889
+ stageReadMs: number;
8890
+ /** Time spent preparing renderable vertex streams. */
8891
+ preparationMs: number;
8892
+ /** Time spent packing the command and raw-data buffers. */
8893
+ packingMs: number;
8894
+ /** Time spent copying command and data buffers from the Wasm heap. */
8895
+ heapCopyMs: number;
8896
+ /** Time spent creating Babylon.js objects. */
8897
+ materializeMs: number;
8898
+ }
8899
+ /**
8900
+ * Statistics reported for an imported USD stage.
8901
+ */
8902
+ export interface USDImportStatistics {
8903
+ /** Number of transform nodes extracted from the composed stage. */
8904
+ nodes: number;
8905
+ /** Number of polygonal `UsdGeomMesh` sources. */
8906
+ meshes: number;
8907
+ /** Number of analytic cube, sphere, cylinder, and cone sources. */
8908
+ analyticPrimitives: number;
8909
+ /** Number of native Babylon instances created from shared USD geometry. */
8910
+ instances: number;
8911
+ /** Number of authored USD materials translated. */
8912
+ materials: number;
8913
+ /** Number of unique vertices in polygonal source meshes. */
8914
+ vertices: number;
8915
+ /** Number of unique triangles in polygonal source meshes. */
8916
+ triangles: number;
8917
+ /** Size of the command buffer in bytes. */
8918
+ commandBytes: number;
8919
+ /** Size of the raw-data buffer in bytes. */
8920
+ dataBytes: number;
8921
+ }
8922
+ /**
8923
+ * Diagnostics reported after a USD import completes.
8924
+ */
8925
+ export interface USDImportDiagnostics {
8926
+ /** Timing data for extraction and Babylon.js object creation. */
8927
+ timings: USDImportTimings;
8928
+ /** Counts and buffer sizes reported by the OpenUSD extractor. */
8929
+ statistics: USDImportStatistics;
8930
+ /** Asset references OpenUSD could not resolve from the supplied virtual files. */
8931
+ missingAssets: readonly string[];
8932
+ }
8933
+
8934
+ }
8935
+ declare module "babylonjs-loaders/USD/usdFileLoader.types" {
8936
+ export {};
8937
+ import { USDFileLoaderMetadata } from "babylonjs-loaders/USD/usdFileLoader.metadata";
8938
+ import { USDFileLoaderOptions } from "babylonjs-loaders/USD/usdLoadingOptions";
8939
+ module "babylonjs/Loading/sceneLoader" {
8940
+ interface SceneLoaderPluginOptions {
8941
+ /**
8942
+ * Defines options for the USD loader.
8943
+ */
8944
+ [USDFileLoaderMetadata.name]: Partial<USDFileLoaderOptions>;
8945
+ }
8946
+ }
8947
+
8948
+ }
8949
+ declare module "babylonjs-loaders/USD/usdFileLoader.pure" {
8950
+ /** This file must only contain pure code and pure imports */
8951
+ import { AssetContainer } from "babylonjs/assetContainer";
8952
+ import { ISceneLoaderAsyncResult, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory, ISceneLoaderProgressEvent, SceneLoaderPluginOptions } from "babylonjs/Loading/sceneLoader";
8953
+ import { Scene } from "babylonjs/scene.pure";
8954
+ import { USDFileLoaderOptions } from "babylonjs-loaders/USD/usdLoadingOptions";
8955
+ /**
8956
+ * OpenUSD scene loader backed by a WebAssembly command-buffer extractor.
8957
+ */
8958
+ export class USDFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
8959
+ /**
8960
+ * Default URLs for the prebuilt OpenUSD importer assets.
8961
+ */
8962
+ static DefaultConfiguration: {
8963
+ glueUrl: string;
8964
+ wasmUrl: string;
8965
+ dataUrl: string;
8966
+ workerUrl: string;
8967
+ };
8968
+ /**
8969
+ * Defines the name of the plugin.
8970
+ */
8971
+ readonly name: "usd";
8972
+ /**
8973
+ * Defines the extensions the plugin can load.
8974
+ */
8975
+ readonly extensions: {
8976
+ readonly ".usd": {
8977
+ readonly isBinary: true;
8978
+ };
8979
+ readonly ".usda": {
8980
+ readonly isBinary: true;
8981
+ };
8982
+ readonly ".usdc": {
8983
+ readonly isBinary: true;
8984
+ };
8985
+ readonly ".usdz": {
8986
+ readonly isBinary: true;
8987
+ };
8988
+ };
8989
+ private readonly _options;
8990
+ private _worker;
8991
+ private _workerUrl;
8992
+ private _workerBlobUrl;
8993
+ private _nextRequestId;
8994
+ private readonly _pending;
8995
+ private readonly _activeLoads;
8996
+ /**
8997
+ * Creates a USD loader.
8998
+ * @param options Options controlling worker assets, supporting files, and diagnostics.
8999
+ */
9000
+ constructor(options?: Partial<USDFileLoaderOptions>);
9001
+ /**
9002
+ * Creates a configured plugin instance for a SceneLoader operation.
9003
+ * @param options SceneLoader plugin options.
9004
+ * @returns The configured USD loader.
9005
+ */
9006
+ createPlugin(options: SceneLoaderPluginOptions): ISceneLoaderPluginAsync;
9007
+ /**
9008
+ * Imports all objects from a USD stage into a scene.
9009
+ * @param _meshesNames Mesh name filtering is not currently supported.
9010
+ * @param scene The scene receiving the imported objects.
9011
+ * @param data The USD, USDA, USDC, or USDZ bytes.
9012
+ * @param rootUrl The source root URL.
9013
+ * @param onProgress SceneLoader progress callback.
9014
+ * @param fileName Name of the root USD layer.
9015
+ * @returns The imported Babylon.js objects.
9016
+ */
9017
+ importMeshAsync(_meshesNames: string | readonly string[] | null | undefined, scene: Scene, data: unknown, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
9018
+ /**
9019
+ * Loads a USD stage into a scene.
9020
+ * @param scene The scene receiving the imported objects.
9021
+ * @param data The USD, USDA, USDC, or USDZ bytes.
9022
+ * @param rootUrl The source root URL.
9023
+ * @param onProgress SceneLoader progress callback.
9024
+ * @param fileName Name of the root USD layer.
9025
+ */
9026
+ loadAsync(scene: Scene, data: unknown, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
9027
+ /**
9028
+ * Loads a USD stage into an asset container.
9029
+ * @param scene The scene used to create imported objects.
9030
+ * @param data The USD, USDA, USDC, or USDZ bytes.
9031
+ * @param rootUrl The source root URL.
9032
+ * @param onProgress SceneLoader progress callback.
9033
+ * @param fileName Name of the root USD layer.
9034
+ * @returns The populated asset container.
9035
+ */
9036
+ loadAssetContainerAsync(scene: Scene, data: unknown, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
9037
+ /**
9038
+ * Releases the worker and rejects pending loads.
9039
+ */
9040
+ dispose(): void;
9041
+ private _loadAsync;
9042
+ private _getWorker;
9043
+ private _terminateWorker;
9044
+ }
9045
+ /** @internal */
9046
+ export function _RegisterUSDLoaderDependencies(): void;
9047
+ /**
9048
+ * Registers the USD scene loader plugin and its Babylon.js runtime dependencies.
9049
+ * Safe to call multiple times; only the first call has an effect.
9050
+ */
9051
+ export function RegisterUSDFileLoader(): void;
9052
+
9053
+ }
9054
+ declare module "babylonjs-loaders/USD/usdFileLoader.metadata" {
9055
+ /**
9056
+ * Defines the USD loader plugin metadata.
9057
+ */
9058
+ export const USDFileLoaderMetadata: {
9059
+ readonly name: "usd";
9060
+ readonly extensions: {
9061
+ readonly ".usd": {
9062
+ readonly isBinary: true;
9063
+ };
9064
+ readonly ".usda": {
9065
+ readonly isBinary: true;
9066
+ };
9067
+ readonly ".usdc": {
9068
+ readonly isBinary: true;
9069
+ };
9070
+ readonly ".usdz": {
9071
+ readonly isBinary: true;
9072
+ };
9073
+ };
9074
+ };
9075
+
9076
+ }
9077
+ declare module "babylonjs-loaders/USD/usdFileLoader" {
9078
+ /**
9079
+ * Re-exports the pure implementation and applies the runtime registration side effect.
9080
+ * Import "./usdFileLoader.pure" for tree-shakeable, side-effect-free usage.
9081
+ */
9082
+ export * from "babylonjs-loaders/USD/usdFileLoader.types";
9083
+ export * from "babylonjs-loaders/USD/usdFileLoader.pure";
9084
+
9085
+ }
9086
+ declare module "babylonjs-loaders/USD/usdCommandProtocol" {
9087
+ export const COMMAND_MAGIC = 1111774037;
9088
+ export const PROTOCOL_VERSION = 4;
9089
+ export const MISSING_OFFSET = 4294967295;
9090
+ export enum Command {
9091
+ Scene = 1,
9092
+ Texture = 2,
9093
+ Material = 3,
9094
+ TransformNode = 4,
9095
+ Skeleton = 5,
9096
+ Geometry = 6,
9097
+ Mesh = 7,
9098
+ Instance = 8,
9099
+ Animation = 9,
9100
+ AnalyticPrimitive = 10
9101
+ }
9102
+ export enum AnalyticPrimitiveType {
9103
+ Cube = 0,
9104
+ Sphere = 1,
9105
+ Cylinder = 2,
9106
+ Cone = 3
9107
+ }
9108
+ export enum PrimitiveAxis {
9109
+ X = 0,
9110
+ Y = 1,
9111
+ Z = 2
9112
+ }
9113
+ export enum AnimationTarget {
9114
+ Node = 0,
9115
+ Bone = 1
9116
+ }
9117
+ export enum AnimationProperty {
9118
+ Position = 0,
9119
+ RotationQuaternion = 1,
9120
+ Scaling = 2,
9121
+ Matrix = 3
9122
+ }
9123
+ export enum MaterialFlags {
9124
+ DoubleSided = 1,
9125
+ Unlit = 2,
9126
+ AlphaBlend = 4
9127
+ }
9128
+ export enum MeshFlags {
9129
+ DoubleSided = 1,
9130
+ LeftHanded = 2
9131
+ }
9132
+ export enum GeometryFlags {
9133
+ Normals = 1,
9134
+ Tangents = 2,
9135
+ Uv0 = 4,
9136
+ Colors = 8,
9137
+ Skin0 = 16,
9138
+ Skin1 = 32
9139
+ }
9140
+ export interface CommandRecord {
9141
+ opcode: Command;
9142
+ flags: number;
9143
+ payloadOffset: number;
9144
+ payloadLength: number;
9145
+ }
9146
+ export function readCommands(buffer: ArrayBuffer): CommandRecord[];
9147
+ export class PayloadReader {
9148
+ #private;
9149
+ offset: number;
9150
+ constructor(buffer: ArrayBuffer, offset: number, length: number);
9151
+ u32(): number;
9152
+ f32(): number;
9153
+ }
9154
+
9155
+ }
9156
+ declare module "babylonjs-loaders/USD/pure" {
9157
+ /** Pure barrel — re-exports only side-effect-free modules */
9158
+ export * from "babylonjs-loaders/USD/usdFileLoader.pure";
9159
+ export * from "babylonjs-loaders/USD/usdLoadingOptions";
9160
+
9161
+ }
9162
+ declare module "babylonjs-loaders/USD/index" {
9163
+ export * from "babylonjs-loaders/USD/usdFileLoader";
9164
+ export * from "babylonjs-loaders/USD/usdLoadingOptions";
9165
+
8734
9166
  }
8735
9167
  declare module "babylonjs-loaders/STL/stlFileLoader.types" {
8736
9168
  export {};
@@ -9776,6 +10208,18 @@ export interface ISOGLODMetadata {
9776
10208
  * Selects which LOD value drives the {@link GaussianSplattingStream} debug wireframe colors.
9777
10209
  */
9778
10210
  export type GaussianSplattingStreamDebugLodSource = "optimal" | "current";
10211
+ /**
10212
+ * Immutable metadata-resolution state for a stream's total number of finest-LOD splats.
10213
+ * @experimental
10214
+ */
10215
+ export type GaussianSplattingStreamLod0SplatCount = Readonly<{
10216
+ status: "pending";
10217
+ }> | Readonly<{
10218
+ status: "available";
10219
+ count: number;
10220
+ }> | Readonly<{
10221
+ status: "unavailable";
10222
+ }>;
9779
10223
  /**
9780
10224
  * Options for {@link GaussianSplattingStream}.
9781
10225
  */
@@ -9895,6 +10339,7 @@ export class GaussianSplattingStream extends GaussianSplattingMesh implements IG
9895
10339
  private readonly _rootUrl;
9896
10340
  private readonly _streamOptions;
9897
10341
  private readonly _leafNodes;
10342
+ private _lod0SplatCount;
9898
10343
  private _lodBaseDistance;
9899
10344
  private _lodMultiplier;
9900
10345
  private _lodBehindPenalty;
@@ -10059,6 +10504,19 @@ export class GaussianSplattingStream extends GaussianSplattingMesh implements IG
10059
10504
  * @experimental
10060
10505
  */
10061
10506
  get effectiveSplatBudget(): number;
10507
+ /**
10508
+ * The resolved maximum number of splats kept resident in the work buffer. This combines
10509
+ * {@link IGaussianSplattingStreamOptions.maxResidentSplats} and {@link IGaussianSplattingStreamOptions.memoryBudgetMb},
10510
+ * taking the smaller limit when both are configured. `0` means the resident budget is disabled.
10511
+ * @experimental
10512
+ */
10513
+ get residentSplatBudget(): number;
10514
+ /**
10515
+ * The total number of splats represented by valid level-0 leaf entries. This remains pending while source
10516
+ * metadata is loading and is unavailable when no applicable level-0 entries exist or required metadata fails.
10517
+ * @experimental
10518
+ */
10519
+ get lod0SplatCount(): GaussianSplattingStreamLod0SplatCount;
10062
10520
  /**
10063
10521
  * Resolves the raw {@link splatBudget} option to a concrete cap: `undefined` ⇒ 0 (disabled), `"auto"` ⇒ a
10064
10522
  * device-tiered default, a positive number ⇒ itself (floored).
@@ -10228,6 +10686,11 @@ export class GaussianSplattingStream extends GaussianSplattingMesh implements IG
10228
10686
  * @returns sorted unique file indices
10229
10687
  */
10230
10688
  private _collectAllFileIds;
10689
+ /**
10690
+ * Settles the level-0 diagnostic from normalized renderable leaf entries after their source metadata resolves.
10691
+ * A file may back several leaf ranges, so its source count is deliberately not used in the total.
10692
+ */
10693
+ private _resolveLod0SplatCount;
10231
10694
  /**
10232
10695
  * Fetches the environment bundle and every referenced file's metadata to learn splat counts, caching
10233
10696
  * each file's parsed metadata for the later on-demand decode. Metadata fetches run in parallel.
@@ -21491,6 +21954,408 @@ declare namespace BABYLON.GLTF1 {
21491
21954
  }
21492
21955
  declare namespace BABYLON {
21493
21956
 
21957
+ export interface WorkerAsset {
21958
+ bytes: Uint8Array;
21959
+ fileName: string;
21960
+ files?: Record<string, Uint8Array>;
21961
+ resolveByFileName: boolean;
21962
+ glueUrl?: string;
21963
+ wasmUrl?: string;
21964
+ dataUrl?: string;
21965
+ }
21966
+ export interface ExtractRequest {
21967
+ type: "extract";
21968
+ requestId: number;
21969
+ asset: WorkerAsset;
21970
+ }
21971
+ export interface WorkerTimings {
21972
+ totalMs: number;
21973
+ stageOpenMs: number;
21974
+ stageReadMs: number;
21975
+ preparationMs: number;
21976
+ packingMs: number;
21977
+ heapCopyMs: number;
21978
+ }
21979
+ export interface WorkerStatistics {
21980
+ nodes: number;
21981
+ meshes: number;
21982
+ analyticPrimitives: number;
21983
+ instances: number;
21984
+ materials: number;
21985
+ vertices: number;
21986
+ triangles: number;
21987
+ commandBytes: number;
21988
+ dataBytes: number;
21989
+ }
21990
+ export type WorkerResponse = {
21991
+ type: "progress";
21992
+ requestId: number;
21993
+ progress: USDLoadProgress;
21994
+ } | {
21995
+ type: "log";
21996
+ requestId: number;
21997
+ level: number;
21998
+ message: string;
21999
+ } | {
22000
+ type: "result";
22001
+ requestId: number;
22002
+ commands: ArrayBuffer;
22003
+ data: ArrayBuffer;
22004
+ timings: WorkerTimings;
22005
+ statistics: WorkerStatistics;
22006
+ missingAssets: string[];
22007
+ } | {
22008
+ type: "error";
22009
+ requestId: number;
22010
+ message: string;
22011
+ stack?: string;
22012
+ };
22013
+
22014
+
22015
+ export interface MaterializationResult {
22016
+ container: AbstractAssetContainer & {
22017
+ dispose(): void;
22018
+ };
22019
+ materializeMs: number;
22020
+ }
22021
+ export function materializeCommandBuffers(scene: Scene, commandBuffer: ArrayBuffer, dataBuffer: ArrayBuffer, addToScene: boolean, signal?: AbortSignal): Promise<MaterializationResult>;
22022
+
22023
+
22024
+ /**
22025
+ * Binary input accepted for supporting USD layers and assets.
22026
+ */
22027
+ export type USDBinaryInput = ArrayBuffer | ArrayBufferView;
22028
+ /**
22029
+ * Virtual files supplied alongside the root USD layer, keyed by their path relative to the
22030
+ * root layer.
22031
+ */
22032
+ export type USDVirtualFiles = Readonly<Record<string, USDBinaryInput>>;
22033
+ /**
22034
+ * Progress phases reported by the USD worker and Babylon materializer.
22035
+ */
22036
+ export interface USDLoadProgress {
22037
+ /**
22038
+ * Current importer phase.
22039
+ */
22040
+ phase: "initializing" | "staging" | "extracting" | "materializing";
22041
+ /**
22042
+ * Human-readable phase description.
22043
+ */
22044
+ message: string;
22045
+ }
22046
+ /**
22047
+ * Options for the OpenUSD scene loader.
22048
+ */
22049
+ export interface USDFileLoaderOptions {
22050
+ /**
22051
+ * Virtual path used to stage the root layer. Set this when supporting files need
22052
+ * to resolve relative to a directory hierarchy.
22053
+ */
22054
+ rootFileName?: string;
22055
+ /**
22056
+ * Supporting layers, payloads, and textures keyed by virtual path in the same
22057
+ * virtual file system as `rootFileName`.
22058
+ */
22059
+ files?: USDVirtualFiles;
22060
+ /**
22061
+ * Enables conservative file-name fallback for unresolved absolute references.
22062
+ * Defaults to true.
22063
+ */
22064
+ resolveByFileName?: boolean;
22065
+ /**
22066
+ * URL of the module worker. Defaults to the protocol-versioned worker hosted on the Babylon.js CDN.
22067
+ */
22068
+ workerUrl?: string | URL;
22069
+ /**
22070
+ * URL of the generated Emscripten JavaScript module.
22071
+ */
22072
+ glueUrl?: string;
22073
+ /**
22074
+ * URL of the OpenUSD WebAssembly binary.
22075
+ */
22076
+ wasmUrl?: string;
22077
+ /**
22078
+ * URL of the OpenUSD preloaded resource bundle.
22079
+ */
22080
+ dataUrl?: string;
22081
+ /**
22082
+ * Called when the importer moves to a new processing phase.
22083
+ */
22084
+ onProgress?: (progress: USDLoadProgress) => void;
22085
+ /**
22086
+ * Called for OpenUSD diagnostic messages.
22087
+ */
22088
+ onLog?: (level: "info" | "warning" | "error", message: string) => void;
22089
+ /**
22090
+ * Called after extraction and Babylon.js object creation complete.
22091
+ */
22092
+ onComplete?: (diagnostics: USDImportDiagnostics) => void;
22093
+ }
22094
+ /**
22095
+ * Timing data measured by the OpenUSD worker and Babylon materializer.
22096
+ */
22097
+ export interface USDImportTimings {
22098
+ /** Total extraction time, including the final Wasm heap copy. */
22099
+ totalMs: number;
22100
+ /** Time spent opening and composing the USD stage. */
22101
+ stageOpenMs: number;
22102
+ /** Time spent traversing the composed stage. */
22103
+ stageReadMs: number;
22104
+ /** Time spent preparing renderable vertex streams. */
22105
+ preparationMs: number;
22106
+ /** Time spent packing the command and raw-data buffers. */
22107
+ packingMs: number;
22108
+ /** Time spent copying command and data buffers from the Wasm heap. */
22109
+ heapCopyMs: number;
22110
+ /** Time spent creating Babylon.js objects. */
22111
+ materializeMs: number;
22112
+ }
22113
+ /**
22114
+ * Statistics reported for an imported USD stage.
22115
+ */
22116
+ export interface USDImportStatistics {
22117
+ /** Number of transform nodes extracted from the composed stage. */
22118
+ nodes: number;
22119
+ /** Number of polygonal `UsdGeomMesh` sources. */
22120
+ meshes: number;
22121
+ /** Number of analytic cube, sphere, cylinder, and cone sources. */
22122
+ analyticPrimitives: number;
22123
+ /** Number of native Babylon instances created from shared USD geometry. */
22124
+ instances: number;
22125
+ /** Number of authored USD materials translated. */
22126
+ materials: number;
22127
+ /** Number of unique vertices in polygonal source meshes. */
22128
+ vertices: number;
22129
+ /** Number of unique triangles in polygonal source meshes. */
22130
+ triangles: number;
22131
+ /** Size of the command buffer in bytes. */
22132
+ commandBytes: number;
22133
+ /** Size of the raw-data buffer in bytes. */
22134
+ dataBytes: number;
22135
+ }
22136
+ /**
22137
+ * Diagnostics reported after a USD import completes.
22138
+ */
22139
+ export interface USDImportDiagnostics {
22140
+ /** Timing data for extraction and Babylon.js object creation. */
22141
+ timings: USDImportTimings;
22142
+ /** Counts and buffer sizes reported by the OpenUSD extractor. */
22143
+ statistics: USDImportStatistics;
22144
+ /** Asset references OpenUSD could not resolve from the supplied virtual files. */
22145
+ missingAssets: readonly string[];
22146
+ }
22147
+
22148
+
22149
+ interface SceneLoaderPluginOptions {
22150
+ /**
22151
+ * Defines options for the USD loader.
22152
+ */
22153
+ [USDFileLoaderMetadata.name]: Partial<USDFileLoaderOptions>;
22154
+ }
22155
+
22156
+
22157
+ /** This file must only contain pure code and pure imports */
22158
+ /**
22159
+ * OpenUSD scene loader backed by a WebAssembly command-buffer extractor.
22160
+ */
22161
+ export class USDFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
22162
+ /**
22163
+ * Default URLs for the prebuilt OpenUSD importer assets.
22164
+ */
22165
+ static DefaultConfiguration: {
22166
+ glueUrl: string;
22167
+ wasmUrl: string;
22168
+ dataUrl: string;
22169
+ workerUrl: string;
22170
+ };
22171
+ /**
22172
+ * Defines the name of the plugin.
22173
+ */
22174
+ readonly name: "usd";
22175
+ /**
22176
+ * Defines the extensions the plugin can load.
22177
+ */
22178
+ readonly extensions: {
22179
+ readonly ".usd": {
22180
+ readonly isBinary: true;
22181
+ };
22182
+ readonly ".usda": {
22183
+ readonly isBinary: true;
22184
+ };
22185
+ readonly ".usdc": {
22186
+ readonly isBinary: true;
22187
+ };
22188
+ readonly ".usdz": {
22189
+ readonly isBinary: true;
22190
+ };
22191
+ };
22192
+ private readonly _options;
22193
+ private _worker;
22194
+ private _workerUrl;
22195
+ private _workerBlobUrl;
22196
+ private _nextRequestId;
22197
+ private readonly _pending;
22198
+ private readonly _activeLoads;
22199
+ /**
22200
+ * Creates a USD loader.
22201
+ * @param options Options controlling worker assets, supporting files, and diagnostics.
22202
+ */
22203
+ constructor(options?: Partial<USDFileLoaderOptions>);
22204
+ /**
22205
+ * Creates a configured plugin instance for a SceneLoader operation.
22206
+ * @param options SceneLoader plugin options.
22207
+ * @returns The configured USD loader.
22208
+ */
22209
+ createPlugin(options: SceneLoaderPluginOptions): ISceneLoaderPluginAsync;
22210
+ /**
22211
+ * Imports all objects from a USD stage into a scene.
22212
+ * @param _meshesNames Mesh name filtering is not currently supported.
22213
+ * @param scene The scene receiving the imported objects.
22214
+ * @param data The USD, USDA, USDC, or USDZ bytes.
22215
+ * @param rootUrl The source root URL.
22216
+ * @param onProgress SceneLoader progress callback.
22217
+ * @param fileName Name of the root USD layer.
22218
+ * @returns The imported Babylon.js objects.
22219
+ */
22220
+ importMeshAsync(_meshesNames: string | readonly string[] | null | undefined, scene: Scene, data: unknown, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
22221
+ /**
22222
+ * Loads a USD stage into a scene.
22223
+ * @param scene The scene receiving the imported objects.
22224
+ * @param data The USD, USDA, USDC, or USDZ bytes.
22225
+ * @param rootUrl The source root URL.
22226
+ * @param onProgress SceneLoader progress callback.
22227
+ * @param fileName Name of the root USD layer.
22228
+ */
22229
+ loadAsync(scene: Scene, data: unknown, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
22230
+ /**
22231
+ * Loads a USD stage into an asset container.
22232
+ * @param scene The scene used to create imported objects.
22233
+ * @param data The USD, USDA, USDC, or USDZ bytes.
22234
+ * @param rootUrl The source root URL.
22235
+ * @param onProgress SceneLoader progress callback.
22236
+ * @param fileName Name of the root USD layer.
22237
+ * @returns The populated asset container.
22238
+ */
22239
+ loadAssetContainerAsync(scene: Scene, data: unknown, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
22240
+ /**
22241
+ * Releases the worker and rejects pending loads.
22242
+ */
22243
+ dispose(): void;
22244
+ private _loadAsync;
22245
+ private _getWorker;
22246
+ private _terminateWorker;
22247
+ }
22248
+ /** @internal */
22249
+ export function _RegisterUSDLoaderDependencies(): void;
22250
+ /**
22251
+ * Registers the USD scene loader plugin and its Babylon.js runtime dependencies.
22252
+ * Safe to call multiple times; only the first call has an effect.
22253
+ */
22254
+ export function RegisterUSDFileLoader(): void;
22255
+
22256
+
22257
+ /**
22258
+ * Defines the USD loader plugin metadata.
22259
+ */
22260
+ export var USDFileLoaderMetadata: {
22261
+ readonly name: "usd";
22262
+ readonly extensions: {
22263
+ readonly ".usd": {
22264
+ readonly isBinary: true;
22265
+ };
22266
+ readonly ".usda": {
22267
+ readonly isBinary: true;
22268
+ };
22269
+ readonly ".usdc": {
22270
+ readonly isBinary: true;
22271
+ };
22272
+ readonly ".usdz": {
22273
+ readonly isBinary: true;
22274
+ };
22275
+ };
22276
+ };
22277
+
22278
+
22279
+ /**
22280
+ * Re-exports the pure implementation and applies the runtime registration side effect.
22281
+ * Import "./usdFileLoader.pure" for tree-shakeable, side-effect-free usage.
22282
+ */
22283
+
22284
+
22285
+ export const COMMAND_MAGIC = 1111774037;
22286
+ export const PROTOCOL_VERSION = 4;
22287
+ export const MISSING_OFFSET = 4294967295;
22288
+ export enum Command {
22289
+ Scene = 1,
22290
+ Texture = 2,
22291
+ Material = 3,
22292
+ TransformNode = 4,
22293
+ Skeleton = 5,
22294
+ Geometry = 6,
22295
+ Mesh = 7,
22296
+ Instance = 8,
22297
+ Animation = 9,
22298
+ AnalyticPrimitive = 10
22299
+ }
22300
+ export enum AnalyticPrimitiveType {
22301
+ Cube = 0,
22302
+ Sphere = 1,
22303
+ Cylinder = 2,
22304
+ Cone = 3
22305
+ }
22306
+ export enum PrimitiveAxis {
22307
+ X = 0,
22308
+ Y = 1,
22309
+ Z = 2
22310
+ }
22311
+ export enum AnimationTarget {
22312
+ Node = 0,
22313
+ Bone = 1
22314
+ }
22315
+ export enum AnimationProperty {
22316
+ Position = 0,
22317
+ RotationQuaternion = 1,
22318
+ Scaling = 2,
22319
+ Matrix = 3
22320
+ }
22321
+ export enum MaterialFlags {
22322
+ DoubleSided = 1,
22323
+ Unlit = 2,
22324
+ AlphaBlend = 4
22325
+ }
22326
+ export enum MeshFlags {
22327
+ DoubleSided = 1,
22328
+ LeftHanded = 2
22329
+ }
22330
+ export enum GeometryFlags {
22331
+ Normals = 1,
22332
+ Tangents = 2,
22333
+ Uv0 = 4,
22334
+ Colors = 8,
22335
+ Skin0 = 16,
22336
+ Skin1 = 32
22337
+ }
22338
+ export interface CommandRecord {
22339
+ opcode: Command;
22340
+ flags: number;
22341
+ payloadOffset: number;
22342
+ payloadLength: number;
22343
+ }
22344
+ export function readCommands(buffer: ArrayBuffer): CommandRecord[];
22345
+ export class PayloadReader {
22346
+ #private;
22347
+ offset: number;
22348
+ constructor(buffer: ArrayBuffer, offset: number, length: number);
22349
+ u32(): number;
22350
+ f32(): number;
22351
+ }
22352
+
22353
+
22354
+ /** Pure barrel — re-exports only side-effect-free modules */
22355
+
22356
+
22357
+
22358
+
21494
22359
  interface SceneLoaderPluginOptions {
21495
22360
  /**
21496
22361
  * Defines options for the stl loader.
@@ -22459,6 +23324,18 @@ declare namespace BABYLON {
22459
23324
  * Selects which LOD value drives the {@link GaussianSplattingStream} debug wireframe colors.
22460
23325
  */
22461
23326
  export type GaussianSplattingStreamDebugLodSource = "optimal" | "current";
23327
+ /**
23328
+ * Immutable metadata-resolution state for a stream's total number of finest-LOD splats.
23329
+ * @experimental
23330
+ */
23331
+ export type GaussianSplattingStreamLod0SplatCount = Readonly<{
23332
+ status: "pending";
23333
+ }> | Readonly<{
23334
+ status: "available";
23335
+ count: number;
23336
+ }> | Readonly<{
23337
+ status: "unavailable";
23338
+ }>;
22462
23339
  /**
22463
23340
  * Options for {@link GaussianSplattingStream}.
22464
23341
  */
@@ -22578,6 +23455,7 @@ declare namespace BABYLON {
22578
23455
  private readonly _rootUrl;
22579
23456
  private readonly _streamOptions;
22580
23457
  private readonly _leafNodes;
23458
+ private _lod0SplatCount;
22581
23459
  private _lodBaseDistance;
22582
23460
  private _lodMultiplier;
22583
23461
  private _lodBehindPenalty;
@@ -22742,6 +23620,19 @@ declare namespace BABYLON {
22742
23620
  * @experimental
22743
23621
  */
22744
23622
  get effectiveSplatBudget(): number;
23623
+ /**
23624
+ * The resolved maximum number of splats kept resident in the work buffer. This combines
23625
+ * {@link IGaussianSplattingStreamOptions.maxResidentSplats} and {@link IGaussianSplattingStreamOptions.memoryBudgetMb},
23626
+ * taking the smaller limit when both are configured. `0` means the resident budget is disabled.
23627
+ * @experimental
23628
+ */
23629
+ get residentSplatBudget(): number;
23630
+ /**
23631
+ * The total number of splats represented by valid level-0 leaf entries. This remains pending while source
23632
+ * metadata is loading and is unavailable when no applicable level-0 entries exist or required metadata fails.
23633
+ * @experimental
23634
+ */
23635
+ get lod0SplatCount(): GaussianSplattingStreamLod0SplatCount;
22745
23636
  /**
22746
23637
  * Resolves the raw {@link splatBudget} option to a concrete cap: `undefined` ⇒ 0 (disabled), `"auto"` ⇒ a
22747
23638
  * device-tiered default, a positive number ⇒ itself (floored).
@@ -22911,6 +23802,11 @@ declare namespace BABYLON {
22911
23802
  * @returns sorted unique file indices
22912
23803
  */
22913
23804
  private _collectAllFileIds;
23805
+ /**
23806
+ * Settles the level-0 diagnostic from normalized renderable leaf entries after their source metadata resolves.
23807
+ * A file may back several leaf ranges, so its source count is deliberately not used in the total.
23808
+ */
23809
+ private _resolveLod0SplatCount;
22914
23810
  /**
22915
23811
  * Fetches the environment bundle and every referenced file's metadata to learn splat counts, caching
22916
23812
  * each file's parsed metadata for the later on-demand decode. Metadata fetches run in parallel.