UNPKG

@babylonjs/loaders

Version:

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

41 lines 1.76 kB
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js"; import { GLTFLoader } from "../glTFLoader.js"; import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry.js"; const NAME = "MSFT_minecraftMesh"; /** @internal */ // eslint-disable-next-line @typescript-eslint/naming-convention export class MSFT_minecraftMesh { /** @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); if (babylonMaterial.needAlphaBlending()) { babylonMaterial.forceDepthWrite = true; babylonMaterial.separateCullingPass = true; } babylonMaterial.backFaceCulling = babylonMaterial.forceDepthWrite; babylonMaterial.twoSidedLighting = true; return await promise; } }); } } unregisterGLTFExtension(NAME); registerGLTFExtension(NAME, true, (loader) => new MSFT_minecraftMesh(loader)); //# sourceMappingURL=MSFT_minecraftMesh.js.map