UNPKG

@babylonjs/viewer

Version:

The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.

3 lines (2 loc) 2.22 kB
import{bM as e,bJ as a,bI as r}from"./index-Bw2N6w1y.esm.min.js";import{GLTFLoader as t}from"./glTFLoader-DEYqxGxH.esm.min.js";import"./bone-BwMp7T0B.esm.min.js";import"./skeleton-CkTZwWbM.esm.min.js";import"./rawTexture-CPAqHIA7.esm.min.js";import"./assetContainer-21j7tcC8.esm.min.js";import"./objectModelMapping-DX92iJ8M.esm.min.js";const o="KHR_materials_clearcoat";class s{constructor(e){this.name=o,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(o)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,a,r){return t.LoadExtensionAsync(e,a,this.name,(async(t,o)=>{const s=new Array;s.push(this._loader.loadMaterialPropertiesAsync(e,a,r)),s.push(this._loadClearCoatPropertiesAsync(t,o,r)),await Promise.all(s)}))}_loadClearCoatPropertiesAsync(a,r,t){if(!(t instanceof e))throw new Error(`${a}: Material type not supported`);const o=new Array;return t.clearCoat.isEnabled=!0,t.clearCoat.useRoughnessFromMainTexture=!1,t.clearCoat.remapF0OnInterfaceChange=!1,null!=r.clearcoatFactor?t.clearCoat.intensity=r.clearcoatFactor:t.clearCoat.intensity=0,r.clearcoatTexture&&o.push(this._loader.loadTextureInfoAsync(`${a}/clearcoatTexture`,r.clearcoatTexture,(e=>{e.name=`${t.name} (ClearCoat)`,t.clearCoat.texture=e}))),null!=r.clearcoatRoughnessFactor?t.clearCoat.roughness=r.clearcoatRoughnessFactor:t.clearCoat.roughness=0,r.clearcoatRoughnessTexture&&(r.clearcoatRoughnessTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync(`${a}/clearcoatRoughnessTexture`,r.clearcoatRoughnessTexture,(e=>{e.name=`${t.name} (ClearCoat Roughness)`,t.clearCoat.textureRoughness=e})))),r.clearcoatNormalTexture&&(r.clearcoatNormalTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync(`${a}/clearcoatNormalTexture`,r.clearcoatNormalTexture,(e=>{e.name=`${t.name} (ClearCoat Normal)`,t.clearCoat.bumpTexture=e}))),t.invertNormalMapX=!t.getScene().useRightHandedSystem,t.invertNormalMapY=t.getScene().useRightHandedSystem,null!=r.clearcoatNormalTexture.scale&&(t.clearCoat.bumpTexture.level=r.clearcoatNormalTexture.scale)),Promise.all(o).then((()=>{}))}}a(o),r(o,!0,(e=>new s(e)));export{s as KHR_materials_clearcoat}; //# sourceMappingURL=KHR_materials_clearcoat-pQoP7Y8N.esm.min.js.map