UNPKG

@babylonjs/loaders

Version:

For usage documentation please visit https://doc.babylonjs.com/features/featuresDeepDive/importers/loadingFileTypes/.

42 lines 1.93 kB
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js"; import { GLTFLoader } from "../glTFLoader.js"; import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry.js"; const NAME = "MSFT_sRGBFactors"; /** @internal */ // eslint-disable-next-line @typescript-eslint/naming-convention export class MSFT_sRGBFactors { /** @internal */ constructor(loader) { /** @internal */ this.name = NAME; this._loader = loader; this.enabled = this._loader.isExtensionUsed(NAME); } /** @internal */ dispose() { this._loader = null; } /** @internal*/ // eslint-disable-next-line no-restricted-syntax loadMaterialPropertiesAsync(context, material, babylonMaterial) { return GLTFLoader.LoadExtraAsync(context, material, this.name, async (extraContext, extra) => { if (extra) { if (!(babylonMaterial instanceof PBRMaterial)) { throw new Error(`${extraContext}: Material type not supported`); } const promise = this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial); const useExactSrgbConversions = babylonMaterial.getScene().getEngine().useExactSrgbConversions; if (!babylonMaterial.albedoTexture) { babylonMaterial.albedoColor.toLinearSpaceToRef(babylonMaterial.albedoColor, useExactSrgbConversions); } if (!babylonMaterial.reflectivityTexture) { babylonMaterial.reflectivityColor.toLinearSpaceToRef(babylonMaterial.reflectivityColor, useExactSrgbConversions); } return await promise; } }); } } unregisterGLTFExtension(NAME); registerGLTFExtension(NAME, true, (loader) => new MSFT_sRGBFactors(loader)); //# sourceMappingURL=MSFT_sRGBFactors.js.map