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) 21.8 kB
import{b1 as e,C as t,i as s}from"./index-BPURObVq.esm.min.js";import{P as r}from"./proceduralTexture.pure-Cev_FPRk.esm.min.js";var i,a,o;function n(e,t,s,r){const i={texture:e,factor:t};return s&&(i.channel=s),r&&(i.colorSpace=r),i}function u(t){return t.factor??new e(1,1,1,1)}function l(e){let t=0,s=512;for(const r of e)if(r.texture){const e=r.texture.getSize(),i=Math.max(e.width,e.height);i>t&&(t=i,s=e.width===e.height?i:e)}return s}function h(e){return!e.getTextureMatrix().isIdentity()}function c(e){if(e.length<=1)return!0;const t=e[0].getTextureMatrix();for(let s=1;s<e.length;s++)if(!t.equals(e[s].getTextureMatrix()))return!1;return!0}function m(e,t,s){if(t.coordinatesIndex=e.coordinatesIndex,t.wrapU=e.wrapU,t.wrapV=e.wrapV,s){const s=e;t.uOffset=s.uOffset??0,t.vOffset=s.vOffset??0,t.uScale=s.uScale??1,t.vScale=s.vScale??1,t.wAng=s.wAng??0}}function g(e){switch(e){case o.R:return"R";case o.G:return"G";case o.B:return"B";case o.A:return"A";default:return""}}function _(e){const t=["OP_INVERT"];return e&a.R&&t.push("INVERT_R"),e&a.G&&t.push("INVERT_G"),e&a.B&&t.push("INVERT_B"),e&a.A&&t.push("INVERT_A"),t}function T(e){const t=[];return e&a.R||t.push("OUTPUT_MASK_R_ZERO"),e&a.G||t.push("OUTPUT_MASK_G_ZERO"),e&a.B||t.push("OUTPUT_MASK_B_ZERO"),e&a.A||t.push("OUTPUT_MASK_A_ONE"),t}function x(t,s){return new e(s&a.R?t.r:0,s&a.G?t.g:0,s&a.B?t.b:0,s&a.A?t.a:1)}function f(e,t,s){const r=[];return e.texture&&(r.push(`OPERAND_${t}_TEXTURE`),s&&h(e.texture)&&r.push(`OPERAND_${t}_MATRIX`),e.colorSpace&&r.push(`OPERAND_${t}_SRGB`),e.channel&&r.push(`OPERAND_${t}_CHANNEL_${g(e.channel)}`)),void 0===e.factor&&e.texture||r.push(`OPERAND_${t}_FACTOR`),r}function p(e,t){const s=[];return e.texture&&(s.push("LERP_T_TEXTURE"),t&&h(e.texture)&&s.push("LERP_T_MATRIX"),void 0!==e.factor&&s.push("LERP_T_FACTOR"),e.colorSpace&&s.push("LERP_T_SRGB"),e.channel&&s.push(`LERP_T_CHANNEL_${g(e.channel)}`)),s}function R(e,t,s,r,i){t.texture&&(e.setTexture(s,t.texture),i&&h(t.texture)&&e.setMatrix(`${s}Matrix`,t.texture.getTextureMatrix()));(void 0!==t.factor||!t.texture)&&e.setColor4(r,u(t))}function d(e,s,a,o,n=i.Linear){const u={type:t.TEXTURETYPE_UNSIGNED_BYTE,format:t.TEXTUREFORMAT_RGBA,samplingMode:t.TEXTURE_BILINEAR_SAMPLINGMODE,generateDepthBuffer:!1,generateMipMaps:!1,gammaSpace:n===i.SRGB,shaderLanguage:o.getEngine().isWebGPU?1:0,extraInitializationsAsync:async()=>{o.getEngine().isWebGPU?await Promise.all([import("./textureProcessor.fragment-Bc0j12X8.esm.min.js")]):await Promise.all([import("./textureProcessor.fragment-DFKl1MD_.esm.min.js")])},skipSceneRegistration:!0},l=new r(e,a,"textureProcessor",o,u);return l.refreshRate=-1,l.defines=s.length>0?"#define "+s.join("\n#define ")+"\n":"",l}async function C(e){return await new Promise((t,s)=>{e.executeWhenReady(()=>{try{e.render(),t()}catch(e){s(e instanceof Error?e:new Error(String(e)))}})})}async function A(t,s,r,i,a,o){if(!s.texture&&!r.texture){const t=function(t,s){return new e(t.r*s.r,t.g*s.g,t.b*s.b,t.a*s.a)}(u(s),u(r));return{texture:null,factor:o?x(t,o):t}}const n=[];s.texture&&n.push(s.texture),r.texture&&n.push(r.texture);const h=c(n),g=!h,_=[...f(s,"A",g),...f(r,"B",g),...o?T(o):[]];a&&_.push("OUTPUT_SRGB");const p=d(t,_,l([s,r]),i,a);R(p,s,"textureA","factorA",g),R(p,r,"textureB","factorB",g);try{await C(p)}catch(e){throw s.dispose?.(),r.dispose?.(),e}s.dispose?.(),r.dispose?.(),m(n[0],p,h);const A={texture:p,dispose:()=>p.dispose()};return a&&(A.colorSpace=a),A}async function b(t,s,r,i,a,o,n){if(!s.texture&&!r.texture&&!i.texture){const t=function(t,s,r){return new e(t.r+(s.r-t.r)*r.r,t.g+(s.g-t.g)*r.g,t.b+(s.b-t.b)*r.b,t.a+(s.a-t.a)*r.a)}(u(s),u(r),u(i));return{texture:null,factor:n?x(t,n):t}}const g=[];s.texture&&g.push(s.texture),r.texture&&g.push(r.texture),i.texture&&g.push(i.texture);const _=c(g),A=!_,b=["OP_LERP",...f(s,"A",A),...f(r,"B",A),...p(i,A),...n?T(n):[]];o&&b.push("OUTPUT_SRGB");const y=d(t,b,l([s,r,i]),a,o);R(y,s,"textureA","factorA",A),R(y,r,"textureB","factorB",A),function(e,t,s){t.texture?(e.setTexture("textureT",t.texture),s&&h(t.texture)&&e.setMatrix("textureTMatrix",t.texture.getTextureMatrix()),void 0!==t.factor&&e.setColor4("factorT",t.factor)):e.setColor4("factorT",u(t))}(y,i,A);try{await C(y)}catch(e){throw s.dispose?.(),r.dispose?.(),i.dispose?.(),e}s.dispose?.(),r.dispose?.(),i.dispose?.(),m(g[0],y,_);const S={texture:y,dispose:()=>y.dispose()};return o&&(S.colorSpace=o),S}async function y(t,s,r,i,a,n){if(!s.texture){const t=function(t,s){switch(s){case o.R:return new e(t.r,t.r,t.r,t.a);case o.G:return new e(t.g,t.g,t.g,t.a);case o.B:return new e(t.b,t.b,t.b,t.a);case o.A:return new e(t.a,t.a,t.a,t.a);default:return t}}(u(s),r);return{texture:null,factor:n?x(t,n):t}}return await A(t,{...s,channel:r},(l=new e(1,1,1,1),{texture:null,factor:l}),i,a,n);var l}!function(e){e[e.Linear=0]="Linear",e[e.SRGB=1]="SRGB"}(i||(i={})),function(e){e[e.R=1]="R",e[e.G=2]="G",e[e.B=4]="B",e[e.A=8]="A",e[e.RGB=7]="RGB",e[e.RGBA=15]="RGBA"}(a||(a={})),function(e){e[e.RGBA=0]="RGBA",e[e.R=1]="R",e[e.G=2]="G",e[e.B=3]="B",e[e.A=4]="A"}(o||(o={}));class S{constructor(e){this._specWorkflow=!1,this._diffuseTransmissionTint=s.White(),this._diffuseTransmissionTintTexture=null,this._material=e}get material(){return this._material}get isUnlit(){return this._material.unlit}set isUnlit(e){this._material.unlit=e}set backFaceCulling(e){this._material.backFaceCulling=e}get backFaceCulling(){return this._material.backFaceCulling}set twoSidedLighting(e){this._material.twoSidedLighting=e}get twoSidedLighting(){return this._material.twoSidedLighting}set alphaCutOff(e){this._material.alphaCutOff=e}get alphaCutOff(){return this._material.alphaCutOff}set useAlphaFromBaseColorTexture(e){this._material._useAlphaFromBaseColorTexture=e}get useAlphaFromBaseColorTexture(){return this._material._useAlphaFromBaseColorTexture}get transparencyAsAlphaCoverage(){return!1}set transparencyAsAlphaCoverage(e){}set baseColor(e){this._material.baseColor=e}get baseColor(){return this._material.baseColor}set baseColorTexture(e){this._material.baseColorTexture=e}get baseColorTexture(){return this._material.baseColorTexture}set baseDiffuseRoughness(e){this._material.baseDiffuseRoughness=e}get baseDiffuseRoughness(){return this._material.baseDiffuseRoughness}set baseDiffuseRoughnessTexture(e){this._material.baseDiffuseRoughnessTexture=e}get baseDiffuseRoughnessTexture(){return this._material.baseDiffuseRoughnessTexture}set baseMetalness(e){this._material.baseMetalness=e}get baseMetalness(){return this._material.baseMetalness}set baseMetalnessTexture(e){this._material.baseMetalnessTexture=e}get baseMetalnessTexture(){return this._material.baseMetalnessTexture}set useRoughnessFromMetallicTextureGreen(e){this._material._useRoughnessFromMetallicTextureGreen=e}set useMetallicFromMetallicTextureBlue(e){this._material._useMetallicFromMetallicTextureBlue=e}enableSpecularEdgeColor(e=!1){}configureSpecularGlossiness(){this._specWorkflow=!0}set specularWeight(e){this._material.specularWeight=e}get specularWeight(){return this._material.specularWeight}set specularWeightTexture(e){this._material.specularColorTexture===e?(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0):this._material.specularWeightTexture=e}get specularWeightTexture(){return this._material.specularWeightTexture}set specularColor(e){this._material.specularColor=e}get specularColor(){return this._material.specularColor}set specularColorTexture(e){this._material.specularColorTexture=e,this._material.specularWeightTexture===this._material.specularColorTexture&&(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0)}get specularColorTexture(){return this._material.specularColorTexture}set specularRoughness(e){this._material.specularRoughness=e}get specularRoughness(){return this._material.specularRoughness}set specularRoughnessTexture(e){this._material.specularRoughnessTexture=e}get specularRoughnessTexture(){return this._material.specularRoughnessTexture}set specularIor(e){this._material.specularIor=e}get specularIor(){return this._material.specularIor}set glossiness(e){this._material.specularRoughness=Math.max(1-e,0)}get glossiness(){return 1-this._material.specularRoughness}set emissionColor(e){this._material.emissionColor=e}get emissionColor(){return this._material.emissionColor}set emissionLuminance(e){this._material.emissionLuminance=e}get emissionLuminance(){return this._material.emissionLuminance}set emissionColorTexture(e){this._material.emissionColorTexture=e}get emissionColorTexture(){return this._material.emissionColorTexture}set ambientOcclusionTexture(e){this._material.ambientOcclusionTexture=e}get ambientOcclusionTexture(){return this._material.ambientOcclusionTexture}set ambientOcclusionTextureStrength(e){const t=this._material.ambientOcclusionTexture;t&&(t.level=e)}get ambientOcclusionTextureStrength(){const e=this._material.ambientOcclusionTexture;return e?.level??1}configureCoat(){}set coatWeight(e){this._material.coatWeight=e}get coatWeight(){return this._material.coatWeight}set coatWeightTexture(e){this._material.coatWeightTexture=e}get coatWeightTexture(){return this._material.coatWeightTexture}set coatColor(e){this._material.coatColor=e}get coatColor(){return this._material.coatColor}set coatColorTexture(e){this._material.coatColorTexture=e}set coatRoughness(e){this._material.coatRoughness=e}get coatRoughness(){return this._material.coatRoughness}set coatRoughnessTexture(e){this._material.coatRoughnessTexture=e,e&&(this._material._useCoatRoughnessFromGreenChannel=!0)}get coatRoughnessTexture(){return this._material.coatRoughnessTexture}set coatIor(e){this._material.coatIor=e}get coatIor(){return this._material.coatIor}set coatDarkening(e){this._material.coatDarkening=e}get coatDarkening(){return this._material.coatDarkening}set coatDarkeningTexture(e){this._material.coatDarkeningTexture=e}set coatRoughnessAnisotropy(e){this._material.coatRoughnessAnisotropy=e}get coatRoughnessAnisotropy(){return this._material.coatRoughnessAnisotropy}set geometryCoatTangentAngle(e){this._material.geometryCoatTangentAngle=e}set geometryCoatTangentTexture(e){this._material.geometryCoatTangentTexture=e,e&&(this._material._useCoatRoughnessAnisotropyFromTangentTexture=!0)}get geometryCoatTangentTexture(){return this._material.geometryCoatTangentTexture}configureTransmission(){this._material.geometryThinWalled=1,this._material.transmissionDepth=0}set transmissionWeight(e){this._material.transmissionWeight=e}set transmissionWeightTexture(e){this._material.transmissionWeightTexture=e}get transmissionWeightTexture(){return this._material.transmissionWeightTexture}get transmissionWeight(){return this._material.transmissionWeight}set transmissionScatter(e){this._material.transmissionScatter=e}get transmissionScatter(){return this._material.transmissionScatter}set transmissionScatterTexture(e){this._material.transmissionScatterTexture=e}get transmissionScatterTexture(){return this._material.transmissionScatterTexture}set transmissionScatterAnisotropy(e){this._material.transmissionScatterAnisotropy=e}set transmissionDispersionAbbeNumber(e){this._material.transmissionDispersionAbbeNumber=e}set transmissionDispersionScale(e){this._material.transmissionDispersionScale=e}set transmissionDepth(e){e!==Number.MAX_VALUE||0!==this._material.transmissionDepth?this._material.transmissionDepth=e:this._material.transmissionDepth=0}get transmissionDepth(){return this._material.transmissionDepth}set transmissionColor(e){e.equals(s.White())||(this._material.transmissionColor=e)}get transmissionColor(){return this._material.transmissionColor}get refractionBackgroundTexture(){return this._material.backgroundRefractionTexture}set refractionBackgroundTexture(e){this._material.backgroundRefractionTexture=e}configureVolume(){this._material.geometryThinWalled=0}set geometryThinWalled(e){this._material.geometryThinWalled=e?1:0}get geometryThinWalled(){return!!this._material.geometryThinWalled}set volumeThicknessTexture(e){this._material.geometryThicknessTexture=e,this._material._useGeometryThicknessFromGreenChannel=!0}set volumeThickness(e){this._material.geometryThickness=e}configureSubsurface(){this._material.geometryThinWalled=1,this._material.subsurfaceScatterAnisotropy=1}set subsurfaceWeight(e){this._material.subsurfaceWeight=e}get subsurfaceWeight(){return this._material.subsurfaceWeight}set subsurfaceWeightTexture(e){this._material.subsurfaceWeightTexture=e,this._material._useSubsurfaceWeightFromTextureAlpha=!0}get subsurfaceWeightTexture(){return this._material.subsurfaceWeightTexture}set subsurfaceColor(e){this._material.subsurfaceColor=e}set subsurfaceColorTexture(e){this._material.subsurfaceColorTexture=e}set diffuseTransmissionTint(e){this._diffuseTransmissionTint=e}get diffuseTransmissionTint(){return this._diffuseTransmissionTint}set diffuseTransmissionTintTexture(e){this._diffuseTransmissionTintTexture=e}get subsurfaceRadius(){return this._material.subsurfaceRadius}set subsurfaceRadius(e){this._material.subsurfaceRadius=e}get subsurfaceRadiusScale(){return this._material.subsurfaceRadiusScale}set subsurfaceRadiusScale(e){this._material.subsurfaceRadiusScale=e}set subsurfaceScatterAnisotropy(e){this._material.subsurfaceScatterAnisotropy=e}isTranslucent(){return this.transmissionWeight>0||this.subsurfaceWeight>0}configureFuzz(){}set fuzzWeight(e){this._material.fuzzWeight=e}set fuzzWeightTexture(e){this._material.fuzzWeightTexture=e}set fuzzColor(e){this._material.fuzzColor=e}set fuzzColorTexture(e){this._material.fuzzColorTexture=e}set fuzzRoughness(e){this._material.fuzzRoughness=e}set fuzzRoughnessTexture(e){this._material.fuzzRoughnessTexture=e,this._material._useFuzzRoughnessFromTextureAlpha=!0}set specularRoughnessAnisotropy(e){this._material.specularRoughnessAnisotropy=e}get specularRoughnessAnisotropy(){return this._material.specularRoughnessAnisotropy}set geometryTangentAngle(e){this._material.geometryTangentAngle=e}set geometryTangentTexture(e){this._material.geometryTangentTexture=e,this._material._useSpecularRoughnessAnisotropyFromTangentTexture=!0}get geometryTangentTexture(){return this._material.geometryTangentTexture}configureGltfStyleAnisotropy(e=!0){this._material._useGltfStyleAnisotropy=e}set thinFilmWeight(e){this._material.thinFilmWeight=e}set thinFilmIor(e){this._material.thinFilmIor=e}set thinFilmThicknessMinimum(e){this._material.thinFilmThicknessMin=e/1e3}set thinFilmThicknessMaximum(e){this._material.thinFilmThickness=e/1e3}set thinFilmWeightTexture(e){this._material.thinFilmWeightTexture=e}set thinFilmThicknessTexture(e){this._material.thinFilmThicknessTexture=e,this._material._useThinFilmThicknessFromTextureGreen=!0}set unlit(e){this._material.unlit=e}set geometryOpacity(e){this._material.geometryOpacity=e}get geometryOpacity(){return this._material.geometryOpacity}set geometryNormalTexture(e){this._material.geometryNormalTexture=e}get geometryNormalTexture(){return this._material.geometryNormalTexture}setNormalMapInversions(e,t){}set geometryCoatNormalTexture(e){this._material.geometryCoatNormalTexture=e}get geometryCoatNormalTexture(){return this._material.geometryCoatNormalTexture}set geometryCoatNormalTextureScale(e){this._material.geometryCoatNormalTexture&&(this._material.geometryCoatNormalTexture.level=e)}async finalizeAsync(t){if(this._diffuseTransmissionTint&&!this._diffuseTransmissionTint.equals(s.White())||this._diffuseTransmissionTintTexture)if(this._material.geometryThinWalled)this.subsurfaceColor=this._diffuseTransmissionTint,this.subsurfaceColorTexture=this._diffuseTransmissionTintTexture;else if(await this.copySurfaceToCoatAsync(t,this.subsurfaceWeight,this.subsurfaceWeightTexture,o.A,this._diffuseTransmissionTint,this._diffuseTransmissionTintTexture,!0),t._disposed)return;if(this.transmissionWeight>0)if(this._material.geometryThinWalled||0===this._material.transmissionDepth)this._material.transmissionColor=this._material.baseColor,this._material.transmissionColorTexture=this._material.baseColorTexture;else if((!this.baseColor.equals(s.White())||null!==this.baseColorTexture)&&(await this.copySurfaceToCoatAsync(t,this.transmissionWeight,this.transmissionWeightTexture,o.R,this.baseColor,this.baseColorTexture,!1),t._disposed))return;if(this._specWorkflow){const r=await async function(t,s,r,i=a.RGBA,o,n){if(!s.texture){const t=u(s),r=new e(i&a.R?1-t.r:t.r,i&a.G?1-t.g:t.g,i&a.B?1-t.b:t.b,i&a.A?1-t.a:t.a);return{texture:null,factor:n?x(r,n):r}}const h=[...f(s,"A",!1),..._(i),...n?T(n):[]];o&&h.push("OUTPUT_SRGB");const c=d(t,h,l([s]),r,o);R(c,s,"textureA","factorA",!1);try{await C(c)}catch(e){throw s.dispose?.(),e}s.dispose?.(),m(s.texture,c,!0);const g={texture:c,dispose:()=>c.dispose()};return o&&(g.colorSpace=o),g}("newRoughnessTexture ("+this._material.name+")",await y("glossiness ("+this._material.name+")",n(this.specularColorTexture,new e(this.specularColor.r,this.specularColor.g,this.specularColor.b,this.glossiness),o.A,i.Linear),o.A,this._material.getScene(),i.Linear,a.R),this._material.getScene(),a.R,i.Linear,a.R);if(t._disposed)return void r.texture?.dispose();this.specularRoughnessTexture=r.texture,this.specularRoughness=r.factor?r.factor.r:1;const h=await async function(t,s,r,i=!1,a,o){if(!s.texture){const t=u(s),r=i?Math.max(t.r,t.g,t.b,t.a):Math.max(t.r,t.g,t.b),a=new e(r,r,r,i?r:t.a);return{texture:null,factor:o?x(a,o):a}}const n=[...f(s,"A",!1),"OP_CHANNEL_MAX",...o?T(o):[]];i&&n.push("CHANNEL_MAX_INCLUDE_ALPHA"),a&&n.push("OUTPUT_SRGB");const h=d(t,n,l([s]),r,a);R(h,s,"textureA","factorA",!1);try{await C(h)}catch(e){throw s.dispose?.(),e}s.dispose?.(),m(s.texture,h,!0);const c={texture:h,dispose:()=>h.dispose()};return a&&(c.colorSpace=a),c}("metallicTexture ("+this._material.name+")",n(this.specularColorTexture,this.specularColor.toColor4(),o.RGBA,i.Linear),this._material.getScene(),!1,i.SRGB,a.RGB);if(t._disposed)return void h.texture?.dispose();this.baseMetalnessTexture=h.texture,this.baseMetalness=h.factor?h.factor.r:1;const c=await b("newBaseColor ("+this._material.name+")",n(this.baseColorTexture,this.baseColor.toColor4(),o.RGBA,i.Linear),n(this.specularColorTexture,this.specularColor.toColor4(),o.RGBA,i.Linear),{...h,dispose:void 0,colorSpace:i.Linear},this._material.getScene(),i.SRGB,a.RGB);if(t._disposed)return void c.texture?.dispose();const g=this.baseColorTexture;g?.dispose(),this.baseColorTexture=c.texture,this.baseColor=c.factor?new s(c.factor.r,c.factor.g,c.factor.b):s.White();const p=this.specularColorTexture;p?.dispose(),this.specularColorTexture=null}}async copySurfaceToCoatAsync(t,r,a,u,l,h,c=!1){const m=this._material.coatWeight,g=this._material.coatWeightTexture,_=this._material.coatColor.clone(),T=this._material.coatColorTexture,x=this._material.geometryCoatNormalTexture,f=new e(m,m,m,m),p=new e(r,r,r,r);this.coatWeightTexture=null,this.coatWeight=1;const R=await Promise.allSettled([b("lerpExistingCoat",n(null,new e(1,1,1,1)),n(T,_.toColor4(),o.RGBA,i.SRGB),n(g,f,o.R),this._material.getScene(),i.SRGB),b("lerpSurfaceColor",n(null,new e(1,1,1,1)),n(h,l.toColor4(),o.RGBA,i.SRGB),n(a,p,u),this._material.getScene(),i.SRGB)]),d=R.find(e=>"rejected"===e.status);if(d){for(const e of R)"fulfilled"===e.status&&e.value.texture?.dispose();throw d.reason}const[C,y]=R.map(e=>e.value);if(t._disposed)return C.texture?.dispose(),void y.texture?.dispose();const S=await A("newCoatColor ("+this._material.name+")",C,y,this._material.getScene(),i.SRGB);if(t._disposed)return void S.texture?.dispose();S.texture?(this.coatColorTexture=S.texture,this.coatColor=s.White()):S.factor&&(this.coatColorTexture=null,this.coatColor.fromArray([S.factor.r,S.factor.g,S.factor.b]));const w=await b("newCoatIor ("+this._material.name+")",n(null,new e(this._material.specularIor,this._material.specularIor,this._material.specularIor,1),o.R),n(null,new e(this.coatIor,this.coatIor,this.coatIor,1),o.R),n(g,f,o.R),this._material.getScene());if(t._disposed)return void w.texture?.dispose();this.coatIor=w.factor?w.factor.r:this.coatIor;const W=await b("newCoatRoughness ("+this._material.name+")",n(this.specularRoughnessTexture,new e(this.specularRoughness,this.specularRoughness,this.specularRoughness,1),o.G),n(this.coatRoughnessTexture,new e(this.coatRoughness,this.coatRoughness,this.coatRoughness,1),o.G),n(g,f,o.R),this._material.getScene());if(t._disposed)return void W.texture?.dispose();this.coatRoughness=W.factor?W.factor.r:1,this.coatRoughnessTexture=W.texture;const B=await b("newCoatDarkening ("+this._material.name+")",n(null,new e(0,0,0,1),o.R),n(null,new e(this.coatDarkening,this.coatDarkening,this.coatDarkening,1),o.R),n(g,f,o.R),this._material.getScene());if(t._disposed)B.texture?.dispose();else{if(this.coatDarkening=B.factor?B.factor.r:this.coatDarkening,c){const s=await b("newSpecularRoughness ("+this._material.name+")",n(this.specularRoughnessTexture,new e(this._material.specularRoughness,this._material.specularRoughness,this._material.specularRoughness,1),o.G),n(null,new e(1,1,1,1),o.R),n(a,p,u),this._material.getScene());if(t._disposed)return void s.texture?.dispose();this.specularRoughness=s.factor?s.factor.r:1,this.specularRoughnessTexture=s.texture}if(x||this.geometryNormalTexture){const s=await b("newCoatNormal ("+this._material.name+")",n(this.geometryNormalTexture,this.geometryNormalTexture?new e(1,1,1,1):new e(.5,.5,1,1),o.RGBA),n(x,x?new e(1,1,1,1):new e(.5,.5,1,1),o.RGBA),n(g,f,o.R),this._material.getScene());if(t._disposed)return void s.texture?.dispose();s.texture&&(this.geometryCoatNormalTexture=s.texture)}}}}export{S as OpenPBRMaterialLoadingAdapter}; //# sourceMappingURL=openpbrMaterialLoadingAdapter-CTilhLtn.esm.min.js.map