@babylonjs/loaders 8.23.0 → 8.23.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.
@@ -126,88 +126,102 @@ declare abstract class GLTFLoaderOptions {
126
126
  */
127
127
  abstract onParsed?: ((loaderData: IGLTFLoaderData) => void) | undefined;
128
128
  /**
129
- * The coordinate system mode. Defaults to AUTO.
130
- */
131
- coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
132
- /**
133
- * The animation start mode. Defaults to FIRST.
129
+ * Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false.
134
130
  */
135
- animationStartMode: GLTFLoaderAnimationStartMode;
131
+ alwaysComputeBoundingBox: boolean;
136
132
  /**
137
- * Defines if the loader should load node animations. Defaults to true.
138
- * NOTE: The animation of this node will still load if the node is also a joint of a skin and `loadSkins` is true.
133
+ * Defines if the loader should always compute the nearest common ancestor of the skeleton joints instead of using `skin.skeleton`. Defaults to false.
134
+ * Set this to true if loading assets with invalid `skin.skeleton` values.
139
135
  */
140
- loadNodeAnimations: boolean;
136
+ alwaysComputeSkeletonRootNode: boolean;
141
137
  /**
142
- * Defines if the loader should load skins. Defaults to true.
138
+ * The animation start mode. Defaults to FIRST.
143
139
  */
144
- loadSkins: boolean;
140
+ animationStartMode: GLTFLoaderAnimationStartMode;
145
141
  /**
146
- * Defines if the loader should load morph targets. Defaults to true.
142
+ * Defines if the loader should capture performance counters.
147
143
  */
148
- loadMorphTargets: boolean;
144
+ abstract capturePerformanceCounters: boolean;
149
145
  /**
150
146
  * Defines if the loader should compile materials before raising the success callback. Defaults to false.
151
147
  */
152
148
  compileMaterials: boolean;
153
- /**
154
- * Defines if the loader should also compile materials with clip planes. Defaults to false.
155
- */
156
- useClipPlane: boolean;
157
149
  /**
158
150
  * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
159
151
  */
160
152
  compileShadowGenerators: boolean;
161
153
  /**
162
- * Defines if the Alpha blended materials are only applied as coverage.
163
- * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
164
- * If true, no extra effects are applied to transparent pixels.
165
- */
166
- transparencyAsCoverage: boolean;
167
- /**
168
- * Defines if the loader should use range requests when load binary glTF files from HTTP.
169
- * Enabling will disable offline support and glTF validator.
170
- * Defaults to false.
154
+ * The coordinate system mode. Defaults to AUTO.
171
155
  */
172
- useRangeRequests: boolean;
156
+ coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
173
157
  /**
174
158
  * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
175
159
  */
176
160
  createInstances: boolean;
177
161
  /**
178
- * Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false.
162
+ * Defines the node to use as the root of the hierarchy when loading the scene (default: undefined). If not defined, a root node will be automatically created.
163
+ * You can also pass null if you don't want a root node to be created.
179
164
  */
180
- alwaysComputeBoundingBox: boolean;
165
+ customRootNode?: Nullable<TransformNode>;
166
+ /**
167
+ * Defines options for glTF extensions.
168
+ */
169
+ extensionOptions: {
170
+ [Extension in keyof GLTFLoaderExtensionOptions]?: {
171
+ [Option in keyof DefaultExtensionOptions<GLTFLoaderExtensionOptions[Extension]>]: DefaultExtensionOptions<GLTFLoaderExtensionOptions[Extension]>[Option];
172
+ };
173
+ };
181
174
  /**
182
175
  * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
183
176
  */
184
177
  loadAllMaterials: boolean;
178
+ /**
179
+ * Defines if the loader should load morph targets. Defaults to true.
180
+ */
181
+ loadMorphTargets: boolean;
182
+ /**
183
+ * Defines if the loader should load node animations. Defaults to true.
184
+ * NOTE: The animation of this node will still load if the node is also a joint of a skin and `loadSkins` is true.
185
+ */
186
+ loadNodeAnimations: boolean;
185
187
  /**
186
188
  * If true, load only the materials defined in the file. Defaults to false.
187
189
  */
188
190
  loadOnlyMaterials: boolean;
189
191
  /**
190
- * If true, do not load any materials defined in the file. Defaults to false.
192
+ * Defines if the loader should load skins. Defaults to true.
191
193
  */
192
- skipMaterials: boolean;
194
+ loadSkins: boolean;
193
195
  /**
194
- * If true, load the color (gamma encoded) textures into sRGB buffers (if supported by the GPU), which will yield more accurate results when sampling the texture. Defaults to true.
196
+ * If true, enable logging for the loader. Defaults to false.
195
197
  */
196
- useSRGBBuffers: boolean;
198
+ abstract loggingEnabled: boolean;
197
199
  /**
198
- * When loading glTF animations, which are defined in seconds, target them to this FPS. Defaults to 60.
200
+ * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
199
201
  */
200
- targetFps: number;
202
+ abstract onCameraLoaded?: (camera: Camera) => void;
201
203
  /**
202
- * Defines if the loader should always compute the nearest common ancestor of the skeleton joints instead of using `skin.skeleton`. Defaults to false.
203
- * Set this to true if loading assets with invalid `skin.skeleton` values.
204
+ * Callback raised when the loader creates a material after parsing the glTF properties of the material.
204
205
  */
205
- alwaysComputeSkeletonRootNode: boolean;
206
+ abstract onMaterialLoaded?: (material: Material) => void;
206
207
  /**
207
- * If true, the loader will derive the name for Babylon textures from the glTF texture name, image name, or image url. Defaults to false.
208
- * Note that it is possible for multiple Babylon textures to share the same name when the Babylon textures load from the same glTF texture or image.
208
+ * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
209
+ * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
209
210
  */
210
- useGltfTextureNames: boolean;
211
+ abstract onMeshLoaded?: (mesh: AbstractMesh) => void;
212
+ /**
213
+ * Callback raised when the loader creates a skin after parsing the glTF properties of the skin node.
214
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/importers/glTF/glTFSkinning#ignoring-the-transform-of-the-skinned-mesh
215
+ */
216
+ abstract onSkinLoaded?: (node: TransformNode, skinnedNode: TransformNode) => void;
217
+ /**
218
+ * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
219
+ */
220
+ abstract onTextureLoaded?: (texture: BaseTexture) => void;
221
+ /**
222
+ * Callback raised after the asset is validated.
223
+ */
224
+ abstract onValidated?: (results: GLTF2.IGLTFValidationResults) => void;
211
225
  /**
212
226
  * Function called before loading a url referenced by the asset.
213
227
  * @param url url referenced by the asset
@@ -215,40 +229,42 @@ declare abstract class GLTFLoaderOptions {
215
229
  */
216
230
  preprocessUrlAsync: (url: string) => Promise<string>;
217
231
  /**
218
- * Defines the node to use as the root of the hierarchy when loading the scene (default: undefined). If not defined, a root node will be automatically created.
219
- * You can also pass null if you don't want a root node to be created.
232
+ * If true, do not load any materials defined in the file. Defaults to false.
220
233
  */
221
- customRootNode?: Nullable<TransformNode>;
234
+ skipMaterials: boolean;
222
235
  /**
223
- * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
224
- * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
236
+ * When loading glTF animations, which are defined in seconds, target them to this FPS. Defaults to 60.
225
237
  */
226
- abstract onMeshLoaded?: ((mesh: AbstractMesh) => void) | undefined;
238
+ targetFps: number;
227
239
  /**
228
- * Callback raised when the loader creates a skin after parsing the glTF properties of the skin node.
229
- * @see https://doc.babylonjs.com/features/featuresDeepDive/importers/glTF/glTFSkinning#ignoring-the-transform-of-the-skinned-mesh
240
+ * Defines if the Alpha blended materials are only applied as coverage.
241
+ * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
242
+ * If true, no extra effects are applied to transparent pixels.
230
243
  */
231
- abstract onSkinLoaded?: ((node: TransformNode, skinnedNode: TransformNode) => void) | undefined;
244
+ transparencyAsCoverage: boolean;
232
245
  /**
233
- * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
246
+ * Defines if the loader should also compile materials with clip planes. Defaults to false.
234
247
  */
235
- abstract onTextureLoaded?: ((texture: BaseTexture) => void) | undefined;
248
+ useClipPlane: boolean;
236
249
  /**
237
- * Callback raised when the loader creates a material after parsing the glTF properties of the material.
250
+ * If true, the loader will derive the name for Babylon textures from the glTF texture name, image name, or image url. Defaults to false.
251
+ * Note that it is possible for multiple Babylon textures to share the same name when the Babylon textures load from the same glTF texture or image.
238
252
  */
239
- abstract onMaterialLoaded?: ((material: Material) => void) | undefined;
253
+ useGltfTextureNames: boolean;
240
254
  /**
241
- * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
255
+ * Defines if the loader should use range requests when load binary glTF files from HTTP.
256
+ * Enabling will disable offline support and glTF validator.
257
+ * Defaults to false.
242
258
  */
243
- abstract onCameraLoaded?: ((camera: Camera) => void) | undefined;
259
+ useRangeRequests: boolean;
244
260
  /**
245
- * Defines options for glTF extensions.
261
+ * If true, load the color (gamma encoded) textures into sRGB buffers (if supported by the GPU), which will yield more accurate results when sampling the texture. Defaults to true.
246
262
  */
247
- extensionOptions: {
248
- [Extension in keyof GLTFLoaderExtensionOptions]?: {
249
- [Option in keyof DefaultExtensionOptions<GLTFLoaderExtensionOptions[Extension]>]: DefaultExtensionOptions<GLTFLoaderExtensionOptions[Extension]>[Option];
250
- };
251
- };
263
+ useSRGBBuffers: boolean;
264
+ /**
265
+ * Defines if the loader should validate the asset.
266
+ */
267
+ validate: boolean;
252
268
  }
253
269
  /**
254
270
  * File loader for loading glTF files into a scene.
@@ -390,17 +406,13 @@ export declare class GLTFFileLoader extends GLTFLoaderOptions implements IDispos
390
406
  */
391
407
  get capturePerformanceCounters(): boolean;
392
408
  set capturePerformanceCounters(value: boolean);
393
- /**
394
- * Defines if the loader should validate the asset.
395
- */
396
- validate: boolean;
397
409
  /**
398
410
  * Observable raised after validation when validate is set to true. The event data is the result of the validation.
399
411
  */
400
412
  readonly onValidatedObservable: Observable<GLTF2.IGLTFValidationResults>;
401
413
  private _onValidatedObserver;
402
414
  /**
403
- * Callback raised after a loader extension is created.
415
+ * Callback raised after the asset is validated.
404
416
  */
405
417
  set onValidated(callback: (results: GLTF2.IGLTFValidationResults) => void);
406
418
  private _loader;
@@ -86,130 +86,138 @@ class GLTFLoaderOptions {
86
86
  // V2 options
87
87
  // ----------
88
88
  /**
89
- * The coordinate system mode. Defaults to AUTO.
90
- */
91
- this.coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO;
92
- /**
93
- * The animation start mode. Defaults to FIRST.
94
- */
95
- this.animationStartMode = GLTFLoaderAnimationStartMode.FIRST;
96
- /**
97
- * Defines if the loader should load node animations. Defaults to true.
98
- * NOTE: The animation of this node will still load if the node is also a joint of a skin and `loadSkins` is true.
89
+ * Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false.
99
90
  */
100
- this.loadNodeAnimations = true;
91
+ this.alwaysComputeBoundingBox = false;
101
92
  /**
102
- * Defines if the loader should load skins. Defaults to true.
93
+ * Defines if the loader should always compute the nearest common ancestor of the skeleton joints instead of using `skin.skeleton`. Defaults to false.
94
+ * Set this to true if loading assets with invalid `skin.skeleton` values.
103
95
  */
104
- this.loadSkins = true;
96
+ this.alwaysComputeSkeletonRootNode = false;
105
97
  /**
106
- * Defines if the loader should load morph targets. Defaults to true.
98
+ * The animation start mode. Defaults to FIRST.
107
99
  */
108
- this.loadMorphTargets = true;
100
+ this.animationStartMode = GLTFLoaderAnimationStartMode.FIRST;
109
101
  /**
110
102
  * Defines if the loader should compile materials before raising the success callback. Defaults to false.
111
103
  */
112
104
  this.compileMaterials = false;
113
- /**
114
- * Defines if the loader should also compile materials with clip planes. Defaults to false.
115
- */
116
- this.useClipPlane = false;
117
105
  /**
118
106
  * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
119
107
  */
120
108
  this.compileShadowGenerators = false;
121
109
  /**
122
- * Defines if the Alpha blended materials are only applied as coverage.
123
- * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
124
- * If true, no extra effects are applied to transparent pixels.
125
- */
126
- this.transparencyAsCoverage = false;
127
- /**
128
- * Defines if the loader should use range requests when load binary glTF files from HTTP.
129
- * Enabling will disable offline support and glTF validator.
130
- * Defaults to false.
110
+ * The coordinate system mode. Defaults to AUTO.
131
111
  */
132
- this.useRangeRequests = false;
112
+ this.coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO;
133
113
  /**
134
114
  * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
135
115
  */
136
116
  this.createInstances = true;
137
117
  /**
138
- * Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false.
118
+ * Defines options for glTF extensions.
139
119
  */
140
- this.alwaysComputeBoundingBox = false;
120
+ this.extensionOptions = {};
141
121
  /**
142
122
  * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
143
123
  */
144
124
  this.loadAllMaterials = false;
125
+ /**
126
+ * Defines if the loader should load morph targets. Defaults to true.
127
+ */
128
+ this.loadMorphTargets = true;
129
+ /**
130
+ * Defines if the loader should load node animations. Defaults to true.
131
+ * NOTE: The animation of this node will still load if the node is also a joint of a skin and `loadSkins` is true.
132
+ */
133
+ this.loadNodeAnimations = true;
145
134
  /**
146
135
  * If true, load only the materials defined in the file. Defaults to false.
147
136
  */
148
137
  this.loadOnlyMaterials = false;
149
138
  /**
150
- * If true, do not load any materials defined in the file. Defaults to false.
139
+ * Defines if the loader should load skins. Defaults to true.
151
140
  */
152
- this.skipMaterials = false;
141
+ this.loadSkins = true;
153
142
  /**
154
- * If true, load the color (gamma encoded) textures into sRGB buffers (if supported by the GPU), which will yield more accurate results when sampling the texture. Defaults to true.
143
+ * Function called before loading a url referenced by the asset.
144
+ * @param url url referenced by the asset
145
+ * @returns Async url to load
155
146
  */
156
- this.useSRGBBuffers = true;
147
+ this.preprocessUrlAsync = (url) => Promise.resolve(url);
148
+ /**
149
+ * If true, do not load any materials defined in the file. Defaults to false.
150
+ */
151
+ this.skipMaterials = false;
157
152
  /**
158
153
  * When loading glTF animations, which are defined in seconds, target them to this FPS. Defaults to 60.
159
154
  */
160
155
  this.targetFps = 60;
161
156
  /**
162
- * Defines if the loader should always compute the nearest common ancestor of the skeleton joints instead of using `skin.skeleton`. Defaults to false.
163
- * Set this to true if loading assets with invalid `skin.skeleton` values.
157
+ * Defines if the Alpha blended materials are only applied as coverage.
158
+ * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
159
+ * If true, no extra effects are applied to transparent pixels.
164
160
  */
165
- this.alwaysComputeSkeletonRootNode = false;
161
+ this.transparencyAsCoverage = false;
162
+ /**
163
+ * Defines if the loader should also compile materials with clip planes. Defaults to false.
164
+ */
165
+ this.useClipPlane = false;
166
166
  /**
167
167
  * If true, the loader will derive the name for Babylon textures from the glTF texture name, image name, or image url. Defaults to false.
168
168
  * Note that it is possible for multiple Babylon textures to share the same name when the Babylon textures load from the same glTF texture or image.
169
169
  */
170
170
  this.useGltfTextureNames = false;
171
171
  /**
172
- * Function called before loading a url referenced by the asset.
173
- * @param url url referenced by the asset
174
- * @returns Async url to load
172
+ * Defines if the loader should use range requests when load binary glTF files from HTTP.
173
+ * Enabling will disable offline support and glTF validator.
174
+ * Defaults to false.
175
175
  */
176
- this.preprocessUrlAsync = (url) => Promise.resolve(url);
176
+ this.useRangeRequests = false;
177
177
  /**
178
- * Defines options for glTF extensions.
178
+ * If true, load the color (gamma encoded) textures into sRGB buffers (if supported by the GPU), which will yield more accurate results when sampling the texture. Defaults to true.
179
179
  */
180
- this.extensionOptions = {};
180
+ this.useSRGBBuffers = true;
181
+ /**
182
+ * Defines if the loader should validate the asset.
183
+ */
184
+ this.validate = false;
181
185
  }
182
186
  // eslint-disable-next-line babylonjs/available
183
187
  copyFrom(options) {
184
188
  if (options) {
185
- this.onParsed = options.onParsed;
186
- this.coordinateSystemMode = options.coordinateSystemMode ?? this.coordinateSystemMode;
189
+ this.alwaysComputeBoundingBox = options.alwaysComputeBoundingBox ?? this.alwaysComputeBoundingBox;
190
+ this.alwaysComputeSkeletonRootNode = options.alwaysComputeSkeletonRootNode ?? this.alwaysComputeSkeletonRootNode;
187
191
  this.animationStartMode = options.animationStartMode ?? this.animationStartMode;
188
- this.loadNodeAnimations = options.loadNodeAnimations ?? this.loadNodeAnimations;
189
- this.loadSkins = options.loadSkins ?? this.loadSkins;
190
- this.loadMorphTargets = options.loadMorphTargets ?? this.loadMorphTargets;
192
+ this.capturePerformanceCounters = options.capturePerformanceCounters ?? this.capturePerformanceCounters;
191
193
  this.compileMaterials = options.compileMaterials ?? this.compileMaterials;
192
- this.useClipPlane = options.useClipPlane ?? this.useClipPlane;
193
194
  this.compileShadowGenerators = options.compileShadowGenerators ?? this.compileShadowGenerators;
194
- this.transparencyAsCoverage = options.transparencyAsCoverage ?? this.transparencyAsCoverage;
195
- this.useRangeRequests = options.useRangeRequests ?? this.useRangeRequests;
195
+ this.coordinateSystemMode = options.coordinateSystemMode ?? this.coordinateSystemMode;
196
196
  this.createInstances = options.createInstances ?? this.createInstances;
197
- this.alwaysComputeBoundingBox = options.alwaysComputeBoundingBox ?? this.alwaysComputeBoundingBox;
197
+ this.customRootNode = options.customRootNode;
198
+ this.extensionOptions = options.extensionOptions ?? this.extensionOptions;
198
199
  this.loadAllMaterials = options.loadAllMaterials ?? this.loadAllMaterials;
200
+ this.loadMorphTargets = options.loadMorphTargets ?? this.loadMorphTargets;
201
+ this.loadNodeAnimations = options.loadNodeAnimations ?? this.loadNodeAnimations;
199
202
  this.loadOnlyMaterials = options.loadOnlyMaterials ?? this.loadOnlyMaterials;
200
- this.skipMaterials = options.skipMaterials ?? this.skipMaterials;
201
- this.useSRGBBuffers = options.useSRGBBuffers ?? this.useSRGBBuffers;
202
- this.targetFps = options.targetFps ?? this.targetFps;
203
- this.alwaysComputeSkeletonRootNode = options.alwaysComputeSkeletonRootNode ?? this.alwaysComputeSkeletonRootNode;
204
- this.useGltfTextureNames = options.useGltfTextureNames ?? this.useGltfTextureNames;
205
- this.preprocessUrlAsync = options.preprocessUrlAsync ?? this.preprocessUrlAsync;
206
- this.customRootNode = options.customRootNode;
203
+ this.loadSkins = options.loadSkins ?? this.loadSkins;
204
+ this.loggingEnabled = options.loggingEnabled ?? this.loggingEnabled;
205
+ this.onCameraLoaded = options.onCameraLoaded;
206
+ this.onMaterialLoaded = options.onMaterialLoaded;
207
207
  this.onMeshLoaded = options.onMeshLoaded;
208
+ this.onParsed = options.onParsed;
208
209
  this.onSkinLoaded = options.onSkinLoaded;
209
210
  this.onTextureLoaded = options.onTextureLoaded;
210
- this.onMaterialLoaded = options.onMaterialLoaded;
211
- this.onCameraLoaded = options.onCameraLoaded;
212
- this.extensionOptions = options.extensionOptions ?? this.extensionOptions;
211
+ this.onValidated = options.onValidated;
212
+ this.preprocessUrlAsync = options.preprocessUrlAsync ?? this.preprocessUrlAsync;
213
+ this.skipMaterials = options.skipMaterials ?? this.skipMaterials;
214
+ this.targetFps = options.targetFps ?? this.targetFps;
215
+ this.transparencyAsCoverage = options.transparencyAsCoverage ?? this.transparencyAsCoverage;
216
+ this.useClipPlane = options.useClipPlane ?? this.useClipPlane;
217
+ this.useGltfTextureNames = options.useGltfTextureNames ?? this.useGltfTextureNames;
218
+ this.useRangeRequests = options.useRangeRequests ?? this.useRangeRequests;
219
+ this.useSRGBBuffers = options.useSRGBBuffers ?? this.useSRGBBuffers;
220
+ this.validate = options.validate ?? this.validate;
213
221
  }
214
222
  }
215
223
  }
@@ -276,10 +284,6 @@ export class GLTFFileLoader extends GLTFLoaderOptions {
276
284
  * Set additional options for a loader extension in this event.
277
285
  */
278
286
  this.onExtensionLoadedObservable = new Observable();
279
- /**
280
- * Defines if the loader should validate the asset.
281
- */
282
- this.validate = false;
283
287
  /**
284
288
  * Observable raised after validation when validate is set to true. The event data is the result of the validation.
285
289
  */
@@ -453,7 +457,7 @@ export class GLTFFileLoader extends GLTFLoaderOptions {
453
457
  }
454
458
  }
455
459
  /**
456
- * Callback raised after a loader extension is created.
460
+ * Callback raised after the asset is validated.
457
461
  */
458
462
  set onValidated(callback) {
459
463
  if (this._onValidatedObserver) {