babylonjs-loaders 7.23.0 → 7.23.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.
@@ -2,6 +2,13 @@
2
2
  declare module BABYLON {
3
3
 
4
4
 
5
+ /**
6
+ * Registers the async plugin factories for all built-in loaders.
7
+ * Loaders will be dynamically imported on demand, only when a SceneLoader load operation needs each respective loader.
8
+ */
9
+ export function registerBuiltInLoaders(): void;
10
+
11
+
5
12
 
6
13
 
7
14
  /**
@@ -34,7 +41,21 @@ declare module BABYLON {
34
41
  }
35
42
 
36
43
 
37
- const PLUGIN_GLTF = "gltf";
44
+ export const GLTFMagicBase64Encoded = "Z2xURg";
45
+ export var GLTFFileLoaderMetadata: {
46
+ readonly name: "gltf";
47
+ readonly extensions: {
48
+ readonly ".gltf": {
49
+ readonly isBinary: false;
50
+ };
51
+ readonly ".glb": {
52
+ readonly isBinary: true;
53
+ };
54
+ };
55
+ readonly canDirectLoad: (data: string) => boolean;
56
+ };
57
+
58
+
38
59
  /**
39
60
  * Defines options for glTF loader extensions. This interface is extended by specific extensions.
40
61
  */
@@ -44,7 +65,7 @@ declare module BABYLON {
44
65
  /**
45
66
  * Defines options for the glTF loader.
46
67
  */
47
- [PLUGIN_GLTF]: Partial<GLTFLoaderOptions>;
68
+ [GLTFFileLoaderMetadata.name]: Partial<GLTFLoaderOptions>;
48
69
  }
49
70
  /**
50
71
  * Mode that determines the coordinate system to use.
@@ -421,11 +442,10 @@ declare module BABYLON {
421
442
  private _state;
422
443
  private _progressCallback?;
423
444
  private _requests;
424
- private static readonly _MagicBase64Encoded;
425
445
  /**
426
446
  * Name of the loader ("gltf")
427
447
  */
428
- readonly name = "gltf";
448
+ readonly name: "gltf";
429
449
  /** @internal */
430
450
  readonly extensions: {
431
451
  readonly ".gltf": {
@@ -784,6 +804,37 @@ declare module BABYLON.GLTF2.Loader {
784
804
 
785
805
 
786
806
 
807
+ }
808
+ declare module BABYLON {
809
+
810
+
811
+ }
812
+ declare module BABYLON.GLTF2 {
813
+ interface IRegisteredGLTFExtension {
814
+ isGLTFExtension: boolean;
815
+ factory: GLTFExtensionFactory;
816
+ }
817
+ export type GLTFExtensionFactory = (loader: BABYLON.GLTF2.GLTFLoader) => BABYLON.GLTF2.IGLTFLoaderExtension | Promise<BABYLON.GLTF2.IGLTFLoaderExtension>;
818
+ /**
819
+ * All currently registered glTF 2.0 loader extensions.
820
+ */
821
+ export var registeredGLTFExtensions: ReadonlyMap<string, Readonly<IRegisteredGLTFExtension>>;
822
+ /**
823
+ * Registers a loader extension.
824
+ * @param name The name of the loader extension.
825
+ * @param isGLTFExtension If the loader extension is a glTF extension, then it will only be used for glTF files that use the corresponding glTF extension. Otherwise, it will be used for all loaded glTF files.
826
+ * @param factory The factory function that creates the loader extension.
827
+ */
828
+ export function registerGLTFExtension(name: string, isGLTFExtension: boolean, factory: GLTFExtensionFactory): void;
829
+ /**
830
+ * Unregisters a loader extension.
831
+ * @param name The name of the loader extension.
832
+ * @returns A boolean indicating whether the extension has been unregistered
833
+ */
834
+ export function unregisterGLTFExtension(name: string): boolean;
835
+
836
+
837
+
787
838
  }
788
839
  declare module BABYLON {
789
840
 
@@ -1056,7 +1107,6 @@ declare module BABYLON.GLTF2 {
1056
1107
  private _rootBabylonMesh;
1057
1108
  private _defaultBabylonMaterialData;
1058
1109
  private readonly _postSceneLoadActions;
1059
- private static _RegisteredExtensions;
1060
1110
  /**
1061
1111
  * The default glTF sampler.
1062
1112
  */
@@ -1065,12 +1115,14 @@ declare module BABYLON.GLTF2 {
1065
1115
  * Registers a loader extension.
1066
1116
  * @param name The name of the loader extension.
1067
1117
  * @param factory The factory function that creates the loader extension.
1118
+ * @deprecated Please use registerGLTFExtension instead.
1068
1119
  */
1069
- static RegisterExtension(name: string, factory: (loader: GLTFLoader) => BABYLON.GLTF2.IGLTFLoaderExtension): void;
1120
+ static RegisterExtension(name: string, factory: BABYLON.GLTF2.GLTFExtensionFactory): void;
1070
1121
  /**
1071
1122
  * Unregisters a loader extension.
1072
1123
  * @param name The name of the loader extension.
1073
1124
  * @returns A boolean indicating whether the extension has been unregistered
1125
+ * @deprecated Please use unregisterGLTFExtension instead.
1074
1126
  */
1075
1127
  static UnregisterExtension(name: string): boolean;
1076
1128
  /**
@@ -1114,8 +1166,7 @@ declare module BABYLON.GLTF2 {
1114
1166
  private _loadAsync;
1115
1167
  private _loadData;
1116
1168
  private _setupData;
1117
- private _loadExtensions;
1118
- private _checkExtensions;
1169
+ private _loadExtensionsAsync;
1119
1170
  private _createRootNode;
1120
1171
  /**
1121
1172
  * Loads a glTF scene.
@@ -1490,6 +1541,19 @@ declare module BABYLON.GLTF2.Loader.Extensions {
1490
1541
 
1491
1542
 
1492
1543
 
1544
+ }
1545
+ declare module BABYLON {
1546
+
1547
+
1548
+ }
1549
+ declare module BABYLON.GLTF2.Loader.Extensions {
1550
+ /**
1551
+ * Registers the built-in glTF 2.0 extension async factories, which dynamically imports and loads each glTF extension on demand (e.g. only when a glTF model uses the extension).
1552
+ */
1553
+ export function registerBuiltInGLTFExtensions(): void;
1554
+
1555
+
1556
+
1493
1557
  }
1494
1558
  declare module BABYLON {
1495
1559
 
@@ -3899,12 +3963,21 @@ declare module BABYLON.GLTF1 {
3899
3963
  }
3900
3964
  declare module BABYLON {
3901
3965
 
3902
- const PLUGIN_STL = "stl";
3966
+ export var STLFileLoaderMetadata: {
3967
+ readonly name: "stl";
3968
+ readonly extensions: {
3969
+ readonly ".stl": {
3970
+ readonly isBinary: true;
3971
+ };
3972
+ };
3973
+ };
3974
+
3975
+
3903
3976
  interface SceneLoaderPluginOptions {
3904
3977
  /**
3905
3978
  * Defines options for the stl loader.
3906
3979
  */
3907
- [PLUGIN_STL]: {};
3980
+ [STLFileLoaderMetadata.name]: {};
3908
3981
  }
3909
3982
  /**
3910
3983
  * STL file type loader.
@@ -3922,7 +3995,7 @@ declare module BABYLON {
3922
3995
  /**
3923
3996
  * Defines the name of the plugin.
3924
3997
  */
3925
- readonly name = "stl";
3998
+ readonly name: "stl";
3926
3999
  /**
3927
4000
  * Defines the extensions the stl loader is able to load.
3928
4001
  * force data to come in as an ArrayBuffer
@@ -3973,12 +4046,35 @@ declare module BABYLON {
3973
4046
 
3974
4047
 
3975
4048
 
3976
- const PLUGIN_SPLAT = "splat";
4049
+ /**
4050
+ * Options for loading Gaussian Splatting and PLY files
4051
+ */
4052
+ export type SPLATLoadingOptions = {
4053
+ /**
4054
+ * Defines if buffers should be kept in memory for editing purposes
4055
+ */
4056
+ keepInRam?: boolean;
4057
+ };
4058
+
4059
+
4060
+ export var SPLATFileLoaderMetadata: {
4061
+ readonly name: "splat";
4062
+ readonly extensions: {
4063
+ readonly ".splat": {
4064
+ readonly isBinary: true;
4065
+ };
4066
+ readonly ".ply": {
4067
+ readonly isBinary: true;
4068
+ };
4069
+ };
4070
+ };
4071
+
4072
+
3977
4073
  interface SceneLoaderPluginOptions {
3978
4074
  /**
3979
4075
  * Defines options for the splat loader.
3980
4076
  */
3981
- [PLUGIN_SPLAT]: {};
4077
+ [SPLATFileLoaderMetadata.name]: Partial<SPLATLoadingOptions>;
3982
4078
  }
3983
4079
  /**
3984
4080
  * @experimental
@@ -3989,7 +4085,9 @@ declare module BABYLON {
3989
4085
  /**
3990
4086
  * Defines the name of the plugin.
3991
4087
  */
3992
- readonly name = "splat";
4088
+ readonly name: "splat";
4089
+ private _assetContainer;
4090
+ private readonly _loadingOptions;
3993
4091
  /**
3994
4092
  * Defines the extensions the splat loader is able to load.
3995
4093
  * force data to come in as an ArrayBuffer
@@ -4004,21 +4102,15 @@ declare module BABYLON {
4004
4102
  };
4005
4103
  /**
4006
4104
  * Creates loader for gaussian splatting files
4105
+ * @param loadingOptions options for loading and parsing splat and PLY files.
4007
4106
  */
4008
- constructor();
4009
- /**
4010
- * Instantiates a gaussian splatting file loader plugin.
4011
- * @returns the created plugin
4012
- */
4013
- createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
4014
- /**
4015
- * If the data string can be loaded directly.
4016
- * @returns if the data can be loaded directly
4017
- */
4018
- canDirectLoad(): boolean;
4107
+ constructor(loadingOptions?: Partial<Readonly<SPLATLoadingOptions>>);
4108
+ private static readonly _DefaultLoadingOptions;
4109
+ /** @internal */
4110
+ createPlugin(options: SceneLoaderPluginOptions): ISceneLoaderPluginAsync;
4019
4111
  /**
4020
4112
  * Imports from the loaded gaussian splatting data and adds them to the scene
4021
- * @param _meshesNames a string or array of strings of the mesh names that should be loaded from the file
4113
+ * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
4022
4114
  * @param scene the scene the meshes should be added to
4023
4115
  * @param data the gaussian splatting data to load
4024
4116
  * @param rootUrl root url to load from
@@ -4026,23 +4118,34 @@ declare module BABYLON {
4026
4118
  * @param fileName Defines the name of the file to load
4027
4119
  * @returns a promise containing the loaded meshes, particles, skeletons and animations
4028
4120
  */
4029
- importMeshAsync(_meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
4121
+ importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
4122
+ private static _BuildPointCloud;
4123
+ private static _BuildMesh;
4124
+ private _parse;
4030
4125
  /**
4031
- * Imports all objects from the loaded gaussian splatting data and adds them to the scene
4126
+ * Load into an asset container.
4127
+ * @param scene The scene to load into
4128
+ * @param data The data to import
4129
+ * @param rootUrl The root url for scene and resources
4130
+ * @returns The loaded asset container
4131
+ */
4132
+ loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string): Promise<AssetContainer>;
4133
+ /**
4134
+ * Imports all objects from the loaded OBJ data and adds them to the scene
4032
4135
  * @param scene the scene the objects should be added to
4033
- * @param data the gaussian splatting data to load
4034
- * @param _rootUrl root url to load from
4136
+ * @param data the OBJ data to load
4137
+ * @param rootUrl root url to load from
4035
4138
  * @returns a promise which completes when objects have been loaded to the scene
4036
4139
  */
4037
- loadAsync(scene: Scene, data: any, _rootUrl: string): Promise<void>;
4140
+ loadAsync(scene: Scene, data: string, rootUrl: string): Promise<void>;
4038
4141
  /**
4039
- * Load into an asset container.
4040
- * @param _scene The scene to load into
4041
- * @param _data The data to import
4042
- * @param _rootUrl The root url for scene and resources
4043
- * @returns The loaded asset container
4142
+ * Code from https://github.com/dylanebert/gsplat.js/blob/main/src/loaders/PLYLoader.ts Under MIT license
4143
+ * Converts a .ply data array buffer to splat
4144
+ * if data array buffer is not ply, returns the original buffer
4145
+ * @param data the .ply data to load
4146
+ * @returns the loaded splat buffer
4044
4147
  */
4045
- loadAssetContainerAsync(_scene: Scene, _data: string, _rootUrl: string): Promise<AssetContainer>;
4148
+ private static _ConvertPLYToSplat;
4046
4149
  }
4047
4150
 
4048
4151
 
@@ -4259,12 +4362,17 @@ declare module BABYLON {
4259
4362
  };
4260
4363
 
4261
4364
 
4262
- const PLUGIN_OBJ = "obj";
4365
+ export var OBJFileLoaderMetadata: {
4366
+ readonly name: "obj";
4367
+ readonly extensions: ".obj";
4368
+ };
4369
+
4370
+
4263
4371
  interface SceneLoaderPluginOptions {
4264
4372
  /**
4265
4373
  * Defines options for the obj loader.
4266
4374
  */
4267
- [PLUGIN_OBJ]: {};
4375
+ [OBJFileLoaderMetadata.name]: {};
4268
4376
  }
4269
4377
  /**
4270
4378
  * OBJ file type loader.
@@ -4318,11 +4426,11 @@ declare module BABYLON {
4318
4426
  /**
4319
4427
  * Defines the name of the plugin.
4320
4428
  */
4321
- readonly name = "obj";
4429
+ readonly name: "obj";
4322
4430
  /**
4323
4431
  * Defines the extension the plugin is able to load.
4324
4432
  */
4325
- readonly extensions = ".obj";
4433
+ readonly extensions: ".obj";
4326
4434
  private _assetContainer;
4327
4435
  private _loadingOptions;
4328
4436
  /**