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) 1.91 kB
import{bK as e,aB as s,bH as r,bG as o}from"./index-yNtOWHHe.esm.min.js";import{GLTFLoader as a}from"./glTFLoader-DrZpsmpQ.esm.min.js";import"./bone-WlJTsCYz.esm.min.js";import"./skeleton-DrI_Z0uE.esm.min.js";import"./rawTexture-BOCcQuA1.esm.min.js";import"./assetContainer-Dkk4zkgP.esm.min.js";import"./objectModelMapping-DJGnHmCN.esm.min.js";const t="KHR_materials_pbrSpecularGlossiness";class i{constructor(e){this.name=t,this.order=200,this._loader=e,this.enabled=this._loader.isExtensionUsed(t)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,s,r){return a.LoadExtensionAsync(e,s,this.name,(async(o,a)=>{const t=new Array;return t.push(this._loader.loadMaterialBasePropertiesAsync(e,s,r)),t.push(this._loadSpecularGlossinessPropertiesAsync(o,a,r)),this._loader.loadMaterialAlphaProperties(e,s,r),await Promise.all(t).then((()=>{}))}))}_loadSpecularGlossinessPropertiesAsync(r,o,a){if(!(a instanceof e))throw new Error(`${r}: Material type not supported`);const t=new Array;return a.metallic=null,a.roughness=null,o.diffuseFactor?(a.albedoColor=s.FromArray(o.diffuseFactor),a.alpha=o.diffuseFactor[3]):a.albedoColor=s.White(),a.reflectivityColor=o.specularFactor?s.FromArray(o.specularFactor):s.White(),a.microSurface=null==o.glossinessFactor?1:o.glossinessFactor,o.diffuseTexture&&t.push(this._loader.loadTextureInfoAsync(`${r}/diffuseTexture`,o.diffuseTexture,(e=>{e.name=`${a.name} (Diffuse)`,a.albedoTexture=e}))),o.specularGlossinessTexture&&(t.push(this._loader.loadTextureInfoAsync(`${r}/specularGlossinessTexture`,o.specularGlossinessTexture,(e=>{e.name=`${a.name} (Specular Glossiness)`,a.reflectivityTexture=e,a.reflectivityTexture.hasAlpha=!0}))),a.useMicroSurfaceFromReflectivityMapAlpha=!0),Promise.all(t).then((()=>{}))}}r(t),o(t,!0,(e=>new i(e)));export{i as KHR_materials_pbrSpecularGlossiness}; //# sourceMappingURL=KHR_materials_pbrSpecularGlossiness-D_QHtLte.esm.min.js.map