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.95 kB
import{bM as e,bJ as s,bI as t}from"./index-Bw2N6w1y.esm.min.js";import{GLTFLoader as n}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_volume";class r{constructor(e){this.name=o,this.order=173,this._loader=e,this.enabled=this._loader.isExtensionUsed(o),this.enabled&&this._loader._disableInstancedMesh++}dispose(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null}loadMaterialPropertiesAsync(e,s,t){return n.LoadExtensionAsync(e,s,this.name,(async(n,o)=>{const r=new Array;return r.push(this._loader.loadMaterialPropertiesAsync(e,s,t)),r.push(this._loadVolumePropertiesAsync(n,s,t,o)),await Promise.all(r).then((()=>{}))}))}_loadVolumePropertiesAsync(s,t,n,o){if(!(n instanceof e))throw new Error(`${s}: Material type not supported`);if(!n.subSurface.isRefractionEnabled&&!n.subSurface.isTranslucencyEnabled||!o.thicknessFactor)return Promise.resolve();n.subSurface.volumeIndexOfRefraction=n.indexOfRefraction;const r=void 0!==o.attenuationDistance?o.attenuationDistance:Number.MAX_VALUE;return n.subSurface.tintColorAtDistance=r,void 0!==o.attenuationColor&&3==o.attenuationColor.length&&n.subSurface.tintColor.copyFromFloats(o.attenuationColor[0],o.attenuationColor[1],o.attenuationColor[2]),n.subSurface.minimumThickness=0,n.subSurface.maximumThickness=o.thicknessFactor,n.subSurface.useThicknessAsDepth=!0,o.thicknessTexture?(o.thicknessTexture.nonColorData=!0,this._loader.loadTextureInfoAsync(`${s}/thicknessTexture`,o.thicknessTexture).then((e=>{e.name=`${n.name} (Thickness)`,n.subSurface.thicknessTexture=e,n.subSurface.useGltfStyleTextures=!0}))):Promise.resolve()}}s(o),t(o,!0,(e=>new r(e)));export{r as KHR_materials_volume}; //# sourceMappingURL=KHR_materials_volume-S2FPh0al.esm.min.js.map