babylonjs-loaders 9.7.0 → 9.9.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.
- package/babylon.glTF2FileLoader.js +1 -1
- package/babylon.glTF2FileLoader.js.map +1 -1
- package/babylon.glTF2FileLoader.min.js +1 -1
- package/babylon.glTF2FileLoader.min.js.map +1 -1
- package/babylon.glTFFileLoader.js +1 -1
- package/babylon.glTFFileLoader.js.map +1 -1
- package/babylon.glTFFileLoader.min.js +1 -1
- package/babylon.glTFFileLoader.min.js.map +1 -1
- package/babylonjs.loaders.d.ts +198 -20
- package/babylonjs.loaders.js +1 -1
- package/babylonjs.loaders.js.map +1 -1
- package/babylonjs.loaders.min.js +1 -1
- package/babylonjs.loaders.min.js.map +1 -1
- package/babylonjs.loaders.module.d.ts +402 -40
- package/package.json +3 -3
package/babylonjs.loaders.d.ts
CHANGED
|
@@ -638,6 +638,11 @@ declare namespace BABYLON.GLTF2 {
|
|
|
638
638
|
* Gets the underlying material
|
|
639
639
|
*/
|
|
640
640
|
get material(): PBRMaterial;
|
|
641
|
+
/**
|
|
642
|
+
* No-op: PBRMaterial has no deferred finalization.
|
|
643
|
+
* @param _loader Unused.
|
|
644
|
+
*/
|
|
645
|
+
finalizeAsync(_loader: BABYLON.GLTF2.GLTFLoader): Promise<void>;
|
|
641
646
|
/**
|
|
642
647
|
* Whether the material should be treated as unlit
|
|
643
648
|
*/
|
|
@@ -2053,10 +2058,9 @@ declare namespace BABYLON.GLTF2 {
|
|
|
2053
2058
|
set geometryCoatNormalTextureScale(value: number);
|
|
2054
2059
|
/**
|
|
2055
2060
|
* Finalizes material properties after all loading is complete.
|
|
2056
|
-
* @param
|
|
2057
|
-
* textures are disposed and the method returns early when aborted.
|
|
2061
|
+
* @param loader The glTF loader; `loader._disposed` is polled between texture passes to bail early on dispose.
|
|
2058
2062
|
*/
|
|
2059
|
-
finalizeAsync(
|
|
2063
|
+
finalizeAsync(loader: BABYLON.GLTF2.GLTFLoader): Promise<void>;
|
|
2060
2064
|
private copySurfaceToCoatAsync;
|
|
2061
2065
|
}
|
|
2062
2066
|
|
|
@@ -2077,20 +2081,17 @@ declare namespace BABYLON.GLTF2 {
|
|
|
2077
2081
|
* Gets the underlying material
|
|
2078
2082
|
*/
|
|
2079
2083
|
readonly material: Material;
|
|
2080
|
-
/** @deprecated Use finalizeAsync instead. */
|
|
2081
|
-
finalize?(): void;
|
|
2082
2084
|
/**
|
|
2083
2085
|
* Finalizes material properties after all loading is complete.
|
|
2084
|
-
* May
|
|
2085
|
-
*
|
|
2086
|
-
*
|
|
2086
|
+
* May do async work (e.g. GPU texture processing); the returned Promise is tracked
|
|
2087
|
+
* by the loader and awaited before the COMPLETE state is reached, so callers can rely
|
|
2088
|
+
* on onCompleteObservable for fully processed materials.
|
|
2087
2089
|
*
|
|
2088
|
-
*
|
|
2089
|
-
*
|
|
2090
|
-
*
|
|
2091
|
-
* @param signal An AbortSignal that fires when the loader is disposed mid-flight.
|
|
2090
|
+
* Implementations should check `loader._disposed` between awaits to bail out early
|
|
2091
|
+
* when the loader is disposed mid-flight.
|
|
2092
|
+
* @param loader The glTF loader driving the finalize step.
|
|
2092
2093
|
*/
|
|
2093
|
-
finalizeAsync
|
|
2094
|
+
finalizeAsync(loader: BABYLON.GLTF2.GLTFLoader): Promise<void>;
|
|
2094
2095
|
/**
|
|
2095
2096
|
* Whether the material should be treated as unlit
|
|
2096
2097
|
*/
|
|
@@ -3025,8 +3026,6 @@ declare namespace BABYLON.GLTF2 {
|
|
|
3025
3026
|
export class GLTFLoader implements IGLTFLoader {
|
|
3026
3027
|
/** @internal */
|
|
3027
3028
|
readonly _completePromises: Promise<unknown>[];
|
|
3028
|
-
/** AbortController used to cancel in-flight finalizeAsync() calls when dispose() is called. */
|
|
3029
|
-
private _finalizeController;
|
|
3030
3029
|
/** @internal */
|
|
3031
3030
|
_assetContainer: Nullable<AssetContainer>;
|
|
3032
3031
|
/** Storage */
|
|
@@ -3039,7 +3038,8 @@ declare namespace BABYLON.GLTF2 {
|
|
|
3039
3038
|
_skipStartAnimationStep: boolean;
|
|
3040
3039
|
private readonly _parent;
|
|
3041
3040
|
private readonly _extensions;
|
|
3042
|
-
|
|
3041
|
+
/** @internal */
|
|
3042
|
+
_disposed: boolean;
|
|
3043
3043
|
private _rootUrl;
|
|
3044
3044
|
private _fileName;
|
|
3045
3045
|
private _uniqueRootUrl;
|
|
@@ -3051,12 +3051,17 @@ declare namespace BABYLON.GLTF2 {
|
|
|
3051
3051
|
private readonly _postSceneLoadActions;
|
|
3052
3052
|
private readonly _materialAdapterCache;
|
|
3053
3053
|
private readonly _materialAdapters;
|
|
3054
|
-
/** @internal */
|
|
3055
|
-
_pbrMaterialImpl: Nullable<Readonly<PBRMaterialImplementation>> | false;
|
|
3056
3054
|
/**
|
|
3057
|
-
*
|
|
3055
|
+
* Loaded PBR material implementations, keyed by their identifier (e.g. "pbr", "openpbr").
|
|
3056
|
+
* Only populated after the load has started and only for the types actually needed by the asset.
|
|
3057
|
+
* Empty when PBR materials are disabled (skipMaterials).
|
|
3058
|
+
* @internal
|
|
3059
|
+
*/
|
|
3060
|
+
readonly _pbrMaterialImpls: Map<string, Readonly<PBRMaterialImplementation>>;
|
|
3061
|
+
/**
|
|
3062
|
+
* Test if the given material is an instance of any PBR material type known to this loader.
|
|
3058
3063
|
* @param material The material to test
|
|
3059
|
-
* @returns true if the material
|
|
3064
|
+
* @returns true if the material matches one of the loaded PBR implementations
|
|
3060
3065
|
*/
|
|
3061
3066
|
isMatchingMaterialType(material: Nullable<Material>): boolean;
|
|
3062
3067
|
/**
|
|
@@ -3251,6 +3256,21 @@ declare namespace BABYLON.GLTF2 {
|
|
|
3251
3256
|
* @internal
|
|
3252
3257
|
*/
|
|
3253
3258
|
_loadMaterialAsync(context: string, material: BABYLON.GLTF2.Loader.IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
|
|
3259
|
+
/**
|
|
3260
|
+
* Selects the appropriate PBR material implementation for a given glTF material.
|
|
3261
|
+
* Uses OpenPBR when the material carries a "KHR_materials_openpbr" extension or when
|
|
3262
|
+
* the loader-level `useOpenPBR` flag is set; falls back to standard PBR otherwise.
|
|
3263
|
+
* @param material The glTF material
|
|
3264
|
+
* @returns The matching loaded implementation
|
|
3265
|
+
*/
|
|
3266
|
+
private _selectImplForGltfMaterial;
|
|
3267
|
+
/**
|
|
3268
|
+
* Returns the default PBR material implementation used when there is no per-material
|
|
3269
|
+
* selection context (e.g. when creating the built-in default material for primitives
|
|
3270
|
+
* that have no glTF material assigned). Prefers OpenPBR when `useOpenPBR` is set.
|
|
3271
|
+
* @returns The default loaded implementation
|
|
3272
|
+
*/
|
|
3273
|
+
private _getDefaultImpl;
|
|
3254
3274
|
private _createDefaultMaterial;
|
|
3255
3275
|
/**
|
|
3256
3276
|
* Creates a Babylon material from a glTF material.
|
|
@@ -3406,6 +3426,164 @@ declare namespace BABYLON.GLTF2 {
|
|
|
3406
3426
|
|
|
3407
3427
|
|
|
3408
3428
|
|
|
3429
|
+
}
|
|
3430
|
+
declare namespace BABYLON {
|
|
3431
|
+
|
|
3432
|
+
|
|
3433
|
+
}
|
|
3434
|
+
declare namespace BABYLON.GLTF2.Loader.Extensions {
|
|
3435
|
+
/**
|
|
3436
|
+
* Describes a material class and its corresponding loading adapter.
|
|
3437
|
+
* Passed to TransmissionHelper so it can classify and interact with materials
|
|
3438
|
+
* independently of any specific loader instance.
|
|
3439
|
+
*/
|
|
3440
|
+
export interface ITransmissionHelperMaterialImpl {
|
|
3441
|
+
/** The material class constructor */
|
|
3442
|
+
materialClass: typeof Material;
|
|
3443
|
+
/** The adapter class constructor */
|
|
3444
|
+
adapterClass: new (material: Material) => BABYLON.GLTF2.IMaterialLoadingAdapter;
|
|
3445
|
+
}
|
|
3446
|
+
/**
|
|
3447
|
+
* @internal
|
|
3448
|
+
*/
|
|
3449
|
+
export interface ITransmissionHelperHolder {
|
|
3450
|
+
/** The transmission helper instance, if created on the scene */
|
|
3451
|
+
_transmissionHelper: TransmissionHelper | undefined;
|
|
3452
|
+
}
|
|
3453
|
+
/**
|
|
3454
|
+
* Options for the TransmissionHelper.
|
|
3455
|
+
*/
|
|
3456
|
+
export interface ITransmissionHelperOptions {
|
|
3457
|
+
/**
|
|
3458
|
+
* The size of the render buffers (default: 1024)
|
|
3459
|
+
*/
|
|
3460
|
+
renderSize: number;
|
|
3461
|
+
/**
|
|
3462
|
+
* The number of samples to use when generating the render target texture for opaque meshes (default: 4)
|
|
3463
|
+
*/
|
|
3464
|
+
samples: number;
|
|
3465
|
+
/**
|
|
3466
|
+
* Scale to apply when selecting the LOD level to sample the refraction texture (default: 1)
|
|
3467
|
+
*/
|
|
3468
|
+
lodGenerationScale: number;
|
|
3469
|
+
/**
|
|
3470
|
+
* Offset to apply when selecting the LOD level to sample the refraction texture (default: -4)
|
|
3471
|
+
*/
|
|
3472
|
+
lodGenerationOffset: number;
|
|
3473
|
+
/**
|
|
3474
|
+
* Type of the refraction render target texture (default: TEXTURETYPE_HALF_FLOAT)
|
|
3475
|
+
*/
|
|
3476
|
+
renderTargetTextureType: number;
|
|
3477
|
+
/**
|
|
3478
|
+
* Defines if the mipmaps for the refraction render target texture must be generated (default: true)
|
|
3479
|
+
*/
|
|
3480
|
+
generateMipmaps: boolean;
|
|
3481
|
+
/**
|
|
3482
|
+
* Clear color of the opaque texture. If not provided, use the scene clear color (which will be converted to linear space).
|
|
3483
|
+
* If provided, should be in linear space
|
|
3484
|
+
*/
|
|
3485
|
+
clearColor?: Color4;
|
|
3486
|
+
}
|
|
3487
|
+
/**
|
|
3488
|
+
* A class to handle setting up the rendering of opaque objects to be shown through transmissive objects.
|
|
3489
|
+
* @internal
|
|
3490
|
+
*/
|
|
3491
|
+
export class TransmissionHelper {
|
|
3492
|
+
/**
|
|
3493
|
+
* Creates the default options for the helper.
|
|
3494
|
+
* @returns the default options
|
|
3495
|
+
*/
|
|
3496
|
+
private static _GetDefaultOptions;
|
|
3497
|
+
private readonly _scene;
|
|
3498
|
+
private _options;
|
|
3499
|
+
private _opaqueRenderTarget;
|
|
3500
|
+
private _opaqueMeshesCache;
|
|
3501
|
+
private _transparentMeshesCache;
|
|
3502
|
+
private _materialObservers;
|
|
3503
|
+
private readonly _materialImpls;
|
|
3504
|
+
private readonly _adapterCache;
|
|
3505
|
+
/**
|
|
3506
|
+
* This observable will be notified with any error during the creation of the environment,
|
|
3507
|
+
* mainly texture creation errors.
|
|
3508
|
+
*/
|
|
3509
|
+
onErrorObservable: Observable<{
|
|
3510
|
+
message?: string;
|
|
3511
|
+
exception?: any;
|
|
3512
|
+
}>;
|
|
3513
|
+
private _translucentMaterialIndices;
|
|
3514
|
+
private _opaqueOnlySubMeshes;
|
|
3515
|
+
private _savedSubMeshes;
|
|
3516
|
+
/**
|
|
3517
|
+
* constructor
|
|
3518
|
+
* @param options Defines the options we want to customize the helper
|
|
3519
|
+
* @param scene The scene to add the material to
|
|
3520
|
+
*/
|
|
3521
|
+
constructor(options: Partial<ITransmissionHelperOptions>, scene: Scene);
|
|
3522
|
+
/**
|
|
3523
|
+
* Registers a material implementation with the helper so it can classify and create
|
|
3524
|
+
* adapters for materials of that type. Safe to call multiple times with the same
|
|
3525
|
+
* implementation — duplicates are ignored.
|
|
3526
|
+
* @param impl The material implementation to register
|
|
3527
|
+
*/
|
|
3528
|
+
addMaterialImpl(impl: ITransmissionHelperMaterialImpl): void;
|
|
3529
|
+
/**
|
|
3530
|
+
* Updates the helper options.
|
|
3531
|
+
* @param options the options to update
|
|
3532
|
+
*/
|
|
3533
|
+
updateOptions(options: Partial<ITransmissionHelperOptions>): void;
|
|
3534
|
+
/**
|
|
3535
|
+
* @returns the opaque render target texture or null if not available.
|
|
3536
|
+
*/
|
|
3537
|
+
getOpaqueTarget(): Nullable<Texture>;
|
|
3538
|
+
private _getOrCreateAdapter;
|
|
3539
|
+
/**
|
|
3540
|
+
* Classify a mesh's materials as transparent, opaque, or mixed.
|
|
3541
|
+
* Sets the refraction background texture on any translucent materials found.
|
|
3542
|
+
* For mixed MultiMaterial meshes, populates _translucentMaterialIndices so
|
|
3543
|
+
* their translucent submeshes can be excluded from the opaque render target.
|
|
3544
|
+
* @param mesh - The mesh to classify
|
|
3545
|
+
* @returns 'transparent' if all materials are translucent, 'opaque' if none are, 'mixed' if both
|
|
3546
|
+
*/
|
|
3547
|
+
private _classifyMeshMaterials;
|
|
3548
|
+
/**
|
|
3549
|
+
* Rebuild the cached opaque-only submesh array for a mixed mesh.
|
|
3550
|
+
* Called when classification changes so the per-frame swap is allocation-free.
|
|
3551
|
+
* @param mesh - The mesh to rebuild for
|
|
3552
|
+
* @param translucentIndices - Set of materialIndex values that are translucent
|
|
3553
|
+
*/
|
|
3554
|
+
private _rebuildOpaqueOnlySubMeshes;
|
|
3555
|
+
private _addMesh;
|
|
3556
|
+
private _removeMesh;
|
|
3557
|
+
private _parseScene;
|
|
3558
|
+
private _onMeshMaterialChanged;
|
|
3559
|
+
/**
|
|
3560
|
+
* @internal
|
|
3561
|
+
* Check if the opaque render target has not been disposed and can still be used.
|
|
3562
|
+
* @returns
|
|
3563
|
+
*/
|
|
3564
|
+
_isRenderTargetValid(): boolean;
|
|
3565
|
+
/**
|
|
3566
|
+
* @internal
|
|
3567
|
+
* Setup the render targets according to the specified options.
|
|
3568
|
+
*/
|
|
3569
|
+
_setupRenderTargets(): void;
|
|
3570
|
+
/**
|
|
3571
|
+
* Dispose all the elements created by the Helper.
|
|
3572
|
+
*/
|
|
3573
|
+
dispose(): void;
|
|
3574
|
+
}
|
|
3575
|
+
/**
|
|
3576
|
+
* Ensures a TransmissionHelper exists on the scene and has all of the loader's material
|
|
3577
|
+
* implementations registered with it. Creates the helper if one does not yet exist on the
|
|
3578
|
+
* scene, and recreates its render target if it has been disposed. Does nothing when the
|
|
3579
|
+
* loader's parent has `dontUseTransmissionHelper` set.
|
|
3580
|
+
* @param loader The glTF loader whose material implementations should be registered
|
|
3581
|
+
* @param babylonMaterial A material belonging to the scene where the helper should live
|
|
3582
|
+
*/
|
|
3583
|
+
export function ensureTransmissionHelper(loader: BABYLON.GLTF2.GLTFLoader, babylonMaterial: Material): void;
|
|
3584
|
+
|
|
3585
|
+
|
|
3586
|
+
|
|
3409
3587
|
}
|
|
3410
3588
|
declare namespace BABYLON {
|
|
3411
3589
|
|