PageSourceSearch

https://prodanremus-disertation.hf.space/assets/index-BWbDOt8M.js

js prodanremus-disertation.hf.space collected 2026-10-03 17:16:29 UTC 1,401,877 bytes, 467 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./background.vertex-SWsJCPxj.js","./backgroundUboDeclaration-Do4TDDkF.js","./sceneUboDeclaration-F_1NQrkS.js","./helperFunctions-Zy_8Hamf.js","./bonesDeclaration-DiRftm69.js","./instancesVertex-mTE7uR-K.js","./instancesDeclaration-BFlzdu8e.js","./clipPlaneVertex-6H6nkJTq.js","./logDepthVertex-DStQhz3m.js","./shadowsVertex-_xw7FwWW.js","./logDepthDeclaration-DVyOcTbb.js","./bonesVertex-Itkd4odE.js","./bakedVertexAnimation-BC_zWM_t.js","./index-9Ev7iYt6.js","./index-CJjI6XC6.css","./background.fragment-BG3FvZXK.js","./shadowsFragmentFunctions-y2g50I1o.js","./imageProcessingFunctions-BHDtWMvN.js","./lightsFragmentFunctions-DQp5v15b.js","./clipPlaneFragment-5elGh6Dm.js","./fogFragment-BG0-rT3V.js","./lightFragment-w3uj9qN8.js","./background.vertex-ZS3q0fNA.js","./backgroundUboDeclaration-Nx5Hf0aT.js","./sceneUboDeclaration-BJS-dCdN.js","./helperFunctions-a-oFdAAo.js","./bakedVertexAnimation-PO5-FXWP.js","./instancesDeclaration-Cp6LY0Bg.js","./clipPlaneVertex-CsG3QS3Y.js","./logDepthVertex-elt9fkxN.js","./shadowsVertex-I0ljO6Zk.js","./logDepthDeclaration-BchGzvOp.js","./background.fragment-BzZWuUI3.js","./shadowsFragmentFunctions-ChYTeEW8.js","./imageProcessingFunctions-BAVKUify.js","./lightsFragmentFunctions-BfQzOJwD.js","./lightFragment-BGNMpWNv.js","./clipPlaneFragment-ioZJoRhL.js","./fogFragment-CCar45hg.js","./postprocess.vertex-CSEam0SV.js","./dumpTools--9pbiuIS.js","./dds-DfG5GArM.js","./abstractEngine.cubeTexture-BljBekQt.js","./iesTextureLoader-D-wCA04Y.js","./ddsTextureLoader-0uCmQMjR.js","./basisTextureLoader-CkZABKjy.js","./envTextureLoader-DlkAv4hf.js","./environmentTextureTools-DyS-yleu.js","./hdrTextureLoader-Dmt8hv9p.js","./hdr-DUf9r7u6.js","./ktxTextureLoader-BRJyxzG2.js","./workerPool-CfMXSLnf.js","./tgaTextureLoader-DEOT4PSv.js","./exrTextureLoader-RVDXldv6.js","./pass.fragment-yO6VVndP.js","./pass.fragment-Cp9OTwUi.js","./passCube.fragment-D6ZVCTUo.js","./passCube.fragment-BcJo8wMb.js","./rgbdDecode.fragment-CNs6GR2F.js","./rgbdDecode.fragment-BSk9DCY7.js","./rgbdEncode.fragment-Bwep2fH2.js","./rgbdEncode.fragment-DeAhXJbd.js","./pbr.vertex-Bqe2YxDs.js","./pbrUboDeclaration-C0k_mtLk.js","./meshUboDeclaration-D_g5X0CW.js","./vertexColorMixing-D-wVL6wc.js","./mainUVVaryingDeclaration-BrPLyCEP.js","./pbrBRDFFunctions-CjFHxlfh.js","./harmonicsFunctions-B3WAEVoQ.js","./bumpVertexDeclaration-D1Q9fUY7.js","./morphTargetsVertexDeclaration-BX10itpf.js","./morphTargetsVertex-DQ9o0vfu.js","./bumpVertex-DSDXLCKj.js","./pbr.fragment-C_KvfDGd.js","./oitFragment-DkaRUtEb.js","./pbrDebug-CZtXGNTs.js","./samplerFragmentDeclaration-BFf4ekMr.js","./hdrFilteringFunctions-B_Q3xOzS.js","./bumpFragment-g-DWH0I9.js","./decalFragment-CrW1Y7EB.js","./pbr.vertex-D3wqzG3a.js","./vertexColorMixing-DNX_HSgP.js","./pbrUboDeclaration-DLdykPAT.js","./meshUboDeclaration-C6vZkcGJ.js","./mainUVVaryingDeclaration-CdKSTzv8.js","./pbrBRDFFunctions-z5Wdivd0.js","./harmonicsFunctions-BTHBw2_d.js","./bumpVertexDeclaration-s8N0wiIX.js","./morphTargetsVertex-BmpE66rh.js","./bumpVertex-C8ow-nYH.js","./pbr.fragment-_GS9UE3N.js","./oitFragment-DjC9lXgW.js","./pbrDebug-CEWOFyXb.js","./bumpFragment-DOQSPjiP.js","./hdrFilteringFunctions-D04Bj3B1.js","./decalFragment-BjNl2nUt.js","./oitBackBlend.fragment-B3_VdH0k.js","./oitBackBlend.fragment-BO1eLYKG.js","./oitFinalSimpleBlend.fragment-C7Ov88Rz.js","./oitFinalSimpleBlend.fragment-FJJQ4Luz.js","./kernelBlur.fragment-UGmt1RMc.js","./kernelBlurVaryingDeclaration-DUAAbSCD.js","./packingFunctions-BP0qsAKH.js","./kernelBlur.vertex-BrtXS4hd.js","./kernelBlur.fragment-DSmQ2hZx.js","./kernelBlurVaryingDeclaration-BnvMxIsP.js","./packingFunctions-XpjVYC6W.js","./kernelBlur.vertex-CqRKMVhS.js","./glowBlurPostProcess.fragment-DWOeXimf.js","./glowBlurPostProcess.fragment-BilEVlle.js","./EXT_lights_image_based-SWSKZQUL.js","./cubeTexture-B_klqm5V.js","./glTFLoader-BGOUmS5T.js","./bone-f76MCnTO.js","./skeleton-jDiqRCo6.js","./rawTexture-DJKlCY_j.js","./assetContainer-BlPFOBoX.js","./objectModelMapping-DvVHGpTP.js","./EXT_mesh_gpu_instancing-DeygevmA.js","./thinInstanceMesh-MFtnKGG7.js","./EXT_meshopt_compression-Dq4crxvM.js","./EXT_texture_avif-C1YmES61.js","./EXT_texture_webp-ByAcJbqF.js","./ExtrasAsMetadata-CsKmPOtS.js","./KHR_animation_pointer-DzL2RBKN.js","./glTFLoaderAnimation-DdewGO-U.js","./KHR_draco_mesh_compression-D6Jj04Y5.js","./KHR_interactivity-CzsGlUw_.js","./declarationMapper-EInN1yx0.js","./KHR_lights_punctual-CFetRXv9.js","./EXT_lights_area-B-tdX2Bs.js","./EXT_lights_ies-CWiJFv2A.js","./KHR_materials_anisotropy-DQIR3UeI.js","./KHR_materials_clearcoat-BoPbSJ8K.js","./KHR_materials_diffuse_roughness-BG9pPBGI.js","./KHR_materials_diffuse_transmission-W7JqopJ7.js","./KHR_materials_dispersion-DQmto9Lx.js","./KHR_materials_emissive_strength-EM0O5p03.js","./KHR_materials_ior-BhpSkOUI.js","./KHR_materials_iridescence-DRoYVwZP.js","./KHR_materials_pbrSpecularGlossiness-j-GfRFkC.js","./KHR_materials_sheen-Db4BcNFO.js","./KHR_materials_specular-_n-vx6JM.js","./KHR_materials_transmission-BeyehkfI.js","./KHR_materials_unlit-BkQ31cFN.js","./KHR_materials_variants-Bb31meL3.js","./KHR_materials_volume-Ckg8jIwt.js","./KHR_mesh_quantization-DSlhHmH4.js","./KHR_texture_basisu-DfPjuahO.js","./KHR_texture_transform-BSdB6Eup.js","./KHR_xmp_json_ld-BPuUNdj6.js","./MSFT_audio_emitter-cYtkp1Tk.js","./spatialWebAudio-BQBUtRVe.js","./webAudioBaseSubGraph-DWixcEX2.js","./audioEngine-B41e-4BO.js","./webAudioSoundSource-Dyw-u1gI.js","./abstractSoundSource-Cw0erri2.js","./webAudioStaticSound-SZZpWuEW.js","./abstractSoundInstance-19-toZgm.js","./webAudioStreamingSound-Dk1N1l1t.js","./MSFT_lod-DoZ681tI.js","./MSFT_minecraftMesh-54Xw-YKx.js","./MSFT_sRGBFactors-DyM8-67K.js","./KHR_node_visibility-CdoAJ1QN.js","./KHR_node_hoverability-D1XQvctI.js","./KHR_node_selectability-57pQBFFc.js","./bvhFileLoader-DpWcrqqc.js","./objFileLoader-CocA2Eag.
1js","./standardMaterial-BFAKxrhM.js","./splatFileLoader-BmVJ6Kq_.js","./shaderMaterial-CiyA1esq.js","./ray-gjj8VnBP.js","./stlFileLoader-C4XuwpP1.js","./ssao2RenderingPipeline-eW2K8HQC.js","./postProcessRenderEffect-m0XHAIBe.js","./geometryBufferRenderer-Dv1weDAX.js","./postProcessRenderPipelineManagerSceneComponent-DmPyG1MD.js","./prePassRendererSceneComponent-CQyfUu7e.js","./geometryBufferRendererSceneComponent-DkZpoIqp.js","./engine.multiRender-DNsfVgN_.js","./webgpuEngine-e5c9iler.js","./fresnelFunction-fm041pFu.js","./hdrCubeTexture-krlTyiqM.js","./iblCdfGenerator-BGHulTsz.js","./discBuilder-Cv7cxbOr.js","./iblShadowsRenderPipeline-Xi6BDASc.js","./openpbrMaterial-CwFF4Ljm.js","./iblCdfGeneratorSceneComponent-H3D0TFaU.js","./envShadowGround.vertex-oRlsSdho-D_myDRd1.js","./envShadowGround.fragment-CB8lNguw-B3SxnLRx.js","./envShadowGround.vertex-6NXvyWvr-CrXyv9Pg.js","./envShadowGround.fragment-L1sPCORS-UYZU9Ntx.js","./shadowGenerator-BA9sdJSm.js","./shadowGeneratorSceneComponent-DOs-bgdv.js","./pointCloudVertex-BVqxbO10.js"])))=>i.map(i=>d[i]);
2import{ad as G}from"./index-9Ev7iYt6.js";function T(a,e,t,i){var s=arguments.length,r=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(a,e,t,i);else for(var o=a.length-1;o>=0;o--)(n=a[o])&&(r=(s<3?n(r):s>3?n(e,t,r):n(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r}const cr={},br={};function _l(a){const e=a.getClassName();return br[e]||(br[e]={}),br[e]}function fn(a){const e=a.getClassName();if(cr[e])return cr[e];cr[e]={};const t=cr[e];let i=a,s=e;for(;s;){const r=br[s];for(const h in r)t[h]=r[h];let n,o=!1;do{if(n=Object.getPrototypeOf(i),!n.getClassName){o=!0;break}if(n.getClassName()!==s)break;i=n}while(n);if(o)break;s=n.getClassName(),i=n}return t}function Yt(a,e){return(t,i)=>{const s=_l(t);s[i]||(s[i]={type:a,sourceName:e})}}function gl(a,e=null){return(t,i)=>{const s=e||"_"+i;Object.defineProperty(t,i,{get:function(){return this[s]},set:function(r){typeof this[s]?.equals=="function"&&this[s].equals(r)||this[s]!==r&&(this[s]=r,t[a].apply(this))},enumerable:!0,configurable:!0})}}function B(a,e=null){return gl(a,e)}function R(a){return Yt(0,a)}function Oe(a){return Yt(1,a)}function At(a){return Yt(2,a)}function l_(a){return Yt(3,a)}function co(a){return Yt(4,a)}function qt(a){return Yt(5,a)}function uo(a){return Yt(6,a)}function pl(a){return Yt(7,a)}function fo(a){return Yt(8,a)}function ml(a){return Yt(9,a)}function Tl(a){return Yt(10,a)}function c_(a){return Yt(12,a)}function yi(a,e,t,i){const s=t.value;t.value=(...r)=>{let n=s;if(typeof _native<"u"&&_native[e]){const o=_native[e];i?n=(...h)=>i(...h)?o(...h):s(...h):n=o}return a[e]=n,n(...r)}}yi.filter=function(a){return(e,t,i)=>yi(e,t,i,a)};function u_(a,e=null){return(t,i)=>{const s=i;Object.defineProperty(t,e||"",{get:function(){return this[s].value},set:function(n){typeof this[s]?.value?.equals=="function"&&this[s].value.equals(n)||this[s].value!==n&&(this[s].value=n,t[a].apply(this))},enumerable:!0,configurable:!0})}}const bl=typeof WeakRef<"u";class El{constructor(e,t=!1,i,s){this.initialize(e,t,i,s)}initialize(e,t=!1,i,s){return this.mask=e,this.skipNextObservers=t,this.target=i,this.currentTarget=s,this}}class Al{constructor(e,t,i=null){this.callback=e,this.mask=t,this.scope=i,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1,this._remove=null}remove(e=!1){this._remove&&this._remove(e)}}class O{static FromPromise(e,t){const i=new O;return e.then(s=>{i.notifyObservers(s)}).catch(s=>{if(t)t.notifyObservers(s);else throw s}),i}get observers(){return this._observers}constructor(e,t=!1){this.notifyIfTriggered=t,this._observers=new Array,this._numObserversMarkedAsDeleted=0,this._hasNotified=!1,this._eventState=new El(0),e&&(this._onObserverAdded=e)}add(e,t=-1,i=!1,s=null,r=!1){if(!e)return null;const n=new Al(e,t,s);n.unregisterOnNextCall=r,i?this._observers.unshift(n):this._observers.push(n),this._onObserverAdded&&this._onObserverAdded(n),this._hasNotified&&this.notifyIfTriggered&&this._lastNotifiedValue!==void 0&&this.notifyObserver(n,this._lastNotifiedValue);const o=bl?new WeakRef(this):{deref:()=>this};return n._remove=(h=!1)=>{const l=o.deref();l&&(h?l.remove(n):l._remove(n))},n}addOnce(e){return this.add(e,void 0,void 0,void 0,!0)}remove(e){return e?(e._remove=null,this._observers.indexOf(e)!==-1?(this._deferUnregister(e),!0):!1):!1}removeCallback(e,t){for(let i=0;i<this._observers.length;i++){const s=this._observers[i];if(!s._willBeUnregistered&&s.callback===e&&(!t||t===s.scope))return this._deferUnregister(s),!0}return!1}_deferUnregister(e){e._willBeUnregistered||(this._numObserversMarkedAsDeleted++,e.unregisterOnNextCall=!1,e._willBeUnregistered=!0,setTimeout(()=>{this._remove(e)},0))}_remove(e,t=!0){if(!e)return!1;const i=this._observers.indexOf(e);return i!==-1?(t&&this._numObserversMarkedAsDeleted--,this._observers.splice(i,1),!0):!1}makeObserverTopPriority(e){this._remove(e,!1),this._observers.unshift(e)}makeObserverBottomPriority(e){this._remove(e,!1),this._observers.push(e)}notifyObservers(e,t=-1,i,s,r){if(this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=e),!this._observers.length)return!0;const n=this._eventState;n.mask=t,n.target=i,n.currentTarget=s,n.skipNextObservers=!1,n.lastReturnValue=e,n.userInfo=r;for(const o of this._observers)if(!o._willBeUnregistered&&(o.mask&t&&(o.unregisterOnNextCall&&this._deferUnregister(o),o.scope?n.lastReturnValue=o.callback.apply(o.scope,[e,n]):n.lastReturnValue=o.callback(e,n)),n.skipNextObservers))return!1;return!0}notifyObserver(e,t,i=-1){if(this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=t),e._willBeUnregistered)return;const s=this._eventState;s.mask=i,s.skipNextObservers=!1,e.unregisterOnNextCall&&this._deferUnregister(e),e.callback(t,s)}hasObservers(){return this._observers.length-this._numObserversMarkedAsDeleted>0}clear(){for(;this._observers.length;){const e=this._observers.pop();e&&(e._remove=null)}this._onObserverAdded=null,this._numObserversMarkedAsDeleted=0,this.cleanLastNotifiedState()}cleanLastNotifiedState(){this._hasNotified=!1,this._lastNotifiedValue=void 0}clone(){const e=new O;return e._observers=this._observers.slice(0),e}hasSpecificMask(e=-1){for(const t of this._observers)if(t.mask&e||t.mask===e)return!0;return!1}}const Rl=1/2.2,Er=2.2,Me=.001;function Ai(a,e){const t=[];for(let i=0;i<a;++i)t.push(e());return t}function xi(a,e){return Ai(a,e)}function yl(a,e,t){const i=a[e];if(typeof i!="function")return null;const s=function(){const r=a.length,n=s.previous.apply(a,arguments);return t(e,r),n};return i.next=s,s.previous=i,a[e]=s,()=>{const r=s.previous;if(!r)return;const n=s.next;n?(r.next=n,n.previous=r):(r.next=void 0,a[e]=r),s.next=void 0,s.previous=void 0}}
vendor: 148,469 bytes, lines 2-21
2const xl=["push","splice","pop","shift","unshift"];function _o(a,e){const t=xl.map(i=>yl(a,i,e));return()=>{for(const i of t)i?.()}}const go={};function nt(a,e){go[a]=e}function Oi(a){return go[a]}class st{static SetMatrixPrecision(e){if(st.MatrixTrackPrecisionChange=!1,e&&!st.MatrixUse64Bits&&st.MatrixTrackedMatrices)for(let t=0;t<st.MatrixTrackedMatrices.length;++t){const i=st.MatrixTrackedMatrices[t],s=i._m;i._m=new Array(16);for(let r=0;r<16;++r)i._m[r]=s[r]}st.MatrixUse64Bits=e,st.MatrixCurrentType=st.MatrixUse64Bits?Array:Float32Array,st.MatrixTrackedMatrices=null}}st.MatrixUse64Bits=!1;st.MatrixTrackPrecisionChange=!0;st.MatrixCurrentType=Float32Array;st.MatrixTrackedMatrices=[];class Te{static get LastCreatedEngine(){return this.Instances.length===0?null:this.Instances[this.Instances.length-1]}static get LastCreatedScene(){return this._LastCreatedScene}}Te.Instances=[];Te.OnEnginesDisposedObservable=new O;Te._LastCreatedScene=null;Te.UseFallbackTexture=!0;Te.FallbackTexture="";function Sl(a){return parseInt(a.toString().replace(/\W/g,""))}function Pe(a,e,t=1401298e-51){return Math.abs(a-e)<=t}function Ml(a,e,t,i=1401298e-51){return a<e-i||a>t+i}function Ve(a,e){return a===e?a:Math.random()*(e-a)+a}function Ii(a,e,t){return a+(e-a)*t}function Cl(a,e,t){let i=Ur(e-a,360);return i>180&&(i-=360),a+i*be(t)}function Il(a,e,t){let i=0;return a!=e?i=be((t-a)/(e-a)):i=0,i}function po(a,e,t,i,s){const r=s*s,n=s*r,o=2*n-3*r+1,h=-2*n+3*r,l=n-2*r+s,c=n-r;return a*o+t*h+e*l+i*c}function Pl(a,e,t,i,s){const r=s*s;return(r-s)*6*a+(3*r-4*s+1)*e+(-r+s)*6*t+(3*r-2*s)*i}function be(a,e=0,t=1){return Math.min(t,Math.max(e,a))}function mo(a){return a-=Math.PI*2*Math.floor((a+Math.PI)/(Math.PI*2)),a}function ei(a){const e=a.toString(16);return a<=15?("0"+e).toUpperCase():e.toUpperCase()}function vl(a){if(Math.log2)return Math.floor(Math.log2(a));if(a<0)return NaN;if(a===0)return-1/0;let e=0;if(a<1){for(;a<1;)e++,a=a*2;e=-e}else if(a>1)for(;a>1;)e++,a=Math.floor(a/2);return e}function Ur(a,e){return a-Math.floor(a/e)*e}function Dl(a,e,t){return(a-e)/(t-e)}function Ol(a,e,t){return a*(t-e)+e}function To(a,e){let t=Ur(e-a,360);return t>180&&(t-=360),t}function Fl(a,e){const t=Ur(a,e*2);return e-Math.abs(t-e)}function wl(a,e,t){let i=be(t);return i=-2*i*i*i+3*i*i,e*i+a*(1-i)}function bo(a,e,t){let i=0;return Math.abs(e-a)<=t?i=e:i=a+Math.sign(e-a)*t,i}function Ll(a,e,t){const i=To(a,e);let s=0;return-t<i&&i<t?s=e:(e=a+i,s=bo(a,e,t)),s}function Bl(a,e,t){return(a-e)/(t-e)}function Nl(a,e,t){return(t-e)*a+e}function Eo(a,e){const t=a%e;return t===0?e:Eo(e,t)}const d_=Object.freeze(Object.defineProperty({__proto__:null,Clamp:be,DeltaAngle:To,Denormalize:Ol,ExtractAsInt:Sl,Hermite:po,Hermite1stDerivative:Pl,HighestCommonFactor:Eo,ILog2:vl,InverseLerp:Il,Lerp:Ii,LerpAngle:Cl,MoveTowards:bo,MoveTowardsAngle:Ll,Normalize:Dl,NormalizeRadians:mo,OutsideRange:Ml,PercentToRange:Nl,PingPong:Fl,RandomRange:Ve,RangeToPercent:Bl,Repeat:Ur,SmoothStep:wl,ToHex:ei,WithinEpsilon:Pe},Symbol.toStringTag,{value:"Module"}));class Cn{}Cn._UpdateFlagSeed=0;function Ao(a){a.updateFlag=Cn._UpdateFlagSeed++}function Ro(a,e,t,i=0){const s=a.asArray(),r=e.asArray(),n=s[0],o=s[1],h=s[2],l=s[3],c=s[4],u=s[5],f=s[6],d=s[7],g=s[8],p=s[9],m=s[10],A=s[11],E=s[12],I=s[13],M=s[14],C=s[15],x=r[0],S=r[1],L=r[2],N=r[3],D=r[4],Re=r[5],pe=r[6],ce=r[7],oe=r[8],Ye=r[9],Qe=r[10],ft=r[11],de=r[12],Fe=r[13],we=r[14],$e=r[15];t[i]=n*x+o*D+h*oe+l*de,t[i+1]=n*S+o*Re+h*Ye+l*Fe,t[i+2]=n*L+o*pe+h*Qe+l*we,t[i+3]=n*N+o*ce+h*ft+l*$e,t[i+4]=c*x+u*D+f*oe+d*de,t[i+5]=c*S+u*Re+f*Ye+d*Fe,t[i+6]=c*L+u*pe+f*Qe+d*we,t[i+7]=c*N+u*ce+f*ft+d*$e,t[i+8]=g*x+p*D+m*oe+A*de,t[i+9]=g*S+p*Re+m*Ye+A*Fe,t[i+10]=g*L+p*pe+m*Qe+A*we,t[i+11]=g*N+p*ce+m*ft+A*$e,t[i+12]=E*x+I*D+M*oe+C*de,t[i+13]=E*S+I*Re+M*Ye+C*Fe,t[i+14]=E*L+I*pe+M*Qe+C*we,t[i+15]=E*N+I*ce+M*ft+C*$e}function gs(a,e,t,i=0){Ro(a,e,t.asArray(),i),Ao(t)}function Ul(a,e,t=0){const i=a.asArray();e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15]}function xr(a,e){const t=yo(a,e.asArray());return t&&Ao(e),t}function yo(a,e){const t=a.asArray(),i=t[0],s=t[1],r=t[2],n=t[3],o=t[4],h=t[5],l=t[6],c=t[7],u=t[8],f=t[9],d=t[10],g=t[11],p=t[12],m=t[13],A=t[14],E=t[15],I=d*E-A*g,M=f*E-m*g,C=f*A-m*d,x=u*E-p*g,S=u*A-d*p,L=u*m-p*f,N=+(h*I-l*M+c*C),D=-(o*I-l*x+c*S),Re=+(o*M-h*x+c*L),pe=-(o*C-h*S+l*L),ce=i*N+s*D+r*Re+n*pe;if(ce===0)return!1;const oe=1/ce,Ye=l*E-A*c,Qe=h*E-m*c,ft=h*A-m*l,de=o*E-p*c,Fe=o*A-p*l,we=o*m-p*h,$e=l*g-d*c,at=h*g-f*c,ke=h*d-f*l,Ni=o*g-u*c,Ui=o*d-u*l,ki=o*f-u*h,Cs=-(s*I-r*M+n*C),Ze=+(i*I-r*x+n*S),Gi=-(i*M-s*x+n*L),Hi=+(i*C-s*S+r*L),Vi=+(s*Ye-r*Qe+n*ft),zi=-(i*Ye-r*de+n*Fe),ci=+(i*Qe-s*de+n*we),ui=-(i*ft-s*Fe+r*we),di=-(s*$e-r*at+n*ke),fi=+(i*$e-r*Ni+n*Ui),dl=-(i*at-s*Ni+n*ki),fl=+(i*ke-s*Ui+r*ki);return e[0]=N*oe,e[1]=Cs*oe,e[2]=Vi*oe,e[3]=di*oe,e[4]=D*oe,e[5]=Ze*oe,e[6]=zi*oe,e[7]=fi*oe,e[8]=Re*oe,e[9]=Gi*oe,e[10]=ci*oe,e[11]=dl*oe,e[12]=pe*oe,e[13]=Hi*oe,e[14]=ui*oe,e[15]=fl*oe,!0}const St=a=>parseInt(a.toString().replace(/\W/g,""));class Q{constructor(e=0,t=0){this.x=e,this.y=t}toString(){return`{X: ${this.x} Y: ${this.y}}`}getClassName(){return"Vector2"}getHashCode(){const e=St(this.x),t=St(this.y);let i=e;return i=i*397^t,i}toArray(e,t=0){return e[t]=this.x,e[t+1]=this.y,this}fromArray(e,t=0){return Q.FromArrayToRef(e,t,this),this}asArray(){return[this.x,this.y]}copyFrom(e){return this.x=e.x,this.y=e.y,this}copyFromFloats(e,t){return this.x=e,this.y=t,this}set(e,t){return this.copyFromFloats(e,t)}setAll(e){return this.copyFromFloats(e,e)}add(e){return new Q(this.x+e.x,this.y+e.y)}addToRef(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,t}addInPlace(e){return this.x+=e.x,this.y+=e.y,this}addInPlaceFromFloats(e,t){return this.x+=e,this.y+=t,this}addVector3(e){return new Q(this.x+e.x,this.y+e.y)}subtract(e){return new Q(this.x-e.x,this.y-e.y)}subtractToRef(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,t}subtractInPlace(e){return this.x-=e.x,this.y-=e.y,this}multiplyInPlace(e){return this.x*=e.x,this.y*=e.y,this}multiply(e){return new Q(this.x*e.x,this.y*e.y)}multiplyToRef(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,t}multiplyByFloats(e,t){return new Q(this.x*e,this.y*t)}divide(e){return new Q(this.x/e.x,this.y/e.y)}divideToRef(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,t}divideInPlace(e){return this.x=this.x/e.x,this.y=this.y/e.y,this}minimizeInPlace(e){return this.minimizeInPlaceFromFloats(e.x,e.y)}maximizeInPlace(e){return this.maximizeInPlaceFromFloats(e.x,e.y)}minimizeInPlaceFromFloats(e,t){return this.x=Math.min(e,this.x),this.y=Math.min(t,this.y),this}maximizeInPlaceFromFloats(e,t){return this.x=Math.max(e,this.x),this.y=Math.max(t,this.y),this}subtractFromFloats(e,t){return new Q(this.x-e,this.y-t)}subtractFromFloatsToRef(e,t,i){return i.x=this.x-e,i.y=this.y-t,i}negate(){return new Q(-this.x,-this.y)}negateInPlace(){return this.x*=-1,this.y*=-1,this}negateToRef(e){return e.x=-this.x,e.y=-this.y,e}scaleInPlace(e){return this.x*=e,this.y*=e,this}scale(e){return new Q(this.x*e,this.y*e)}scaleToRef(e,t){return t.x=this.x*e,t.y=this.y*e,t}scaleAndAddToRef(e,t){return t.x+=this.x*e,t.y+=this.y*e,t}equals(e){return e&&this.x===e.x&&this.y===e.y}equalsWithEpsilon(e,t=Me){return e&&Pe(this.x,e.x,t)&&Pe(this.y,e.y,t)}equalsToFloats(e,t){return this.x===e&&this.y===t}floor(){return new Q(Math.floor(this.x),Math.floor(this.y))}floorToRef(e){return e.x=Math.floor(this.x),e.y=Math.floor(this.y),e}fract(){return new Q(this.x-Math.floor(this.x),this.y-Math.floor(this.y))}fractToRef(e){return e.x=this.x-Math.floor(this.x),e.y=this.y-Math.floor(this.y),e}rotate(e){return this.rotateToRef(e,new Q)}rotateToRef(e,t){const i=Math.cos(e),s=Math.sin(e);return t.x=i*this.x-s*this.y,t.y=s*this.x+i*this.y,t}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}lengthSquared(){return this.x*this.x+this.y*this.y}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){const e=new Q;return this.normalizeToRef(e),e}normalizeToRef(e){const t=this.length();return t===0&&(e.x=this.x,e.y=this.y),this.scaleToRef(1/t,e)}clone(){return new Q(this.x,this.y)}dot(e){return this.x*e.x+this.y*e.y}static Zero(){return new Q(0,0)}static One(){return new Q(1,1)}static Random(e=0,t=1){return new Q(Ve(e,t),Ve(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(Ve(e,t),Ve(e,t))}static get ZeroReadOnly(){return Q._ZeroReadOnly}static FromArray(e,t=0){return new Q(e[t],e[t+1])}static FromArrayToRef(e,t,i){return i.x=e[t],i.y=e[t+1],i}static FromFloatsToRef(e,t,i){return i.copyFromFloats(e,t),i}static CatmullRom(e,t,i,s,r){const n=r*r,o=r*n,h=.5*(2*t.x+(-e.x+i.x)*r+(2*e.x-5*t.x+4*i.x-s.x)*n+(-e.x+3*t.x-3*i.x+s.x)*o),l=.5*(2*t.y+(-e.y+i.y)*r+(2*e.y-5*t.y+4*i.y-s.y)*n+(-e.y+3*t.y-3*i.y+s.y)*o);return new Q(h,l)}static ClampToRef(e,t,i,s){return s.x=be(e.x,t.x,i.x),s.y=be(e.y,t.y,i.y),s}static Clamp(e,t,i){const s=be(e.x,t.x,i.x),r=be(e.y,t.y,i.y);return new Q(s,r)}static Hermite(e,t,i,s,r){const n=r*r,o=r*n,h=2*o-3*n+1,l=-2*o+3*n,c=o-2*n+r,u=o-n,f=e.x*h+i.x*l+t.x*c+s.x*u,d=e.y*h+i.y*l+t.y*c+s.y*u;return new Q(f,d)}static Hermite1stDerivative(e,t,i,s,r){return this.Hermite1stDerivativeToRef(e,t,i,s,r,new Q)}static Hermite1stDerivativeToRef(e,t,i,s,r,n){const o=r*r;return n.x=(o-r)*6*e.x+(3*o-4*r+1)*t.x+(-o+r)*6*i.x+(3*o-2*r)*s.x,n.y=(o-r)*6*e.y+(3*o-4*r+1)*t.y+(-o+r)*6*i.y+(3*o-2*r)*s.y,n}static Lerp(e,t,i){return Q.LerpToRef(e,t,i,new Q)}static LerpToRef(e,t,i,s){return s.x=e.x+(t.x-e.x)*i,s.y=e.y+(t.y-e.y)*i,s}static Dot(e,t){return e.x*t.x+e.y*t.y}static Normalize(e){return Q.NormalizeToRef(e,new Q)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){const i=e.x<t.x?e.x:t.x,s=e.y<t.y?e.y:t.y;return new Q(i,s)}static Maximize(e,t){const i=e.x>t.x?e.x:t.x,s=e.y>t.y?e.y:t.y;return new Q(i,s)}static Transform(e,t){return Q.TransformToRef(e,t,new Q)}static TransformToRef(e,t,i){const s=t.m,r=e.x*s[0]+e.y*s[4]+s[12],n=e.x*s[1]+e.y*s[5]+s[13];return i.x=r,i.y=n,i}static PointInTriangle(e,t,i,s){const r=.5*(-i.y*s.x+t.y*(-i.x+s.x)+t.x*(i.y-s.y)+i.x*s.y),n=r<0?-1:1,o=(t.y*s.x-t.x*s.y+(s.y-t.y)*e.x+(t.x-s.x)*e.y)*n,h=(t.x*i.y-t.y*i.x+(t.y-i.y)*e.x+(i.x-t.x)*e.y)*n;return o>0&&h>0&&o+h<2*r*n}static Distance(e,t){return Math.sqrt(Q.DistanceSquared(e,t))}static DistanceSquared(e,t){const i=e.x-t.x,s=e.y-t.y;return i*i+s*s}static Center(e,t){return Q.CenterToRef(e,t,new Q)}static CenterToRef(e,t,i){return i.copyFromFloats((e.x+t.x)/2,(e.y+t.y)/2)}static DistanceOfPointFromSegment(e,t,i){const s=Q.DistanceSquared(t,i);if(s===0)return Q.Distance(e,t);const r=i.subtract(t),n=Math.max(0,Math.min(1,Q.Dot(e.subtract(t),r)/s)),o=t.add(r.multiplyByFloats(n,n));return Q.Distance(e,o)}}Q._V8PerformanceHack=new Q(.5,.5);Q._ZeroReadOnly=Q.Zero();Object.defineProperties(Q.prototype,{dimension:{value:[2]},rank:{value:1}});class _{get x(){return this._x}set x(e){this._x=e,this._isDirty=!0}get y(){return this._y}set y(e){this._y=e,this._isDirty=!0}get z(){return this._z}set z(e){this._z=e,this._isDirty=!0}constructor(e=0,t=0,i=0){this._isDirty=!0,this._x=e,this._y=t,this._z=i}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z}}`}getClassName(){return"Vector3"}getHashCode(){const e=St(this._x),t=St(this._y),i=St(this._z);let s=e;return s=s*397^t,s=s*397^i,s}asArray(){return[this._x,this._y,this._z]}toArray(e,t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,this}fromArray(e,t=0){return _.FromArrayToRef(e,t,this),this}toQuaternion(){return W.RotationYawPitchRoll(this._y,this._x,this._z)}addInPlace(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._isDirty=!0,this}addInPlaceFromFloats(e,t,i){return this._x+=e,this._y+=t,this._z+=i,this._isDirty=!0,this}add(e){return new _(this._x+e._x,this._y+e._y,this._z+e._z)}addToRef(e,t){return t._x=this._x+e._x,t._y=this._y+e._y,t._z=this._z+e._z,t._isDirty=!0,t}subtractInPlace(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._isDirty=!0,this}subtract(e){return new _(this._x-e._x,this._y-e._y,this._z-e._z)}subtractToRef(e,t){return this.subtractFromFloatsToRef(e._x,e._y,e._z,t)}subtractFromFloats(e,t,i){return new _(this._x-e,this._y-t,this._z-i)}subtractFromFloatsToRef(e,t,i,s){return s._x=this._x-e,s._y=this._y-t,s._z=this._z-i,s._isDirty=!0,s}negate(){return new _(-this._x,-this._y,-this._z)}negateInPlace(){return this._x*=-1,this._y*=-1,this._z*=-1,this._isDirty=!0,this}negateToRef(e){return e._x=this._x*-1,e._y=this._y*-1,e._z=this._z*-1,e._isDirty=!0,e}scaleInPlace(e){return this._x*=e,this._y*=e,this._z*=e,this._isDirty=!0,this}scale(e){return new _(this._x*e,this._y*e,this._z*e)}scaleToRef(e,t){return t._x=this._x*e,t._y=this._y*e,t._z=this._z*e,t._isDirty=!0,t}getNormalToRef(e){const t=this.length();let i=Math.acos(this._y/t);const s=Math.atan2(this._z,this._x);i>Math.PI/2?i-=Math.PI/2:i+=Math.PI/2;const r=t*Math.sin(i)*Math.cos(s),n=t*Math.cos(i),o=t*Math.sin(i)*Math.sin(s);return e.set(r,n,o),e}applyRotationQuaternionToRef(e,t){const i=this._x,s=this._y,r=this._z,n=e._x,o=e._y,h=e._z,l=e._w,c=2*(o*r-h*s),u=2*(h*i-n*r),f=2*(n*s-o*i);return t._x=i+l*c+o*f-h*u,t._y=s+l*u+h*c-n*f,t._z=r+l*f+n*u-o*c,t._isDirty=!0,t}applyRotationQuaternionInPlace(e){return this.applyRotationQuaternionToRef(e,this)}applyRotationQuaternion(e){return this.applyRotationQuaternionToRef(e,new _)}scaleAndAddToRef(e,t){return t._x+=this._x*e,t._y+=this._y*e,t._z+=this._z*e,t._isDirty=!0,t}projectOnPlane(e,t){return this.projectOnPlaneToRef(e,t,new _)}projectOnPlaneToRef(e,t,i){const s=e.normal,r=e.d,n=X.Vector3[0];this.subtractToRef(t,n),n.normalize();const o=_.Dot(n,s);if(Math.abs(o)<1e-10)i.setAll(1/0);else{const h=-(_.Dot(t,s)+r)/o,l=n.scaleInPlace(h);t.addToRef(l,i)}return i}equals(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z}equalsWithEpsilon(e,t=Me){return e&&Pe(this._x,e._x,t)&&Pe(this._y,e._y,t)&&Pe(this._z,e._z,t)}equalsToFloats(e,t,i){return this._x===e&&this._y===t&&this._z===i}multiplyInPlace(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._isDirty=!0,this}multiply(e){return this.multiplyByFloats(e._x,e._y,e._z)}multiplyToRef(e,t){return t._x=this._x*e._x,t._y=this._y*e._y,t._z=this._z*e._z,t._isDirty=!0,t}multiplyByFloats(e,t,i){return new _(this._x*e,this._y*t,this._z*i)}divide(e){return new _(this._x/e._x,this._y/e._y,this._z/e._z)}divideToRef(e,t){return t._x=this._x/e._x,t._y=this._y/e._y,t._z=this._z/e._z,t._isDirty=!0,t}divideInPlace(e){return this._x=this._x/e._x,this._y=this._y/e._y,this._z=this._z/e._z,this._isDirty=!0,this}minimizeInPlace(e){return this.minimizeInPlaceFromFloats(e._x,e._y,e._z)}maximizeInPlace(e){return this.maximizeInPlaceFromFloats(e._x,e._y,e._z)}minimizeInPlaceFromFloats(e,t,i){return e<this._x&&(this.x=e),t<this._y&&(this.y=t),i<this._z&&(this.z=i),this}maximizeInPlaceFromFloats(e,t,i){return e>this._x&&(this.x=e),t>this._y&&(this.y=t),i>this._z&&(this.z=i),this}isNonUniformWithinEpsilon(e){const t=Math.abs(this._x),i=Math.abs(this._y);if(!Pe(t,i,e))return!0;const s=Math.abs(this._z);return!Pe(t,s,e)||!Pe(i,s,e)}get isNonUniform(){const e=Math.abs(this._x),t=Math.abs(this._y);if(e!==t)return!0;const i=Math.abs(this._z);return e!==i}floorToRef(e){return e._x=Math.floor(this._x),e._y=Math.floor(this._y),e._z=Math.floor(this._z),e._isDirty=!0,e}floor(){return new _(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))}fractToRef(e){return e._x=this._x-Math.floor(this._x),e._y=this._y-Math.floor(this._y),e._z=this._z-Math.floor(this._z),e._isDirty=!0,e}fract(){return new _(this._x-Math.floor(this._x),this._y-Math.floor(this._y),this._z-Math.floor(this._z))}length(){return Math.sqrt(this.lengthSquared())}lengthSquared(){return this._x*this._x+this._y*this._y+this._z*this._z}get hasAZeroComponent(){return this._x*this._y*this._z===0}normalize(){return this.normalizeFromLength(this.length())}reorderInPlace(e){if(e=e.toLowerCase(),e==="xyz")return this;const t=X.Vector3[0].copyFrom(this);return this.x=t[e[0]],this.y=t[e[1]],this.z=t[e[2]],this}rotateByQuaternionToRef(e,t){return e.toRotationMatrix(X.Matrix[0]),_.TransformCoordinatesToRef(this,X.Matrix[0],t),t}rotateByQuaternionAroundPointToRef(e,t,i){return this.subtractToRef(t,X.Vector3[0]),X.Vector3[0].rotateByQuaternionToRef(e,X.Vector3[0]),t.addToRef(X.Vector3[0],i),i}cross(e){return _.CrossToRef(this,e,new _)}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){return this.normalizeToRef(new _)}normalizeToRef(e){const t=this.length();return t===0||t===1?(e._x=this._x,e._y=this._y,e._z=this._z,e._isDirty=!0,e):this.scaleToRef(1/t,e)}clone(){return new _(this._x,this._y,this._z)}copyFrom(e){return this.copyFromFloats(e._x,e._y,e._z)}copyFromFloats(e,t,i){return this._x=e,this._y=t,this._z=i,this._isDirty=!0,this}set(e,t,i){return this.copyFromFloats(e,t,i)}setAll(e){return this._x=this._y=this._z=e,this._isDirty=!0,this}static GetClipFactor(e,t,i,s){const r=_.Dot(e,i),n=_.Dot(t,i);return(r-s)/(r-n)}static GetAngleBetweenVectors(e,t,i){const s=e.normalizeToRef(X.Vector3[1]),r=t.normalizeToRef(X.Vector3[2]);let n=_.Dot(s,r);n=be(n,-1,1);const o=Math.acos(n),h=X.Vector3[3];return _.CrossToRef(s,r,h),_.Dot(h,i)>0?isNaN(o)?0:o:isNaN(o)?-Math.PI:-Math.acos(n)}static GetAngleBetweenVectorsOnPlane(e,t,i){X.Vector3[0].copyFrom(e);const s=X.Vector3[0];X.Vector3[1].copyFrom(t);const r=X.Vector3[1];X.Vector3[2].copyFrom(i);const n=X.Vector3[2],o=X.Vector3[3],h=X.Vector3[4];s.normalize(),r.normalize(),n.normalize(),_.CrossToRef(n,s,o),_.CrossToRef(o,n,h);const l=Math.atan2(_.Dot(r,o),_.Dot(r,h));return mo(l)}static PitchYawRollToMoveBetweenPointsToRef(e,t,i){const s=v.Vector3[0];return t.subtractToRef(e,s),i._y=Math.atan2(s.x,s.z)||0,i._x=Math.atan2(Math.sqrt(s.x**2+s.z**2),s.y)||0,i._z=0,i._isDirty=!0,i}static PitchYawRollToMoveBetweenPoints(e,t){const i=_.Zero();return _.PitchYawRollToMoveBetweenPointsToRef(e,t,i)}static SlerpToRef(e,t,i,s){i=be(i,0,1);const r=X.Vector3[0],n=X.Vector3[1];r.copyFrom(e);const o=r.length();r.normalizeFromLength(o),n.copyFrom(t);const h=n.length();n.normalizeFromLength(h);const l=_.Dot(r,n);let c,u;if(l<1-Me){const f=Math.acos(l),d=1/Math.sin(f);c=Math.sin((1-i)*f)*d,u=Math.sin(i*f)*d}else c=1-i,u=i;return r.scaleInPlace(c),n.scaleInPlace(u),s.copyFrom(r).addInPlace(n),s.scaleInPlace(Ii(o,h,i)),s}static SmoothToRef(e,t,i,s,r){return _.SlerpToRef(e,t,s===0?1:i/s,r),r}static FromArray(e,t=0){return new _(e[t],e[t+1],e[t+2])}static FromFloatArray(e,t){return _.FromArray(e,t)}static FromArrayToRef(e,t,i){return i._x=e[t],i._y=e[t+1],i._z=e[t+2],i._isDirty=!0,i}static FromFloatArrayToRef(e,t,i){return _.FromArrayToRef(e,t,i)}static FromFloatsToRef(e,t,i,s){return s.copyFromFloats(e,t,i),s}static Zero(){return new _(0,0,0)}static One(){return new _(1,1,1)}static Up(){return new _(0,1,0)}static get UpReadOnly(){return _._UpReadOnly}static get DownReadOnly(){return _._DownReadOnly}static get RightReadOnly(){return _._RightReadOnly}static get LeftReadOnly(){return _._LeftReadOnly}static get LeftHandedForwardReadOnly(){return _._LeftHandedForwardReadOnly}static get RightHandedForwardReadOnly(){return _._RightHandedForwardReadOnly}static get LeftHandedBackwardReadOnly(){return _._LeftHandedBackwardReadOnly}static get RightHandedBackwardReadOnly(){return _._RightHandedBackwardReadOnly}static get ZeroReadOnly(){return _._ZeroReadOnly}static get OneReadOnly(){return _._OneReadOnly}static Down(){return new _(0,-1,0)}static Forward(e=!1){return new _(0,0,e?-1:1)}static Backward(e=!1){return new _(0,0,e?1:-1)}static Right(){return new _(1,0,0)}static Left(){return new _(-1,0,0)}static Random(e=0,t=1){return new _(Ve(e,t),Ve(e,t),Ve(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(Ve(e,t),Ve(e,t),Ve(e,t))}static TransformCoordinates(e,t){const i=_.Zero();return _.TransformCoordinatesToRef(e,t,i),i}static TransformCoordinatesToRef(e,t,i){return _.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformCoordinatesFromFloatsToRef(e,t,i,s,r){const n=s.m,o=e*n[0]+t*n[4]+i*n[8]+n[12],h=e*n[1]+t*n[5]+i*n[9]+n[13],l=e*n[2]+t*n[6]+i*n[10]+n[14],c=1/(e*n[3]+t*n[7]+i*n[11]+n[15]);return r._x=o*c,r._y=h*c,r._z=l*c,r._isDirty=!0,r}static TransformNormal(e,t){const i=_.Zero();return _.TransformNormalToRef(e,t,i),i}static TransformNormalToRef(e,t,i){return this.TransformNormalFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformNormalFromFloatsToRef(e,t,i,s,r){const n=s.m;return r._x=e*n[0]+t*n[4]+i*n[8],r._y=e*n[1]+t*n[5]+i*n[9],r._z=e*n[2]+t*n[6]+i*n[10],r._isDirty=!0,r}static CatmullRom(e,t,i,s,r){const n=r*r,o=r*n,h=.5*(2*t._x+(-e._x+i._x)*r+(2*e._x-5*t._x+4*i._x-s._x)*n+(-e._x+3*t._x-3*i._x+s._x)*o),l=.5*(2*t._y+(-e._y+i._y)*r+(2*e._y-5*t._y+4*i._y-s._y)*n+(-e._y+3*t._y-3*i._y+s._y)*o),c=.5*(2*t._z+(-e._z+i._z)*r+(2*e._z-5*t._z+4*i._z-s._z)*n+(-e._z+3*t._z-3*i._z+s._z)*o);return new _(h,l,c)}static Clamp(e,t,i){const s=new _;return _.ClampToRef(e,t,i,s),s}static ClampToRef(e,t,i,s){let r=e._x;r=r>i._x?i._x:r,r=r<t._x?t._x:r;let n=e._y;n=n>i._y?i._y:n,n=n<t._y?t._y:n;let o=e._z;return o=o>i._z?i._z:o,o=o<t._z?t._z:o,s.copyFromFloats(r,n,o),s}static CheckExtends(e,t,i){t.minimizeInPlace(e),i.maximizeInPlace(e)}static Hermite(e,t,i,s,r){const n=r*r,o=r*n,h=2*o-3*n+1,l=-2*o+3*n,c=o-2*n+r,u=o-n,f=e._x*h+i._x*l+t._x*c+s._x*u,d=e._y*h+i._y*l+t._y*c+s._y*u,g=e._z*h+i._z*l+t._z*c+s._z*u;return new _(f,d,g)}static Hermite1stDerivative(e,t,i,s,r){const n=new _;return this.Hermite1stDerivativeToRef(e,t,i,s,r,n),n}static Hermite1stDerivativeToRef(e,t,i,s,r,n){const o=r*r;return n._x=(o-r)*6*e._x+(3*o-4*r+1)*t._x+(-o+r)*6*i._x+(3*o-2*r)*s._x,n._y=(o-r)*6*e._y+(3*o-4*r+1)*t._y+(-o+r)*6*i._y+(3*o-2*r)*s._y,n._z=(o-r)*6*e._z+(3*o-4*r+1)*t._z+(-o+r)*6*i._z+(3*o-2*r)*s._z,n._isDirty=!0,n}static Lerp(e,t,i){const s=new _(0,0,0);return _.LerpToRef(e,t,i,s),s}static LerpToRef(e,t,i,s){return s._x=e._x+(t._x-e._x)*i,s._y=e._y+(t._y-e._y)*i,s._z=e._z+(t._z-e._z)*i,s._isDirty=!0,s}static Dot(e,t){return e._x*t._x+e._y*t._y+e._z*t._z}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z}static Cross(e,t){const i=new _;return _.CrossToRef(e,t,i),i}static CrossToRef(e,t,i){const s=e._y*t._z-e._z*t._y,r=e._z*t._x-e._x*t._z,n=e._x*t._y-e._y*t._x;return i.copyFromFloats(s,r,n),i}static Normalize(e){const t=_.Zero();return _.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Project(e,t,i,s){const r=new _;return _.ProjectToRef(e,t,i,s,r),r}static ProjectToRef(e,t,i,s,r){const n=s.width,o=s.height,h=s.x,l=s.y,c=X.Matrix[1],u=Te.LastCreatedEngine?.isNDCHalfZRange,f=u?1:.5,d=u?0:.5;P.FromValuesToRef(n/2,0,0,0,0,-o/2,0,0,0,0,f,0,h+n/2,o/2+l,d,1,c);const g=X.Matrix[0];return t.multiplyToRef(i,g),g.multiplyToRef(c,g),_.TransformCoordinatesToRef(e,g,r),r}static Reflect(e,t){return this.ReflectToRef(e,t,new _)}static ReflectToRef(e,t,i){const s=v.Vector3[0];return s.copyFrom(t).scaleInPlace(2*_.Dot(e,t)),i.copyFrom(e).subtractInPlace(s)}static UnprojectFromTransform(e,t,i,s,r){return this.Unproject(e,t,i,s,r,P.IdentityReadOnly)}static Unproject(e,t,i,s,r,n){const o=new _;return _.UnprojectToRef(e,t,i,s,r,n,o),o}static UnprojectToRef(e,t,i,s,r,n,o){return _.UnprojectFloatsToRef(e._x,e._y,e._z,t,i,s,r,n,o),o}static UnprojectFloatsToRef(e,t,i,s,r,n,o,h,l){const c=X.Matrix[0];n.multiplyToRef(o,c),c.multiplyToRef(h,c),c.invert();const u=X.Vector3[0];return u.x=e/s*2-1,u.y=-(t/r*2-1),Te.LastCreatedEngine?.isNDCHalfZRange?u.z=i:u.z=2*i-1,_.TransformCoordinatesToRef(u,c,l),l}static Minimize(e,t){const i=new _;return i.copyFrom(e),i.minimizeInPlace(t),i}static Maximize(e,t){const i=new _;return i.copyFrom(e),i.maximizeInPlace(t),i}static Distance(e,t){return Math.sqrt(_.DistanceSquared(e,t))}static DistanceSquared(e,t){const i=e._x-t._x,s=e._y-t._y,r=e._z-t._z;return i*i+s*s+r*r}static ProjectOnTriangleToRef(e,t,i,s,r){const n=X.Vector3[0],o=X.Vector3[1],h=X.Vector3[2],l=X.Vector3[3],c=X.Vector3[4];i.subtractToRef(t,n),s.subtractToRef(t,o),s.subtractToRef(i,h);const u=n.length(),f=o.length(),d=h.length();if(u<Me||f<Me||d<Me)return r.copyFrom(t),_.Distance(e,t);e.subtractToRef(t,c),_.CrossToRef(n,o,l);const g=l.length();if(g<Me)return r.copyFrom(t),_.Distance(e,t);l.normalizeFromLength(g);let p=c.length();if(p<Me)return r.copyFrom(t),0;c.normalizeFromLength(p);const m=_.Dot(l,c),A=X.Vector3[5],E=X.Vector3[6];A.copyFrom(l).scaleInPlace(-p*m),E.copyFrom(e).addInPlace(A);const I=X.Vector3[4],M=X.Vector3[5],C=X.Vector3[7],x=X.Vector3[8];I.copyFrom(n).scaleInPlace(1/u),x.copyFrom(o).scaleInPlace(1/f),I.addInPlace(x).scaleInPlace(-1),M.copyFrom(n).scaleInPlace(-1/u),x.copyFrom(h).scaleInPlace(1/d),M.addInPlace(x).scaleInPlace(-1),C.copyFrom(h).scaleInPlace(-1/d),x.copyFrom(o).scaleInPlace(-1/f),C.addInPlace(x).scaleInPlace(-1);const S=X.Vector3[9];let L;S.copyFrom(E).subtractInPlace(t),_.CrossToRef(I,S,x),L=_.Dot(x,l);const N=L;S.copyFrom(E).subtractInPlace(i),_.CrossToRef(M,S,x),L=_.Dot(x,l);const D=L;S.copyFrom(E).subtractInPlace(s),_.CrossToRef(C,S,x),L=_.Dot(x,l);const Re=L,pe=X.Vector3[10];let ce,oe;N>0&&D<0?(pe.copyFrom(n),ce=t,oe=i):D>0&&Re<0?(pe.copyFrom(h),ce=i,oe=s):(pe.copyFrom(o).scaleInPlace(-1),ce=s,oe=t);const Ye=X.Vector3[9],Qe=X.Vector3[4];if(ce.subtractToRef(E,x),oe.subtractToRef(E,Ye),_.CrossToRef(x,Ye,Qe),!(_.Dot(Qe,l)<0))return r.copyFrom(E),Math.abs(p*m);const de=X.Vector3[5];_.CrossToRef(pe,Qe,de),de.normalize();const Fe=X.Vector3[9];Fe.copyFrom(ce).subtractInPlace(E);const we=Fe.length();if(we<Me)return r.copyFrom(ce),_.Distance(e,ce);Fe.normalizeFromLength(we);const $e=_.Dot(de,Fe),at=X.Vector3[7];at.copyFrom(E).addInPlace(de.scaleInPlace(we*$e)),x.copyFrom(at).subtractInPlace(ce),p=pe.length(),pe.normalizeFromLength(p);let ke=_.Dot(x,pe)/Math.max(p,Me);return ke=be(ke,0,1),at.copyFrom(ce).addInPlace(pe.scaleInPlace(ke*p)),r.copyFrom(at),_.Distance(e,at)}static Center(e,t){return _.CenterToRef(e,t,_.Zero())}static CenterToRef(e,t,i){return i.copyFromFloats((e._x+t._x)/2,(e._y+t._y)/2,(e._z+t._z)/2)}static RotationFromAxis(e,t,i){const s=new _;return _.RotationFromAxisToRef(e,t,i,s),s}static RotationFromAxisToRef(e,t,i,s){const r=X.Quaternion[0];return W.RotationQuaternionFromAxisToRef(e,t,i,r),r.toEulerAnglesToRef(s),s}}_._V8PerformanceHack=new _(.5,.5,.5);_._UpReadOnly=_.Up();_._DownReadOnly=_.Down();_._LeftHandedForwardReadOnly=_.Forward(!1);_._RightHandedForwardReadOnly=_.Forward(!0);_._LeftHandedBackwardReadOnly=_.Backward(!1);_._RightHandedBackwardReadOnly=_.Backward(!0);_._RightReadOnly=_.Right();_._LeftReadOnly=_.Left();_._ZeroReadOnly=_.Zero();_._OneReadOnly=_.One();Object.defineProperties(_.prototype,{dimension:{value:[3]},rank:{value:1}});class ge{get x(){return this._x}set x(e){this._x=e,this._isDirty=!0}get y(){return this._y}set y(e){this._y=e,this._isDirty=!0}get z(){return this._z}set z(e){this._z=e,this._isDirty=!0}get w(){return this._w}set w(e){this._w=e,this._isDirty=!0}constructor(e=0,t=0,i=0,s=0){this._isDirty=!0,this._x=e,this._y=t,this._z=i,this._w=s}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z} W: ${this._w}}`}getClassName(){return"Vector4"}getHashCode(){const e=St(this._x),t=St(this._y),i=St(this._z),s=St(this._w);let r=e;return r=r*397^t,r=r*397^i,r=r*397^s,r}asArray(){return[this._x,this._y,this._z,this._w]}toArray(e,t){return t===void 0&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,this}fromArray(e,t=0){return ge.FromArrayToRef(e,t,this),this}addInPlace(e){return this.x+=e._x,this.y+=e._y,this.z+=e._z,this.w+=e._w,this}addInPlaceFromFloats(e,t,i,s){return this.x+=e,this.y+=t,this.z+=i,this.w+=s,this}add(e){return new ge(this._x+e.x,this._y+e.y,this._z+e.z,this._w+e.w)}addToRef(e,t){return t.x=this._x+e.x,t.y=this._y+e.y,t.z=this._z+e.z,t.w=this._w+e.w,t}subtractInPlace(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subtract(e){return new ge(this._x-e.x,this._y-e.y,this._z-e.z,this._w-e.w)}subtractToRef(e,t){return t.x=this._x-e.x,t.y=this._y-e.y,t.z=this._z-e.z,t.w=this._w-e.w,t}subtractFromFloats(e,t,i,s){return new ge(this._x-e,this._y-t,this._z-i,this._w-s)}subtractFromFloatsToRef(e,t,i,s,r){return r.x=this._x-e,r.y=this._y-t,r.z=this._z-i,r.w=this._w-s,r}negate(){return new ge(-this._x,-this._y,-this._z,-this._w)}negateInPlace(){return this.x*=-1,this.y*=-1,this.z*=-1,this.w*=-1,this}negateToRef(e){return e.x=-this._x,e.y=-this._y,e.z=-this._z,e.w=-this._w,e}scaleInPlace(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}scale(e){return new ge(this._x*e,this._y*e,this._z*e,this._w*e)}scaleToRef(e,t){return t.x=this._x*e,t.y=this._y*e,t.z=this._z*e,t.w=this._w*e,t}scaleAndAddToRef(e,t){return t.x+=this._x*e,t.y+=this._y*e,t.z+=this._z*e,t.w+=this._w*e,t}equals(e){return e&&this._x===e.x&&this._y===e.y&&this._z===e.z&&this._w===e.w}equalsWithEpsilon(e,t=Me){return e&&Pe(this._x,e.x,t)&&Pe(this._y,e.y,t)&&Pe(this._z,e.z,t)&&Pe(this._w,e.w,t)}equalsToFloats(e,t,i,s){return this._x===e&&this._y===t&&this._z===i&&this._w===s}multiplyInPlace(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiply(e){return new ge(this._x*e.x,this._y*e.y,this._z*e.z,this._w*e.w)}multiplyToRef(e,t){return t.x=this._x*e.x,t.y=this._y*e.y,t.z=this._z*e.z,t.w=this._w*e.w,t}multiplyByFloats(e,t,i,s){return new ge(this._x*e,this._y*t,this._z*i,this._w*s)}divide(e){return new ge(this._x/e.x,this._y/e.y,this._z/e.z,this._w/e.w)}divideToRef(e,t){return t.x=this._x/e.x,t.y=this._y/e.y,t.z=this._z/e.z,t.w=this._w/e.w,t}divideInPlace(e){return this.divideToRef(e,this)}minimizeInPlace(e){return e.x<this._x&&(this.x=e.x),e.y<this._y&&(this.y=e.y),e.z<this._z&&(this.z=e.z),e.w<this._w&&(this.w=e.w),this}maximizeInPlace(e){return e.x>this._x&&(this.x=e.x),e.y>this._y&&(this.y=e.y),e.z>this._z&&(this.z=e.z),e.w>this._w&&(this.w=e.w),this}minimizeInPlaceFromFloats(e,t,i,s){return this.x=Math.min(e,this._x),this.y=Math.min(t,this._y),this.z=Math.min(i,this._z),this.w=Math.min(s,this._w),this}maximizeInPlaceFromFloats(e,t,i,s){return this.x=Math.max(e,this._x),this.y=Math.max(t,this._y),this.z=Math.max(i,this._z),this.w=Math.max(s,this._w),this}floorToRef(e){return e.x=Math.floor(this._x),e.y=Math.floor(this._y),e.z=Math.floor(this._z),e.w=Math.floor(this._w),e}floor(){return new ge(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z),Math.floor(this._w))}fractToRef(e){return e.x=this._x-Math.floor(this._x),e.y=this._y-Math.floor(this._y),e.z=this._z-Math.floor(this._z),e.w=this._w-Math.floor(this._w),e}fract(){return new ge(this._x-Math.floor(this._x),this._y-Math.floor(this._y),this._z-Math.floor(this._z),this._w-Math.floor(this._w))}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}lengthSquared(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){return this.normalizeToRef(new ge)}normalizeToRef(e){const t=this.length();return t===0||t===1?(e.x=this._x,e.y=this._y,e.z=this._z,e.w=this._w,e):this.scaleToRef(1/t,e)}toVector3(){return new _(this._x,this._y,this._z)}clone(){return new ge(this._x,this._y,this._z,this._w)}copyFrom(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}copyFromFloats(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}set(e,t,i,s){return this.copyFromFloats(e,t,i,s)}setAll(e){return this.x=this.y=this.z=this.w=e,this}dot(e){return this._x*e.x+this._y*e.y+this._z*e.z+this._w*e.w}static FromArray(e,t){return t||(t=0),new ge(e[t],e[t+1],e[t+2],e[t+3])}static FromArrayToRef(e,t,i){return i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3],i}static FromFloatArrayToRef(e,t,i){return ge.FromArrayToRef(e,t,i),i}static FromFloatsToRef(e,t,i,s,r){return r.x=e,r.y=t,r.z=i,r.w=s,r}static Zero(){return new ge(0,0,0,0)}static One(){return new ge(1,1,1,1)}static Random(e=0,t=1){return new ge(Ve(e,t),Ve(e,t),Ve(e,t),Ve(e,t))}static RandomToRef(e=0,t=1,i){return i.x=Ve(e,t),i.y=Ve(e,t),i.z=Ve(e,t),i.w=Ve(e,t),i}static Clamp(e,t,i){return ge.ClampToRef(e,t,i,new ge)}static ClampToRef(e,t,i,s){return s.x=be(e.x,t.x,i.x),s.y=be(e.y,t.y,i.y),s.z=be(e.z,t.z,i.z),s.w=be(e.w,t.w,i.w),s}static CheckExtends(e,t,i){t.minimizeInPlace(e),i.maximizeInPlace(e)}static get ZeroReadOnly(){return ge._ZeroReadOnly}static Normalize(e){return ge.NormalizeToRef(e,new ge)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){const i=new ge;return i.copyFrom(e),i.minimizeInPlace(t),i}static Maximize(e,t){const i=new ge;return i.copyFrom(e),i.maximizeInPlace(t),i}static Distance(e,t){return Math.sqrt(ge.DistanceSquared(e,t))}static DistanceSquared(e,t){const i=e.x-t.x,s=e.y-t.y,r=e.z-t.z,n=e.w-t.w;return i*i+s*s+r*r+n*n}static Center(e,t){return ge.CenterToRef(e,t,new ge)}static CenterToRef(e,t,i){return i.x=(e.x+t.x)/2,i.y=(e.y+t.y)/2,i.z=(e.z+t.z)/2,i.w=(e.w+t.w)/2,i}static TransformCoordinates(e,t){return ge.TransformCoordinatesToRef(e,t,new ge)}static TransformCoordinatesToRef(e,t,i){return ge.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformCoordinatesFromFloatsToRef(e,t,i,s,r){const n=s.m,o=e*n[0]+t*n[4]+i*n[8]+n[12],h=e*n[1]+t*n[5]+i*n[9]+n[13],l=e*n[2]+t*n[6]+i*n[10]+n[14],c=e*n[3]+t*n[7]+i*n[11]+n[15];return r.x=o,r.y=h,r.z=l,r.w=c,r}static TransformNormal(e,t){return ge.TransformNormalToRef(e,t,new ge)}static TransformNormalToRef(e,t,i){const s=t.m,r=e.x*s[0]+e.y*s[4]+e.z*s[8],n=e.x*s[1]+e.y*s[5]+e.z*s[9],o=e.x*s[2]+e.y*s[6]+e.z*s[10];return i.x=r,i.y=n,i.z=o,i.w=e.w,i}static TransformNormalFromFloatsToRef(e,t,i,s,r,n){const o=r.m;return n.x=e*o[0]+t*o[4]+i*o[8],n.y=e*o[1]+t*o[5]+i*o[9],n.z=e*o[2]+t*o[6]+i*o[10],n.w=s,n}static FromVector3(e,t=0){return new ge(e._x,e._y,e._z,t)}static Dot(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w}}ge._V8PerformanceHack=new ge(.5,.5,.5,.5);ge._ZeroReadOnly=ge.Zero();Object.defineProperties(ge.prototype,{dimension:{value:[4]},rank:{value:1}});class W{get x(){return this._x}set x(e){this._x=e,this._isDirty=!0}get y(){return this._y}set y(e){this._y=e,this._isDirty=!0}get z(){return this._z}set z(e){this._z=e,this._isDirty=!0}get w(){return this._w}set w(e){this._w=e,this._isDirty=!0}constructor(e=0,t=0,i=0,s=1){this._isDirty=!0,this._x=e,this._y=t,this._z=i,this._w=s}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z} W: ${this._w}}`}getClassName(){return"Quaternion"}getHashCode(){const e=St(this._x),t=St(this._y),i=St(this._z),s=St(this._w);let r=e;return r=r*397^t,r=r*397^i,r=r*397^s,r}asArray(){return[this._x,this._y,this._z,this._w]}toArray(e,t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,this}fromArray(e,t=0){return W.FromArrayToRef(e,t,this)}equals(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z&&this._w===e._w}equalsWithEpsilon(e,t=Me){return e&&Pe(this._x,e._x,t)&&Pe(this._y,e._y,t)&&Pe(this._z,e._z,t)&&Pe(this._w,e._w,t)}isApprox(e,t=Me){return e&&(Pe(this._x,e._x,t)&&Pe(this._y,e._y,t)&&Pe(this._z,e._z,t)&&Pe(this._w,e._w,t)||Pe(this._x,-e._x,t)&&Pe(this._y,-e._y,t)&&Pe(this._z,-e._z,t)&&Pe(this._w,-e._w,t))}clone(){return new W(this._x,this._y,this._z,this._w)}copyFrom(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._w=e._w,this._isDirty=!0,this}copyFromFloats(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._isDirty=!0,this}set(e,t,i,s){return this.copyFromFloats(e,t,i,s)}setAll(e){return this.copyFromFloats(e,e,e,e)}add(e){return new W(this._x+e._x,this._y+e._y,this._z+e._z,this._w+e._w)}addInPlace(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._w+=e._w,this._isDirty=!0,this}addToRef(e,t){return t._x=this._x+e._x,t._y=this._y+e._y,t._z=this._z+e._z,t._w=this._w+e._w,t._isDirty=!0,t}addInPlaceFromFloats(e,t,i,s){return this._x+=e,this._y+=t,this._z+=i,this._w+=s,this._isDirty=!0,this}subtractToRef(e,t){return t._x=this._x-e._x,t._y=this._y-e._y,t._z=this._z-e._z,t._w=this._w-e._w,t._isDirty=!0,t}subtractFromFloats(e,t,i,s){return this.subtractFromFloatsToRef(e,t,i,s,new W)}subtractFromFloatsToRef(e,t,i,s,r){return r._x=this._x-e,r._y=this._y-t,r._z=this._z-i,r._w=this._w-s,r._isDirty=!0,r}subtract(e){return new W(this._x-e._x,this._y-e._y,this._z-e._z,this._w-e._w)}subtractInPlace(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._w-=e._w,this._isDirty=!0,this}scale(e){return new W(this._x*e,this._y*e,this._z*e,this._w*e)}scaleToRef(e,t){return t._x=this._x*e,t._y=this._y*e,t._z=this._z*e,t._w=this._w*e,t._isDirty=!0,t}scaleInPlace(e){return this._x*=e,this._y*=e,this._z*=e,this._w*=e,this._isDirty=!0,this}scaleAndAddToRef(e,t){return t._x+=this._x*e,t._y+=this._y*e,t._z+=this._z*e,t._w+=this._w*e,t._isDirty=!0,t}multiply(e){const t=new W(0,0,0,1);return this.multiplyToRef(e,t),t}multiplyToRef(e,t){const i=this._x*e._w+this._y*e._z-this._z*e._y+this._w*e._x,s=-this._x*e._z+this._y*e._w+this._z*e._x+this._w*e._y,r=this._x*e._y-this._y*e._x+this._z*e._w+this._w*e._z,n=-this._x*e._x-this._y*e._y-this._z*e._z+this._w*e._w;return t.copyFromFloats(i,s,r,n),t}multiplyInPlace(e){return this.multiplyToRef(e,this)}multiplyByFloats(e,t,i,s){return this._x*=e,this._y*=t,this._z*=i,this._w*=s,this._isDirty=!0,this}divide(e){throw new ReferenceError("Can not divide a quaternion")}divideToRef(e,t){throw new ReferenceError("Can not divide a quaternion")}divideInPlace(e){throw new ReferenceError("Can not divide a quaternion")}minimizeInPlace(){throw new ReferenceError("Can not minimize a quaternion")}minimizeInPlaceFromFloats(){throw new ReferenceError("Can not minimize a quaternion")}maximizeInPlace(){throw new ReferenceError("Can not maximize a quaternion")}maximizeInPlaceFromFloats(){throw new ReferenceError("Can not maximize a quaternion")}negate(){return this.negateToRef(new W)}negateInPlace(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._isDirty=!0,this}negateToRef(e){return e._x=-this._x,e._y=-this._y,e._z=-this._z,e._w=-this._w,e._isDirty=!0,e}equalsToFloats(e,t,i,s){return this._x===e&&this._y===t&&this._z===i&&this._w===s}floorToRef(e){throw new ReferenceError("Can not floor a quaternion")}floor(){throw new ReferenceError("Can not floor a quaternion")}fractToRef(e){throw new ReferenceError("Can not fract a quaternion")}fract(){throw new ReferenceError("Can not fract a quaternion")}conjugateToRef(e){return e.copyFromFloats(-this._x,-this._y,-this._z,this._w),e}conjugateInPlace(){return this._x*=-1,this._y*=-1,this._z*=-1,this._isDirty=!0,this}conjugate(){return new W(-this._x,-this._y,-this._z,this._w)}invert(){const e=this.conjugate(),t=this.lengthSquared();return t==0||t==1||e.scaleInPlace(1/t),e}invertInPlace(){this.conjugateInPlace();const e=this.lengthSquared();return e==0||e==1?this:(this.scaleInPlace(1/e),this)}lengthSquared(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this.lengthSquared())}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){const e=new W(0,0,0,1);return this.normalizeToRef(e),e}normalizeToRef(e){const t=this.length();return t===0||t===1?e.copyFromFloats(this._x,this._y,this._z,this._w):this.scaleToRef(1/t,e)}toEulerAngles(){const e=_.Zero();return this.toEulerAnglesToRef(e),e}toEulerAnglesToRef(e){const t=this._z,i=this._x,s=this._y,r=this._w,n=s*t-i*r,o=.4999999;if(n<-o)e._y=2*Math.atan2(s,r),e._x=Math.PI/2,e._z=0,e._isDirty=!0;else if(n>o)e._y=2*Math.atan2(s,r),e._x=-Math.PI/2,e._z=0,e._isDirty=!0;else{const h=r*r,l=t*t,c=i*i,u=s*s;e._z=Math.atan2(2*(i*s+t*r),-l-c+u+h),e._x=Math.asin(-2*n),e._y=Math.atan2(2*(t*i+s*r),l-c-u+h),e._isDirty=!0}return e}toAlphaBetaGammaToRef(e){const t=this._z,i=this._x,s=this._y,r=this._w,n=Math.sqrt(i*i+s*s),o=Math.sqrt(t*t+r*r),h=2*Math.atan2(n,o),l=2*Math.atan2(t,r),c=2*Math.atan2(s,i),u=(l+c)/2,f=(l-c)/2;return e.set(f,h,u),e}toRotationMatrix(e){return P.FromQuaternionToRef(this,e),e}fromRotationMatrix(e){return W.FromRotationMatrixToRef(e,this),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}toAxisAngle(){const e=_.Zero(),t=this.toAxisAngleToRef(e);return{axis:e,angle:t}}toAxisAngleToRef(e){let t=0;const i=Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z),s=this._w;return i>0?(t=2*Math.atan2(i,s),e.set(this._x/i,this._y/i,this._z/i)):(t=0,e.set(1,0,0)),t}static FromRotationMatrix(e){const t=new W;return W.FromRotationMatrixToRef(e,t),t}static FromRotationMatrixToRef(e,t){const i=e.m,s=i[0],r=i[4],n=i[8],o=i[1],h=i[5],l=i[9],c=i[2],u=i[6],f=i[10],d=s+h+f;let g;return d>0?(g=.5/Math.sqrt(d+1),t._w=.25/g,t._x=(u-l)*g,t._y=(n-c)*g,t._z=(o-r)*g,t._isDirty=!0):s>h&&s>f?(g=2*Math.sqrt(1+s-h-f),t._w=(u-l)/g,t._x=.25*g,t._y=(r+o)/g,t._z=(n+c)/g,t._isDirty=!0):h>f?(g=2*Math.sqrt(1+h-s-f),t._w=(n-c)/g,t._x=(r+o)/g,t._y=.25*g,t._z=(l+u)/g,t._isDirty=!0):(g=2*Math.sqrt(1+f-s-h),t._w=(o-r)/g,t._x=(n+c)/g,t._y=(l+u)/g,t._z=.25*g,t._isDirty=!0),t}static Dot(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w}static AreClose(e,t,i=.1){const s=W.Dot(e,t);return 1-s*s<=i}static SmoothToRef(e,t,i,s,r){let n=s===0?1:i/s;return n=be(n,0,1),W.SlerpToRef(e,t,n,r),r}static Zero(){return new W(0,0,0,0)}static Inverse(e){return new W(-e._x,-e._y,-e._z,e._w)}static InverseToRef(e,t){return t.set(-e._x,-e._y,-e._z,e._w),t}static Identity(){return new W(0,0,0,1)}static IsIdentity(e){return e&&e._x===0&&e._y===0&&e._z===0&&e._w===1}static RotationAxis(e,t){return W.RotationAxisToRef(e,t,new W)}static RotationAxisToRef(e,t,i){i._w=Math.cos(t/2);const s=Math.sin(t/2)/e.length();return i._x=e._x*s,i._y=e._y*s,i._z=e._z*s,i._isDirty=!0,i}static FromArray(e,t){return t||(t=0),new W(e[t],e[t+1],e[t+2],e[t+3])}static FromArrayToRef(e,t,i){return i._x=e[t],i._y=e[t+1],i._z=e[t+2],i._w=e[t+3],i._isDirty=!0,i}static FromFloatsToRef(e,t,i,s,r){return r.copyFromFloats(e,t,i,s),r}static FromEulerAngles(e,t,i){const s=new W;return W.RotationYawPitchRollToRef(t,e,i,s),s}static FromEulerAnglesToRef(e,t,i,s){return W.RotationYawPitchRollToRef(t,e,i,s),s}static FromEulerVector(e){const t=new W;return W.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromEulerVectorToRef(e,t){return W.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromUnitVectorsToRef(e,t,i,s=Me){const r=_.Dot(e,t)+1;return r<s?Math.abs(e.x)>Math.abs(e.z)?i.set(-e.y,e.x,0,0):i.set(0,-e.z,e.y,0):(_.CrossToRef(e,t,v.Vector3[0]),i.set(v.Vector3[0].x,v.Vector3[0].y,v.Vector3[0].z,r)),i.normalize()}static RotationYawPitchRoll(e,t,i){const s=new W;return W.RotationYawPitchRollToRef(e,t,i,s),s}static RotationYawPitchRollToRef(e,t,i,s){const r=i*.5,n=t*.5,o=e*.5,h=Math.sin(r),l=Math.cos(r),c=Math.sin(n),u=Math.cos(n),f=Math.sin(o),d=Math.cos(o);return s._x=d*c*l+f*u*h,s._y=f*u*l-d*c*h,s._z=d*u*h-f*c*l,s._w=d*u*l+f*c*h,s._isDirty=!0,s}static RotationAlphaBetaGamma(e,t,i){const s=new W;return W.RotationAlphaBetaGammaToRef(e,t,i,s),s}static RotationAlphaBetaGammaToRef(e,t,i,s){const r=(i+e)*.5,n=(i-e)*.5,o=t*.5;return s._x=Math.cos(n)*Math.sin(o),s._y=Math.sin(n)*Math.sin(o),s._z=Math.sin(r)*Math.cos(o),s._w=Math.cos(r)*Math.cos(o),s._isDirty=!0,s}static RotationQuaternionFromAxis(e,t,i){const s=new W(0,0,0,0);return W.RotationQuaternionFromAxisToRef(e,t,i,s),s}static RotationQuaternionFromAxisToRef(e,t,i,s){const r=X.Matrix[0];return e=e.normalizeToRef(X.Vector3[0]),t=t.normalizeToRef(X.Vector3[1]),i=i.normalizeToRef(X.Vector3[2]),P.FromXYZAxesToRef(e,t,i,r),W.FromRotationMatrixToRef(r,s),s}static FromLookDirectionLH(e,t){const i=new W;return W.FromLookDirectionLHToRef(e,t,i),i}static FromLookDirectionLHToRef(e,t,i){const s=X.Matrix[0];return P.LookDirectionLHToRef(e,t,s),W.FromRotationMatrixToRef(s,i),i}static FromLookDirectionRH(e,t){const i=new W;return W.FromLookDirectionRHToRef(e,t,i),i}static FromLookDirectionRHToRef(e,t,i){const s=X.Matrix[0];return P.LookDirectionRHToRef(e,t,s),W.FromRotationMatrixToRef(s,i)}static Slerp(e,t,i){const s=W.Identity();return W.SlerpToRef(e,t,i,s),s}static SlerpToRef(e,t,i,s){let r,n,o=e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w,h=!1;if(o<0&&(h=!0,o=-o),o>.999999)n=1-i,r=h?-i:i;else{const l=Math.acos(o),c=1/Math.sin(l);n=Math.sin((1-i)*l)*c,r=h?-Math.sin(i*l)*c:Math.sin(i*l)*c}return s._x=n*e._x+r*t._x,s._y=n*e._y+r*t._y,s._z=n*e._z+r*t._z,s._w=n*e._w+r*t._w,s._isDirty=!0,s}static Hermite(e,t,i,s,r){const n=r*r,o=r*n,h=2*o-3*n+1,l=-2*o+3*n,c=o-2*n+r,u=o-n,f=e._x*h+i._x*l+t._x*c+s._x*u,d=e._y*h+i._y*l+t._y*c+s._y*u,g=e._z*h+i._z*l+t._z*c+s._z*u,p=e._w*h+i._w*l+t._w*c+s._w*u;return new W(f,d,g,p)}static Hermite1stDerivative(e,t,i,s,r){const n=new W;return this.Hermite1stDerivativeToRef(e,t,i,s,r,n),n}static Hermite1stDerivativeToRef(e,t,i,s,r,n){const o=r*r;return n._x=(o-r)*6*e._x+(3*o-4*r+1)*t._x+(-o+r)*6*i._x+(3*o-2*r)*s._x,n._y=(o-r)*6*e._y+(3*o-4*r+1)*t._y+(-o+r)*6*i._y+(3*o-2*r)*s._y,n._z=(o-r)*6*e._z+(3*o-4*r+1)*t._z+(-o+r)*6*i._z+(3*o-2*r)*s._z,n._w=(o-r)*6*e._w+(3*o-4*r+1)*t._w+(-o+r)*6*i._w+(3*o-2*r)*s._w,n._isDirty=!0,n}static Normalize(e){const t=W.Zero();return W.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Clamp(e,t,i){const s=new W;return W.ClampToRef(e,t,i,s),s}static ClampToRef(e,t,i,s){return s.copyFromFloats(be(e.x,t.x,i.x),be(e.y,t.y,i.y),be(e.z,t.z,i.z),be(e.w,t.w,i.w))}static Random(e=0,t=1){return new W(Ve(e,t),Ve(e,t),Ve(e,t),Ve(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(Ve(e,t),Ve(e,t),Ve(e,t),Ve(e,t))}static Minimize(){throw new ReferenceError("Quaternion.Minimize does not make sense")}static Maximize(){throw new ReferenceError("Quaternion.Maximize does not make sense")}static Distance(e,t){return Math.sqrt(W.DistanceSquared(e,t))}static DistanceSquared(e,t){const i=e.x-t.x,s=e.y-t.y,r=e.z-t.z,n=e.w-t.w;return i*i+s*s+r*r+n*n}static Center(e,t){return W.CenterToRef(e,t,W.Zero())}static CenterToRef(e,t,i){return i.copyFromFloats((e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2,(e.w+t.w)/2)}}W._V8PerformanceHack=new W(.5,.5,.5,.5);Object.defineProperties(W.prototype,{dimension:{value:[4]},rank:{value:1}});class P{static get Use64Bits(){return st.MatrixUse64Bits}get m(){return this._m}markAsUpdated(){this.updateFlag=Cn._UpdateFlagSeed++,this._isIdentity=!1,this._isIdentity3x2=!1,this._isIdentityDirty=!0,this._isIdentity3x2Dirty=!0}_updateIdentityStatus(e,t=!1,i=!1,s=!0){this._isIdentity=e,this._isIdentity3x2=e||i,this._isIdentityDirty=this._isIdentity?!1:t,this._isIdentity3x2Dirty=this._isIdentity3x2?!1:s}constructor(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,st.MatrixTrackPrecisionChange&&st.MatrixTrackedMatrices.push(this),this._m=new st.MatrixCurrentType(16),this.markAsUpdated()}isIdentity(){if(this._isIdentityDirty){this._isIdentityDirty=!1;const e=this._m;this._isIdentity=e[0]===1&&e[1]===0&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===1&&e[6]===0&&e[7]===0&&e[8]===0&&e[9]===0&&e[10]===1&&e[11]===0&&e[12]===0&&e[13]===0&&e[14]===0&&e[15]===1}return this._isIdentity}isIdentityAs3x2(){return this._isIdentity3x2Dirty&&(this._isIdentity3x2Dirty=!1,this._m[0]!==1||this._m[5]!==1||this._m[15]!==1?this._isIdentity3x2=!1:this._m[1]!==0||this._m[2]!==0||this._m[3]!==0||this._m[4]!==0||this._m[6]!==0||this._m[7]!==0||this._m[8]!==0||this._m[9]!==0||this._m[10]!==0||this._m[11]!==0||this._m[12]!==0||this._m[13]!==0||this._m[14]!==0?this._isIdentity3x2=!1:this._isIdentity3x2=!0),this._isIdentity3x2}determinant(){if(this._isIdentity===!0)return 1;const e=this._m,t=e[0],i=e[1],s=e[2],r=e[3],n=e[4],o=e[5],h=e[6],l=e[7],c=e[8],u=e[9],f=e[10],d=e[11],g=e[12],p=e[13],m=e[14],A=e[15],E=f*A-m*d,I=u*A-p*d,M=u*m-p*f,C=c*A-g*d,x=c*m-f*g,S=c*p-g*u,L=+(o*E-h*I+l*M),N=-(n*E-h*C+l*x),D=+(n*I-o*C+l*S),Re=-(n*M-o*x+h*S);return t*L+i*N+s*D+r*Re}toString(){return`{${this.m[0]}, ${this.m[1]}, ${this.m[2]}, ${this.m[3]}
3${this.m[4]}, ${this.m[5]}, ${this.m[6]}, ${this.m[7]}
4${this.m[8]}, ${this.m[9]}, ${this.m[10]}, ${this.m[11]}
5${this.m[12]}, ${this.m[13]}, ${this.m[14]}, ${this.m[15]}}`}toArray(e=null,t=0){if(!e)return this._m;const i=this._m;for(let s=0;s<16;s++)e[t+s]=i[s];return this}asArray(){return this._m}fromArray(e,t=0){return P.FromArrayToRef(e,t,this)}copyFromFloats(...e){return P.FromArrayToRef(e,0,this)}set(...e){const t=this._m;for(let i=0;i<16;i++)t[i]=e[i];return this.markAsUpdated(),this}setAll(e){const t=this._m;for(let i=0;i<16;i++)t[i]=e;return this.markAsUpdated(),this}invert(){return this.invertToRef(this),this}reset(){return P.FromValuesToRef(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,this),this._updateIdentityStatus(!1),this}add(e){const t=new P;return this.addToRef(e,t),t}addToRef(e,t){const i=this._m,s=t._m,r=e.m;for(let n=0;n<16;n++)s[n]=i[n]+r[n];return t.markAsUpdated(),t}addToSelf(e){const t=this._m,i=e.m;return t[0]+=i[0],t[1]+=i[1],t[2]+=i[2],t[3]+=i[3],t[4]+=i[4],t[5]+=i[5],t[6]+=i[6],t[7]+=i[7],t[8]+=i[8],t[9]+=i[9],t[10]+=i[10],t[11]+=i[11],t[12]+=i[12],t[13]+=i[13],t[14]+=i[14],t[15]+=i[15],this.markAsUpdated(),this}addInPlace(e){const t=this._m,i=e.m;for(let s=0;s<16;s++)t[s]+=i[s];return this.markAsUpdated(),this}addInPlaceFromFloats(...e){const t=this._m;for(let i=0;i<16;i++)t[i]+=e[i];return this.markAsUpdated(),this}subtract(e){const t=this._m,i=e.m;for(let s=0;s<16;s++)t[s]-=i[s];return this.markAsUpdated(),this}subtractToRef(e,t){const i=this._m,s=e.m,r=t._m;for(let n=0;n<16;n++)r[n]=i[n]-s[n];return t.markAsUpdated(),t}subtractInPlace(e){const t=this._m,i=e.m;for(let s=0;s<16;s++)t[s]-=i[s];return this.markAsUpdated(),this}subtractFromFloats(...e){return this.subtractFromFloatsToRef(...e,new P)}subtractFromFloatsToRef(...e){const t=e.pop(),i=this._m,s=t._m,r=e;for(let n=0;n<16;n++)s[n]=i[n]-r[n];return t.markAsUpdated(),t}invertToRef(e){return this._isIdentity===!0?(P.IdentityToRef(e),e):(yo(this,e.asArray())?e.markAsUpdated():e.copyFrom(this),e)}addAtIndex(e,t){return this._m[e]+=t,this.markAsUpdated(),this}multiplyAtIndex(e,t){return this._m[e]*=t,this.markAsUpdated(),this}setTranslationFromFloats(e,t,i){return this._m[12]=e,this._m[13]=t,this._m[14]=i,this.markAsUpdated(),this}addTranslationFromFloats(e,t,i){return this._m[12]+=e,this._m[13]+=t,this._m[14]+=i,this.markAsUpdated(),this}setTranslation(e){return this.setTranslationFromFloats(e._x,e._y,e._z)}getTranslation(){return new _(this._m[12],this._m[13],this._m[14])}getTranslationToRef(e){return e.x=this._m[12],e.y=this._m[13],e.z=this._m[14],e}removeRotationAndScaling(){const e=this.m;return P.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e[12],e[13],e[14],e[15],this),this._updateIdentityStatus(e[12]===0&&e[13]===0&&e[14]===0&&e[15]===1),this}copyFrom(e){e.copyToArray(this._m);const t=e;return this.updateFlag=t.updateFlag,this._updateIdentityStatus(t._isIdentity,t._isIdentityDirty,t._isIdentity3x2,t._isIdentity3x2Dirty),this}copyToArray(e,t=0){return Ul(this,e,t),this}multiply(e){const t=new P;return this.multiplyToRef(e,t),t}multiplyInPlace(e){const t=this._m,i=e.m;for(let s=0;s<16;s++)t[s]*=i[s];return this.markAsUpdated(),this}multiplyByFloats(...e){const t=this._m;for(let i=0;i<16;i++)t[i]*=e[i];return this.markAsUpdated(),this}multiplyByFloatsToRef(...e){const t=e.pop(),i=this._m,s=t._m,r=e;for(let n=0;n<16;n++)s[n]=i[n]*r[n];return t.markAsUpdated(),t}multiplyToRef(e,t){return this._isIdentity?(t.copyFrom(e),t):e._isIdentity?(t.copyFrom(this),t):(this.multiplyToArray(e,t._m,0),t.markAsUpdated(),t)}multiplyToArray(e,t,i){return Ro(this,e,t,i),this}divide(e){return this.divideToRef(e,new P)}divideToRef(e,t){const i=this._m,s=e.m,r=t._m;for(let n=0;n<16;n++)r[n]=i[n]/s[n];return t.markAsUpdated(),t}divideInPlace(e){const t=this._m,i=e.m;for(let s=0;s<16;s++)t[s]/=i[s];return this.markAsUpdated(),this}minimizeInPlace(e){const t=this._m,i=e.m;for(let s=0;s<16;s++)t[s]=Math.min(t[s],i[s]);return this.markAsUpdated(),this}minimizeInPlaceFromFloats(...e){const t=this._m;for(let i=0;i<16;i++)t[i]=Math.min(t[i],e[i]);return this.markAsUpdated(),this}maximizeInPlace(e){const t=this._m,i=e.m;for(let s=0;s<16;s++)t[s]=Math.min(t[s],i[s]);return this.markAsUpdated(),this}maximizeInPlaceFromFloats(...e){const t=this._m;for(let i=0;i<16;i++)t[i]=Math.min(t[i],e[i]);return this.markAsUpdated(),this}negate(){return this.negateToRef(new P)}negateInPlace(){const e=this._m;for(let t=0;t<16;t++)e[t]=-e[t];return this.markAsUpdated(),this}negateToRef(e){const t=this._m,i=e._m;for(let s=0;s<16;s++)i[s]=-t[s];return e.markAsUpdated(),e}equals(e){const t=e;if(!t)return!1;if((this._isIdentity||t._isIdentity)&&!this._isIdentityDirty&&!t._isIdentityDirty)return this._isIdentity&&t._isIdentity;const i=this.m,s=t.m;return i[0]===s[0]&&i[1]===s[1]&&i[2]===s[2]&&i[3]===s[3]&&i[4]===s[4]&&i[5]===s[5]&&i[6]===s[6]&&i[7]===s[7]&&i[8]===s[8]&&i[9]===s[9]&&i[10]===s[10]&&i[11]===s[11]&&i[12]===s[12]&&i[13]===s[13]&&i[14]===s[14]&&i[15]===s[15]}equalsWithEpsilon(e,t=0){const i=this._m,s=e.m;for(let r=0;r<16;r++)if(!Pe(i[r],s[r],t))return!1;return!0}equalsToFloats(...e){const t=this._m;for(let i=0;i<16;i++)if(t[i]!=e[i])return!1;return!0}floor(){return this.floorToRef(new P)}floorToRef(e){const t=this._m,i=e._m;for(let s=0;s<16;s++)i[s]=Math.floor(t[s]);return e.markAsUpdated(),e}fract(){return this.fractToRef(new P)}fractToRef(e){const t=this._m,i=e._m;for(let s=0;s<16;s++)i[s]=t[s]-Math.floor(t[s]);return e.markAsUpdated(),e}clone(){const e=new P;return e.copyFrom(this),e}getClassName(){return"Matrix"}getHashCode(){let e=St(this._m[0]);for(let t=1;t<16;t++)e=e*397^St(this._m[t]);return e}decomposeToTransformNode(e){return e.rotationQuaternion=e.rotationQuaternion||new W,this.decompose(e.scaling,e.rotationQuaternion,e.position)}decompose(e,t,i,s,r=!0){if(this._isIdentity)return i&&i.setAll(0),e&&e.setAll(1),t&&t.copyFromFloats(0,0,0,1),!0;const n=this._m;if(i&&i.copyFromFloats(n[12],n[13],n[14]),e=e||X.Vector3[0],e.x=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]),e.y=Math.sqrt(n[4]*n[4]+n[5]*n[5]+n[6]*n[6]),e.z=Math.sqrt(n[8]*n[8]+n[9]*n[9]+n[10]*n[10]),s){const o=(r?s.absoluteScaling.x:s.scaling.x)<0?-1:1,h=(r?s.absoluteScaling.y:s.scaling.y)<0?-1:1,l=(r?s.absoluteScaling.z:s.scaling.z)<0?-1:1;e.x*=o,e.y*=h,e.z*=l}else this.determinant()<=0&&(e.y*=-1);if(e._x===0||e._y===0||e._z===0)return t&&t.copyFromFloats(0,0,0,1),!1;if(t){const o=1/e._x,h=1/e._y,l=1/e._z;P.FromValuesToRef(n[0]*o,n[1]*o,n[2]*o,0,n[4]*h,n[5]*h,n[6]*h,0,n[8]*l,n[9]*l,n[10]*l,0,0,0,0,1,X.Matrix[0]),W.FromRotationMatrixToRef(X.Matrix[0],t)}return!0}getRow(e){if(e<0||e>3)return null;const t=e*4;return new ge(this._m[t+0],this._m[t+1],this._m[t+2],this._m[t+3])}getRowToRef(e,t){if(e>=0&&e<=3){const i=e*4;t.x=this._m[i+0],t.y=this._m[i+1],t.z=this._m[i+2],t.w=this._m[i+3]}return t}setRow(e,t){return this.setRowFromFloats(e,t.x,t.y,t.z,t.w)}transpose(){const e=new P;return P.TransposeToRef(this,e),e}transposeToRef(e){return P.TransposeToRef(this,e),e}setRowFromFloats(e,t,i,s,r){if(e<0||e>3)return this;const n=e*4;return this._m[n+0]=t,this._m[n+1]=i,this._m[n+2]=s,this._m[n+3]=r,this.markAsUpdated(),this}scale(e){const t=new P;return this.scaleToRef(e,t),t}scaleToRef(e,t){for(let i=0;i<16;i++)t._m[i]=this._m[i]*e;return t.markAsUpdated(),t}scaleAndAddToRef(e,t){for(let i=0;i<16;i++)t._m[i]+=this._m[i]*e;return t.markAsUpdated(),t}scaleInPlace(e){const t=this._m;for(let i=0;i<16;i++)t[i]*=e;return this.markAsUpdated(),this}toNormalMatrix(e){const t=X.Matrix[0];this.invertToRef(t),t.transposeToRef(e);const i=e._m;return P.FromValuesToRef(i[0],i[1],i[2],0,i[4],i[5],i[6],0,i[8],i[9],i[10],0,0,0,0,1,e),e}getRotationMatrix(){const e=new P;return this.getRotationMatrixToRef(e),e}getRotationMatrixToRef(e){const t=X.Vector3[0];if(!this.decompose(t))return P.IdentityToRef(e),e;const i=this._m,s=1/t._x,r=1/t._y,n=1/t._z;return P.FromValuesToRef(i[0]*s,i[1]*s,i[2]*s,0,i[4]*r,i[5]*r,i[6]*r,0,i[8]*n,i[9]*n,i[10]*n,0,0,0,0,1,e),e}toggleModelMatrixHandInPlace(){const e=this._m;return e[2]*=-1,e[6]*=-1,e[8]*=-1,e[9]*=-1,e[14]*=-1,this.markAsUpdated(),this}toggleProjectionMatrixHandInPlace(){const e=this._m;return e[8]*=-1,e[9]*=-1,e[10]*=-1,e[11]*=-1,this.markAsUpdated(),this}static FromArray(e,t=0){const i=new P;return P.FromArrayToRef(e,t,i),i}static FromArrayToRef(e,t,i){for(let s=0;s<16;s++)i._m[s]=e[s+t];return i.markAsUpdated(),i}static FromFloat32ArrayToRefScaled(e,t,i,s){return s._m[0]=e[0+t]*i,s._m[1]=e[1+t]*i,s._m[2]=e[2+t]*i,s._m[3]=e[3+t]*i,s._m[4]=e[4+t]*i,s._m[5]=e[5+t]*i,s._m[6]=e[6+t]*i,s._m[7]=e[7+t]*i,s._m[8]=e[8+t]*i,s._m[9]=e[9+t]*i,s._m[10]=e[10+t]*i,s._m[11]=e[11+t]*i,s._m[12]=e[12+t]*i,s._m[13]=e[13+t]*i,s._m[14]=e[14+t]*i,s._m[15]=e[15+t]*i,s.markAsUpdated(),s}static get IdentityReadOnly(){return P._IdentityReadOnly}static FromValuesToRef(e,t,i,s,r,n,o,h,l,c,u,f,d,g,p,m,A){const E=A._m;E[0]=e,E[1]=t,E[2]=i,E[3]=s,E[4]=r,E[5]=n,E[6]=o,E[7]=h,E[8]=l,E[9]=c,E[10]=u,E[11]=f,E[12]=d,E[13]=g,E[14]=p,E[15]=m,A.markAsUpdated()}static FromValues(e,t,i,s,r,n,o,h,l,c,u,f,d,g,p,m){const A=new P,E=A._m;return E[0]=e,E[1]=t,E[2]=i,E[3]=s,E[4]=r,E[5]=n,E[6]=o,E[7]=h,E[8]=l,E[9]=c,E[10]=u,E[11]=f,E[12]=d,E[13]=g,E[14]=p,E[15]=m,A.markAsUpdated(),A}static Compose(e,t,i){const s=new P;return P.ComposeToRef(e,t,i,s),s}static ComposeToRef(e,t,i,s){const r=s._m,n=t._x,o=t._y,h=t._z,l=t._w,c=n+n,u=o+o,f=h+h,d=n*c,g=n*u,p=n*f,m=o*u,A=o*f,E=h*f,I=l*c,M=l*u,C=l*f,x=e._x,S=e._y,L=e._z;return r[0]=(1-(m+E))*x,r[1]=(g+C)*x,r[2]=(p-M)*x,r[3]=0,r[4]=(g-C)*S,r[5]=(1-(d+E))*S,r[6]=(A+I)*S,r[7]=0,r[8]=(p+M)*L,r[9]=(A-I)*L,r[10]=(1-(d+m))*L,r[11]=0,r[12]=i._x,r[13]=i._y,r[14]=i._z,r[15]=1,s.markAsUpdated(),s}static Identity(){const e=P.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return e._updateIdentityStatus(!0),e}static IdentityToRef(e){return P.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,e),e._updateIdentityStatus(!0),e}static Zero(){const e=P.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return e._updateIdentityStatus(!1),e}static RotationX(e){const t=new P;return P.RotationXToRef(e,t),t}static Invert(e){const t=new P;return e.invertToRef(t),t}static RotationXToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return P.FromValuesToRef(1,0,0,0,0,s,i,0,0,-i,s,0,0,0,0,1,t),t._updateIdentityStatus(s===1&&i===0),t}static RotationY(e){const t=new P;return P.RotationYToRef(e,t),t}static RotationYToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return P.FromValuesToRef(s,0,-i,0,0,1,0,0,i,0,s,0,0,0,0,1,t),t._updateIdentityStatus(s===1&&i===0),t}static RotationZ(e){const t=new P;return P.RotationZToRef(e,t),t}static RotationZToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return P.FromValuesToRef(s,i,0,0,-i,s,0,0,0,0,1,0,0,0,0,1,t),t._updateIdentityStatus(s===1&&i===0),t}static RotationAxis(e,t){const i=new P;return P.RotationAxisToRef(e,t,i),i}static RotationAxisToRef(e,t,i){const s=Math.sin(-t),r=Math.cos(-t),n=1-r;e=e.normalizeToRef(X.Vector3[0]);const o=i._m;return o[0]=e._x*e._x*n+r,o[1]=e._x*e._y*n-e._z*s,o[2]=e._x*e._z*n+e._y*s,o[3]=0,o[4]=e._y*e._x*n+e._z*s,o[5]=e._y*e._y*n+r,o[6]=e._y*e._z*n-e._x*s,o[7]=0,o[8]=e._z*e._x*n-e._y*s,o[9]=e._z*e._y*n+e._x*s,o[10]=e._z*e._z*n+r,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,i.markAsUpdated(),i}static RotationAlignToRef(e,t,i,s=!1){const r=_.Dot(t,e),n=i._m;if(r<-1+Me)n[0]=-1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=s?1:-1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=s?-1:1,n[11]=0;else{const o=_.Cross(t,e),h=1/(1+r);n[0]=o._x*o._x*h+r,n[1]=o._y*o._x*h-o._z,n[2]=o._z*o._x*h+o._y,n[3]=0,n[4]=o._x*o._y*h+o._z,n[5]=o._y*o._y*h+r,n[6]=o._z*o._y*h-o._x,n[7]=0,n[8]=o._x*o._z*h-o._y,n[9]=o._y*o._z*h+o._x,n[10]=o._z*o._z*h+r,n[11]=0}return n[12]=0,n[13]=0,n[14]=0,n[15]=1,i.markAsUpdated(),i}static RotationYawPitchRoll(e,t,i){const s=new P;return P.RotationYawPitchRollToRef(e,t,i,s),s}static RotationYawPitchRollToRef(e,t,i,s){return W.RotationYawPitchRollToRef(e,t,i,X.Quaternion[0]),X.Quaternion[0].toRotationMatrix(s),s}static Scaling(e,t,i){const s=new P;return P.ScalingToRef(e,t,i,s),s}static ScalingToRef(e,t,i,s){return P.FromValuesToRef(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1,s),s._updateIdentityStatus(e===1&&t===1&&i===1),s}static Translation(e,t,i){const s=new P;return P.TranslationToRef(e,t,i,s),s}static TranslationToRef(e,t,i,s){return P.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,t,i,1,s),s._updateIdentityStatus(e===0&&t===0&&i===0),s}static Lerp(e,t,i){const s=new P;return P.LerpToRef(e,t,i,s),s}static LerpToRef(e,t,i,s){const r=s._m,n=e.m,o=t.m;for(let h=0;h<16;h++)r[h]=n[h]*(1-i)+o[h]*i;return s.markAsUpdated(),s}static DecomposeLerp(e,t,i){const s=new P;return P.DecomposeLerpToRef(e,t,i,s),s}static DecomposeLerpToRef(e,t,i,s){const r=X.Vector3[0],n=X.Quaternion[0],o=X.Vector3[1];e.decompose(r,n,o);const h=X.Vector3[2],l=X.Quaternion[1],c=X.Vector3[3];t.decompose(h,l,c);const u=X.Vector3[4];_.LerpToRef(r,h,i,u);const f=X.Quaternion[2];W.SlerpToRef(n,l,i,f);const d=X.Vector3[5];return _.LerpToRef(o,c,i,d),P.ComposeToRef(u,f,d,s),s}static LookAtLH(e,t,i){const s=new P;return P.LookAtLHToRef(e,t,i,s),s}static LookAtLHToRef(e,t,i,s){const r=X.Vector3[0],n=X.Vector3[1],o=X.Vector3[2];t.subtractToRef(e,o),o.normalize(),_.CrossToRef(i,o,r);const h=r.lengthSquared();h===0?r.x=1:r.normalizeFromLength(Math.sqrt(h)),_.CrossToRef(o,r,n),n.normalize();const l=-_.Dot(r,e),c=-_.Dot(n,e),u=-_.Dot(o,e);return P.FromValuesToRef(r._x,n._x,o._x,0,r._y,n._y,o._y,0,r._z,n._z,o._z,0,l,c,u,1,s),s}static LookAtRH(e,t,i){const s=new P;return P.LookAtRHToRef(e,t,i,s),s}static LookAtRHToRef(e,t,i,s){const r=X.Vector3[0],n=X.Vector3[1],o=X.Vector3[2];e.subtractToRef(t,o),o.normalize(),_.CrossToRef(i,o,r);const h=r.lengthSquared();h===0?r.x=1:r.normalizeFromLength(Math.sqrt(h)),_.CrossToRef(o,r,n),n.normalize();const l=-_.Dot(r,e),c=-_.Dot(n,e),u=-_.Dot(o,e);return P.FromValuesToRef(r._x,n._x,o._x,0,r._y,n._y,o._y,0,r._z,n._z,o._z,0,l,c,u,1,s),s}static LookDirectionLH(e,t){const i=new P;return P.LookDirectionLHToRef(e,t,i),i}static LookDirectionLHToRef(e,t,i){const s=X.Vector3[0];s.copyFrom(e),s.scaleInPlace(-1);const r=X.Vector3[1];return _.CrossToRef(t,s,r),P.FromValuesToRef(r._x,r._y,r._z,0,t._x,t._y,t._z,0,s._x,s._y,s._z,0,0,0,0,1,i),i}static LookDirectionRH(e,t){const i=new P;return P.LookDirectionRHToRef(e,t,i),i}static LookDirectionRHToRef(e,t,i){const s=X.Vector3[2];return _.CrossToRef(t,e,s),P.FromValuesToRef(s._x,s._y,s._z,0,t._x,t._y,t._z,0,e._x,e._y,e._z,0,0,0,0,1,i),i}static OrthoLH(e,t,i,s,r){const n=new P;return P.OrthoLHToRef(e,t,i,s,n,r),n}static OrthoLHToRef(e,t,i,s,r,n){const o=i,h=s,l=2/e,c=2/t,u=2/(h-o),f=-(h+o)/(h-o);return P.FromValuesToRef(l,0,0,0,0,c,0,0,0,0,u,0,0,0,f,1,r),n&&r.multiplyToRef(Wi,r),r._updateIdentityStatus(l===1&&c===1&&u===1&&f===0),r}static OrthoOffCenterLH(e,t,i,s,r,n,o){const h=new P;return P.OrthoOffCenterLHToRef(e,t,i,s,r,n,h,o),h}static OrthoOffCenterLHToRef(e,t,i,s,r,n,o,h){const l=r,c=n,u=2/(t-e),f=2/(s-i),d=2/(c-l),g=-(c+l)/(c-l),p=(e+t)/(e-t),m=(s+i)/(i-s);return P.FromValuesToRef(u,0,0,0,0,f,0,0,0,0,d,0,p,m,g,1,o),h&&o.multiplyToRef(Wi,o),o.markAsUpdated(),o}static ObliqueOffCenterLHToRef(e,t,i,s,r,n,o,h,l,c,u){const f=-o*Math.cos(h),d=-o*Math.sin(h);return P.TranslationToRef(0,0,-l,X.Matrix[1]),P.FromValuesToRef(1,0,0,0,0,1,0,0,f,d,1,0,0,0,0,1,X.Matrix[0]),X.Matrix[1].multiplyToRef(X.Matrix[0],X.Matrix[0]),P.TranslationToRef(0,0,l,X.Matrix[1]),X.Matrix[0].multiplyToRef(X.Matrix[1],X.Matrix[0]),P.OrthoOffCenterLHToRef(e,t,i,s,r,n,c,u),X.Matrix[0].multiplyToRef(c,c),c}static OrthoOffCenterRH(e,t,i,s,r,n,o){const h=new P;return P.OrthoOffCenterRHToRef(e,t,i,s,r,n,h,o),h}static OrthoOffCenterRHToRef(e,t,i,s,r,n,o,h){return P.OrthoOffCenterLHToRef(e,t,i,s,r,n,o,h),o._m[10]*=-1,o}static ObliqueOffCenterRHToRef(e,t,i,s,r,n,o,h,l,c,u){const f=o*Math.cos(h),d=o*Math.sin(h);return P.TranslationToRef(0,0,l,X.Matrix[1]),P.FromValuesToRef(1,0,0,0,0,1,0,0,f,d,1,0,0,0,0,1,X.Matrix[0]),X.Matrix[1].multiplyToRef(X.Matrix[0],X.Matrix[0]),P.TranslationToRef(0,0,-l,X.Matrix[1]),X.Matrix[0].multiplyToRef(X.Matrix[1],X.Matrix[0]),P.OrthoOffCenterRHToRef(e,t,i,s,r,n,c,u),X.Matrix[0].multiplyToRef(c,c),c}static PerspectiveLH(e,t,i,s,r,n=0){const o=new P,h=i,l=s,c=2*h/e,u=2*h/t,f=(l+h)/(l-h),d=-2*l*h/(l-h),g=Math.tan(n);return P.FromValuesToRef(c,0,0,0,0,u,0,g,0,0,f,1,0,0,d,0,o),r&&o.multiplyToRef(Wi,o),o._updateIdentityStatus(!1),o}static PerspectiveFovLH(e,t,i,s,r,n=0,o=!1){const h=new P;return P.PerspectiveFovLHToRef(e,t,i,s,h,!0,r,n,o),h}static PerspectiveFovLHToRef(e,t,i,s,r,n=!0,o,h=0,l=!1){const c=i,u=s,f=1/Math.tan(e*.5),d=n?f/t:f,g=n?f:f*t,p=l&&c===0?-1:u!==0?(u+c)/(u-c):1,m=l&&c===0?2*u:u!==0?-2*u*c/(u-c):-2*c,A=Math.tan(h);return P.FromValuesToRef(d,0,0,0,0,g,0,A,0,0,p,1,0,0,m,0,r),o&&r.multiplyToRef(Wi,r),r._updateIdentityStatus(!1),r}static PerspectiveFovReverseLHToRef(e,t,i,s,r,n=!0,o,h=0){const l=1/Math.tan(e*.5),c=n?l/t:l,u=n?l:l*t,f=Math.tan(h);return P.FromValuesToRef(c,0,0,0,0,u,0,f,0,0,-i,1,0,0,1,0,r),o&&r.multiplyToRef(Wi,r),r._updateIdentityStatus(!1),r}static PerspectiveFovRH(e,t,i,s,r,n=0,o=!1){const h=new P;return P.PerspectiveFovRHToRef(e,t,i,s,h,!0,r,n,o),h}static PerspectiveFovRHToRef(e,t,i,s,r,n=!0,o,h=0,l=!1){const c=i,u=s,f=1/Math.tan(e*.5),d=n?f/t:f,g=n?f:f*t,p=l&&c===0?1:u!==0?-(u+c)/(u-c):-1,m=l&&c===0?2*u:u!==0?-2*u*c/(u-c):-2*c,A=Math.tan(h);return P.FromValuesToRef(d,0,0,0,0,g,0,A,0,0,p,-1,0,0,m,0,r),o&&r.multiplyToRef(Wi,r),r._updateIdentityStatus(!1),r}static PerspectiveFovReverseRHToRef(e,t,i,s,r,n=!0,o,h=0){const l=1/Math.tan(e*.5),c=n?l/t:l,u=n?l:l*t,f=Math.tan(h);return P.FromValuesToRef(c,0,0,0,0,u,0,f,0,0,-i,-1,0,0,-1,0,r),o&&r.multiplyToRef(Wi,r),r._updateIdentityStatus(!1),r}static GetFinalMatrix(e,t,i,s,r,n){const o=e.width,h=e.height,l=e.x,c=e.y,u=P.FromValues(o/2,0,0,0,0,-h/2,0,0,0,0,n-r,0,l+o/2,h/2+c,r,1),f=new P;return t.multiplyToRef(i,f),f.multiplyToRef(s,f),f.multiplyToRef(u,f)}static GetAsMatrix2x2(e){const t=e.m,i=[t[0],t[1],t[4],t[5]];return st.MatrixUse64Bits?i:new Float32Array(i)}static GetAsMatrix3x3(e){const t=e.m,i=[t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10]];return st.MatrixUse64Bits?i:new Float32Array(i)}static Transpose(e){const t=new P;return P.TransposeToRef(e,t),t}static TransposeToRef(e,t){const i=e.m,s=i[0],r=i[4],n=i[8],o=i[12],h=i[1],l=i[5],c=i[9],u=i[13],f=i[2],d=i[6],g=i[10],p=i[14],m=i[3],A=i[7],E=i[11],I=i[15],M=t._m;return M[0]=s,M[1]=r,M[2]=n,M[3]=o,M[4]=h,M[5]=l,M[6]=c,M[7]=u,M[8]=f,M[9]=d,M[10]=g,M[11]=p,M[12]=m,M[13]=A,M[14]=E,M[15]=I,t.markAsUpdated(),t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty),t}static Reflection(e){const t=new P;return P.ReflectionToRef(e,t),t}static ReflectionToRef(e,t){e.normalize();const i=e.normal.x,s=e.normal.y,r=e.normal.z,n=-2*i,o=-2*s,h=-2*r;return P.FromValuesToRef(n*i+1,o*i,h*i,0,n*s,o*s+1,h*s,0,n*r,o*r,h*r+1,0,n*e.d,o*e.d,h*e.d,1,t),t}static FromXYZAxesToRef(e,t,i,s){return P.FromValuesToRef(e._x,e._y,e._z,0,t._x,t._y,t._z,0,i._x,i._y,i._z,0,0,0,0,1,s),s}static FromQuaternionToRef(e,t){const i=e._x*e._x,s=e._y*e._y,r=e._z*e._z,n=e._x*e._y,o=e._z*e._w,h=e._z*e._x,l=e._y*e._w,c=e._y*e._z,u=e._x*e._w;return t._m[0]=1-2*(s+r),t._m[1]=2*(n+o),t._m[2]=2*(h-l),t._m[3]=0,t._m[4]=2*(n-o),t._m[5]=1-2*(r+i),t._m[6]=2*(c+u),t._m[7]=0,t._m[8]=2*(h+l),t._m[9]=2*(c-u),t._m[10]=1-2*(s+i),t._m[11]=0,t._m[12]=0,t._m[13]=0,t._m[14]=0,t._m[15]=1,t.markAsUpdated(),t}}P._IdentityReadOnly=P.Identity();Object.defineProperties(P.prototype,{dimension:{value:[4,4]},rank:{value:2}});class X{}X.Vector3=xi(11,_.Zero);X.Matrix=xi(2,P.Identity);X.Quaternion=xi(3,W.Zero);class v{}v.Vector2=xi(3,Q.Zero);v.Vector3=xi(13,_.Zero);v.Vector4=xi(3,ge.Zero);v.Quaternion=xi(3,W.Zero);v.Matrix=xi(8,P.Identity);nt("BABYLON.Vector2",Q);nt("BABYLON.Vector3",_);nt("BABYLON.Vector4",ge);nt("BABYLON.Matrix",P);const Wi=P.FromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1),ea={};function ie(a,e=!1){if(!(e&&ea[a]))return ea[a]=!0,`${a} needs to be imported before as it contains a side-effect required by your code.`}class ji{static Eval(e,t){return e.match(/\([^()]*\)/g)?e=e.replace(/\([^()]*\)/g,i=>(i=i.slice(1,i.length-1),ji._HandleParenthesisContent(i,t))):e=ji._HandleParenthesisContent(e,t),e==="true"?!0:e==="false"?!1:ji.Eval(e,t)}static _HandleParenthesisContent(e,t){t=t||(r=>r==="true");let i;const s=e.split("||");for(const r in s)if(Object.prototype.hasOwnProperty.call(s,r)){let n=ji._SimplifyNegation(s[r].trim());const o=n.split("&&");if(o.length>1)for(let h=0;h<o.length;++h){const l=ji._SimplifyNegation(o[h].trim());if(l!=="true"&&l!=="false"?l[0]==="!"?i=!t(l.substring(1)):i=t(l):i=l==="true",!i){n="false";break}}if(i||n==="true"){i=!0;break}n!=="true"&&n!=="false"?n[0]==="!"?i=!t(n.substring(1)):i=t(n):i=n==="true"}return i?"true":"false"}static _SimplifyNegation(e){return e=e.replace(/^[\s!]+/,t=>(t=t.replace(/[\s]/g,()=>""),t.length%2?"!":"")),e=e.trim(),e==="!true"?e="false":e==="!false"&&(e="true"),e}}class Ae{static EnableFor(e){e._tags=e._tags||{},e.hasTags=()=>Ae.HasTags(e),e.addTags=t=>Ae.AddTagsTo(e,t),e.removeTags=t=>Ae.RemoveTagsFrom(e,t),e.matchesTagsQuery=t=>Ae.MatchesQuery(e,t)}static DisableFor(e){delete e._tags,delete e.hasTags,delete e.addTags,delete e.removeTags,delete e.matchesTagsQuery}static HasTags(e){if(!e._tags)return!1;const t=e._tags;for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i))return!0;return!1}static GetTags(e,t=!0){if(!e._tags)return null;if(t){const i=[];for(const s in e._tags)Object.prototype.hasOwnProperty.call(e._tags,s)&&e._tags[s]===!0&&i.push(s);return i.join(" ")}else return e._tags}static AddTagsTo(e,t){if(!t||typeof t!="string")return;const i=t.split(" ");for(const s of i)Ae._AddTagTo(e,s)}static _AddTagTo(e,t){t=t.trim(),!(t===""||t==="true"||t==="false")&&(t.match(/[\s]/)||t.match(/^([!]|([|]|[&]){2})/)||(Ae.EnableFor(e),e._tags[t]=!0))}static RemoveTagsFrom(e,t){if(!Ae.HasTags(e))return;const i=t.split(" ");for(const s in i)Ae._RemoveTagFrom(e,i[s])}static _RemoveTagFrom(e,t){delete e._tags[t]}static MatchesQuery(e,t){return t===void 0?!0:t===""?Ae.HasTags(e):ji.Eval(t,i=>Ae.HasTags(e)&&e._tags[i])}}function ls(a){return Math.pow(a,Er)}function cs(a){return a<=.04045?.0773993808*a:Math.pow(.947867299*(a+.055),2.4)}function us(a){return Math.pow(a,Rl)}function ds(a){return a<=.0031308?12.92*a:1.055*Math.pow(a,.41666)-.055}class q{constructor(e=0,t=0,i=0){this.r=e,this.g=t,this.b=i}toString(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"}getClassName(){return"Color3"}getHashCode(){let e=this.r*255|0;return e=e*397^(this.g*255|0),e=e*397^(this.b*255|0),e}toArray(e,t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,this}fromArray(e,t=0){return q.FromArrayToRef(e,t,this),this}toColor4(e=1){return new fe(this.r,this.g,this.b,e)}asArray(){return[this.r,this.g,this.b]}toLuminance(){return this.r*.3+this.g*.59+this.b*.11}multiply(e){return new q(this.r*e.r,this.g*e.g,this.b*e.b)}multiplyToRef(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t}multiplyInPlace(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyByFloats(e,t,i){return new q(this.r*e,this.g*t,this.b*i)}divide(e){throw new ReferenceError("Can not divide a color")}divideToRef(e,t){throw new ReferenceError("Can not divide a color")}divideInPlace(e){throw new ReferenceError("Can not divide a color")}minimizeInPlace(e){return this.minimizeInPlaceFromFloats(e.r,e.g,e.b)}maximizeInPlace(e){return this.maximizeInPlaceFromFloats(e.r,e.g,e.b)}minimizeInPlaceFromFloats(e,t,i){return this.r=Math.min(e,this.r),this.g=Math.min(t,this.g),this.b=Math.min(i,this.b),this}maximizeInPlaceFromFloats(e,t,i){return this.r=Math.max(e,this.r),this.g=Math.max(t,this.g),this.b=Math.max(i,this.b),this}floorToRef(e){throw new ReferenceError("Can not floor a color")}floor(){throw new ReferenceError("Can not floor a color")}fractToRef(e){throw new ReferenceError("Can not fract a color")}fract(){throw new ReferenceError("Can not fract a color")}equals(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b}equalsFloats(e,t,i){return this.equalsToFloats(e,t,i)}equalsToFloats(e,t,i){return this.r===e&&this.g===t&&this.b===i}equalsWithEpsilon(e,t=Me){return Pe(this.r,e.r,t)&&Pe(this.g,e.g,t)&&Pe(this.b,e.b,t)}negate(){throw new ReferenceError("Can not negate a color")}negateInPlace(){throw new ReferenceError("Can not negate a color")}negateToRef(e){throw new ReferenceError("Can not negate a color")}scale(e){return new q(this.r*e,this.g*e,this.b*e)}scaleInPlace(e){return this.r*=e,this.g*=e,this.b*=e,this}scaleToRef(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t}scaleAndAddToRef(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,t}clampToRef(e=0,t=1,i){return i.r=be(this.r,e,t),i.g=be(this.g,e,t),i.b=be(this.b,e,t),i}add(e){return new q(this.r+e.r,this.g+e.g,this.b+e.b)}addInPlace(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addInPlaceFromFloats(e,t,i){return this.r+=e,this.g+=t,this.b+=i,this}addToRef(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,t}subtract(e){return new q(this.r-e.r,this.g-e.g,this.b-e.b)}subtractToRef(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t}subtractInPlace(e){return this.r-=e.r,this.g-=e.g,this.b-=e.b,this}subtractFromFloats(e,t,i){return new q(this.r-e,this.g-t,this.b-i)}subtractFromFloatsToRef(e,t,i,s){return s.r=this.r-e,s.g=this.g-t,s.b=this.b-i,s}clone(){return new q(this.r,this.g,this.b)}copyFrom(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copyFromFloats(e,t,i){return this.r=e,this.g=t,this.b=i,this}set(e,t,i){return this.copyFromFloats(e,t,i)}setAll(e){return this.r=this.g=this.b=e,this}toHexString(){const e=Math.round(this.r*255),t=Math.round(this.g*255),i=Math.round(this.b*255);return"#"+ei(e)+ei(t)+ei(i)}fromHexString(e){return e.substring(0,1)!=="#"||e.length!==7?this:(this.r=parseInt(e.substring(1,3),16)/255,this.g=parseInt(e.substring(3,5),16)/255,this.b=parseInt(e.substring(5,7),16)/255,this)}toHSV(){return this.toHSVToRef(new q)}toHSVToRef(e){const t=this.r,i=this.g,s=this.b,r=Math.max(t,i,s),n=Math.min(t,i,s);let o=0,h=0;const l=r,c=r-n;return r!==0&&(h=c/r),r!=n&&(r==t?(o=(i-s)/c,i<s&&(o+=6)):r==i?o=(s-t)/c+2:r==s&&(o=(t-i)/c+4),o*=60),e.r=o,e.g=h,e.b=l,e}toLinearSpace(e=!1){const t=new q;return this.toLinearSpaceToRef(t,e),t}toLinearSpaceToRef(e,t=!1){return t?(e.r=cs(this.r),e.g=cs(this.g),e.b=cs(this.b)):(e.r=ls(this.r),e.g=ls(this.g),e.b=ls(this.b)),this}toGammaSpace(e=!1){const t=new q;return this.toGammaSpaceToRef(t,e),t}toGammaSpaceToRef(e,t=!1){return t?(e.r=ds(this.r),e.g=ds(this.g),e.b=ds(this.b)):(e.r=us(this.r),e.g=us(this.g),e.b=us(this.b)),this}static HSVtoRGBToRef(e,t,i,s){const r=i*t,n=e/60,o=r*(1-Math.abs(n%2-1));let h=0,l=0,c=0;n>=0&&n<=1?(h=r,l=o):n>=1&&n<=2?(h=o,l=r):n>=2&&n<=3?(l=r,c=o):n>=3&&n<=4?(l=o,c=r):n>=4&&n<=5?(h=o,c=r):n>=5&&n<=6&&(h=r,c=o);const u=i-r;return s.r=h+u,s.g=l+u,s.b=c+u,s}static FromHSV(e,t,i){const s=new q(0,0,0);return q.HSVtoRGBToRef(e,t,i,s),s}static FromHexString(e){return new q(0,0,0).fromHexString(e)}static FromArray(e,t=0){return new q(e[t],e[t+1],e[t+2])}static FromArrayToRef(e,t=0,i){i.r=e[t],i.g=e[t+1],i.b=e[t+2]}static FromInts(e,t,i){return new q(e/255,t/255,i/255)}static Lerp(e,t,i){const s=new q(0,0,0);return q.LerpToRef(e,t,i,s),s}static LerpToRef(e,t,i,s){s.r=e.r+(t.r-e.r)*i,s.g=e.g+(t.g-e.g)*i,s.b=e.b+(t.b-e.b)*i}static Hermite(e,t,i,s,r){const n=r*r,o=r*n,h=2*o-3*n+1,l=-2*o+3*n,c=o-2*n+r,u=o-n,f=e.r*h+i.r*l+t.r*c+s.r*u,d=e.g*h+i.g*l+t.g*c+s.g*u,g=e.b*h+i.b*l+t.b*c+s.b*u;return new q(f,d,g)}static Hermite1stDerivative(e,t,i,s,r){const n=q.Black();return this.Hermite1stDerivativeToRef(e,t,i,s,r,n),n}static Hermite1stDerivativeToRef(e,t,i,s,r,n){const o=r*r;n.r=(o-r)*6*e.r+(3*o-4*r+1)*t.r+(-o+r)*6*i.r+(3*o-2*r)*s.r,n.g=(o-r)*6*e.g+(3*o-4*r+1)*t.g+(-o+r)*6*i.g+(3*o-2*r)*s.g,n.b=(o-r)*6*e.b+(3*o-4*r+1)*t.b+(-o+r)*6*i.b+(3*o-2*r)*s.b}static Red(){return new q(1,0,0)}static Green(){return new q(0,1,0)}static Blue(){return new q(0,0,1)}static Black(){return new q(0,0,0)}static get BlackReadOnly(){return q._BlackReadOnly}static White(){return new q(1,1,1)}static Purple(){return new q(.5,0,.5)}static Magenta(){return new q(1,0,1)}static Yellow(){return new q(1,1,0)}static Gray(){return new q(.5,.5,.5)}static Teal(){return new q(0,1,1)}static Random(){return new q(Math.random(),Math.random(),Math.random())}}q._V8PerformanceHack=new q(.5,.5,.5);q._BlackReadOnly=q.Black();Object.defineProperties(q.prototype,{dimension:{value:[3]},rank:{value:1}});class fe{constructor(e=0,t=0,i=0,s=1){this.r=e,this.g=t,this.b=i,this.a=s}asArray(){return[this.r,this.g,this.b,this.a]}toArray(e,t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e[t+3]=this.a,this}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this.a=e[t+3],this}equals(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b&&this.a===e.a}add(e){return new fe(this.r+e.r,this.g+e.g,this.b+e.b,this.a+e.a)}addToRef(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,t.a=this.a+e.a,t}addInPlace(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this}addInPlaceFromFloats(e,t,i,s){return this.r+=e,this.g+=t,this.b+=i,this.a+=s,this}subtract(e){return new fe(this.r-e.r,this.g-e.g,this.b-e.b,this.a-e.a)}subtractToRef(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t.a=this.a-e.a,t}subtractInPlace(e){return this.r-=e.r,this.g-=e.g,this.b-=e.b,this.a-=e.a,this}subtractFromFloats(e,t,i,s){return new fe(this.r-e,this.g-t,this.b-i,this.a-s)}subtractFromFloatsToRef(e,t,i,s,r){return r.r=this.r-e,r.g=this.g-t,r.b=this.b-i,r.a=this.a-s,r}scale(e){return new fe(this.r*e,this.g*e,this.b*e,this.a*e)}scaleInPlace(e){return this.r*=e,this.g*=e,this.b*=e,this.a*=e,this}scaleToRef(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t.a=this.a*e,t}scaleAndAddToRef(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,t.a+=this.a*e,t}clampToRef(e=0,t=1,i){return i.r=be(this.r,e,t),i.g=be(this.g,e,t),i.b=be(this.b,e,t),i.a=be(this.a,e,t),i}multiply(e){return new fe(this.r*e.r,this.g*e.g,this.b*e.b,this.a*e.a)}multiplyToRef(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t.a=this.a*e.a,t}multiplyInPlace(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this.a*=e.a,this}multiplyByFloats(e,t,i,s){return new fe(this.r*e,this.g*t,this.b*i,this.a*s)}divide(e){throw new ReferenceError("Can not divide a color")}divideToRef(e,t){throw new ReferenceError("Can not divide a color")}divideInPlace(e){throw new ReferenceError("Can not divide a color")}minimizeInPlace(e){return this.r=Math.min(this.r,e.r),this.g=Math.min(this.g,e.g),this.b=Math.min(this.b,e.b),this.a=Math.min(this.a,e.a),this}maximizeInPlace(e){return this.r=Math.max(this.r,e.r),this.g=Math.max(this.g,e.g),this.b=Math.max(this.b,e.b),this.a=Math.max(this.a,e.a),this}minimizeInPlaceFromFloats(e,t,i,s){return this.r=Math.min(e,this.r),this.g=Math.min(t,this.g),this.b=Math.min(i,this.b),this.a=Math.min(s,this.a),this}maximizeInPlaceFromFloats(e,t,i,s){return this.r=Math.max(e,this.r),this.g=Math.max(t,this.g),this.b=Math.max(i,this.b),this.a=Math.max(s,this.a),this}floorToRef(e){throw new ReferenceError("Can not floor a color")}floor(){throw new ReferenceError("Can not floor a color")}fractToRef(e){throw new ReferenceError("Can not fract a color")}fract(){throw new ReferenceError("Can not fract a color")}negate(){throw new ReferenceError("Can not negate a color")}negateInPlace(){throw new ReferenceError("Can not negate a color")}negateToRef(e){throw new ReferenceError("Can not negate a color")}equalsWithEpsilon(e,t=Me){return Pe(this.r,e.r,t)&&Pe(this.g,e.g,t)&&Pe(this.b,e.b,t)&&Pe(this.a,e.a,t)}equalsToFloats(e,t,i,s){return this.r===e&&this.g===t&&this.b===i&&this.a===s}toString(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"}getClassName(){return"Color4"}getHashCode(){let e=this.r*255|0;return e=e*397^(this.g*255|0),e=e*397^(this.b*255|0),e=e*397^(this.a*255|0),e}clone(){return new fe().copyFrom(this)}copyFrom(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this}copyFromFloats(e,t,i,s){return this.r=e,this.g=t,this.b=i,this.a=s,this}set(e,t,i,s){return this.copyFromFloats(e,t,i,s)}setAll(e){return this.r=this.g=this.b=this.a=e,this}toHexString(e=!1){const t=Math.round(this.r*255),i=Math.round(this.g*255),s=Math.round(this.b*255);if(e)return"#"+ei(t)+ei(i)+ei(s);const r=Math.round(this.a*255);return"#"+ei(t)+ei(i)+ei(s)+ei(r)}fromHexString(e){return e.substring(0,1)!=="#"||e.length!==9&&e.length!==7?this:(this.r=parseInt(e.substring(1,3),16)/255,this.g=parseInt(e.substring(3,5),16)/255,this.b=parseInt(e.substring(5,7),16)/255,e.length===9&&(this.a=parseInt(e.substring(7,9),16)/255),this)}toLinearSpace(e=!1){const t=new fe;return this.toLinearSpaceToRef(t,e),t}toLinearSpaceToRef(e,t=!1){return t?(e.r=cs(this.r),e.g=cs(this.g),e.b=cs(this.b)):(e.r=ls(this.r),e.g=ls(this.g),e.b=ls(this.b)),e.a=this.a,this}toGammaSpace(e=!1){const t=new fe;return this.toGammaSpaceToRef(t,e),t}toGammaSpaceToRef(e,t=!1){return t?(e.r=ds(this.r),e.g=ds(this.g),e.b=ds(this.b)):(e.r=us(this.r),e.g=us(this.g),e.b=us(this.b)),e.a=this.a,this}static FromHexString(e){return e.substring(0,1)!=="#"||e.length!==9&&e.length!==7?new fe(0,0,0,0):new fe(0,0,0,1).fromHexString(e)}static Lerp(e,t,i){return fe.LerpToRef(e,t,i,new fe)}static LerpToRef(e,t,i,s){return s.r=e.r+(t.r-e.r)*i,s.g=e.g+(t.g-e.g)*i,s.b=e.b+(t.b-e.b)*i,s.a=e.a+(t.a-e.a)*i,s}static Hermite(e,t,i,s,r){const n=r*r,o=r*n,h=2*o-3*n+1,l=-2*o+3*n,c=o-2*n+r,u=o-n,f=e.r*h+i.r*l+t.r*c+s.r*u,d=e.g*h+i.g*l+t.g*c+s.g*u,g=e.b*h+i.b*l+t.b*c+s.b*u,p=e.a*h+i.a*l+t.a*c+s.a*u;return new fe(f,d,g,p)}static Hermite1stDerivative(e,t,i,s,r){const n=new fe;return this.Hermite1stDerivativeToRef(e,t,i,s,r,n),n}static Hermite1stDerivativeToRef(e,t,i,s,r,n){const o=r*r;n.r=(o-r)*6*e.r+(3*o-4*r+1)*t.r+(-o+r)*6*i.r+(3*o-2*r)*s.r,n.g=(o-r)*6*e.g+(3*o-4*r+1)*t.g+(-o+r)*6*i.g+(3*o-2*r)*s.g,n.b=(o-r)*6*e.b+(3*o-4*r+1)*t.b+(-o+r)*6*i.b+(3*o-2*r)*s.b,n.a=(o-r)*6*e.a+(3*o-4*r+1)*t.a+(-o+r)*6*i.a+(3*o-2*r)*s.a}static FromColor3(e,t=1){return new fe(e.r,e.g,e.b,t)}static FromArray(e,t=0){return new fe(e[t],e[t+1],e[t+2],e[t+3])}static FromArrayToRef(e,t=0,i){i.r=e[t],i.g=e[t+1],i.b=e[t+2],i.a=e[t+3]}static FromInts(e,t,i,s){return new fe(e/255,t/255,i/255,s/255)}static CheckColors4(e,t){if(e.length===t*3){const i=[];for(let s=0;s<e.length;s+=3){const r=s/3*4;i[r]=e[s],i[r+1]=e[s+1],i[r+2]=e[s+2],i[r+3]=1}return i}return e}}fe._V8PerformanceHack=new fe(.5,.5,.5,.5);Object.defineProperties(fe.prototype,{dimension:{value:[4]},rank:{value:1}});class Vt{}Vt.Color3=Ai(3,q.Black);Vt.Color4=Ai(3,()=>new fe(0,0,0,0));nt("BABYLON.Color3",q);nt("BABYLON.Color4",fe);const ta=function(a,e,t,i={}){const s=a();Ae&&Ae.HasTags(e)&&Ae.AddTagsTo(s,Ae.GetTags(e,!0));const r=fn(s),n={};for(const o in r){const h=r[o],l=e[o],c=h.type;if(l!=null&&(o!=="uniqueId"||le.AllowLoadingUniqueId))switch(c){case 0:case 6:case 9:case 11:s[o]=l;break;case 1:i.cloneTexturesOnlyOnce&&n[l.uniqueId]?s[o]=n[l.uniqueId]:(s[o]=t||l.isRenderTarget?l:l.clone(),n[l.uniqueId]=s[o]);break;case 2:case 3:case 4:case 5:case 7:case 8:case 10:case 12:s[o]=t?l:l.clone();break}}return s};class le{static AppendSerializedAnimations(e,t){if(e.animations){t.animations=[];for(let i=0;i<e.animations.length;i++){const s=e.animations[i];t.animations.push(s.serialize())}}}static Serialize(e,t){t||(t={}),Ae&&(t.tags=Ae.GetTags(e));const i=fn(e);for(const s in i){const r=i[s],n=r.sourceName||s,o=r.type,h=e[s];if(h!=null&&(s!=="uniqueId"||le.AllowLoadingUniqueId))switch(o){case 0:Array.isArray(h)?t[n]=h.slice():t[n]=h;break;case 1:t[n]=h.serialize();break;case 2:t[n]=h.asArray();break;case 3:t[n]=h.serialize();break;case 4:t[n]=h.asArray();break;case 5:t[n]=h.asArray();break;case 6:t[n]=h.id;break;case 7:t[n]=h.serialize();break;case 8:t[n]=h.asArray();break;case 9:t[n]=h.serialize();break;case 10:t[n]=h.asArray();break;case 11:t[n]=h.id;break;case 12:t[n]=h.asArray();break}}return t}static ParseProperties(e,t,i,s){s||(s="");const r=fn(t);for(const n in r){const o=r[n],h=e[o.sourceName||n],l=o.type;if(h!=null&&(n!=="uniqueId"||le.AllowLoadingUniqueId)){const c=t;switch(l){case 0:c[n]=h;break;case 1:i&&(c[n]=le._TextureParser(h,i,s));break;case 2:c[n]=q.FromArray(h);break;case 3:c[n]=le._FresnelParametersParser(h);break;case 4:c[n]=Q.FromArray(h);break;case 5:c[n]=_.FromArray(h);break;case 6:i&&(c[n]=i.getLastMeshById(h));break;case 7:c[n]=le._ColorCurvesParser(h);break;case 8:c[n]=fe.FromArray(h);break;case 9:c[n]=le._ImageProcessingConfigurationParser(h);break;case 10:c[n]=W.FromArray(h);break;case 11:i&&(c[n]=i.getCameraById(h));break;case 12:c[n]=P.FromArray(h);break}}}}static Parse(e,t,i,s=null){const r=e();return Ae&&Ae.AddTagsTo(r,t.tags),le.ParseProperties(t,r,i,s),r}static Clone(e,t,i={}){return ta(e,t,!1,i)}static Instanciate(e,t){return ta(e,t,!0)}}le.AllowLoadingUniqueId=!1;le._ImageProcessingConfigurationParser=a=>{throw ie("ImageProcessingConfiguration")};le._FresnelParametersParser=a=>{throw ie("FresnelParameters")};le._ColorCurvesParser=a=>{throw ie("ColorCurves")};le._TextureParser=(a,e,t)=>{throw ie("Texture")};class kl{constructor(){this._doNotSerialize=!1,this._isDisposed=!1,this._sceneRootNodesIndex=-1,this._isEnabled=!0,this._isParentEnabled=!0,this._isReady=!0,this._onEnabledStateChangedObservable=new O,this._onClonedObservable=new O,this._inheritVisibility=!1,this._isVisible=!0}}class qe{static AddNodeConstructor(e,t){this._NodeConstructors[e]=t}static Construct(e,t,i,s){const r=this._NodeConstructors[e];return r?r(t,i,s):null}set accessibilityTag(e){this._accessibilityTag=e,this.onAccessibilityTagChangedObservable.notifyObservers(e)}get accessibilityTag(){return this._accessibilityTag}get doNotSerialize(){return this._nodeDataStorage._doNotSerialize?!0:this._parentNode?this._parentNode.doNotSerialize:!1}set doNotSerialize(e){this._nodeDataStorage._doNotSerialize=e}isDisposed(){return this._nodeDataStorage._isDisposed}set parent(e){if(this._parentNode===e)return;const t=this._parentNode;if(this._parentNode&&this._parentNode._children!==void 0&&this._parentNode._children!==null){const i=this._parentNode._children.indexOf(this);i!==-1&&this._parentNode._children.splice(i,1),!e&&!this._nodeDataStorage._isDisposed&&this._addToSceneRootNodes()}this._parentNode=e,this._isDirty=!0,this._parentNode&&((this._parentNode._children===void 0||this._parentNode._children===null)&&(this._parentNode._children=new Array),this._parentNode._children.push(this),t||this._removeFromSceneRootNodes()),this._syncParentEnabledState()}get parent(){return this._parentNode}get inheritVisibility(){return this._nodeDataStorage._inheritVisibility}set inheritVisibility(e){this._nodeDataStorage._inheritVisibility=e}get isVisible(){return this.inheritVisibility&&this._parentNode&&!this._parentNode.isVisible?!1:this._nodeDataStorage._isVisible}set isVisible(e){this._nodeDataStorage._isVisible=e}_serializeAsParent(e){e.parentId=this.uniqueId}_addToSceneRootNodes(){this._nodeDataStorage._sceneRootNodesIndex===-1&&(this._nodeDataStorage._sceneRootNodesIndex=this._scene.rootNodes.length,this._scene.rootNodes.push(this))}_removeFromSceneRootNodes(){if(this._nodeDataStorage._sceneRootNodesIndex!==-1){const e=this._scene.rootNodes,t=e.length-1;e[this._nodeDataStorage._sceneRootNodesIndex]=e[t],e[this._nodeDataStorage._sceneRootNodesIndex]._nodeDataStorage._sceneRootNodesIndex=this._nodeDataStorage._sceneRootNodesIndex,this._scene.rootNodes.pop(),this._nodeDataStorage._sceneRootNodesIndex=-1}}get animationPropertiesOverride(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}getClassName(){return"Node"}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}get onEnabledStateChangedObservable(){return this._nodeDataStorage._onEnabledStateChangedObservable}get onClonedObservable(){return this._nodeDataStorage._onClonedObservable}constructor(e,t=null,i=!0){this._isDirty=!1,this._nodeDataStorage=new kl,this.state="",this.metadata=null,this.reservedDataStore=null,this._accessibilityTag=null,this.onAccessibilityTagChangedObservable=new O,this._parentContainer=null,this.animations=[],this._ranges={},this.onReady=null,this._currentRenderId=-1,this._parentUpdateId=-1,this._childUpdateId=-1,this._waitingParentId=null,this._waitingParentInstanceIndex=null,this._waitingParsedUniqueId=null,this._cache={},this._parentNode=null,this._children=null,this._worldMatrix=P.Identity(),this._worldMatrixDeterminant=0,this._worldMatrixDeterminantIsDirty=!0,this._animationPropertiesOverride=null,this._isNode=!0,this.onDisposeObservable=new O,this._onDisposeObserver=null,this._behaviors=new Array,this.name=e,this.id=e,this._scene=t||Te.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache(),i&&this._addToSceneRootNodes()}getScene(){return this._scene}getEngine(){return this._scene.getEngine()}addBehavior(e,t=!1){return this._behaviors.indexOf(e)!==-1?this:(e.init(),this._scene.isLoading&&!t?this._scene.onDataLoadedObservable.addOnce(()=>{this._behaviors.includes(e)&&e.attach(this)}):e.attach(this),this._behaviors.push(e),this)}removeBehavior(e){const t=this._behaviors.indexOf(e);return t===-1?this:(this._behaviors[t].detach(),this._behaviors.splice(t,1),this)}get behaviors(){return this._behaviors}getBehaviorByName(e){for(const t of this._behaviors)if(t.name===e)return t;return null}getWorldMatrix(){return this._currentRenderId!==this._scene.getRenderId()&&this.computeWorldMatrix(),this._worldMatrix}_getWorldMatrixDeterminant(){return this._worldMatrixDeterminantIsDirty&&(this._worldMatrixDeterminantIsDirty=!1,this._worldMatrixDeterminant=this._worldMatrix.determinant()),this._worldMatrixDeterminant}get worldMatrixFromCache(){return this._worldMatrix}_initCache(){this._cache={}}updateCache(e){!e&&this.isSynchronized()||this._updateCache()}_getActionManagerForTrigger(e,t=!0){return this.parent?this.parent._getActionManagerForTrigger(e,!1):null}_updateCache(e){}_isSynchronized(){return!0}_markSyncedWithParent(){this._parentNode&&(this._parentUpdateId=this._parentNode._childUpdateId)}isSynchronizedWithParent(){return this._parentNode?this._parentNode._isDirty||this._parentUpdateId!==this._parentNode._childUpdateId?!1:this._parentNode.isSynchronized():!0}isSynchronized(){return this._parentNode&&!this.isSynchronizedWithParent()?!1:this._isSynchronized()}isReady(e=!1){return this._nodeDataStorage._isReady}markAsDirty(e){return this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0,this}isEnabled(e=!0){return e===!1?this._nodeDataStorage._isEnabled:this._nodeDataStorage._isEnabled?this._nodeDataStorage._isParentEnabled:!1}_syncParentEnabledState(){if(this._nodeDataStorage._isParentEnabled=this._parentNode?this._parentNode.isEnabled():!0,this._children)for(const e of this._children)e._syncParentEnabledState()}setEnabled(e){this._nodeDataStorage._isEnabled!==e&&(this._nodeDataStorage._isEnabled=e,this._syncParentEnabledState(),this._nodeDataStorage._onEnabledStateChangedObservable.notifyObservers(e))}isDescendantOf(e){return this.parent?this.parent===e?!0:this.parent.isDescendantOf(e):!1}_getDescendants(e,t=!1,i){if(this._children)for(let s=0;s<this._children.length;s++){const r=this._children[s];(!i||i(r))&&e.push(r),t||r._getDescendants(e,!1,i)}}getDescendants(e,t){const i=[];return this._getDescendants(i,e,t),i}getChildMeshes(e,t){const i=[];return this._getDescendants(i,e,s=>(!t||t(s))&&s.cullingStrategy!==void 0),i}getChildren(e,t=!0){return this.getDescendants(t,e)}_setReady(e){if(e!==this._nodeDataStorage._isReady){if(!e){this._nodeDataStorage._isReady=!1;return}this.onReady&&this.onReady(this),this._nodeDataStorage._isReady=!0}}getAnimationByName(e){for(let t=0;t<this.animations.length;t++){const i=this.animations[t];if(i.name===e)return i}return null}createAnimationRange(e,t,i){if(!this._ranges[e]){this._ranges[e]=qe._AnimationRangeFactory(e,t,i);for(let s=0,r=this.animations.length;s<r;s++)this.animations[s]&&this.animations[s].createRange(e,t,i)}}deleteAnimationRange(e,t=!0){for(let i=0,s=this.animations.length;i<s;i++)this.animations[i]&&this.animations[i].deleteRange(e,t);this._ranges[e]=null}getAnimationRange(e){return this._ranges[e]||null}clone(e,t,i){const s=le.Clone(()=>new qe(e,this.getScene()),this);if(t&&(s.parent=t),!i){const r=this.getDescendants(!0);for(let n=0;n<r.length;n++){const o=r[n];o.clone(e+"."+o.name,s)}}return s}getAnimationRanges(){const e=[];let t;for(t in this._ranges)e.push(this._ranges[t]);return e}beginAnimation(e,t,i,s){const r=this.getAnimationRange(e);return r?this._scene.beginAnimation(this,r.from,r.to,t,i,s):null}serializeAnimationRanges(){const e=[];for(const t in this._ranges){const i=this._ranges[t];if(!i)continue;const s={};s.name=t,s.from=i.from,s.to=i.to,e.push(s)}return e}computeWorldMatrix(e){return this._worldMatrix||(this._worldMatrix=P.Identity()),this._worldMatrix}dispose(e,t=!1){if(this._nodeDataStorage._isDisposed=!0,!e){const i=this.getDescendants(!0);for(const s of i)s.dispose(e,t)}this.parent?this.parent=null:this._removeFromSceneRootNodes(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onEnabledStateChangedObservable.clear(),this.onClonedObservable.clear();for(const i of this._behaviors)i.detach();this._behaviors.length=0,this.metadata=null}static ParseAnimationRanges(e,t,i){if(t.ranges)for(let s=0;s<t.ranges.length;s++){const r=t.ranges[s];e.createAnimationRange(r.name,r.from,r.to)}}getHierarchyBoundingVectors(e=!0,t=null){this.getScene().incrementRenderId(),this.computeWorldMatrix(!0);let i,s;const r=this;if(r.getBoundingInfo&&r.subMeshes){const n=r.getBoundingInfo();i=n.boundingBox.minimumWorld.clone(),s=n.boundingBox.maximumWorld.clone()}else i=new _(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s=new _(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);if(e){const n=this.getDescendants(!1);for(const o of n){const h=o;if(h.computeWorldMatrix(!0),t&&!t(h)||!h.getBoundingInfo||h.getTotalVertices()===0)continue;const c=h.getBoundingInfo().boundingBox,u=c.minimumWorld,f=c.maximumWorld;_.CheckExtends(u,i,s),_.CheckExtends(f,i,s)}}return{min:i,max:s}}}qe._AnimationRangeFactory=(a,e,t)=>{throw ie("AnimationRange")};qe._NodeConstructors={};T([R()],qe.prototype,"name",void 0);T([R()],qe.prototype,"id",void 0);T([R()],qe.prototype,"uniqueId",void 0);T([R()],qe.prototype,"state",void 0);T([R()],qe.prototype,"metadata",void 0);function _t(){return typeof window<"u"}function hs(){return typeof navigator<"u"}function Fs(){return typeof document<"u"}function xo(a){let e="",t=a.firstChild;for(;t;)t.nodeType===3&&(e+=t.textContent),t=t.nextSibling;return e}class w{static _CheckLimit(e,t){let i=w._LogLimitOutputs[e];return i?i.current++:(i={limit:t,current:1},w._LogLimitOutputs[e]=i),i.current<=i.limit}static _GenerateLimitMessage(e,t=1){const i=w._LogLimitOutputs[e];if(!i||!w.MessageLimitReached)return;const s=this._Levels[t];i.current===i.limit&&w[s.name](w.MessageLimitReached.replace(/%LIMIT%/g,""+i.limit).replace(/%TYPE%/g,s.name??""))}static _AddLogEntry(e){w._LogCache=e+w._LogCache,w.OnNewCacheEntry&&w.OnNewCacheEntry(e)}static _FormatMessage(e){const t=s=>s<10?"0"+s:""+s,i=new Date;return"["+t(i.getHours())+":"+t(i.getMinutes())+":"+t(i.getSeconds())+"]: "+e}static _LogDisabled(e,t){}static _LogEnabled(e=1,t,i){const s=Array.isArray(t)?t[0]:t;if(i!==void 0&&!w._CheckLimit(s,i))return;const r=w._FormatMessage(s),n=this._Levels[e],o=Array.isArray(t)?t.slice(1):[];n.logFunc&&n.logFunc("BJS - "+r,...o);const h=`<div style='color:${n.color}'>${r}</div><br>`;w._AddLogEntry(h),w._GenerateLimitMessage(s,e)}static get LogCache(){return w._LogCache}static ClearLogCache(){w._LogCache="",w._LogLimitOutputs={},w.errorsCount=0}static set LogLevels(e){w.Log=w._LogDisabled,w.Warn=w._LogDisabled,w.Error=w._LogDisabled;const t=[w.MessageLogLevel,w.WarningLogLevel,w.ErrorLogLevel];for(const i of t)if((e&i)===i){const s=this._Levels[i];w[s.name]=w._LogEnabled.bind(w,i)}}}w.NoneLogLevel=0;w.MessageLogLevel=1;w.WarningLogLevel=2;w.ErrorLogLevel=4;w.AllLogLevel=7;w.MessageLimitReached="Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.";w._LogCache="";w._LogLimitOutputs={};w._Levels=[{},{color:"white",logFunc:console.log,name:"Log"},{color:"orange",logFunc:console.warn,name:"Warn"},{},{color:"red",logFunc:console.error,name:"Error"}];w.errorsCount=0;w.Log=w._LogEnabled.bind(w,w.MessageLogLevel);w.Warn=w._LogEnabled.bind(w,w.WarningLogLevel);w.Error=w._LogEnabled.bind(w,w.ErrorLogLevel);const ia=(a,e,t)=>!a||a.getClassName&&a.getClassName()==="Mesh"?null:a.getClassName&&(a.getClassName()==="SubMesh"||a.getClassName()==="PhysicsBody")?a.clone(e):a.clone?a.clone():Array.isArray(a)?a.slice():t&&typeof a=="object"?{...a}:null;function Gl(a){const e=[];do{const t=Object.getOwnPropertyNames(a);for(const i of t)e.indexOf(i)===-1&&e.push(i)}while(a=Object.getPrototypeOf(a));return e}class So{static DeepCopy(e,t,i,s,r=!1){const n=Gl(e);for(const o of n){if(o[0]==="_"&&(!s||s.indexOf(o)===-1)||o.endsWith("Observable")||i&&i.indexOf(o)!==-1)continue;const h=e[o],l=typeof h;if(l!=="function")try{if(l==="object")if(h instanceof Uint8Array)t[o]=Uint8Array.from(h);else if(h instanceof Array){if(t[o]=[],h.length>0)if(typeof h[0]=="object")for(let c=0;c<h.length;c++){const u=ia(h[c],t,r);t[o].indexOf(u)===-1&&t[o].push(u)}else t[o]=h.slice(0)}else t[o]=ia(h,t,r);else t[o]=h}catch(c){w.Warn(c.message)}}}}class vt{static get Now(){return _t()&&window.performance&&window.performance.now?window.performance.now():Date.now()}}function Hl(){return typeof _native<"u"&&_native.XMLHttpRequest?new _native.XMLHttpRequest:new XMLHttpRequest}class gt{constructor(){this._xhr=Hl(),this._requestURL=""}static get IsCustomRequestAvailable(){return Object.keys(gt.CustomRequestHeaders).length>0||gt.CustomRequestModifiers.length>0}get requestURL(){return this._requestURL}_injectCustomRequestHeaders(){if(!this._shouldSkipRequestModifications(this._requestURL))for(const e in gt.CustomRequestHeaders){const t=gt.CustomRequestHeaders[e];t&&this._xhr.setRequestHeader(e,t)}}_shouldSkipRequestModifications(e){return gt.SkipRequestModificationForBabylonCDN&&(e.includes("preview.babylonjs.com")||e.includes("cdn.babylonjs.com"))}get onprogress(){return this._xhr.onprogress}set onprogress(e){this._xhr.onprogress=e}get readyState(){return this._xhr.readyState}get status(){return this._xhr.status}get statusText(){return this._xhr.statusText}get response(){return this._xhr.response}get responseURL(){return this._xhr.responseURL}get responseText(){return this._xhr.responseText}get responseType(){return this._xhr.responseType}set responseType(e){this._xhr.responseType=e}get timeout(){return this._xhr.timeout}set timeout(e){this._xhr.timeout=e}addEventListener(e,t,i){this._xhr.addEventListener(e,t,i)}removeEventListener(e,t,i){this._xhr.removeEventListener(e,t,i)}abort(){this._xhr.abort()}send(e){gt.CustomRequestHeaders&&this._injectCustomRequestHeaders(),this._xhr.send(e)}open(e,t){for(const i of gt.CustomRequestModifiers){if(this._shouldSkipRequestModifications(t))return;t=i(this._xhr,t)||t}t=t.replace("file:http:","http:"),t=t.replace("file:https:","https:"),this._requestURL=t,this._xhr.open(e,t,!0)}setRequestHeader(e,t){this._xhr.setRequestHeader(e,t)}getResponseHeader(e){return this._xhr.getResponseHeader(e)}}gt.CustomRequestHeaders={};gt.CustomRequestModifiers=new Array;gt.SkipRequestModificationForBabylonCDN=!0;class ws{}ws.FilesToLoad={};class Vl{static ExponentialBackoff(e=3,t=500){return(i,s,r)=>s.status!==0||r>=e||i.indexOf("file:")!==-1?-1:Math.pow(2,r)*t}}class Fi extends Error{}Fi._setPrototypeOf=Object.setPrototypeOf||((a,e)=>(a.__proto__=e,a));const xs={MeshInvalidPositionsError:0,GLTFLoaderUnexpectedMagicError:2e3,SceneLoaderError:3e3,LoadFileError:4e3,RequestFileError:4001,ReadFileError:4002};class Li extends Fi{constructor(e,t,i){super(e),this.errorCode=t,this.innerError=i,this.name="RuntimeError",Fi._setPrototypeOf(this,Li.prototype)}}class Ot extends Fi{constructor(e="Operation aborted"){super(e),this.name="AbortError",Fi._setPrototypeOf(this,Ot.prototype)}}const f_=a=>{if(typeof TextDecoder<"u")return new TextDecoder().decode(a);let e="";for(let t=0;t<a.byteLength;t++)e+=String.fromCharCode(a[t]);return e},Mo=a=>{const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let t="",i,s,r,n,o,h,l,c=0;const u=ArrayBuffer.isView(a)?new Uint8Array(a.buffer,a.byteOffset,a.byteLength):new Uint8Array(a);for(;c<u.length;)i=u[c++],s=c<u.length?u[c++]:Number.NaN,r=c<u.length?u[c++]:Number.NaN,n=i>>2,o=(i&3)<<4|s>>4,h=(s&15)<<2|r>>6,l=r&63,isNaN(s)?h=l=64:isNaN(r)&&(l=64),t+=e.charAt(n)+e.charAt(o)+e.charAt(h)+e.charAt(l);return t},Co=a=>atob(a),zl=a=>{const e=Co(a),t=e.length,i=new Uint8Array(new ArrayBuffer(t));for(let s=0;s<t;s++)i[s]=e.charCodeAt(s);return i.buffer},Wl="attribute",Xl="varying";class er{constructor(){this.children=[]}isValid(e){return!0}process(e,t,i){let s="";if(this.line){let r=this.line;const n=t.processor;if(n){n.lineProcessor&&(r=n.lineProcessor(r,t.isFragment,t.processingContext));const o=t.processor?.attributeKeywordName??Wl,h=t.isFragment&&t.processor?.varyingFragmentKeywordName?t.processor?.varyingFragmentKeywordName:!t.isFragment&&t.processor?.varyingVertexKeywordName?t.processor?.varyingVertexKeywordName:Xl;!t.isFragment&&n.attributeProcessor&&this.line.startsWith(o)?r=n.attributeProcessor(this.line,e,t.processingContext):n.varyingProcessor&&(n.varyingCheck?.(this.line,t.isFragment)||!n.varyingCheck&&this.line.startsWith(h))?r=n.varyingProcessor(this.line,t.isFragment,e,t.processingContext):n.uniformProcessor&&n.uniformRegexp&&n.uniformRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(r=n.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):n.uniformBufferProcessor&&n.uniformBufferRegexp&&n.uniformBufferRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(r=n.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0):n.textureProcessor&&n.textureRegexp&&n.textureRegexp.test(this.line)?r=n.textureProcessor(this.line,t.isFragment,e,t.processingContext):(n.uniformProcessor||n.uniformBufferProcessor)&&this.line.startsWith("uniform")&&!t.lookForClosingBracketForUniformBuffer&&(/uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/.test(this.line)?n.uniformProcessor&&(r=n.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):n.uniformBufferProcessor&&(r=n.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0)),t.lookForClosingBracketForUniformBuffer&&this.line.indexOf("}")!==-1&&(t.lookForClosingBracketForUniformBuffer=!1,n.endOfUniformBufferProcessor&&(r=n.endOfUniformBufferProcessor(this.line,t.isFragment,t.processingContext)))}s+=r+`
6`}for(const r of this.children)s+=r.process(e,t,i);return this.additionalDefineKey&&(e[this.additionalDefineKey]=this.additionalDefineValue||"true",i[this.additionalDefineKey]=e[this.additionalDefineKey]),s}}class Kl{constructor(){this._lines=[]}get currentLine(){return this._lines[this.lineIndex]}get canRead(){return this.lineIndex<this._lines.length-1}set lines(e){this._lines.length=0;for(const t of e){if(!t||t==="\r")continue;if(t[0]==="#"){this._lines.push(t);continue}const i=t.trim();if(!i)continue;if(i.startsWith("//")){this._lines.push(t);continue}const s=i.indexOf(";");if(s===-1)this._lines.push(i);else if(s===i.length-1)i.length>1&&this._lines.push(i);else{const r=t.split(";");for(let n=0;n<r.length;n++){let o=r[n];o&&(o=o.trim(),o&&this._lines.push(o+(n!==r.length-1?";":"")))}}}}}class qr extends er{process(e,t,i){for(let s=0;s<this.children.length;s++){const r=this.children[s];if(r.isValid(e))return r.process(e,t,i)}return""}}class Yl extends er{isValid(e){return this.testExpression.isTrue(e)}}class Ge{isTrue(e){return!0}static postfixToInfix(e){const t=[];for(const i of e)if(Ge._OperatorPriority[i]===void 0)t.push(i);else{const s=t[t.length-1],r=t[t.length-2];t.length-=2,t.push(`(${r}${i}${s})`)}return t[t.length-1]}static infixToPostfix(e){const t=Ge._InfixToPostfixCache.get(e);if(t)return t.accessTime=Date.now(),t.result;if(!e.includes("&&")&&!e.includes("||")&&!e.includes(")")&&!e.includes("("))return[e];const i=[];let s=-1;const r=()=>{c=c.trim(),c!==""&&(i.push(c),c="")},n=u=>{s<Ge._Stack.length-1&&(Ge._Stack[++s]=u)},o=()=>Ge._Stack[s],h=()=>s===-1?"!!INVALID EXPRESSION!!":Ge._Stack[s--];let l=0,c="";for(;l<e.length;){const u=e.charAt(l),f=l<e.length-1?e.substring(l,2+l):"";if(u==="(")c="",n(u);else if(u===")"){for(r();s!==-1&&o()!=="(";)i.push(h());h()}else if(Ge._OperatorPriority[f]>1){for(r();s!==-1&&Ge._OperatorPriority[o()]>=Ge._OperatorPriority[f];)i.push(h());n(f),l++}else c+=u;l++}for(r();s!==-1;)o()==="("?h():i.push(h());return Ge._InfixToPostfixCache.size>=Ge.InfixToPostfixCacheLimitSize&&Ge.ClearCache(),Ge._InfixToPostfixCache.set(e,{result:i,accessTime:Date.now()}),i}static ClearCache(){const e=Array.from(Ge._InfixToPostfixCache.entries()).sort((t,i)=>t[1].accessTime-i[1].accessTime);for(let t=0;t<Ge.InfixToPostfixCacheCleanupSize;t++)Ge._InfixToPostfixCache.delete(e[t][0])}}Ge.InfixToPostfixCacheLimitSize=5e4;Ge.InfixToPostfixCacheCleanupSize=25e3;Ge._InfixToPostfixCache=new Map;Ge._OperatorPriority={")":0,"(":1,"||":2,"&&":3};Ge._Stack=["","","","","","","","","","","","","","","","","","","",""];class Sr extends Ge{constructor(e,t=!1){super(),this.define=e,this.not=t}isTrue(e){let t=e[this.define]!==void 0;return this.not&&(t=!t),t}}class ql extends Ge{isTrue(e){return this.leftOperand.isTrue(e)||this.rightOperand.isTrue(e)}}class jl extends Ge{isTrue(e){return this.leftOperand.isTrue(e)&&this.rightOperand.isTrue(e)}}class Ql extends Ge{constructor(e,t,i){super(),this.define=e,this.operand=t,this.testValue=i}toString(){return`${this.define} ${this.operand} ${this.testValue}`}isTrue(e){let t=!1;const i=parseInt(e[this.define]!=null?e[this.define]:this.define),s=parseInt(e[this.testValue]!=null?e[this.testValue]:this.testValue);if(isNaN(i)||isNaN(s))return!1;switch(this.operand){case">":t=i>s;break;case"<":t=i<s;break;case"<=":t=i<=s;break;case">=":t=i>=s;break;case"==":t=i===s;break;case"!=":t=i!==s;break}return t}}const Mr={};function Io(a,e,t=""){return t+(e?e+`
7`:"")+a}function Po(a,e,t,i,s,r,n){const o=n||Mr.loadFile;if(o)return o(a,e,t,i,s,r);throw ie("FileTools")}function vo(a,e,t,i){if(a){e?a.IS_NDC_HALF_ZRANGE="":delete a.IS_NDC_HALF_ZRANGE,t?a.USE_REVERSE_DEPTHBUFFER="":delete a.USE_REVERSE_DEPTHBUFFER,i?a.USE_EXACT_SRGB_CONVERSIONS="":delete a.USE_EXACT_SRGB_CONVERSIONS;return}else{let s="";return e&&(s+="#define IS_NDC_HALF_ZRANGE"),t&&(s&&(s+=`
8`),s+="#define USE_REVERSE_DEPTHBUFFER"),i&&(s&&(s+=`
9`),s+="#define USE_EXACT_SRGB_CONVERSIONS"),s}}function Zl(a,e,t=!1,i){switch(a){case 3:{const r=e instanceof ArrayBuffer?new Int8Array(e):new Int8Array(e);return i&&r.set(new Int8Array(i)),r}case 0:{const r=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e);return i&&r.set(new Uint8Array(i)),r}case 4:{const r=e instanceof ArrayBuffer?new Int16Array(e):new Int16Array(t?e/2:e);return i&&r.set(new Int16Array(i)),r}case 5:case 8:case 9:case 10:case 2:{const r=e instanceof ArrayBuffer?new Uint16Array(e):new Uint16Array(t?e/2:e);return i&&r.set(new Uint16Array(i)),r}case 6:{const r=e instanceof ArrayBuffer?new Int32Array(e):new Int32Array(t?e/4:e);return i&&r.set(new Int32Array(i)),r}case 7:case 11:case 12:case 13:case 14:case 15:{const r=e instanceof ArrayBuffer?new Uint32Array(e):new Uint32Array(t?e/4:e);return i&&r.set(new Uint32Array(i)),r}case 1:{const r=e instanceof ArrayBuffer?new Float32Array(e):new Float32Array(t?e/4:e);return i&&r.set(new Float32Array(i)),r}}const s=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e);return i&&s.set(new Uint8Array(i)),s}const $l=/defined\s*?\((.+?)\)/g,jr=/defined\s*?\[(.+?)\]/g,Jl=/#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g,ec=/__decl__/,sa=/light\{X\}.(\w*)/g,ra=/\{X\}/g,ur=[],tc=/(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/;function ic(a){a.processor&&a.processor.initializeShaders&&a.processor.initializeShaders(a.processingContext)}function na(a,e,t,i){e.processor?.preProcessShaderCode&&(a=e.processor.preProcessShaderCode(a,e.isFragment)),Cr(a,e,s=>{e.processCodeAfterIncludes&&(s=e.processCodeAfterIncludes(e.isFragment?"fragment":"vertex",s,e.defines));const r=hc(s,e,i);t(r,s)})}function sc(a,e,t){return!t.processor||!t.processor.finalizeShaders?{vertexCode:a,fragmentCode:e}:t.processor.finalizeShaders(a,e,t.processingContext)}function rc(a,e){if(e.processor?.noPrecision)return a;const t=e.shouldUseHighPrecisionShader;return a.indexOf("precision highp float")===-1?t?a=`precision highp float;
10`+a:a=`precision mediump float;
11`+a:t||(a=a.replace("precision highp float","precision mediump float")),a}function Qr(a){const t=/defined\((.+)\)/.exec(a);if(t&&t.length)return new Sr(t[1].trim(),a[0]==="!");const i=["==","!=",">=","<=","<",">"];let s="",r=0;for(s of i)if(r=a.indexOf(s),r>-1)break;if(r===-1)return new Sr(a);const n=a.substring(0,r).trim(),o=a.substring(r+s.length).trim();return new Ql(n,s,o)}function nc(a){a=a.replace($l,"defined[$1]");const e=Ge.infixToPostfix(a),t=[];for(const s of e)if(s!=="||"&&s!=="&&")t.push(s);else if(t.length>=2){let r=t[t.length-1],n=t[t.length-2];t.length-=2;const o=s=="&&"?new jl:new ql;typeof r=="string"&&(r=r.replace(jr,"defined($1)")),typeof n=="string"&&(n=n.replace(jr,"defined($1)")),o.leftOperand=typeof n=="string"?Qr(n):n,o.rightOperand=typeof r=="string"?Qr(r):r,t.push(o)}let i=t[t.length-1];return typeof i=="string"&&(i=i.replace(jr,"defined($1)")),typeof i=="string"?Qr(i):i}function Ar(a,e){const t=new Yl,i=a.substring(0,e);let s=a.substring(e);return s=s.substring(0,(s.indexOf("//")+1||s.length+1)-1).trim(),i==="#ifdef"?t.testExpression=new Sr(s):i==="#ifndef"?t.testExpression=new Sr(s,!0):t.testExpression=nc(s),t}function Zr(a,e,t,i){let s=a.currentLine;for(;_n(a,t);){s=a.currentLine;const r=s.substring(0,5).toLowerCase();if(r==="#else"){const n=new er;e.children.push(n),_n(a,n);return}else if(r==="#elif"){const n=Ar(s,5);e.children.push(n),t=n}}}function _n(a,e,t){for(;a.canRead;){a.lineIndex++;const i=a.currentLine;if(i.indexOf("#")>=0){const r=tc.exec(i);if(r&&r.length){switch(r[0]){case"#ifdef":{const o=new qr;e.children.push(o);const h=Ar(i,6);o.children.push(h),Zr(a,o,h);break}case"#else":case"#elif":return!0;case"#endif":return!1;case"#ifndef":{const o=new qr;e.children.push(o);const h=Ar(i,7);o.children.push(h),Zr(a,o,h);break}case"#if":{const o=new qr,h=Ar(i,3);e.children.push(o),o.children.push(h),Zr(a,o,h);break}}continue}}const s=new er;if(s.line=i,e.children.push(s),i[0]==="#"&&i[1]==="d"){const r=i.replace(";","").split(" ");s.additionalDefineKey=r[1],r.length===3&&(s.additionalDefineValue=r[2])}}return!1}function ac(a,e,t,i){const s=new er,r=new Kl;return r.lineIndex=-1,r.lines=a.split(`
12`),_n(r,s),s.process(e,t,i)}function oc(a,e){const t=a.defines,i={};for(const s of t){const n=s.replace("#define","").replace(";","").trim().split(" ");i[n[0]]=n.length>1?n[1]:""}return a.processor?.shaderLanguage===0&&(i.GL_ES="true"),i.__VERSION__=a.version,i[a.platformName]="true",vo(i,e?.isNDCHalfZRange,e?.useReverseDepthBuffer,e?.useExactSrgbConversions),i}function hc(a,e,t){let i=rc(a,e);if(!e.processor||e.processor.shaderLanguage===0&&i.indexOf("#version 3")!==-1&&(i=i.replace("#version 300 es",""),!e.processor.parseGLES3))return i;const s=e.defines,r=oc(e,t);e.processor.preProcessor&&(i=e.processor.preProcessor(i,s,r,e.isFragment,e.processingContext));const n={};return i=ac(i,r,e,n),e.processor.postProcessor&&(i=e.processor.postProcessor(i,s,e.isFragment,e.processingContext,t?{drawBuffersExtensionDisabled:!t.getCaps().drawBuffersExtension}:{},r,n)),t?._features.needShaderCodeInlining&&(i=t.inlineShaderCode(i)),i}function Cr(a,e,t){ur.length=0;let i;for(;(i=Jl.exec(a))!==null;)ur.push(i);let s=String(a),r=[a],n=!1;for(const o of ur){let h=o[1];if(h.indexOf("__decl__")!==-1&&(h=h.replace(ec,""),e.supportsUniformBuffers&&(h=h.replace("Vertex","Ubo").replace("Fragment","Ubo")),h=h+"Declaration"),e.includesShadersStore[h]){let l=e.includesShadersStore[h];if(o[2]){const u=o[3].split(",");for(let f=0;f<u.length;f+=2){const d=new RegExp(u[f],"g"),g=u[f+1];l=l.replace(d,g)}}if(o[4]){const u=o[5];if(u.indexOf("..")!==-1){const f=u.split(".."),d=parseInt(f[0]);let g=parseInt(f[1]),p=l.slice(0);l="",isNaN(g)&&(g=e.indexParameters[f[1]]);for(let m=d;m<g;m++)e.supportsUniformBuffers||(p=p.replace(sa,(A,E)=>E+"{X}")),l+=p.replace(ra,m.toString())+`
13`}else e.supportsUniformBuffers||(l=l.replace(sa,(f,d)=>d+"{X}")),l=l.replace(ra,u)}const c=[];for(const u of r){const f=u.split(o[0]);for(let d=0;d<f.length-1;d++)c.push(f[d]),c.push(l);c.push(f[f.length-1])}r=c,n=n||l.indexOf("#include<")>=0||l.indexOf("#include <")>=0}else{const l=e.shadersRepository+"ShadersInclude/"+h+".fx";Do.loadFile(l,c=>{e.includesShadersStore[h]=c,Cr(r.join(""),e,t)});return}}ur.length=0,s=r.join(""),n?Cr(s.toString(),e,t):t(s)}const Do={loadFile:(a,e,t,i,s,r)=>{throw ie("FileTools")}};let dr=[];class ks{static SetImmediate(e){dr.length===0&&setTimeout(()=>{const t=dr;dr=[];for(const i of t)i()},1),dr.push(e)}}function aa(a,e,t){try{if(a())return e(),!0}catch(i){return t?.(i),!0}return!1}const tr=(a,e,t,i=16,s=3e4,r=!0,n)=>{if(r&&aa(a,e,t))return null;const o=setInterval(()=>{aa(a,e,t)?clearInterval(o):(s-=i,s<0&&(clearInterval(o),t?.(new Error("Operation timed out after maximum retries. "+(n||"")),!0)))},i);return()=>clearInterval(o)};class We{static GetShadersRepository(e=0){return e===0?We.ShadersRepository:We.ShadersRepositoryWGSL}static GetShadersStore(e=0){return e===0?We.ShadersStore:We.ShadersStoreWGSL}static GetIncludesShadersStore(e=0){return e===0?We.IncludesShadersStore:We.IncludesShadersStoreWGSL}}We.ShadersRepository="src/Shaders/";We.ShadersStore={};We.IncludesShadersStore={};We.ShadersRepositoryWGSL="src/ShadersWGSL/";We.ShadersStoreWGSL={};We.IncludesShadersStoreWGSL={};class lc{constructor(){this._valueCache={},this.vertexCompilationError=null,this.fragmentCompilationError=null,this.programLinkError=null,this.programValidationError=null,this._isDisposed=!1}get isAsync(){return this.isParallelCompiled}get isReady(){return this.program?this.isParallelCompiled?this.engine._isRenderingStateCompiled(this):!0:!1}_handlesSpectorRebuildCallback(e){e&&this.program&&e(this.program)}setEngine(e){this.engine=e}_fillEffectInformation(e,t,i,s,r,n,o,h){const l=this.engine;if(l.supportsUniformBuffers)for(const f in t)e.bindUniformBlock(f,t[f]);this.engine.getUniforms(this,i).forEach((f,d)=>{s[i[d]]=f}),this._uniforms=s;let u;for(u=0;u<r.length;u++)e.getUniform(r[u])==null&&(r.splice(u,1),u--);r.forEach((f,d)=>{n[f]=d});for(const f of l.getAttributes(this,o))h.push(f)}dispose(){this._uniforms={},this._isDisposed=!0}_cacheMatrix(e,t){const i=this._valueCache[e],s=t.updateFlag;return i!==void 0&&i===s?!1:(this._valueCache[e]=s,!0)}_cacheFloat2(e,t,i){let s=this._valueCache[e];if(!s||s.length!==2)return s=[t,i],this._valueCache[e]=s,!0;let r=!1;return s[0]!==t&&(s[0]=t,r=!0),s[1]!==i&&(s[1]=i,r=!0),r}_cacheFloat3(e,t,i,s){let r=this._valueCache[e];if(!r||r.length!==3)return r=[t,i,s],this._valueCache[e]=r,!0;let n=!1;return r[0]!==t&&(r[0]=t,n=!0),r[1]!==i&&(r[1]=i,n=!0),r[2]!==s&&(r[2]=s,n=!0),n}_cacheFloat4(e,t,i,s,r){let n=this._valueCache[e];if(!n||n.length!==4)return n=[t,i,s,r],this._valueCache[e]=n,!0;let o=!1;return n[0]!==t&&(n[0]=t,o=!0),n[1]!==i&&(n[1]=i,o=!0),n[2]!==s&&(n[2]=s,o=!0),n[3]!==r&&(n[3]=r,o=!0),o}setInt(e,t){const i=this._valueCache[e];i!==void 0&&i===t||this.engine.setInt(this._uniforms[e],t)&&(this._valueCache[e]=t)}setInt2(e,t,i){this._cacheFloat2(e,t,i)&&(this.engine.setInt2(this._uniforms[e],t,i)||(this._valueCache[e]=null))}setInt3(e,t,i,s){this._cacheFloat3(e,t,i,s)&&(this.engine.setInt3(this._uniforms[e],t,i,s)||(this._valueCache[e]=null))}setInt4(e,t,i,s,r){this._cacheFloat4(e,t,i,s,r)&&(this.engine.setInt4(this._uniforms[e],t,i,s,r)||(this._valueCache[e]=null))}setIntArray(e,t){this._valueCache[e]=null,this.engine.setIntArray(this._uniforms[e],t)}setIntArray2(e,t){this._valueCache[e]=null,this.engine.setIntArray2(this._uniforms[e],t)}setIntArray3(e,t){this._valueCache[e]=null,this.engine.setIntArray3(this._uniforms[e],t)}setIntArray4(e,t){this._valueCache[e]=null,this.engine.setIntArray4(this._uniforms[e],t)}setUInt(e,t){const i=this._valueCache[e];i!==void 0&&i===t||this.engine.setUInt(this._uniforms[e],t)&&(this._valueCache[e]=t)}setUInt2(e,t,i){this._cacheFloat2(e,t,i)&&(this.engine.setUInt2(this._uniforms[e],t,i)||(this._valueCache[e]=null))}setUInt3(e,t,i,s){this._cacheFloat3(e,t,i,s)&&(this.engine.setUInt3(this._uniforms[e],t,i,s)||(this._valueCache[e]=null))}setUInt4(e,t,i,s,r){this._cacheFloat4(e,t,i,s,r)&&(this.engine.setUInt4(this._uniforms[e],t,i,s,r)||(this._valueCache[e]=null))}setUIntArray(e,t){this._valueCache[e]=null,this.engine.setUIntArray(this._uniforms[e],t)}setUIntArray2(e,t){this._valueCache[e]=null,this.engine.setUIntArray2(this._uniforms[e],t)}setUIntArray3(e,t){this._valueCache[e]=null,this.engine.setUIntArray3(this._uniforms[e],t)}setUIntArray4(e,t){this._valueCache[e]=null,this.engine.setUIntArray4(this._uniforms[e],t)}setArray(e,t){this._valueCache[e]=null,this.engine.setArray(this._uniforms[e],t)}setArray2(e,t){this._valueCache[e]=null,this.engine.setArray2(this._uniforms[e],t)}setArray3(e,t){this._valueCache[e]=null,this.engine.setArray3(this._uniforms[e],t)}setArray4(e,t){this._valueCache[e]=null,this.engine.setArray4(this._uniforms[e],t)}setMatrices(e,t){t&&(this._valueCache[e]=null,this.engine.setMatrices(this._uniforms[e],t))}setMatrix(e,t){this._cacheMatrix(e,t)&&(this.engine.setMatrices(this._uniforms[e],t.asArray())||(this._valueCache[e]=null))}setMatrix3x3(e,t){this._valueCache[e]=null,this.engine.setMatrix3x3(this._uniforms[e],t)}setMatrix2x2(e,t){this._valueCache[e]=null,this.engine.setMatrix2x2(this._uniforms[e],t)}setFloat(e,t){const i=this._valueCache[e];i!==void 0&&i===t||this.engine.setFloat(this._uniforms[e],t)&&(this._valueCache[e]=t)}setVector2(e,t){this._cacheFloat2(e,t.x,t.y)&&(this.engine.setFloat2(this._uniforms[e],t.x,t.y)||(this._valueCache[e]=null))}setFloat2(e,t,i){this._cacheFloat2(e,t,i)&&(this.engine.setFloat2(this._uniforms[e],t,i)||(this._valueCache[e]=null))}setVector3(e,t){this._cacheFloat3(e,t.x,t.y,t.z)&&(this.engine.setFloat3(this._uniforms[e],t.x,t.y,t.z)||(this._valueCache[e]=null))}setFloat3(e,t,i,s){this._cacheFloat3(e,t,i,s)&&(this.engine.setFloat3(this._uniforms[e],t,i,s)||(this._valueCache[e]=null))}setVector4(e,t){this._cacheFloat4(e,t.x,t.y,t.z,t.w)&&(this.engine.setFloat4(this._uniforms[e],t.x,t.y,t.z,t.w)||(this._valueCache[e]=null))}setQuaternion(e,t){this._cacheFloat4(e,t.x,t.y,t.z,t.w)&&(this.engine.setFloat4(this._uniforms[e],t.x,t.y,t.z,t.w)||(this._valueCache[e]=null))}setFloat4(e,t,i,s,r){this._cacheFloat4(e,t,i,s,r)&&(this.engine.setFloat4(this._uniforms[e],t,i,s,r)||(this._valueCache[e]=null))}setColor3(e,t){this._cacheFloat3(e,t.r,t.g,t.b)&&(this.engine.setFloat3(this._uniforms[e],t.r,t.g,t.b)||(this._valueCache[e]=null))}setColor4(e,t,i){this._cacheFloat4(e,t.r,t.g,t.b,i)&&(this.engine.setFloat4(this._uniforms[e],t.r,t.g,t.b,i)||(this._valueCache[e]=null))}setDirectColor4(e,t){this._cacheFloat4(e,t.r,t.g,t.b,t.a)&&(this.engine.setFloat4(this._uniforms[e],t.r,t.g,t.b,t.a)||(this._valueCache[e]=null))}_getVertexShaderCode(){return this.vertexShader?this.engine._getShaderSource(this.vertexShader):null}_getFragmentShaderCode(){return this.fragmentShader?this.engine._getShaderSource(this.fragmentShader):null}}const gn=new WeakMap,cc={_webGLVersion:2,cachedPipelines:{}};function Pt(a){let e=gn.get(a);if(!e){if(!a)return cc;e={_webGLVersion:a.TEXTURE_BINDING_3D?2:1,_context:a,parallelShaderCompile:a.getExtension("KHR_parallel_shader_compile")||void 0,cachedPipelines:{}},gn.set(a,e)}return e}function $r(a){gn.delete(a)}function Oo(a,e,t,i,s,r){const n=Pt(i);r||(r=n._createShaderProgramInjection??In);const o=pn(e,"vertex",i,n._contextWasLost),h=pn(t,"fragment",i,n._contextWasLost);return r(a,o,h,i,s,n.validateShaderPrograms)}function Fo(a,e,t,i,s,r=null,n){const o=Pt(s);n||(n=o._createShaderProgramInjection??In);const h=o._webGLVersion>1?`#version 300 es
14#define WEBGL2 
15`:"",l=oa(e,"vertex",i,h,s,o._contextWasLost),c=oa(t,"fragment",i,h,s,o._contextWasLost);return n(a,l,c,s,r,o.validateShaderPrograms)}function uc(a,e){const t=new lc,i=Pt(a);return i.parallelShaderCompile&&!i.disableParallelShaderCompile&&(t.isParallelCompiled=!0),t.context=i._context,t}function In(a,e,t,i,s=null,r){const n=i.createProgram();if(a.program=n,!n)throw new Error("Unable to create program");return i.attachShader(n,e),i.attachShader(n,t),i.linkProgram(n),a.context=i,a.vertexShader=e,a.fragmentShader=t,a.isParallelCompiled||Pn(a,i,r),n}function dc(a,e,t){const i=a;if(i._isDisposed)return!1;const s=Pt(e);return s&&s.parallelShaderCompile&&s.parallelShaderCompile.COMPLETION_STATUS_KHR&&i.program&&e.getProgramParameter(i.program,s.parallelShaderCompile.COMPLETION_STATUS_KHR)?(Pn(i,e,t),!0):!1}function Pn(a,e,t){const i=a.context,s=a.vertexShader,r=a.fragmentShader,n=a.program;if(!i.getProgramParameter(n,i.LINK_STATUS)){if(!e.getShaderParameter(s,e.COMPILE_STATUS)){const l=e.getShaderInfoLog(s);if(l)throw a.vertexCompilationError=l,new Error("VERTEX SHADER "+l)}if(!e.getShaderParameter(r,e.COMPILE_STATUS)){const l=e.getShaderInfoLog(r);if(l)throw a.fragmentCompilationError=l,new Error("FRAGMENT SHADER "+l)}const h=i.getProgramInfoLog(n);if(h)throw a.programLinkError=h,new Error(h)}if(t&&(i.validateProgram(n),!i.getProgramParameter(n,i.VALIDATE_STATUS))){const l=i.getProgramInfoLog(n);if(l)throw a.programValidationError=l,new Error(l)}i.deleteShader(s),i.deleteShader(r),a.vertexShader=void 0,a.fragmentShader=void 0,a.onCompiled&&(a.onCompiled(),a.onCompiled=void 0)}function fc(a,e,t,i,s,r,n,o,h,l="",c,u,f){const d=Pt(a.context);u||(u=d.createRawShaderProgramInjection??Oo),f||(f=d.createShaderProgramInjection??Fo);const g=a;i?g.program=u(g,e,t,g.context,h):g.program=f(g,e,t,o,g.context,h),g.program.__SPECTOR_rebuildProgram=n,c()}function oa(a,e,t,i,s,r){return pn(Io(a,t,i),e,s,r)}function pn(a,e,t,i){const s=t.createShader(e==="vertex"?t.VERTEX_SHADER:t.FRAGMENT_SHADER);if(!s){let r=t.NO_ERROR,n=t.NO_ERROR;for(;(n=t.getError())!==t.NO_ERROR;)r=n;throw new Error(`Something went wrong while creating a gl ${e} shader object. gl error=${r}, gl isContextLost=${t.isContextLost()}, _contextWasLost=${i}`)}return t.shaderSource(s,a),t.compileShader(s),s}function _c(a,e){e.useProgram(a)}function gc(a,e){const t=a;if(!t.isParallelCompiled){e(a);return}const i=t.onCompiled;t.onCompiled=()=>{i?.(),e(a)}}function pc(a,e){return Pt(e).cachedPipelines[a]}function wo(a){const e=a._name,t=a.context;if(e&&t){const i=Pt(t);i.cachedPipelines[e]?.dispose(),delete i.cachedPipelines[e]}}function mc(a,e,t,i,s,r,n){let o,h;const l=_t()?r?.getHostDocument():null;typeof e=="string"?o=e:e.vertexSource?o="source:"+e.vertexSource:e.vertexElement?o=l?.getElementById(e.vertexElement)||e.vertexElement:o=e.vertex||e,typeof e=="string"?h=e:e.fragmentSource?h="source:"+e.fragmentSource:e.fragmentElement?h=l?.getElementById(e.fragmentElement)||e.fragmentElement:h=e.fragment||e;const c=[void 0,void 0],u=()=>{if(c[0]&&c[1]){a.isFragment=!0;const[f,d]=c;na(d,a,(g,p)=>{n&&(n._fragmentSourceCodeBeforeMigration=p),t&&(g=t("fragment",g));const m=sc(f,g,a);a=null;const A=Tc(m.vertexCode,m.fragmentCode,e,s);i?.(A.vertexSourceCode,A.fragmentSourceCode)},r)}};ha(o,"Vertex","",f=>{ic(a),na(f,a,(d,g)=>{n&&(n._rawVertexSourceCode=f,n._vertexSourceCodeBeforeMigration=g),t&&(d=t("vertex",d)),c[0]=d,u()},r)},s),ha(h,"Fragment","Pixel",f=>{n&&(n._rawFragmentSourceCode=f),c[1]=f,u()},s)}function ha(a,e,t,i,s,r){if(typeof HTMLElement<"u"&&a instanceof HTMLElement){const h=xo(a);i(h);return}if(a.substring(0,7)==="source:"){i(a.substring(7));return}if(a.substring(0,7)==="base64:"){const h=window.atob(a.substring(7));i(h);return}const n=We.GetShadersStore(s);if(n[a+e+"Shader"]){i(n[a+e+"Shader"]);return}if(t&&n[a+t+"Shader"]){i(n[a+t+"Shader"]);return}let o;if(a[0]==="."||a[0]==="/"||a.indexOf("http")>-1?o=a:o=We.GetShadersRepository(s)+a,r=r||Po,!r)throw new Error("loadFileInjection is not defined");r(o+"."+e.toLowerCase()+".fx",i)}function Tc(a,e,t,i){if(t){const s=t.vertexElement||t.vertex||t.spectorName||t,r=t.fragmentElement||t.fragment||t.spectorName||t;return{vertexSourceCode:(i===1?"//":"")+"#define SHADER_NAME vertex:"+s+`
16`+a,fragmentSourceCode:(i===1?"//":"")+"#define SHADER_NAME fragment:"+r+`
17`+e}}else return{vertexSourceCode:a,fragmentSourceCode:e}}const bc=(a,e,t,i)=>{try{const s=a.context?Pt(a.context):null;s&&(s.disableParallelShaderCompile=a.disableParallelCompilation);const r=a.existingPipelineContext||e(a.shaderProcessingContext);return r._name=a.name,a.name&&s&&(s.cachedPipelines[a.name]=r),t(r,a.vertex,a.fragment,!!a.createAsRaw,"","",a.rebuildRebind,a.defines,a.transformFeedbackVaryings,"",()=>{i(r,()=>{a.onRenderingStateCompiled?.(r)})}),r}catch(s){throw w.Error("Error compiling effect"),s}};class ze{static get ShadersRepository(){return We.ShadersRepository}static set ShadersRepository(e){We.ShadersRepository=e}get isDisposed(){return this._isDisposed}get onBindObservable(){return this._onBindObservable||(this._onBindObservable=new O),this._onBindObservable}get shaderLanguage(){return this._shaderLanguage}constructor(e,t,i,s=null,r,n=null,o=null,h=null,l=null,c,u="",f=0,d){this.defines="",this.onCompiled=null,this.onError=null,this.onBind=null,this.uniqueId=0,this.onCompileObservable=new O,this.onErrorObservable=new O,this._onBindObservable=null,this._isDisposed=!1,this._refCount=1,this._bonesComputationForcedToCPU=!1,this._uniformBuffersNames={},this._multiTarget=!1,this._samplers={},this._isReady=!1,this._compilationError="",this._allFallbacksProcessed=!1,this._uniforms={},this._key="",this._fallbacks=null,this._vertexSourceCodeOverride="",this._fragmentSourceCodeOverride="",this._transformFeedbackVaryings=null,this._disableParallelShaderCompilation=!1,this._pipelineContext=null,this._vertexSourceCode="",this._fragmentSourceCode="",this._vertexSourceCodeBeforeMigration="",this._fragmentSourceCodeBeforeMigration="",this._rawVertexSourceCode="",this._rawFragmentSourceCode="",this._processCodeAfterIncludes=void 0,this._processFinalCode=null,this._onReleaseEffectsObserver=null,this.name=e,this._key=u;const g=this._key.replace(/\r/g,"").replace(/\n/g,"|");let p;if(t.attributes){const m=t;if(this._engine=i,this._attributesNames=m.attributes,this._uniformsNames=m.uniformsNames.concat(m.samplers),this._samplerList=m.samplers.slice(),this.defines=m.defines,this.onError=m.onError,this.onCompiled=m.onCompiled,this._fallbacks=m.fallbacks,this._indexParameters=m.indexParameters,this._transformFeedbackVaryings=m.transformFeedbackVaryings||null,this._multiTarget=!!m.multiTarget,this._shaderLanguage=m.shaderLanguage??0,this._disableParallelShaderCompilation=!!m.disableParallelShaderCompilation,m.uniformBuffersNames){this._uniformBuffersNamesList=m.uniformBuffersNames.slice();for(let A=0;A<m.uniformBuffersNames.length;A++)this._uniformBuffersNames[m.uniformBuffersNames[A]]=A}this._processFinalCode=m.processFinalCode??null,this._processCodeAfterIncludes=m.processCodeAfterIncludes??void 0,d=m.extraInitializationsAsync,p=m.existingPipelineContext}else this._engine=r,this.defines=n??"",this._uniformsNames=i.concat(s),this._samplerList=s?s.slice():[],this._attributesNames=t,this._uniformBuffersNamesList=[],this._shaderLanguage=f,this.onError=l,this.onCompiled=h,this._indexParameters=c,this._fallbacks=o;this._engine.shaderPlatformName==="WEBGL2"&&(p=pc(g,this._engine._gl)??p),this._attributeLocationByName={},this.uniqueId=ze._UniqueIdSeed++,p?(this._pipelineContext=p,this._pipelineContext.setEngine(this._engine),this._onRenderingStateCompiled(this._pipelineContext),this._pipelineContext.program&&(this._pipelineContext.program.__SPECTOR_rebuildProgram=this._rebuildProgram.bind(this))):this._processShaderCodeAsync(null,!1,null,d),this._onReleaseEffectsObserver=this._engine.onReleaseEffectsObservable.addOnce(()=>{this._onReleaseEffectsObserver=null,!this.isDisposed&&this.dispose(!0)})}async _processShaderCodeAsync(e=null,t=!1,i=null,s){s&&await s(),this._processingContext=i||this._engine._getShaderProcessingContext(this._shaderLanguage,!1);const r={defines:this.defines.split(`
18`),indexParameters:this._indexParameters,isFragment:!1,shouldUseHighPrecisionShader:this._engine._shouldUseHighPrecisionShader,processor:e??this._engine._getShaderProcessor(this._shaderLanguage),supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:We.GetShadersRepository(this._shaderLanguage),includesShadersStore:We.GetIncludesShadersStore(this._shaderLanguage),version:(this._engine.version*100).toString(),platformName:this._engine.shaderPlatformName,processingContext:this._processingContext,isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer,processCodeAfterIncludes:this._processCodeAfterIncludes};mc(r,this.name,this._processFinalCode,(n,o)=>{this._vertexSourceCode=n,this._fragmentSourceCode=o,this._prepareEffect(t)},this._shaderLanguage,this._engine,this)}get key(){return this._key}isReady(){try{return this._isReadyInternal()}catch{return!1}}_isReadyInternal(){return this._engine.isDisposed||this._isReady?!0:this._pipelineContext?this._pipelineContext.isReady:!1}getEngine(){return this._engine}getPipelineContext(){return this._pipelineContext}getAttributesNames(){return this._attributesNames}getAttributeLocation(e){return this._attributes[e]}getAttributeLocationByName(e){return this._attributeLocationByName[e]}getAttributesCount(){return this._attributes.length}getUniformIndex(e){return this._uniformsNames.indexOf(e)}getUniform(e){return this._uniforms[e]}getSamplers(){return this._samplerList}getUniformNames(){return this._uniformsNames}getUniformBuffersNames(){return this._uniformBuffersNamesList}getIndexParameters(){return this._indexParameters}getCompilationError(){return this._compilationError}allFallbacksProcessed(){return this._allFallbacksProcessed}async whenCompiledAsync(){return await new Promise(e=>{this.executeWhenCompiled(e)})}executeWhenCompiled(e){if(this.isReady()){e(this);return}this.onCompileObservable.add(t=>{e(t)}),(!this._pipelineContext||this._pipelineContext.isAsync)&&this._checkIsReady(null)}_checkIsReady(e){tr(()=>this._isReadyInternal()||this._isDisposed,()=>{},t=>{this._processCompilationErrors(t,e)},16,12e4,!0,` - Effect: ${typeof this.name=="string"?this.name:this.key}`)}get vertexSourceCode(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._vertexSourceCodeOverride:this._pipelineContext?._getVertexShaderCode()??this._vertexSourceCode}get fragmentSourceCode(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._fragmentSourceCodeOverride:this._pipelineContext?._getFragmentShaderCode()??this._fragmentSourceCode}get vertexSourceCodeBeforeMigration(){return this._vertexSourceCodeBeforeMigration}get fragmentSourceCodeBeforeMigration(){return this._fragmentSourceCodeBeforeMigration}get rawVertexSourceCode(){return this._rawVertexSourceCode}get rawFragmentSourceCode(){return this._rawFragmentSourceCode}getPipelineGenerationOptions(){return{platformName:this._engine.shaderPlatformName,shaderLanguage:this._shaderLanguage,shaderNameOrContent:this.name,key:this._key,defines:this.defines.split(`
19`),addGlobalDefines:!1,extendedProcessingOptions:{indexParameters:this._indexParameters,isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer,supportsUniformBuffers:this._engine.supportsUniformBuffers},extendedCreatePipelineOptions:{transformFeedbackVaryings:this._transformFeedbackVaryings,createAsRaw:!!(this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride)}}}_rebuildProgram(e,t,i,s){this._isReady=!1,this._vertexSourceCodeOverride=e,this._fragmentSourceCodeOverride=t,this.onError=(r,n)=>{s&&s(n)},this.onCompiled=()=>{const r=this.getEngine().scenes;if(r)for(let n=0;n<r.length;n++)r[n].markAllMaterialsAsDirty(127);this._pipelineContext._handlesSpectorRebuildCallback?.(i)},this._fallbacks=null,this._prepareEffect()}_onRenderingStateCompiled(e){if(this._pipelineContext=e,this._pipelineContext.setEngine(this._engine),this._attributes=[],this._pipelineContext._fillEffectInformation(this,this._uniformBuffersNames,this._uniformsNames,this._uniforms,this._samplerList,this._samplers,this._attributesNames,this._attributes),this._attributesNames)for(let t=0;t<this._attributesNames.length;t++){const i=this._attributesNames[t];this._attributeLocationByName[i]=this._attributes[t]}this._engine.bindSamplers(this),this._compilationError="",this._isReady=!0,this.onCompiled&&this.onCompiled(this),this.onCompileObservable.notifyObservers(this),this.onCompileObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh(),ze.AutomaticallyClearCodeCache&&this.clearCodeCache()}_prepareEffect(e=!1){const t=this._pipelineContext;this._isReady=!1;try{const i=!!(this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride),s=i?null:this.defines,r=i?this._vertexSourceCodeOverride:this._vertexSourceCode,n=i?this._fragmentSourceCodeOverride:this._fragmentSourceCode,o=this._engine;this._pipelineContext=bc({existingPipelineContext:e?t:null,vertex:r,fragment:n,context:o.shaderPlatformName==="WEBGL2"||o.shaderPlatformName==="WEBGL1"?o._gl:void 0,rebuildRebind:(h,l,c,u)=>this._rebuildProgram(h,l,c,u),defines:s,transformFeedbackVaryings:this._transformFeedbackVaryings,name:this._key.replace(/\r/g,"").replace(/\n/g,"|"),createAsRaw:i,disableParallelCompilation:this._disableParallelShaderCompilation,shaderProcessingContext:this._processingContext,onRenderingStateCompiled:h=>{t&&!e&&this._engine._deletePipelineContext(t),h&&this._onRenderingStateCompiled(h)}},this._engine.createPipelineContext.bind(this._engine),this._engine._preparePipelineContextAsync.bind(this._engine),this._engine._executeWhenRenderingStateIsCompiled.bind(this._engine)),this._pipelineContext.isAsync&&this._checkIsReady(t)}catch(i){this._processCompilationErrors(i,t)}}_getShaderCodeAndErrorLine(e,t,i){const s=i?/FRAGMENT SHADER ERROR: 0:(\d+?):/:/VERTEX SHADER ERROR: 0:(\d+?):/;let r=null;if(t&&e){const n=t.match(s);if(n&&n.length===2){const o=parseInt(n[1]),h=e.split(`
20`,-1);h.length>=o&&(r=`Offending line [${o}] in ${i?"fragment":"vertex"} code: ${h[o-1]}`)}}return[e,r]}_processCompilationErrors(e,t=null){this._compilationError=e.message;const i=this._attributesNames,s=this._fallbacks;if(w.Error("Unable to compile effect:"),w.Error(`Uniforms: ${this._uniformsNames.join(" ")}`),w.Error(`Attributes: ${i.join(" ")}`),w.Error(`Defines:
21`+this.defines),ze.LogShaderCodeOnCompilationError){let n=null,o=null,h=null;this._pipelineContext?._getVertexShaderCode()&&([h,n]=this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(),this._compilationError,!1),h&&(w.Error("Vertex code:"),w.Error(h))),this._pipelineContext?._getFragmentShaderCode()&&([h,o]=this._getShaderCodeAndErrorLine(this._pipelineContext?._getFragmentShaderCode(),this._compilationError,!0),h&&(w.Error("Fragment code:"),w.Error(h))),n&&w.Error(n),o&&w.Error(o)}w.Error("Error: "+this._compilationError);const r=()=>{this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this),this._engine.onEffectErrorObservable.notifyObservers({effect:this,errors:this._compilationError})};t&&(this._pipelineContext=t,this._isReady=!0,r()),s?(this._pipelineContext=null,s.hasMoreFallbacks?(this._allFallbacksProcessed=!1,w.Error("Trying next fallback."),this.defines=s.reduce(this.defines,this),this._prepareEffect()):(this._allFallbacksProcessed=!0,r(),this.onErrorObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh())):(this._allFallbacksProcessed=!0,t||r())}get isSupported(){return this._compilationError===""}_bindTexture(e,t){this._engine._bindTexture(this._samplers[e],t,e)}setTexture(e,t){this._engine.setTexture(this._samplers[e],this._uniforms[e],t,e)}setTextureArray(e,t){const i=e+"Ex";if(this._samplerList.indexOf(i+"0")===-1){const s=this._samplerList.indexOf(e);for(let n=1;n<t.length;n++){const o=i+(n-1).toString();this._samplerList.splice(s+n,0,o)}let r=0;for(const n of this._samplerList)this._samplers[n]=r,r+=1}this._engine.setTextureArray(this._samplers[e],this._uniforms[e],t,e)}bindUniformBuffer(e,t){const i=this._uniformBuffersNames[t];i===void 0||ze._BaseCache[i]===e&&this._engine._features.useUBOBindingCache||(ze._BaseCache[i]=e,this._engine.bindUniformBufferBase(e,i,t))}bindUniformBlock(e,t){this._engine.bindUniformBlock(this._pipelineContext,e,t)}setInt(e,t){return this._pipelineContext.setInt(e,t),this}setInt2(e,t,i){return this._pipelineContext.setInt2(e,t,i),this}setInt3(e,t,i,s){return this._pipelineContext.setInt3(e,t,i,s),this}setInt4(e,t,i,s,r){return this._pipelineContext.setInt4(e,t,i,s,r),this}setIntArray(e,t){return this._pipelineContext.setIntArray(e,t),this}setIntArray2(e,t){return this._pipelineContext.setIntArray2(e,t),this}setIntArray3(e,t){return this._pipelineContext.setIntArray3(e,t),this}setIntArray4(e,t){return this._pipelineContext.setIntArray4(e,t),this}setUInt(e,t){return this._pipelineContext.setUInt(e,t),this}setUInt2(e,t,i){return this._pipelineContext.setUInt2(e,t,i),this}setUInt3(e,t,i,s){return this._pipelineContext.setUInt3(e,t,i,s),this}setUInt4(e,t,i,s,r){return this._pipelineContext.setUInt4(e,t,i,s,r),this}setUIntArray(e,t){return this._pipelineContext.setUIntArray(e,t),this}setUIntArray2(e,t){return this._pipelineContext.setUIntArray2(e,t),this}setUIntArray3(e,t){return this._pipelineContext.setUIntArray3(e,t),this}setUIntArray4(e,t){return this._pipelineContext.setUIntArray4(e,t),this}setFloatArray(e,t){return this._pipelineContext.setArray(e,t),this}setFloatArray2(e,t){return this._pipelineContext.setArray2(e,t),this}setFloatArray3(e,t){return this._pipelineContext.setArray3(e,t),this}setFloatArray4(e,t){return this._pipelineContext.setArray4(e,t),this}setArray(e,t){return this._pipelineContext.setArray(e,t),this}setArray2(e,t){return this._pipelineContext.setArray2(e,t),this}setArray3(e,t){return this._pipelineContext.setArray3(e,t),this}setArray4(e,t){return this._pipelineContext.setArray4(e,t),this}setMatrices(e,t){return this._pipelineContext.setMatrices(e,t),this}setMatrix(e,t){return this._pipelineContext.setMatrix(e,t),this}setMatrix3x3(e,t){return this._pipelineContext.setMatrix3x3(e,t),this}setMatrix2x2(e,t){return this._pipelineContext.setMatrix2x2(e,t),this}setFloat(e,t){return this._pipelineContext.setFloat(e,t),this}setBool(e,t){return this._pipelineContext.setInt(e,t?1:0),this}setVector2(e,t){return this._pipelineContext.setVector2(e,t),this}setFloat2(e,t,i){return this._pipelineContext.setFloat2(e,t,i),this}setVector3(e,t){return this._pipelineContext.setVector3(e,t),this}setFloat3(e,t,i,s){return this._pipelineContext.setFloat3(e,t,i,s),this}setVector4(e,t){return this._pipelineContext.setVector4(e,t),this}setQuaternion(e,t){return this._pipelineContext.setQuaternion(e,t),this}setFloat4(e,t,i,s,r){return this._pipelineContext.setFloat4(e,t,i,s,r),this}setColor3(e,t){return this._pipelineContext.setColor3(e,t),this}setColor4(e,t,i){return this._pipelineContext.setColor4(e,t,i),this}setDirectColor4(e,t){return this._pipelineContext.setDirectColor4(e,t),this}clearCodeCache(){this._vertexSourceCode="",this._fragmentSourceCode="",this._fragmentSourceCodeBeforeMigration="",this._vertexSourceCodeBeforeMigration=""}dispose(e=!1){if(e)this._refCount=0;else{if(ze.PersistentMode)return;this._refCount--}this._refCount>0||this._isDisposed||(this._onReleaseEffectsObserver&&(this._engine.onReleaseEffectsObservable.remove(this._onReleaseEffectsObserver),this._onReleaseEffectsObserver=null),this._pipelineContext&&wo(this._pipelineContext),this._engine._releaseEffect(this),this.clearCodeCache(),this._isDisposed=!0)}static RegisterShader(e,t,i,s=0){t&&(We.GetShadersStore(s)[`${e}PixelShader`]=t),i&&(We.GetShadersStore(s)[`${e}VertexShader`]=i)}static ResetCache(){ze._BaseCache={}}}ze.LogShaderCodeOnCompilationError=!0;ze.PersistentMode=!1;ze.AutomaticallyClearCodeCache=!1;ze._UniqueIdSeed=0;ze._BaseCache={};ze.ShadersStore=We.ShadersStore;ze.IncludesShadersStore=We.IncludesShadersStore;class Ec{constructor(e=!0){this._isDepthTestDirty=!1,this._isDepthMaskDirty=!1,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1,this._isFrontFaceDirty=!1,e&&this.reset()}get isDirty(){return this._isDepthFuncDirty||this._isDepthTestDirty||this._isDepthMaskDirty||this._isCullFaceDirty||this._isCullDirty||this._isZOffsetDirty||this._isFrontFaceDirty}get zOffset(){return this._zOffset}set zOffset(e){this._zOffset!==e&&(this._zOffset=e,this._isZOffsetDirty=!0)}get zOffsetUnits(){return this._zOffsetUnits}set zOffsetUnits(e){this._zOffsetUnits!==e&&(this._zOffsetUnits=e,this._isZOffsetDirty=!0)}get cullFace(){return this._cullFace}set cullFace(e){this._cullFace!==e&&(this._cullFace=e,this._isCullFaceDirty=!0)}get cull(){return this._cull}set cull(e){this._cull!==e&&(this._cull=e,this._isCullDirty=!0)}get depthFunc(){return this._depthFunc}set depthFunc(e){this._depthFunc!==e&&(this._depthFunc=e,this._isDepthFuncDirty=!0)}get depthMask(){return this._depthMask}set depthMask(e){this._depthMask!==e&&(this._depthMask=e,this._isDepthMaskDirty=!0)}get depthTest(){return this._depthTest}set depthTest(e){this._depthTest!==e&&(this._depthTest=e,this._isDepthTestDirty=!0)}get frontFace(){return this._frontFace}set frontFace(e){this._frontFace!==e&&(this._frontFace=e,this._isFrontFaceDirty=!0)}reset(){this._depthMask=!0,this._depthTest=!0,this._depthFunc=null,this._cullFace=null,this._cull=null,this._zOffset=0,this._zOffsetUnits=0,this._frontFace=null,this._isDepthTestDirty=!0,this._isDepthMaskDirty=!0,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!0,this._isFrontFaceDirty=!1}apply(e){this.isDirty&&(this._isCullDirty&&(this.cull?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this._isCullDirty=!1),this._isCullFaceDirty&&(e.cullFace(this.cullFace),this._isCullFaceDirty=!1),this._isDepthMaskDirty&&(e.depthMask(this.depthMask),this._isDepthMaskDirty=!1),this._isDepthTestDirty&&(this.depthTest?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this._isDepthTestDirty=!1),this._isDepthFuncDirty&&(e.depthFunc(this.depthFunc),this._isDepthFuncDirty=!1),this._isZOffsetDirty&&(this.zOffset||this.zOffsetUnits?(e.enable(e.POLYGON_OFFSET_FILL),e.polygonOffset(this.zOffset,this.zOffsetUnits)):e.disable(e.POLYGON_OFFSET_FILL),this._isZOffsetDirty=!1),this._isFrontFaceDirty&&(e.frontFace(this.frontFace),this._isFrontFaceDirty=!1))}}class Ac{get isDirty(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty}get func(){return this._func}set func(e){this._func!==e&&(this._func=e,this._isStencilFuncDirty=!0)}get backFunc(){return this._func}set backFunc(e){this._backFunc!==e&&(this._backFunc=e,this._isStencilFuncDirty=!0)}get funcRef(){return this._funcRef}set funcRef(e){this._funcRef!==e&&(this._funcRef=e,this._isStencilFuncDirty=!0)}get funcMask(){return this._funcMask}set funcMask(e){this._funcMask!==e&&(this._funcMask=e,this._isStencilFuncDirty=!0)}get opStencilFail(){return this._opStencilFail}set opStencilFail(e){this._opStencilFail!==e&&(this._opStencilFail=e,this._isStencilOpDirty=!0)}get opDepthFail(){return this._opDepthFail}set opDepthFail(e){this._opDepthFail!==e&&(this._opDepthFail=e,this._isStencilOpDirty=!0)}get opStencilDepthPass(){return this._opStencilDepthPass}set opStencilDepthPass(e){this._opStencilDepthPass!==e&&(this._opStencilDepthPass=e,this._isStencilOpDirty=!0)}get backOpStencilFail(){return this._backOpStencilFail}set backOpStencilFail(e){this._backOpStencilFail!==e&&(this._backOpStencilFail=e,this._isStencilOpDirty=!0)}get backOpDepthFail(){return this._backOpDepthFail}set backOpDepthFail(e){this._backOpDepthFail!==e&&(this._backOpDepthFail=e,this._isStencilOpDirty=!0)}get backOpStencilDepthPass(){return this._backOpStencilDepthPass}set backOpStencilDepthPass(e){this._backOpStencilDepthPass!==e&&(this._backOpStencilDepthPass=e,this._isStencilOpDirty=!0)}get mask(){return this._mask}set mask(e){this._mask!==e&&(this._mask=e,this._isStencilMaskDirty=!0)}get enabled(){return this._enabled}set enabled(e){this._enabled!==e&&(this._enabled=e,this._isStencilTestDirty=!0)}constructor(e=!0){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.useStencilGlobalOnly=!1,e&&this.reset()}reset(){this.stencilMaterial=void 0,this.stencilGlobal?.reset(),this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0}apply(e){if(!e)return;const t=!this.useStencilGlobalOnly&&!!this.stencilMaterial?.enabled;this.enabled=t?this.stencilMaterial.enabled:this.stencilGlobal.enabled,this.func=t?this.stencilMaterial.func:this.stencilGlobal.func,this.backFunc=t?this.stencilMaterial.backFunc:this.stencilGlobal.backFunc,this.funcRef=t?this.stencilMaterial.funcRef:this.stencilGlobal.funcRef,this.funcMask=t?this.stencilMaterial.funcMask:this.stencilGlobal.funcMask,this.opStencilFail=t?this.stencilMaterial.opStencilFail:this.stencilGlobal.opStencilFail,this.opDepthFail=t?this.stencilMaterial.opDepthFail:this.stencilGlobal.opDepthFail,this.opStencilDepthPass=t?this.stencilMaterial.opStencilDepthPass:this.stencilGlobal.opStencilDepthPass,this.backOpStencilFail=t?this.stencilMaterial.backOpStencilFail:this.stencilGlobal.backOpStencilFail,this.backOpDepthFail=t?this.stencilMaterial.backOpDepthFail:this.stencilGlobal.backOpDepthFail,this.backOpStencilDepthPass=t?this.stencilMaterial.backOpStencilDepthPass:this.stencilGlobal.backOpStencilDepthPass,this.mask=t?this.stencilMaterial.mask:this.stencilGlobal.mask,this.isDirty&&(this._isStencilTestDirty&&(this.enabled?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.mask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFuncSeparate(e.FRONT,this.func,this.funcRef,this.funcMask),e.stencilFuncSeparate(e.BACK,this.backFunc,this.funcRef,this.funcMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOpSeparate(e.FRONT,this.opStencilFail,this.opDepthFail,this.opStencilDepthPass),e.stencilOpSeparate(e.BACK,this.backOpStencilFail,this.backOpDepthFail,this.backOpStencilDepthPass),this._isStencilOpDirty=!1))}}class Dt{constructor(){this.reset()}reset(){this.enabled=!1,this.mask=255,this.funcRef=1,this.funcMask=255,this.func=Dt.ALWAYS,this.opStencilFail=Dt.KEEP,this.opDepthFail=Dt.KEEP,this.opStencilDepthPass=Dt.REPLACE,this.backFunc=Dt.ALWAYS,this.backOpStencilFail=Dt.KEEP,this.backOpDepthFail=Dt.KEEP,this.backOpStencilDepthPass=Dt.REPLACE}get stencilFunc(){return this.func}set stencilFunc(e){this.func=e}get stencilBackFunc(){return this.backFunc}set stencilBackFunc(e){this.backFunc=e}get stencilFuncRef(){return this.funcRef}set stencilFuncRef(e){this.funcRef=e}get stencilFuncMask(){return this.funcMask}set stencilFuncMask(e){this.funcMask=e}get stencilOpStencilFail(){return this.opStencilFail}set stencilOpStencilFail(e){this.opStencilFail=e}get stencilOpDepthFail(){return this.opDepthFail}set stencilOpDepthFail(e){this.opDepthFail=e}get stencilOpStencilDepthPass(){return this.opStencilDepthPass}set stencilOpStencilDepthPass(e){this.opStencilDepthPass=e}get stencilBackOpStencilFail(){return this.backOpStencilFail}set stencilBackOpStencilFail(e){this.backOpStencilFail=e}get stencilBackOpDepthFail(){return this.backOpDepthFail}set stencilBackOpDepthFail(e){this.backOpDepthFail=e}get stencilBackOpStencilDepthPass(){return this.backOpStencilDepthPass}set stencilBackOpStencilDepthPass(e){this.backOpStencilDepthPass=e}get stencilMask(){return this.mask}set stencilMask(e){this.mask=e}get stencilTest(){return this.enabled}set stencilTest(e){this.enabled=e}}Dt.ALWAYS=519;Dt.KEEP=7680;Dt.REPLACE=7681;class Lo{constructor(e){this._supportBlendParametersPerTarget=e,this._blendFunctionParameters=new Array(32),this._blendEquationParameters=new Array(16),this._blendConstants=new Array(4),this._isBlendConstantsDirt
21y=!1,this._alphaBlend=Array(8).fill(!1),this._numTargetEnabled=0,this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this.reset()}get isDirty(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty||this._isBlendEquationParametersDirty}get alphaBlend(){return this._numTargetEnabled>0}set alphaBlend(e){this.setAlphaBlend(e)}setAlphaBlend(e,t=0){this._alphaBlend[t]!==e&&(e?this._numTargetEnabled++:this._numTargetEnabled--,this._alphaBlend[t]=e,this._isAlphaBlendDirty=!0)}setAlphaBlendConstants(e,t,i,s){this._blendConstants[0]===e&&this._blendConstants[1]===t&&this._blendConstants[2]===i&&this._blendConstants[3]===s||(this._blendConstants[0]=e,this._blendConstants[1]=t,this._blendConstants[2]=i,this._blendConstants[3]=s,this._isBlendConstantsDirty=!0)}setAlphaBlendFunctionParameters(e,t,i,s,r=0){const n=r*4;this._blendFunctionParameters[n+0]===e&&this._blendFunctionParameters[n+1]===t&&this._blendFunctionParameters[n+2]===i&&this._blendFunctionParameters[n+3]===s||(this._blendFunctionParameters[n+0]=e,this._blendFunctionParameters[n+1]=t,this._blendFunctionParameters[n+2]=i,this._blendFunctionParameters[n+3]=s,this._isBlendFunctionParametersDirty=!0)}setAlphaEquationParameters(e,t,i=0){const s=i*2;this._blendEquationParameters[s+0]===e&&this._blendEquationParameters[s+1]===t||(this._blendEquationParameters[s+0]=e,this._blendEquationParameters[s+1]=t,this._isBlendEquationParametersDirty=!0)}reset(){this._alphaBlend.fill(!1),this._numTargetEnabled=0,this._blendFunctionParameters.fill(null),this._blendEquationParameters.fill(null),this._blendConstants[0]=null,this._blendConstants[1]=null,this._blendConstants[2]=null,this._blendConstants[3]=null,this._isAlphaBlendDirty=!0,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1}apply(e,t=1){if(!this.isDirty)return;if(this._isBlendConstantsDirty&&(e.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1),t===1||!this._supportBlendParametersPerTarget){this._isAlphaBlendDirty&&(this._alphaBlend[0]?e.enable(e.BLEND):e.disable(e.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(e.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1),this._isBlendEquationParametersDirty&&(e.blendEquationSeparate(this._blendEquationParameters[0],this._blendEquationParameters[1]),this._isBlendEquationParametersDirty=!1);return}const i=e;if(this._isAlphaBlendDirty){for(let s=0;s<t;s++){const r=s<this._numTargetEnabled?s:0;this._alphaBlend[r]?i.enableIndexed(e.BLEND,s):i.disableIndexed(e.BLEND,s)}this._isAlphaBlendDirty=!1}if(this._isBlendFunctionParametersDirty){for(let s=0;s<t;s++){const r=s<this._numTargetEnabled?s*4:0;i.blendFuncSeparateIndexed(s,this._blendFunctionParameters[r+0],this._blendFunctionParameters[r+1],this._blendFunctionParameters[r+2],this._blendFunctionParameters[r+3])}this._isBlendFunctionParametersDirty=!1}if(this._isBlendEquationParametersDirty){for(let s=0;s<t;s++){const r=s<this._numTargetEnabled?s*2:0;i.blendEquationSeparateIndexed(s,this._blendEquationParameters[r+0],this._blendEquationParameters[r+1])}this._isBlendEquationParametersDirty=!1}}setAlphaMode(e,t){let i=32774;switch(e){case 0:break;case 7:this.setAlphaBlendFunctionParameters(1,771,1,1,t);break;case 8:this.setAlphaBlendFunctionParameters(1,771,1,771,t);break;case 2:this.setAlphaBlendFunctionParameters(770,771,1,1,t);break;case 6:this.setAlphaBlendFunctionParameters(1,1,0,1,t);break;case 1:this.setAlphaBlendFunctionParameters(770,1,0,1,t);break;case 3:this.setAlphaBlendFunctionParameters(0,769,1,1,t),i=32778;break;case 4:this.setAlphaBlendFunctionParameters(774,0,1,1,t);break;case 5:this.setAlphaBlendFunctionParameters(770,769,1,1,t);break;case 9:this.setAlphaBlendFunctionParameters(32769,32770,32771,32772,t);break;case 10:this.setAlphaBlendFunctionParameters(1,769,1,771,t);break;case 11:this.setAlphaBlendFunctionParameters(1,1,1,1,t);break;case 12:this.setAlphaBlendFunctionParameters(772,1,0,0,t);break;case 13:this.setAlphaBlendFunctionParameters(775,769,773,771,t);break;case 14:this.setAlphaBlendFunctionParameters(1,771,1,771,t);break;case 15:this.setAlphaBlendFunctionParameters(1,1,1,0,t);break;case 16:this.setAlphaBlendFunctionParameters(775,769,0,1,t);break;case 17:this.setAlphaBlendFunctionParameters(770,771,1,771,t);break;case 18:this.setAlphaBlendFunctionParameters(1,1,1,1,t),i=32775;break;case 19:this.setAlphaBlendFunctionParameters(1,1,1,1,t),i=32776;break;case 20:this.setAlphaBlendFunctionParameters(1,35065,0,1,t);break}this.setAlphaEquationParameters(i,i,t)}}class Rc{get wrapU(){return this._cachedWrapU}set wrapU(e){this._cachedWrapU=e}get wrapV(){return this._cachedWrapV}set wrapV(e){this._cachedWrapV=e}get wrapR(){return this._cachedWrapR}set wrapR(e){this._cachedWrapR=e}get anisotropicFilteringLevel(){return this._cachedAnisotropicFilteringLevel}set anisotropicFilteringLevel(e){this._cachedAnisotropicFilteringLevel=e}get comparisonFunction(){return this._comparisonFunction}set comparisonFunction(e){this._comparisonFunction=e}get useMipMaps(){return this._useMipMaps}set useMipMaps(e){this._useMipMaps=e}constructor(){this.samplingMode=-1,this._useMipMaps=!0,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedWrapR=null,this._cachedAnisotropicFilteringLevel=null,this._comparisonFunction=0}setParameters(e=1,t=1,i=1,s=1,r=2,n=0){return this._cachedWrapU=e,this._cachedWrapV=t,this._cachedWrapR=i,this._cachedAnisotropicFilteringLevel=s,this.samplingMode=r,this._comparisonFunction=n,this}compareSampler(e){return this._cachedWrapU===e._cachedWrapU&&this._cachedWrapV===e._cachedWrapV&&this._cachedWrapR===e._cachedWrapR&&this._cachedAnisotropicFilteringLevel===e._cachedAnisotropicFilteringLevel&&this.samplingMode===e.samplingMode&&this._comparisonFunction===e._comparisonFunction&&this._useMipMaps===e._useMipMaps}}var la;(function(a){a[a.Unknown=0]="Unknown",a[a.Url=1]="Url",a[a.Temp=2]="Temp",a[a.Raw=3]="Raw",a[a.Dynamic=4]="Dynamic",a[a.RenderTarget=5]="RenderTarget",a[a.MultiRenderTarget=6]="MultiRenderTarget",a[a.Cube=7]="Cube",a[a.CubeRaw=8]="CubeRaw",a[a.CubePrefiltered=9]="CubePrefiltered",a[a.Raw3D=10]="Raw3D",a[a.Raw2DArray=11]="Raw2DArray",a[a.DepthStencil=12]="DepthStencil",a[a.CubeRawRGBD=13]="CubeRawRGBD",a[a.Depth=14]="Depth"})(la||(la={}));class Et extends Rc{get useMipMaps(){return this._useMipMaps===null?this.generateMipMaps:this._useMipMaps}set useMipMaps(e){this._useMipMaps=e}get uniqueId(){return this._uniqueId}_setUniqueId(e){this._uniqueId=e}getEngine(){return this._engine}get source(){return this._source}constructor(e,t,i=!1){super(),this.isReady=!1,this.isCube=!1,this.is3D=!1,this.is2DArray=!1,this.isMultiview=!1,this.url="",this.generateMipMaps=!1,this._useMipMaps=null,this.samples=0,this.type=-1,this.format=-1,this.onLoadedObservable=new O,this.onErrorObservable=new O,this.onRebuildCallback=null,this.width=0,this.height=0,this.depth=0,this.baseWidth=0,this.baseHeight=0,this.baseDepth=0,this.invertY=!1,this._invertVScale=!1,this._associatedChannel=-1,this._source=0,this._buffer=null,this._bufferView=null,this._bufferViewArray=null,this._bufferViewArrayArray=null,this._size=0,this._extension="",this._files=null,this._workingCanvas=null,this._workingContext=null,this._cachedCoordinatesMode=null,this._isDisabled=!1,this._compression=null,this._sphericalPolynomial=null,this._sphericalPolynomialPromise=null,this._sphericalPolynomialComputed=!1,this._lodGenerationScale=0,this._lodGenerationOffset=0,this._useSRGBBuffer=!1,this._creationFlags=0,this._lodTextureHigh=null,this._lodTextureMid=null,this._lodTextureLow=null,this._isRGBD=!1,this._linearSpecularLOD=!1,this._irradianceTexture=null,this._hardwareTexture=null,this._maxLodLevel=null,this._references=1,this._gammaSpace=null,this._premulAlp
vendor: 4,787 bytes, line 21
21ha=!1,this._dynamicTextureSource=null,this._autoMSAAManagement=!1,this._engine=e,this._source=t,this._uniqueId=Et._Counter++,i||(this._hardwareTexture=e._createHardwareTexture())}incrementReferences(){this._references++}updateSize(e,t,i=1){this._engine.updateTextureDimensions(this,e,t,i),this.width=e,this.height=t,this.depth=i,this.baseWidth=e,this.baseHeight=t,this.baseDepth=i,this._size=e*t*i}_rebuild(){if(this.isReady=!1,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedWrapR=null,this._cachedAnisotropicFilteringLevel=null,this.onRebuildCallback){const t=this.onRebuildCallback(this),i=s=>{s._swapAndDie(this,!1),this.isReady=t.isReady};t.isAsync?t.proxy.then(i):i(t.proxy);return}let e;switch(this.source){case 2:break;case 1:e=this._engine.createTexture(this._originalUrl??this.url,!this.generateMipMaps,this.invertY,null,this.samplingMode,t=>{t._swapAndDie(this,!1),this.isReady=!0},null,this._buffer,void 0,this.format,this._extension,void 0,void 0,void 0,this._useSRGBBuffer);return;case 3:e=this._engine.createRawTexture(this._bufferView,this.baseWidth,this.baseHeight,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression,this.type,this._creationFlags,this._useSRGBBuffer),e._swapAndDie(this,!1),this.isReady=!0;break;case 10:e=this._engine.createRawTexture3D(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression,this.type),e._swapAndDie(this,!1),this.isReady=!0;break;case 11:e=this._engine.createRawTexture2DArray(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression,this.type),e._swapAndDie(this,!1),this.isReady=!0;break;case 4:e=this._engine.createDynamicTexture(this.baseWidth,this.baseHeight,this.generateMipMaps,this.samplingMode),e._swapAndDie(this,!1),this._dynamicTextureSource&&this._engine.updateDynamicTexture(this,this._dynamicTextureSource,this.invertY,this._premulAlpha,this.format,!0);break;case 7:e=this._engine.createCubeTexture(this.url,null,this._files,!this.generateMipMaps,()=>{e._swapAndDie(this,!1),this.isReady=!0},null,this.format,this._extension,!1,0,0,null,void 0,this._useSRGBBuffer,ArrayBuffer.isView(this._buffer)?this._buffer:null);return;case 8:e=this._engine.createRawCubeTexture(this._bufferViewArray,this.width,this._originalFormat??this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression),e._swapAndDie(this,!1),this.isReady=!0;break;case 13:return;case 9:e=this._engine.createPrefilteredCubeTexture(this.url,null,this._lodGenerationScale,this._lodGenerationOffset,t=>{t&&t._swapAndDie(this,!1),this.isReady=!0},null,this.format,this._extension),e._sphericalPolynomial=this._sphericalPolynomial;return}}_swapAndDie(e,t=!0){this._hardwareTexture?.setUsage(e._source,this.generateMipMaps,this.is2DArray,this.isCube,this.is3D,this.width,this.height,this.depth),e._hardwareTexture=this._hardwareTexture,t&&(e._isRGBD=this._isRGBD),this._lodTextureHigh&&(e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureHigh=this._lodTextureHigh),this._lodTextureMid&&(e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureMid=this._lodTextureMid),this._lodTextureLow&&(e._lodTextureLow&&e._lodTextureLow.dispose(),e._lodTextureLow=this._lodTextureLow),this._irradianceTexture&&(e._irradianceTexture&&e._irradianceTexture.dispose(),e._irradianceTexture=this._irradianceTexture);const i=this._engine.getLoadedTexturesCache();let s=i.indexOf(this);s!==-1&&i.splice(s,1),s=i.indexOf(e),s===-1&&i.push(e)}dispose(){this._references--,this._references===0&&(this.onLoadedObservable.clear(),this.onErrorObservable.clear(),this._engine._releaseTexture(this),this._hardwareTexture=null,this._dynamicTextureSource=null)}}Et._Counter=0;function Bo(a,e){if(_t()){const{requestAnimationFrame:t}=e||window;if(typeof t=="function")return t(a)}else if(typeof requestAnimationFrame=="function")return requestAnimationFrame(a);return setTimeout(a,16)}class H{get frameId(){return this._frameId}get isWebGPU(){return this._isWebGPU}_getShaderProcessor(e){return this._shaderProcessor}_resetAlphaMode(){this._alphaMode.fill(-1),this._alphaEquation.fill(-1)}get shaderPlatformName(){return this._shaderPlatformName}_clearEmptyResources(){this._emptyTexture=null,this._emptyCubeTexture=null,this._emptyTexture3D=null,this._emptyTexture2DArray=null}get useReverseDepthBuffer(){return this._useReverseDepthBuffer}set useReverseDepthBuffer(e){e!==this._useReverseDepthBuffer&&(this._useReverseDepthBuffer=e,e?this._depthCullingState.depthFunc=518:this._depthCullingState.depthFunc=515)}setColorWrite(e){e!==this._colorWrite&&(this._colorWriteChanged=!0,this._colorWrite=e)}
21getColorWrite(){return this._colorWrite}get depthCullingState(){return this._depthCullingState}get alphaState(){return this._alphaState}get stencilState(){return this._stencilState}get stencilStateComposer(){return this._stencilStateComposer}_getGlobalDefines(e){if(e){this.isNDCHalfZRange?e.IS_NDC_HALF_ZRANGE="":delete e.IS_NDC_HALF_ZRANGE,this.useReverseDepthBuffer?e.USE_REVERSE_DEPTHBUFFER="":delete e.USE_REVERSE_DEPTHBUFFER,this.useExactSrgbConversions?e.USE_EXACT_SRGB_CONVERSIONS="":delete e.USE_EXACT_SRGB_CONVERSIONS;return}else{let t="";return this.isNDCHalfZRange&&(t+="#define IS_NDC_HALF_ZRANGE"),this.useReverseDepthBuffer&&(t&&(t+=`
22`),t+="#define USE_REVERSE_DEPTHBUFFER"),this.useExactSrgbConversions&&(t&&(t+=`
23`),t+="#define USE_EXACT_SRGB_CONVERSIONS"),t}}_rebuildInternalTextures(){const e=this._internalTexturesCache.slice();for(const t of e)t._rebuild()}_rebuildRenderTargetWrappers(){const e=this._renderTargetWrapperCache.slice();for(const t of e)t._rebuild()}_rebuildEffects(){for(const e in this._compiledEffects){const t=this._compiledEffects[e];t._pipelineContext=null,t._prepareEffect()}ze.ResetCache()}_rebuildGraphicsResources(){this.wipeCaches(!0),this._rebuildEffects(),this._rebuildComputeEffects?.(),this._rebuildBuffers(),this._rebuildInternalTextures(),this._rebuildTextures(),this._rebuildRenderTargetWrappers(),this.wipeCaches(!0)}_flagContextRestored(){w.Warn(this.name+" context successfully restored."),this.onContextRestoredObservable.notifyObservers(this),this._contextWasLost=!1}_restoreEngineAfterContextLost(e){setTimeout(()=>{this._clearEmptyResources();const t=this._depthCullingState.depthTest,i=this._depthCullingState.depthFunc,s=this._depthCullingState.depthMask,r=this._stencilState.stencilTest;e(),this._rebuildGraphicsResources(),this._depthCullingState.depthTest=t,this._depthCullingState.depthFunc=i,this._depthCullingState.depthMask=s,this._stencilState.stencilTest=r,this._flagContextRestored()},0)}get isDisposed(){return this._isDisposed}get snapshotRendering(){return!1}set snapshotRendering(e){}get snapshotRenderingMode(){return 0}set snapshotRenderingMode(e){}getClassName(){return"AbstractEngine"}get emptyTexture(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,5,!1,!1,1)),this._emptyTexture}get emptyTexture3D(){return this._emptyTexture3D||(this._emptyTexture3D=this.createRawTexture3D(new Uint8Array(4),1,1,1,5,!1,!1,1)),this._emptyTexture3D}get emptyTexture2DArray(){return this._emptyTexture2DArray||(this._emptyTexture2DArray=this.createRawTexture2DArray(new Uint8Array(4),1,1,1,5,!1,!1,1)),this._emptyTexture2DArray}get emptyCubeTexture(){if(!this._emptyCubeTexture){const e=new Uint8Array(4),t=[e,e,e,e,e,e];this._emptyCubeTexture=this.createRawCubeTexture(t,1,5,0,!1,!1,1)}return this._emptyCubeTexture}get activeRenderLoops(){return this._activeRenderLoops}stopRenderLoop(e){if(!e){this._activeRenderLoops.length=0,this._cancelFrame();return}const t=this._activeRenderLoops.indexOf(e);t>=0&&(this._activeRenderLoops.splice(t,1),this._activeRenderLoops.length==0&&this._cancelFrame())}_cancelFrame(){if(this._frameHandler!==0){const e=this._frameHandler;if(this._frameHandler=0,_t()){const{cancelAnimationFrame:t}=this.getHostWindow()||window;if(typeof t=="function")return t(e)}else if(typeof cancelAnimationFrame=="function")return cancelAnimationFrame(e);return clearTimeout(e)}}beginFrame(){this.onBeginFrameObservable.notifyObservers(this)}endFrame(){this._frameId++,this.onEndFrameObservable.notifyObservers(this)}get maxFPS(){return this._maxFPS}set maxFPS(e){if(this._maxFPS=e,e!==void 0){if(e<=0){this._minFrameTime=Number.MAX_VALUE;return}this._minFrameTime=1e3/e}}_isOverFrameTime(e){if(!e||this._maxFPS===void 0)return!1;const t=e-this._lastFrameTime;return this._lastFrameTime=e,this._renderAccumulator+=t,this._renderAccumulator<this._minFrameTime?!0:(this._renderAccumulator-=this._minFrameTime,this._renderAccumulator>this._minFrameTime&&(this._renderAccumulator=this._minFrameTime),!1)}_processFrame(e){if(this._frameHandler=0,!this._contextWasLost&&!this._isOverFrameTime(e)){let t=!0;
vendor: 6,497 bytes, line 23
23(this.isDisposed||!this.renderEvenInBackground&&this._windowIsBackground)&&(t=!1),t&&(this.beginFrame(),!this.skipFrameRender&&!this._renderViews()&&this._renderFrame(),this.endFrame())}}_renderLoop(e){this._processFrame(e),this._activeRenderLoops.length>0&&this._frameHandler===0&&(this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()))}_renderFrame(){for(let e=0;e<this._activeRenderLoops.length;e++){const t=this._activeRenderLoops[e];t()}}_renderViews(){return!1}_queueNewFrame(e,t){return Bo(e,t)}runRenderLoop(e){this._activeRenderLoops.indexOf(e)===-1&&(this._activeRenderLoops.push(e),this._activeRenderLoops.length===1&&this._frameHandler===0&&(this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow())))}getDepthBuffer(){return this._depthCullingState.depthTest}setDepthBuffer(e){this._depthCullingState.depthTest=e}setZOffset(e){this._depthCullingState.zOffset=this.useReverseDepthBuffer?-e:e}getZOffset(){const e=this._depthCullingState.zOffset;return this.useReverseDepthBuffer?-e:e}setZOffsetUnits(e){this._depthCullingState.zOffsetUnits=this.useReverseDepthBuffer?-e:e}getZOffsetUnits(){const e=this._depthCullingState.zOffsetUnits;return this.useReverseDepthBuffer?-e:e}getHostWindow(){return _t()?this._renderingCanvas&&this._renderingCanvas.ownerDocument&&this._renderingCanvas.ownerDocument.defaultView?this._renderingCanvas.ownerDocument.defaultView:window:null}get compatibilityMode(){return this._compatibilityMode}set compatibilityMode(e){this._compatibilityMode=!0}_rebuildTextures(){for(const e of this.scenes)e._rebuildTextures();for(const e of this._virtualScenes)e._rebuildTextures()}_releaseRenderTargetWrapper(e){const t=this._renderTargetWrapperCache.indexOf(e);t!==-1&&this._renderTargetWrapperCache.splice(t,1)}get currentViewport(){return this._cachedViewport}setViewport(e,t,i){const s=t||this.getRenderWidth(),r=i||this.getRenderHeight(),n=e.x||0,o=e.y||0;this._cachedViewport=e,this._viewport(n*s,o*r,s*e.width,r*e.height)}createCanvasImage(){return document.createElement("img")}createCanvasPath2D(e){return new Path2D(e)}get description(){let e=this.name+this.version;return this._caps.parallelShaderCompile&&(e+=" - Parallel shader compilation"),e}_createTextureBase(e,t,i,s,r=3,n=null,o=null,h,l,c=null,u=null,f=null,d=null,g,p,m){e=e||"";const A=e.substring(0,5)==="data:",E=e.substring(0,5)==="blob:",I=A&&e.indexOf(";base64,")!==-1,M=u||new Et(this,1);M!==u&&(M.label=e.substring(0,60));const C=e;this._transformTextureUrl&&!I&&!u&&!c&&(e=this._transformTextureUrl(e)),C!==e&&(M._originalUrl=C);const x=e.lastIndexOf(".");let S=d||(x>-1?e.substring(x).toLowerCase():"");S.indexOf("?")>-1&&(S=S.split("?")[0]);const N=H.GetCompatibleTextureLoader(S,g);s&&s.addPendingData(M),M.url=e,M.generateMipMaps=!t,M.samplingMode=r,M.invertY=i,M._useSRGBBuffer=this._getUseSRGBBuffer(!!m,t),this._doNotHandleContextLost||(M._buffer=c);let D=null;n&&!u&&(D=M.onLoadedObservable.add(n)),u||this._internalTexturesCache.push(M);const Re=(pe,ce)=>{s&&s.removePendingData(M),e===C?(D&&M.onLoadedObservable.remove(D),Te.UseFallbackTexture&&e!==Te.FallbackTexture&&this._createTextureBase(Te.FallbackTexture,t,M.invertY,s,r,null,o,h,l,c,M),pe=(pe||"Unknown error")+(Te.UseFallbackTexture?" - Fallback texture was used":""),M.onErrorObservable.notifyObservers({message:pe,exception:ce}),o&&o(pe,ce)):(w.Warn(`Failed to load ${e}, falling back to ${C}`),this._createTextureBase(C,t,M.invertY,s,r,n,o,h,l,c,M,f,d,g,p,m))};if(N){const pe=async ce=>{(await N).loadData(ce,M,(Ye,Qe,ft,de,Fe,we)=>{we?Re("TextureLoader failed to load data"):h(M,S,s,{width:Ye,height:Qe},M.invertY,!ft,de,()=>(Fe(),!1),r)},p)};c?c instanceof ArrayBuffer?pe(new Uint8Array(c)):ArrayBuffer.isView(c)?pe(c):o&&o("Unable to load: only ArrayBuffer or ArrayBufferView is supported",null):this._loadFile(e,ce=>{pe(new Uint8Array(ce))},void 0,s?s.offlineProvider:void 0,!0,(ce,oe)=>{Re("Unable to load "+(ce&&ce.responseURL,oe))})}else{const pe=ce=>{E&&!this._doNotHandleContextLost&&(M._buffer=ce),h(M,S,s,ce,M.invertY,t,!1,l,r)};!A||I?c&&(typeof c.decoding=="string"||c.close)?pe(c):H._FileToolsLoadImage(e||"",pe,Re,s?s.offlineProvider:null,g,M.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0,this):typeof c=="string"||c instanceof ArrayBuffer||ArrayBuffer.isView(c)||c instanceof Blob?H._FileToolsLoadImage(c,pe,Re,s?s.offlineProvider:null,g,M.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0,this):c&&pe(c)}return M}_rebuildBuffers(){for(const e of this._uniformBuffers)e._rebuildAfterContextLost()}get _shouldUseHighPrecisionShader(){return!!(this._caps.highPrecisionShaderSupported&&this._highPrecisionShadersAllowed)}getHostDocument(){return this._renderingCanvas&&this._renderingCanvas.ownerDocument?this._renderingCanvas.ownerDocument:Fs()?document:null}getLoadedTexturesCache(){return this._internalTexturesCache}clearInternalTexturesCache(){this._internalTexturesCache.length=0}getCaps(){return this._caps}resetTextureCache(){for(const e in this._boundTexturesCache)Object.prototype.hasOwnProperty.call(this._boundTexturesCache,e)&&(this._boundTexturesCache[e]=null);this._currentTextureChannel=-1}get name(){return this._name}set name(e){this._name=e}static get NpmPackage(){return"[email protected]"}static get Version(){return"8.46.2"}getRenderingCanvas(){return this._renderingCanvas}getAudioContext(){return this._audioContext}getAudioDestination(){return this._audioDestination}setHardwareScalingLevel(e){this._hardwareScalingLevel=e,this.resize()}getHardwareScalingLevel(){return this._hardwareScalingLevel}get doNotHandleContextLost(){return this._doNotHandleContextLost}set doNotHandleContextLost(e){this._doNotHandleContextLost=e}get isStencilEnable(){return this._isStencilEnable}getCreationOptions(){return this._creationOptions}constructor(e,t,i){this._colorWrite=!0,this._colorWriteChanged=!0,this._depthCullingState=new Ec,this._stencilStateComposer=new Ac,this._stencilState=new Dt,this._alphaState=new Lo(!1),this._alphaMode=Array(8).fill(-1),this._alphaEquation=Array(8).fill(-1),this._activeRequests=[],this._badOS=!1,this._badDesktopOS=!1,this._compatibilityMode=!0,this._internalTexturesCache=new Array,this._currentRenderTarget=null,this._boundTexturesCache={},this._activeChannel=0,this._currentTextureChannel=-1,this._viewportCached={x:0,y:0,z:0,w:0},this._isWebGPU=!1,this._enableGPUDebugMarkers=!1,this.onCanvasBlurObservable=new O,this.onCanvasF
23ocusObservable=new O,this.onNewSceneAddedObservable=new O,this.onResizeObservable=new O,this.onCanvasPointerOutObservable=new O,this.onEffectErrorObservable=new O,this.disablePerformanceMonitorInBackground=!1,this.disableVertexArrayObjects=!1,this._frameId=0,this.hostInformation={isMobile:!1},this.isFullscreen=!1,this.enableOfflineSupport=!1,this.disableManifestCheck=!1,this.disableContextMenu=!0,this.currentRenderPassId=0,this.isPointerLock=!1,this.postProcesses=[],this.canvasTabIndex=1,this._contextWasLost=!1,this._useReverseDepthBuffer=!1,this.isNDCHalfZRange=!1,this.hasOriginBottomLeft=!0,this._renderTargetWrapperCache=new Array,this._compiledEffects={},this._isDisposed=!1,this.scenes=[],this._virtualScenes=new Array,this.onBeforeTextureInitObservable=new O,this.renderEvenInBackground=!0,this.preventCacheWipeBetweenFrames=!1,this._frameHandler=0,this._activeRenderLoops=new Array,this._windowIsBackground=!1,this._boundRenderFunction=n=>this._renderLoop(n),this._lastFrameTime=0,this._renderAccumulator=0,this.skipFrameRender=!1,this.onBeforeShaderCompilationObservable=new O,this.onAfterShaderCompilationObservable=new O,this.onBeginFrameObservable=new O,this.onEndFrameObservable=new O,this._transformTextureUrl=null,this._uniformBuffers=new Array,this._storageBuffers=new Array,this._highPrecisionShadersAllowed=!0,this.onContextLostObservable=new O,this.onContextRestoredObservable=new O,this._name="",this.premultipliedAlpha=!0,this.adaptToDeviceRatio=!1,this._lastDevicePixelRatio=1,this._doNotHandleContextLost=!1,this.cullBackFaces=null,this._renderPassNames=["main"],this._fps=60,this._deltaTime=0,this._deterministicLockstep=!1,this._lockstepMaxSteps=4,this._timeStep=1/60,this.onDisposeObservable=new O,this.onReleaseEffectsObservable=new O,Te.Instances.push(this),this.startTime=vt.Now,this._stencilStateComposer.stencilGlobal=this._stencilState,st.SetMatr
vendor: 14,921 bytes, line 23
23ixPrecision(!!t.useLargeWorldRendering||!!t.useHighPrecisionMatrix),hs()&&navigator.userAgent&&(this._badOS=/iPad/i.test(navigator.userAgent)||/iPhone/i.test(navigator.userAgent),this._badDesktopOS=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)),this.adaptToDeviceRatio=i??!1,t.antialias=e??t.antialias,t.deterministicLockstep=t.deterministicLockstep??!1,t.lockstepMaxSteps=t.lockstepMaxSteps??4,t.timeStep=t.timeStep??1/60,t.stencil=t.stencil??!0,this._audioContext=t.audioEngineOptions?.audioContext??null,this._audioDestination=t.audioEngineOptions?.audioDestination??null,this.premultipliedAlpha=t.premultipliedAlpha??!0,this._doNotHandleContextLost=!!t.doNotHandleContextLost,this._isStencilEnable=!!t.stencil,this.useExactSrgbConversions=t.useExactSrgbConversions??!1;const s=_t()&&window.devicePixelRatio||1,r=t.limitDeviceRatio||s;i=i||t.adaptToDeviceRatio||!1,this._hardwareScalingLevel=i?1/Math.min(r,s):1,this._lastDevicePixelRatio=s,this._creationOptions=t}resize(e=!1){let t,i;if(this.adaptToDeviceRatio){const s=_t()&&window.devicePixelRatio||1,r=this._lastDevicePixelRatio/s;this._lastDevicePixelRatio=s,this._hardwareScalingLevel*=r}if(_t()&&Fs())if(this._renderingCanvas){const s=this._renderingCanvas.getBoundingClientRect?.();t=this._renderingCanvas.clientWidth||s?.width||this._renderingCanvas.width*this._hardwareScalingLevel||100,i=this._renderingCanvas.clientHeight||s?.height||this._renderingCanvas.height*this._hardwareScalingLevel||100}else t=window.innerWidth,i=window.innerHeight;else t=this._renderingCanvas?this._renderingCanvas.width:100,i=this._renderingCanvas?this._renderingCanvas.height:100;this.setSize(t/this._hardwareScalingLevel,i/this._hardwareScalingLevel,e)}setSize(e,t,i=!1){if(!this._renderingCanvas||(e=e|0,t=t|0,!i&&this._renderingCanvas.width===e&&this._renderingCanvas.height===t))return!1;if(this._renderingCanvas.width=e,this._renderingCanvas.height=t,this.scenes){for(let s=0;s<this.scenes.length;s++){const r=this.scenes[s];for(let n=0;n<r.cameras.length;n++){const o=r.cameras[n];o._currentRenderId=0}}this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this)}return!0}createRawTexture(e,t,i,s,r,n,o,h,l,c,u){throw ie("engine.rawTexture")}createRawCubeTexture(e,t,i,s,r,n,o,h){throw ie("engine.rawTexture")}createRawTexture3D(e,t,i,s,r,n,o,h,l,c,u){throw ie("engine.rawTexture")}createRawTexture2DArray(e,t,i,s,r,n,o,h,l,c,u){throw ie("engine.rawTexture")}_sharedInit(e){this._renderingCanvas=e}_setupMobileChecks(){navigator&&navigator.userAgent&&(this._checkForMobile=()=>{const e=navigator.userAgent;this.hostInformation.isMobile=e.indexOf("Mobile")!==-1||e.indexOf("Mac")!==-1&&Fs()&&"ontouchend"in document},this._checkForMobile(),_t()&&window.addEventListener("resize",this._checkForMobile))}createVideoElement(e){return document.createElement("video")}_reportDrawCall(e=1){this._drawCalls?.addCount(e,!1)}getFps(){return this._fps}getDeltaTime(){return this._deltaTime}isDeterministicLockStep(){return this._deterministicLockstep}getLockstepMaxSteps(){return this._lockstepMaxSteps}getTimeStep(){return this._timeStep*1e3}_createImageBitmapFromSource(e,t){throw new Error("createImageBitmapFromSource is not implemented")}createImageBitmap(e,t){return createImageBitmap(e,t)}resizeImageBitmap(e,t,i){throw new Error("resizeImageBitmap is not implemented")}getFontOffset(e){throw new Error("getFontOffset is not implemented")}static _CreateCanvas(e,t){if(typeof document>"u")return new OffscreenCanvas(e,t);const i=document.createElement("canvas");return i.width=e,i.height=t,i}createCanvas(e,t){return H._CreateCanvas(e,t)}static _FileToolsLoadImage(e,t,i,s,r,n,o){throw ie("FileTools")}_loadFile(e,t,i,s,r,n){const o=Po(e,t,i,s,r,n);return this._activeRequests.push(o),o.onCompleteObservable.add(()=>{const h=this._activeRequests.indexOf(o);h!==-1&&this._activeRequests.splice(h,1)}),o}static _FileToolsLoadFile(e,t,i,s,r,n){if(Mr.loadFile)return Mr.loadFile(e,t,i,s,r,n);throw ie("FileTools")}dispose(){for(this.releaseEffects(),this._isDisposed=!0,this.stopRenderLoop(),this._emptyTexture&&(this._releaseTexture(this._emptyTexture),this._emptyTexture=null),this._emptyCubeTexture&&(this._releaseTexture(this._emptyCubeTexture),this._emptyCubeTexture=null),this._renderingCanvas=null,this.onBeforeTextureInitObservable&&this.onBeforeTextureInitObservable.clear();this.postProcesses.length;)this.postProcesses[0].dispose();for(;this.scenes.length;)this.scenes[0].dispose();for(;this._virtualScenes.length;)this._virtualScenes[0].dispose();this.releaseComputeEffects?.(),ze.ResetCache();for(const t of this._activeRequests)t.abort();this._boundRenderFunction=null,this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onResizeObservable.clear(),this.onCanvasBlurObservable.clear(),this.onCanvasFocusObservable.clear(),this.onCanvasPointerOutObservable.clear(),this.onNewSceneAddedObservable.clear(),this.onEffectErrorObservable.clear(),_t()&&window.removeEventListener("resize",this._checkForMobile);const e=Te.Instances.indexOf(this);e>=0&&Te.Instances.splice(e,1),Te.Instances.length||(Te.OnEnginesDisposedObservable.notifyObservers(this),Te.OnEnginesDisposedObservable.clear()),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear()}static DefaultLoadingScreenFactory(e){throw ie("LoadingScreen")}static MarkAllMaterialsAsDirty(e,t){for(let i=0;i<Te.Instances.length;i++){const s=Te.Instances[i];for(let r=0;r<s.scenes.length;r++)s.scenes[r].markAllMaterialsAsDirty(e,t)}}static GetCompatibleTextureLoader(e,t){return null}}H._RenderPassIdCounter=0;H._RescalePostProcessFactory=null;H.CollisionsEpsilon=.001;H.QueueNewFrame=Bo;const No=new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i);class Ir extends Li{constructor(e,t){super(e,xs.LoadFileError),this.name="LoadFileError",Fi._setPrototypeOf(this,Ir.prototype),t instanceof gt?this.request=t:this.file=t}}class Pr extends Li{constructor(e,t){super(e,xs.RequestFileError),this.request=t,this.name="RequestFileError",Fi._setPrototypeOf(this,Pr.prototype)}}class vn extends Li{constructor(e,t){super(e,xs.ReadFileError),this.file=t,this.name="ReadFileError",Fi._setPrototypeOf(this,vn.prototype)}}const yc=a=>(a=a.replace(/#/gm,"%23"),a),He={DefaultRetryStrategy:Vl.ExponentialBackoff(),BaseUrl:"",CorsBehavior:"anonymous",PreprocessUrl:a=>a,ScriptBaseUrl:"",ScriptPreprocessUrl:a=>a,CleanUrl:yc},Dn=(a,e)=>{if(!(a&&a.indexOf("data:")===0)&&He.CorsBehavior)if(typeof He.CorsBehavior=="string"||He.CorsBehavior instanceof String)e.crossOrigin=He.CorsBehavior;else{const t=He.CorsBehavior(a);t&&(e.crossOrigin=t)}},On=(a,e,t,i,s="",r,n=Te.LastCreatedEngine)=>{if(typeof HTMLImageElement>"u"&&!n?._features.forceBitmapOverHTMLImageElement)return t("LoadImage is only supported in web or BabylonNative environments."),null;let o,h=!1;a instanceof ArrayBuffer||ArrayBuffer.isView(a)?typeof Blob<"u"&&typeof URL<"u"?(o=URL.createObjectURL(new Blob([a],{type:s})),h=!0):o=`data:${s};base64,`+Mo(a):a instanceof Blob?(o=URL.createObjectURL(a),h=!0):(o=He.CleanUrl(a),o=He.PreprocessUrl(o));const l=C=>{if(t){const x=o||a.toString();t(`Error while trying to load image: ${x.indexOf("http")===0||x.length<=128?x:x.slice(0,128)+"..."}`,C)}};if(n?._features.forceBitmapOverHTMLImageElement)return wi(o,C=>{n.createImageBitmap(new Blob([C],{type:s}),{premultiplyAlpha:"none",...r}).then(x=>{e(x),h&&URL.revokeObjectURL(o)}).catch(x=>{t&&t("Error while trying to load image: "+a,x)})},void 0,i||void 0,!0,(C,x)=>{l(x)}),null;const c=new Image;Dn(o,c);const u=[],f=()=>{for(const C of u)C.target.addEventListener(C.name,C.handler)},d=()=>{for(const C of u)C.target.removeEventListener(C.name,C.handler);u.length=0},g=()=>{d(),e(c),h&&c.src&&URL.revokeObjectURL(c.src)},p=C=>{d(),l(C),h&&c.src&&URL.revokeObjectURL(c.src)},m=C=>{if(C.blockedURI!==c.src||C.disposition==="report")return;d();const x=new Error(`CSP violation of policy ${C.effectiveDirective} ${C.blockedURI}. Current policy is ${C.originalPolicy}`);Te.UseFallbackTexture=!1,l(x),h&&c.src&&URL.revokeObjectURL(c.src),c.src=""};u.push({target:c,name:"load",handler:g}),u.push({target:c,name:"error",handler:p}),u.push({target:document,name:"securitypolicyviolation",handler:m}),f();const A=o.substring(0,5)==="blob:",E=o.substring(0,5)==="data:",I=()=>{A||E||!gt.IsCustomRequestAvailable?c.src=o:wi(o,(C,x,S)=>{const L=!s&&S?S:s,N=new Blob([C],{type:L}),D=URL.createObjectURL(N);h=!0,c.src=D},void 0,i||void 0,!0,(C,x)=>{l(x)})},M=()=>{i&&i.loadImage(o,c)};if(!A&&!E&&i&&i.enableTexturesOffline)i.open(M,I);else{if(o.indexOf("file:")!==-1){const C=decodeURIComponent(o.substring(5).toLowerCase());if(ws.FilesToLoad[C]&&typeof URL<"u"){try{let x;try{x=URL.createObjectURL(ws.FilesToLoad[C])}catch{x=URL.createObjectURL(ws.FilesToLoad[C])}c.src=x,h=!0}catch{c.src=""}return c}}I()}return c},Gs=(a,e,t,i,s)=>{const r=new FileReader,n={onCompleteObservable:new O,abort:()=>r.abort()};return r.onloadend=()=>n.onCompleteObservable.notifyObservers(n),s&&(r.onerror=()=>{s(new vn(`Unable to read ${a.name}`,a))}),r.onload=o=>{e(o.target.result)},t&&(r.onprogress=t),i?r.readAsArrayBuffer(a):r.readAsText(a),n},wi=(a,e,t,i,s,r,n)=>{if(a.name)return Gs(a,e,t,s,r?c=>{r(void 0,c)}:void 0);const o=a;if(o.indexOf("file:")!==-1){let c=decodeURIComponent(o.substring(5).toLowerCase());c.indexOf("./")===0&&(c=c.substring(2));const u=ws.FilesToLoad[c];if(u)return Gs(u,e,t,s,r?f=>r(void 0,new Ir(f.message,f.file)):void 0)}const{match:h,type:l}=ko(o);if(h){const c={onCompleteObservable:new O,abort:()=>()=>{}};try{const u=s?Ln(o):Go(o);e(u,void 0,l)}catch(u){r?r(void 0,u):w.Error(u.message||"Failed to parse the Data URL")}return ks.SetImmediate(()=>{c.onCompleteObservable.notifyObservers(c)}),c}return Fn(o,(c,u)=>{e(c,u?.responseURL,u?.getResponseHeader("content-type"))},t,i,s,r?c=>{r(c.request,new Ir(c.message,c.request))}:void 0,n)},Fn=(a,e,t,i,s,r,n)=>{i!==null&&(i??(i=Te.LastCreatedScene?.offlineProvider)),a=He.CleanUrl(a),a=He.PreprocessUrl(a);const o=He.BaseUrl+a;let h=!1;const l={onCompleteObservable:new O,abort:()=>h=!0},c=()=>{let u=new gt,f=null,d;const g=()=>{u&&(t&&u.removeEventListener("progress",t),d&&u.removeEventListener("readystatechange",d),u.removeEventListener("loadend",p))};let p=()=>{g(),l.onCompleteObservable.notifyObservers(l),l.onCompleteObservable.clear(),t=void 0,d=null,p=null,r=void 0,n=void 0,e=void 0};l.abort=()=>{h=!0,p&&p(),u&&u.readyState!==(XMLHttpRequest.DONE||4)&&u.abort(),f!==null&&(clearTimeout(f),f=null),u=null};const m=E=>{const I=E.message||"Unknown error";r&&u?r(new Pr(I,u)):w.Error(I)},A=E=>{if(u){if(u.open("GET",o),n)try{n(u)}catch(I){m(I);return}s&&(u.responseType="arraybuffer"),t&&u.addEventListener("progress",t),p&&u.addEventListener("loadend",p),d=()=>{if(!(h||!u)&&u.readyState===(XMLHttpRequest.DONE||4)){if(d&&u.removeEventListener("readystatechange",d),u.status>=200&&u.status<300||u.status===0&&(!_t()||Uo())){const C=s?u.response:u.responseText;if(C!==null){try{e&&e(C,u)}catch(x){m(x)}return}}const I=He.DefaultRetryStrategy;if(I){const C=I(o,u,E);if(C!==-1){g(),u=new gt,f=setTimeout(()=>A(E+1),C);return}}const M=new Pr("Error status: "+u.status+" "+u.statusText+" - Unable to load "+o,u);r&&r(M)}},u.addEventListener("readystatechange",d),u.send()}};A(0)};if(i&&i.enableSceneOffline&&!a.startsWith("blob:")){const u=d=>{d&&d.status>400?r&&r(d):c()},f=()=>{i&&i.loadFile(He.BaseUrl+a,d=>{!h&&e&&e(d),l.onCompleteObservable.notifyObservers(l)},t?d=>{!h&&t&&t(d)}:void 0,u,s)};i.open(f,u)}else c();return l},__=a=>{const{match:e,type:t}=ko(a);if(e)return t||void 0;const i=a.lastIndexOf(".");switch(a.substring(i+1).toLowerCase()){case"glb":return"model/gltf-binary";case"bin":return"application/octet-stream";case"gltf":return"model/gltf+json";case"jpg":case"jpeg":return"image/jpeg";case"png":return"image/png";case"webp":return"image/webp";case"ktx":return"image/ktx";case"ktx2":return"image/ktx2";case"avif":return"image/avif";default:return}},Uo=()=>typeof location<"u"&&location.protocol==="file:",wn=a=>No.test(a),ko=a=>{const e=No.exec(a);return e===null||e.length===0?{match:!1,type:""}:{match:!0,type:e[0].replace("data:","").replace(";base64,","")}};function Ln(a){return zl(a.split(",")[1])}const Go=a=>Co(a.split(",")[1]),xc=()=>{H._FileToolsLoadImage=On,Mr.loadFile=wi,Do.loadFile=wi};xc();let Is;const Sc=(a,e,t,i,s,r,n,o,h,l)=>{Is={DecodeBase64UrlToBinary:a,DecodeBase64UrlToString:e,DefaultRetryStrategy:t.DefaultRetryStrategy,BaseUrl:t.BaseUrl,CorsBehavior:t.CorsBehavior,PreprocessUrl:t.PreprocessUrl,IsBase64DataUrl:i,IsFileURL:s,LoadFile:r,LoadImage:n,ReadFile:o,RequestFile:h,SetCorsBehavior:l},Object.defineProperty(Is,"DefaultRetryStrategy",{get:function(){return t.DefaultRetryStrategy},set:function(c){t.DefaultRetryStrategy=c}}),Object.defineProperty(Is,"BaseUrl",{get:function(){return t.BaseUrl},set:function(c){t.BaseUrl=c}}),Object.defineProperty(Is,"PreprocessUrl",{get:function(){return t.PreprocessUrl},set:function(c){t.PreprocessUrl=c}}),Object.defineProperty(Is,"CorsBehavior",{get:function(){return t.CorsBehavior},set:function(c){t.CorsBehavior=c}})};Sc(Ln,Go,He,wn,Uo,wi,On,Gs,Fn,Dn);class Ls{static Instantiate(e){if(this.RegisteredExternalClasses&&this.RegisteredExternalClasses[e])return this.RegisteredExternalClasses[e];const t=Oi(e);if(t)return t;w.Warn(e+" not found, you may have missed an import.");const i=e.split(".");let s=window||this;for(let r=0,n=i.length;r<n;r++)s=s[i[r]];return typeof s!="function"?null:s}}Ls.RegisteredExternalClasses={};function Bn(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{const e=Math.random()*16|0;return(a==="x"?e:e&3|8).toString(16)})}function Hs(a){let e=1;do e*=2;while(e<a);return e===a}function mn(a,e,t){return a*(1-t)+e*t}function Ho(a){const e=Vo(a),t=Nn(a);return e-a>a-t?t:e}function Vo(a){return a--,a|=a>>1,a|=a>>2,a|=a>>4,a|=a>>8,a|=a>>16,a++,a}function Nn(a){return a=a|a>>1,a=a|a>>2,a=a|a>>4,a=a|a>>8,a=a|a>>16,a-(a>>1)}function Vs(a,e,t=2){let i;switch(t){case 1:i=Nn(a);break;case 2:i=Ho(a);break;default:i=Vo(a);break}return Math.min(i,e)}var Z;class se{static get BaseUrl(){return He.BaseUrl}static set BaseUrl(e){He.BaseUrl=e}static get CleanUrl(){return He.CleanUrl}static set CleanUrl(e){He.CleanUrl=e}static IsAbsoluteUrl(e){return e.indexOf("//")===0?!0:e.indexOf("://")===-1||e.indexOf(".")===-1||e.indexOf("/")===-1||e.indexOf(":")>e.indexOf("/")?!1:e.indexOf("://")<e.indexOf(".")||e.indexOf("data:")===0||e.indexOf("blob:")===0}static set ScriptBaseUrl(e){He.ScriptBaseUrl=e}static get ScriptBaseUrl(){return He.ScriptBaseUrl}static set CDNBaseUrl(e){Z.ScriptBaseUrl=e,Z.AssetBaseUrl=e}static set ScriptPreprocessUrl(e){He.ScriptPreprocessUrl=e}static get ScriptPreprocessUrl(){return He.ScriptPreprocessUrl}static get DefaultRetryStrategy(){return He.DefaultRetryStrategy}static set DefaultRetryStrategy(e){He.DefaultRetryStrategy=e}static get CorsBehavior(){return He.CorsBehavior}
23static set CorsBehavior(e){He.CorsBehavior=e}static get UseFallbackTexture(){return Te.UseFallbackTexture}static set UseFallbackTexture(e){Te.UseFallbackTexture=e}static get RegisteredExternalClasses(){return Ls.RegisteredExternalClasses}static set RegisteredExternalClasses(e){Ls.RegisteredExternalClasses=e}static get fallbackTexture(){return Te.FallbackTexture}static set fallbackTexture(e){Te.FallbackTexture=e}static FetchToRef(e,t,i,s,r,n){const o=Math.abs(e)*i%i|0,h=Math.abs(t)*s%s|0,l=(o+h*i)*4;n.r=r[l]/255,n.g=r[l+1]/255,n.b=r[l+2]/255,n.a=r[l+3]/255}static Mix(e,t,i){return 0}static Instantiate(e){return Ls.Instantiate(e)}static SetImmediate(e){ks.SetImmediate(e)}static IsExponentOfTwo(e){return!0}static FloatRound(e){return Math.fround(e)}static GetFilename(e){const t=e.lastIndexOf("/");return t<0?e:e.substring(t+1)}static GetFolderPath(e,t=!1){const i=e.lastIndexOf("/");return i<0?t?e:"":e.substring(0,i+1)}static ToDegrees(e){return e*180/Math.PI}static ToRadians(e){return e*Math.PI/180}static SmoothAngleChange(e,t,i=.9){const s=this.ToRadians(e),r=this.ToRadians(t);return this.ToDegrees(Math.atan2((1-i)*Math.sin(r)+i*Math.sin(s),(1-i)*Math.cos(r)+i*Math.cos(s)))}static MakeArray(e,t){return t!==!0&&(e===void 0||e==null)?null:Array.isArray(e)?e:[e]}static GetPointerPrefix(e){return _t()&&!window.PointerEvent?"mouse":"pointer"}static SetCorsBehavior(e,t){Dn(e,t)}static SetReferrerPolicyBehavior(e,t){t.referrerPolicy=e}static get PreprocessUrl(){return He.PreprocessUrl}static set PreprocessUrl(e){He.PreprocessUrl=e}static LoadImage(e,t,i,s,r,n){return On(e,t,i,s,r,n)}static LoadFile(e,t,i,s,r,n){return wi(e,t,i,s,r,n)}static async LoadFileAsync(e,t=!0){return await new Promise((i,s)=>{wi(e,r=>{i(r)},void 0,void 0,t,(r,n)=>{s(n)})})}static GetAssetUrl(e){if(!e)return"";if(Z.AssetBaseUrl&&e.startsWith(Z._DefaultAssetsUrl)){const t=Z.AssetBaseUrl[Z.AssetBaseUrl.length-1]==="/"?Z.AssetBaseUrl.substring(0,Z.AssetBaseUrl.length-1):Z.AssetBaseUrl;return e.replace(Z._DefaultAssetsUrl,t)}return e}static GetBabylonScriptURL(e,t){if(!e)return"";if(Z.ScriptBaseUrl&&e.startsWith(Z._DefaultCdnUrl)){const i=Z.ScriptBaseUrl[Z.ScriptBaseUrl.length-1]==="/"?Z.ScriptBaseUrl.substring(0,Z.ScriptBaseUrl.length-1):Z.ScriptBaseUrl;e=e.replace(Z._DefaultCdnUrl,i)}return e=Z.ScriptPreprocessUrl(e),t&&!Z.IsAbsoluteUrl(e)&&(e=Z.GetAbsoluteUrl(e)),e}static LoadBabylonScript(e,t,i,s){e=Z.GetBabylonScriptURL(e),Z.LoadScript(e,t,i)}static async LoadBabylonScriptAsync(e){return e=Z.GetBabylonScriptURL(e),await Z.LoadScriptAsync(e)}static _LoadScriptNative(e,t,i){_native&&Z.LoadFile(e,s=>{Function(s).apply(null),t&&t()},void 0,void 0,!1,(s,r)=>{i&&i("LoadScript Error",r)})}static _LoadScriptWeb(e,t,i,s,r=!1){if(typeof importScripts=="function"){try{importScripts(e),t&&t()}catch(h){i?.(`Unable to load script '${e}' in worker`,h)}return}else if(!_t()){i?.(`Cannot load script '${e}' outside of a window or a worker`);return}const n=document.getElementsByTagName("head")[0],o=document.createElement("script");r?(o.setAttribute("type","module"),o.innerText=e):(o.setAttribute("type","text/javascript"),o.setAttribute("src",e)),s&&(o.id=s),o.onload=()=>{t&&t()},o.onerror=h=>{i&&i(`Unable to load script '${e}'`,h)},n.appendChild(o)}static async LoadScriptAsync(e,t){return await new Promise((i,s)=>{this.LoadScript(e,()=>{i()},(r,n)=>{s(n||new Error(r))},t)})}static ReadFileAsDataURL(e,t,i){const s=new FileReader,r={onCompleteObservable:new O,abort:()=>s.abort()};return s.onloadend=()=>{r.onCompleteObservable.notifyObservers(r)},s.onload=n=>{t(n.target.result)},s.onprogress=i,s.readAsDataURL(e),r}static ReadFile(e,t,i,s,r){return Gs(e,t,i,s,r)}static FileAsURL(e){const t=new Blob([e]);return window.URL.createObjectURL(t)}static Format(e,t=2){return e.toFixed(t)}static DeepCopy(e,t,i,s){So.DeepCopy(e,t,i,s)}static IsEmpty(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}static RegisterTopRootEvents(e,t){for(let i=0;i<t.length;i++){const s=t[i];e.addEventListener(s.name,s.handler,!1);try{window.parent&&window.parent.addEventListener(s.name,s.handler,!1)}catch{}}}static UnregisterTopRootEvents(e,t){for(let i=0;i<t.length;i++){const s=t[i];e.removeEventListener(s.name,s.handler);try{e.parent&&e.parent.removeEventListener(s.name,s.handler)}catch{}}}static async DumpFramebuffer(e,t,i,s,r="image/png",n,o){throw ie("DumpTools")}static DumpData(e,t,i,s,r="image/png",n,o=!1,h=!1,l){throw ie("DumpTools")}static async DumpDataAsync(e,t,i,s="image/png",r,n=!1,o=!1,h){throw ie("DumpTools")}static _IsOffScreenCanvas(e){return e.convertToBlob!==void 0}static ToBlob(e,t,i="image/png",s){!Z._IsOffScreenCanvas(e)&&!e.toBlob&&(e.toBlob=function(r,n,o){setTimeout(()=>{const h=atob(this.toDataURL(n,o).split(",")[1]),l=h.length,c=new Uint8Array(l);for(let u=0;u<l;
23u++)c[u]=h.charCodeAt(u);r(new Blob([c]))})}),Z._IsOffScreenCanvas(e)?e.convertToBlob({type:i,quality:s}).then(r=>t(r)):e.toBlob(function(r){t(r)},i,s)}static DownloadBlob(e,t){if("download"in document.createElement("a")){if(!t){const i=new Date;t="screenshot_"+((i.getFullYear()+"-"+(i.getMonth()+1)).slice(2)+"-"+i.getDate()+"_"+i.getHours()+"-"+("0"+i.getMinutes()).slice(-2))+".png"}Z.Download(e,t)}else if(e&&typeof URL<"u"){const i=URL.createObjectURL(e),s=window.open("");if(!s)return;const r=s.document.createElement("img");r.onload=function(){URL.revokeObjectURL(i)},r.src=i,s.document.body.appendChild(r)}}static EncodeScreenshotCanvasData(e,t,i="image/png",s,r){if(typeof s=="string"||!t)this.ToBlob(e,function(n){n&&Z.DownloadBlob(n,s),t&&t("")},i,r);else if(t){if(Z._IsOffScreenCanvas(e)){e.convertToBlob({type:i,quality:r}).then(o=>{const h=new FileReader;h.readAsDataURL(o),h.onloadend=()=>{const l=h.result;t(l)}});return}const n=e.toDataURL(i,r);t(n)}}static Download(e,t){if(typeof URL>"u")return;const i=window.URL.createObjectURL(e),s=document.createElement("a");document.body.appendChild(s),s.style.display="none",s.href=i,s.download=t,s.addEventListener("click",()=>{s.parentElement&&s.parentElement.removeChild(s)}),s.click(),window.URL.revokeObjectURL(i)}static BackCompatCameraNoPreventDefault(e){return typeof e[0]=="boolean"?e[0]:typeof e[1]=="boolean"?e[1]:!1}static CreateScreenshot(e,t,i,s,r="image/png",n=!1,o){throw ie("ScreenshotTools")}static async CreateScreenshotAsync(e,t,i,s="image/png",r){throw ie("ScreenshotTools")}static CreateScreenshotUsingRenderTarget(e,t,i,s,r="image/png",n=1,o=!1,h,l=!1,c=!1,u=!0,f,d){throw ie("ScreenshotTools")}static async CreateScreenshotUsingRenderTargetAsync(e,t,i,s="image/png",r=1,n=!1,o,h=!1,l=!1,c=!0,u,f){throw ie("ScreenshotTools")}static RandomId(){return Bn()}static IsBase64(e){return wn(e)}static DecodeBase64(e){return Ln(e)}static get errorsCount(){return w.errorsCount}static Log(e){w.Log(e)}static Warn(e){w.Warn(e)}static Error(e){w.Error(e)}static get LogCache(){return w.LogCache}static ClearLogCache(){w.ClearLogCache()}static set LogLevels(e){w.LogLevels=e}static set PerformanceLogLevel(e){if((e&Z.PerformanceUserMarkLogLevel)===Z.PerformanceUserMarkLogLevel){_native?.enablePerformanceLogging?(_native.enablePerformanceLogging(1),Z.StartPerformanceCounter=Z._StartMarkNative,Z.EndPerformanceCounter=Z._EndMarkNative):(Z.StartPerformanceCounter=Z._StartUserMark,Z.EndPerformanceCounter=Z._EndUserMark);return}if((e&Z.PerformanceConsoleLogLevel)===Z.PerformanceConsoleLogLevel){_native?.enablePerformanceLogging?(_native.enablePerformanceLogging(2),Z.StartPerformanceCounter=Z._StartMarkNative,Z.EndPerformanceCounter=Z._EndMarkNative):(Z.StartPerformanceCounter=Z._StartPerformanceConsole,Z.EndPerformanceCounter=Z._EndPerformanceConsole);return}Z.StartPerformanceCounter=Z._StartPerformanceCounterDisabled,Z.EndPerformanceCounter=Z._EndPerformanceCounterDisabled,_native?.disablePerformanceLogging?.()}static _StartPerformanceCounterDisabled(e,t){}static _EndPerformanceCounterDisabled(e,t){}static _StartUserMark(e,t=!0){if(!Z._Performance){if(!_t())return;Z._Performance=window.performance}!t||!Z._Performance.mark||Z._Performance.mark(e+"-Begin")}static _EndUserMark(e,t=!0){!t||!Z._Performance.mark||(Z._Performance.mark(e+"-End"),Z._Performance.measure(e,e+"-Begin",e+"-End"))}static _StartPerformanceConsole(e,t=!0){t&&(Z._StartUserMark(e,t),console.time&&console.time(e))}static _EndPerformanceConsole(e,t=!0){t&&(Z._EndUserMark(e,t),console.timeEnd(e))}static _StartMarkNative(e,t=!0){if(t&&_native?.startPerformanceCounter)if(Z._NativePerformanceCounterHandles.has(e))Z.Warn(`Performance counter with name ${e} is already started.`);else{const i=_native.startPerformanceCounter(e);Z._NativePerformanceCounterHandles.set(e,i)}}static _EndMarkNative(e,t=!0){if(t&&_native?.endPerformanceCounter){const i=Z._NativePerformanceCounterHandles.get(e);i?(_native.endPerformanceCounter(i),Z._NativePerformanceCounterHandles.delete(e)):Z.Warn(`Performance counter with name ${e} was not started.`)}}static get Now(){return vt.Now}static GetClassName(e,t=!1){let i=null;return!t&&e.getClassName?i=e.getClassName():(e instanceof Object&&(i=(t?e:Object.getPrototypeOf(e)).constructor.__bjsclassName__),i||(i=typeof e)),i}static First(e,t){for(const i of e)if(t(i))return i;return null}static getFullClassName(e,t=!1){let i=null,s=null;if(!t&&e.getClassName)i=e.getClassName();else{if(e instanceof Object){const r=t?e:Object.getPrototypeOf(e);i=r.constructor.__bjsclassName__,s=r.constructor.__bjsmoduleName__}i||(i=typeof e)}return i?(s!=null?s+".":"")+i:null}static async DelayAsync(e){await new Promise(t=>{setTimeout(()=>{t()},e)})}static IsSafari(){return hs()?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}}Z=se;se.AssetBaseUrl="";se.UseCustomRequestHeaders=!1;se.CustomRequestHeaders=gt.CustomRequestHeaders;se.GetDOMTextContent=xo;se._DefaultCdnUrl="https://cdn.babylonjs.com";se._DefaultAssetsUrl="https://assets.babylonjs.com/core";se.LoadScript=typeof _native>"u"?Z._LoadScriptWeb:Z._LoadScriptNative;se.GetAbsoluteUrl=typeof document=="object"?a=>{const e=document.createElement("a");return e.href=a,e.href}:typeof URL=="function"&&typeof location=="object"?a=>new URL(a,location.origin).href:()=>{throw new Error("Unable to get absolute URL. Override BABYLON.Tools.GetAbsoluteUrl to a custom implementation for the current context.")};se.NoneLogLevel=w.NoneLogLevel;se.MessageLogLevel=w.MessageLogLevel;se.WarningLogLevel=w.WarningLogLevel;se.ErrorLogLevel=w.ErrorLogLevel;se.AllLogLevel=w.AllLogLevel;se.IsWindowObjectExist=_t;se.PerformanceNoneLogLevel=0;se.PerformanceUserMarkLogLevel=1;se.PerformanceConsoleLogLevel=2;se._NativePerformanceCounterHandles=new Map;se.StartPerformanceCounter=Z._StartPerformanceCounterDisabled;se.EndPerformanceCounter=Z._EndPerformanceCounterDisabled;class vr{constructor(e,t,i,s=0){this.iterations=e,this.index=s-1,this._done=!1,this._fn=t,this._successCallback=i}executeNext(){this._done||(this.index+1<this.iterations?(++this.index,this._fn(this)):this.breakLoop())}breakLoop(){this._done=!0,this._successCallback()}static Run(e,t,i,s=0){const r=new vr(e,t,i,s);return r.executeNext(),r}static SyncAsyncForLoop(e,t,i,s,r,n=0){return vr.Run(Math.ceil(e/t),o=>{r&&r()?o.breakLoop():setTimeout(()=>{for(let h=0;h<t;++h){const l=o.index*t+h;if(l>=e)break;if(i(l),r&&r()){o.breakLoop();break}}o.executeNext()},n)},s)}}se.Mix=mn;se.IsExponentOfTwo=Hs;Te.FallbackTexture="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQ
23FCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z";function Tn(a,e,t){try{const i=a.next();i.done?e(i):i.value?i.value.then(()=>{i.value=void 0,e(i)},t):e(i)}catch(i){t(i)}}function Mc(a=25){let e;return(t,i,s)=>{const r=performance.now();e===void 0||r-e>a?(e=r,setTimeout(()=>{Tn(t,i,s)},0)):Tn(t,i,s)}}function zo(a,e,t,i,s){const r=()=>{let n;const o=h=>{h.done?t(h.value):n===void 0?n=!0:r()};do n=void 0,e(a,o,i),n===void 0&&(n=!1);while(n)};r()}function Un(a,e){let t;return zo(a,Tn,i=>t=i,i=>{throw i}),t}async function Cc(a,e,t){return await new Promise((i,s)=>{zo(a,e,i,s)})}function Ic(a,e){return(...t)=>Un(a(...t))}class it{constructor(e){this.length=0,this.data=new Array(e),this._id=it._GlobalId++}push(e){this.data[this.length++]=e,this.length>this.data.length&&(this.data.length*=2)}forEach(e){for(let t=0;t<this.length;t++)e(this.data[t])}sort(e){this.data.sort(e)}reset(){this.length=0}dispose(){this.reset(),this.data&&(this.data.length=0)}concat(e){if(e.length!==0){this.length+e.length>this.data.length&&(this.data.length=(this.length+e.length)*2);for(let t=0;t<e.length;t++)this.data[this.length++]=(e.data||e)[t]}}indexOf(e){const t=this.data.indexOf(e);return t>=this.length?-1:t}contains(e){return this.indexOf(e)!==-1}}it._GlobalId=0;class Yi extends it{constructor(){super(...arguments),this._duplicateId=0}push(e){super.push(e),e.__smartArrayFlags||(e.__smartArrayFlags={}),e.__smartArrayFlags[this._id]=this._duplicateId}pushNoDuplicate(e){return e.__smartArrayFlags&&e.__smartArrayFlags[this._id]===this._duplicateId?!1:(this.push(e),!0)}reset(){super.reset(),this._duplicateId++}concatWithNoDuplicate(e){if(e.length!==0){this.length+e.length>this.data.length&&(this.data.length=(this.length+e.length)*2);for(let t=0;t<e.length;t++){const i=(e.data||e)[t];
vendor: 22,850 bytes, line 23
23this.pushNoDuplicate(i)}}}}class ps{constructor(e,t,i,s){this.x=e,this.y=t,this.width=i,this.height=s}toGlobal(e,t){return new ps(this.x*e,this.y*t,this.width*e,this.height*t)}toGlobalToRef(e,t,i){return i.x=this.x*e,i.y=this.y*t,i.width=this.width*e,i.height=this.height*t,this}clone(){return new ps(this.x,this.y,this.width,this.height)}}class Ht{constructor(e,t,i,s){this.normal=new _(e,t,i),this.d=s}asArray(){return[this.normal.x,this.normal.y,this.normal.z,this.d]}clone(){return new Ht(this.normal.x,this.normal.y,this.normal.z,this.d)}getClassName(){return"Plane"}getHashCode(){let e=this.normal.getHashCode();return e=e*397^(this.d|0),e}normalize(){const e=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z);let t=0;return e!==0&&(t=1/e),this.normal.x*=t,this.normal.y*=t,this.normal.z*=t,this.d*=t,this}transform(e){const t=Ht._TmpMatrix;e.invertToRef(t);const i=t.m,s=this.normal.x,r=this.normal.y,n=this.normal.z,o=this.d,h=s*i[0]+r*i[1]+n*i[2]+o*i[3],l=s*i[4]+r*i[5]+n*i[6]+o*i[7],c=s*i[8]+r*i[9]+n*i[10]+o*i[11],u=s*i[12]+r*i[13]+n*i[14]+o*i[15];return new Ht(h,l,c,u)}dotCoordinate(e){return this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z+this.d}copyFromPoints(e,t,i){const s=t.x-e.x,r=t.y-e.y,n=t.z-e.z,o=i.x-e.x,h=i.y-e.y,l=i.z-e.z,c=r*l-n*h,u=n*o-s*l,f=s*h-r*o,d=Math.sqrt(c*c+u*u+f*f);let g;return d!==0?g=1/d:g=0,this.normal.x=c*g,this.normal.y=u*g,this.normal.z=f*g,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this}isFrontFacingTo(e,t){return _.Dot(this.normal,e)<=t}signedDistanceTo(e){return _.Dot(e,this.normal)+this.d}static FromArray(e){return new Ht(e[0],e[1],e[2],e[3])}static FromPoints(e,t,i){const s=new Ht(0,0,0,0);return s.copyFromPoints(e,t,i),s}static FromPositionAndNormal(e,t){const i=new Ht(0,0,0,0);return this.FromPositionAndNormalToRef(e,t,i)}static FromPositionAndNormalToRef(e,t,i){return i.normal.copyFrom(t),i.normal.normalize(),i.d=-e.dot(i.normal),i}static SignedDistanceToPlaneFromPositionAndNormal(e,t,i){const s=-(t.x*e.x+t.y*e.y+t.z*e.z);return _.Dot(i,t)+s}}Ht._TmpMatrix=P.Identity();class Gt{static GetPlanes(e){const t=[];for(let i=0;i<6;i++)t.push(new Ht(0,0,0,0));return Gt.GetPlanesToRef(e,t),t}static GetNearPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]+i[2],t.normal.y=i[7]+i[6],t.normal.z=i[11]+i[10],t.d=i[15]+i[14],t.normalize()}static GetFarPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]-i[2],t.normal.y=i[7]-i[6],t.normal.z=i[11]-i[10],t.d=i[15]-i[14],t.normalize()}static GetLeftPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]+i[0],t.normal.y=i[7]+i[4],t.normal.z=i[11]+i[8],t.d=i[15]+i[12],t.normalize()}static GetRightPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]-i[0],t.normal.y=i[7]-i[4],t.normal.z=i[11]-i[8],t.d=i[15]-i[12],t.normalize()}static GetTopPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]-i[1],t.normal.y=i[7]-i[5],t.normal.z=i[11]-i[9],t.d=i[15]-i[13],t.normalize()}static GetBottomPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]+i[1],t.normal.y=i[7]+i[5],t.normal.z=i[11]+i[9],t.d=i[15]+i[13],t.normalize()}static GetPlanesToRef(e,t){Gt.GetNearPlaneToRef(e,t[0]),Gt.GetFarPlaneToRef(e,t[1]),Gt.GetLeftPlaneToRef(e,t[2]),Gt.GetRightPlaneToRef(e,t[3]),Gt.GetTopPlaneToRef(e,t[4]),Gt.GetBottomPlaneToRef(e,t[5])}static IsPointInFrustum(e,t){for(let i=0;i<6;i++)if(t[i].dotCoordinate(e)<0)return!1;return!0}}class J extends qe{get position(){return this._position}set position(e){this._position=e}set upVector(e){this._upVector=e}get upVector(){return this._upVector}get screenArea(){let e=0,t=0;if(this.mode===J.PERSPECTIVE_CAMERA)this.fovMode===J.FOVMODE_VERTICAL_FIXED?(t=this.minZ*2*Math.tan(this.fov/2),e=this.getEngine().getAspectRatio(this)*t):(e=this.minZ*2*Math.tan(this.fov/2),t=e/this.getEngine().getAspectRatio(this));else{const i=this.getEngine().getRenderWidth()/2,s=this.getEngine().getRenderHeight()/2;e=(this.orthoRight??i)-(this.orthoLeft??-i),t=(this.orthoTop??s)-(this.orthoBottom??-s)}return e*t}set orthoLeft(e){this._orthoLeft=e;for(const t of this._rigCameras)t.orthoLeft=e}get orthoLeft(){return this._orthoLeft}set orthoRight(e){this._orthoRight=e;for(const t of this._rigCameras)t.orthoRight=e}get orthoRight(){return this._orthoRight}set orthoBottom(e){this._orthoBottom=e;for(const t of this._rigCameras)t.orthoBottom=e}get orthoBottom(){return this._orthoBottom}set orthoTop(e){this._orthoTop=e;for(const t of this._rigCameras)t.orthoTop=e}get orthoTop(){return this._orthoTop}setFocalLength(e,t=36){this.fov=2*Math.atan(t/(2*e))}set mode(e){this._mode=e;for(const t of this._rigCameras)t.mode=e}get mode(){return this._mode}get hasMoved(){return this._hasMoved}constructor(e,t,i,s=!0){super(e,i,!1),this._position=_.Zero(),this._upVector=_.Up(),this.oblique=null,this._orthoLeft=null,this._orthoRight=null,this._orthoBottom=null,this._orthoTop=null,this.fov=.8,this.projectionPlaneTilt=0,this.minZ=1,this.maxZ=1e4,this.inertia=.9,this._mode=J.PERSPECTIVE_CAMERA,this.isIntermediate=!1,this.viewport=new ps(0,0,1,1),this.layerMask=268435455,this.fovMode=J.FOVMODE_VERTICAL_FIXED,this.cameraRigMode=J.RIG_MODE_NONE,this.ignoreCameraMaxZ=!1,this.customRenderTargets=[],this.outputRenderTarget=null,this.onViewMatrixChangedObservable=new O,this.onProjectionMatrixChangedObservable=new O,this.onAfterCheckInputsObservable=new O,this.onRestoreStateObservable=new O,this.isRigCamera=!1,this._hasMoved=!1,this._rigCameras=new Array,this._skipRendering=!1,this._projectionMatrix=new P,this._postProcesses=new Array,this._activeMeshes=new it(256),this._globalPosition=_.Zero(),this._computedViewMatrix=P.Identity(),this._doNotComputeProjectionMatrix=!1,this._transformMatrix=P.Zero(),this._refreshFrustumPlanes=!0,this._absoluteRotation=W.Identity(),this._isCamera=!0,this._isLeftCamera=!1,this._isRightCamera=!1,this.getScene().addCamera(this),s&&!this.getScene().activeCamera&&(this.getScene().activeCamera=this),this.position=t,this.renderPassId=this.getScene().getEngine().createRenderPassId(`Camera ${e}`)}storeState(){return this._stateStored=!0,this._storedFov=this.fov,this}hasStateStored(){return!!this._stateStored}_restoreStateValues(){return this._stateStored?(this.fov=this._storedFov,!0):!1}restoreState(){return this._restoreStateValues()?(this.onRestoreStateObservable.notifyObservers(this),!0):!1}getClassName(){return"Camera"}toString(e){let t="Name: "+this.name;if(t+=", type: "+this.getClassName(),this.animations)for(let i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);return t}applyVerticalCorrection(){const e=this.absoluteRotation.toEulerAngles();this.projectionPlaneTilt=this._scene.useRightHandedSystem?-e.x:e.x}get globalPosition(){return this._globalPosition}getActiveMeshes(){return this._activeMeshes}isActiveMesh(e){return this._activeMeshes.indexOf(e)!==-1}isReady(e=!1){if(e){for(const t of this._postProcesses)if(t&&!t.isReady())return!1}return super.isReady(e)}_initCache(){super._initCache(),this._cache.position=new _(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.upVector=new _(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.mode=void 0,this._cache.minZ=void 0,this._cache.maxZ=void 0,this._cache.fov=void 0,this._cache.fovMode=void 0,this._cache.aspectRatio=void 0,this._cache.orthoLeft=void 0,this._cache.orthoRight=void 0,this._cache.orthoBottom=void 0,this._cache.orthoTop=void 0,this._cache.obliqueAngle=void 0,this._cache.obliqueLength=void 0,this._cache.obliqueOffset=void 0,this._cache.renderWidth=void 0,this._cache.renderHeight=void 0}_updateCache(e){e||super._updateCache(),this._cache.position.copyFrom(this.position),this._cache.upVector.copyFrom(this.upVector)}_isSynchronized(){return this._isSynchronizedViewMatrix()&&this._isSynchronizedProjectionMatrix()}_isSynchronizedViewMatrix(){return super._isSynchronized()?this._cache.position.equals(this.position)&&this._cache.upVector.equals(this.upVector)&&this.isSynchronizedWithParent():!1}_isSynchronizedProjectionMatrix(){const e=this.ignoreCameraMaxZ?0:this.maxZ;let t=this._cache.mode===this.mode&&this._cache.minZ===this.minZ&&this._cache.maxZ===e;if(!t)return!1;const i=this.getEngine();return this.mode===J.PERSPECTIVE_CAMERA?t=this._cache.fov===this.fov&&this._cache.fovMode===this.fovMode&&this._cache.aspectRatio===i.getAspectRatio(this)&&this._cache.projectionPlaneTilt===this.projectionPlaneTilt:(t=this._cache.orthoLeft===this.orthoLeft&&this._cache.orthoRight===this.orthoRight&&this._cache.orthoBottom===this.orthoBottom&&this._cache.orthoTop===this.orthoTop&&this._cache.renderWidth===i.getRenderWidth()&&this._cache.renderHeight===i.getRenderHeight(),this.oblique&&(t=t&&this._cache.obliqueAngle===this.oblique.angle&&this._cache.obliqueLength===this.oblique.length&&this._cache.obliqueOffset===this.oblique.offset)),t}attachControl(e,t){}detachControl(e){}update(){this._hasMoved=!1,this._checkInputs(),this.cameraRigMode!==J.RIG_MODE_NONE&&this._updateRigCameras(),this.getViewMatrix(),this.getProjectionMatrix()}_checkInputs(){this.onAfterCheckInputsObservable.notifyObservers(this)}get rigCameras(){return this._rigCameras}get rigPostProcess(){return this._rigPostProcess}_getFirstPostProcess(){for(let e=0;e<this._postProcesses.length;e++)if(this._postProcesses[e]!==null)return this._postProcesses[e];return null}_cascadePostProcessesToRigCams(){const e=this._getFirstPostProcess();e&&e.markTextureDirty();for(let t=0,i=this._rigCameras.length;t<i;t++){const s=this._rigCameras[t],r=s._rigPostProcess;r?(r.getEffectName()==="pass"&&(s.isIntermediate=this._postProcesses.length===0),s._postProcesses=this._postProcesses.slice(0).concat(r),r.markTextureDirty()):s._postProcesses=this._postProcesses.slice(0)}}attachPostProcess(e,t=null){return!e.isReusable()&&this._postProcesses.indexOf(e)>-1?(w.Error("You're trying to reuse a post process not defined as reusable."),0):(t==null||t<0?this._postProcesses.push(e):this._postProcesses[t]===null?this._postProcesses[t]=e:this._postProcesses.splice(t,0,e),this._cascadePostProcessesToRigCams(),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._postProcesses.indexOf(e))}detachPostProcess(e){const t=this._postProcesses.indexOf(e);t!==-1&&(this._postProcesses[t]=null),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._cascadePostProcessesToRigCams()}getWorldMatrix(){return this._isSynchronizedViewMatrix()?this._worldMatrix:(this.getViewMatrix(),this._worldMatrix)}_getViewMatrix(){return P.Identity()}getViewMatrix(e){return!e&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(this._hasMoved=!0,this.updateCache(),this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._childUpdateId++,this._refreshFrustumPlanes=!0,this._cameraRigParams&&this._cameraRigParams.vrPreViewMatrix&&this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix,this._computedViewMatrix),this.parent&&this.parent.onViewMatrixChangedObservable&&this.parent.onViewMatrixChangedObservable.notifyObservers(this.parent),this.onViewMatrixChangedObservable.notifyObservers(this),this._computedViewMatrix.invertToRef(this._worldMatrix),this._worldMatrix.getTranslationToRef(this._globalPosition),this._computedViewMatrix)}freezeProjectionMatrix(e){this._doNotComputeProjectionMatrix=!0,e!==void 0&&(this._projectionMatrix=e)}unfreezeProjectionMatrix(){this._doNotComputeProjectionMatrix=!1}getProjectionMatrix(e){if(this._doNotComputeProjectionMatrix||!e&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;const t=this.ignoreCameraMaxZ?0:this.maxZ;this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=t,this._refreshFrustumPlanes=!0;const i=this.getEngine(),s=this.getScene(),r=i.useReverseDepthBuffer;if(this.mode===J.PERSPECTIVE_CAMERA){this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=i.getAspectRatio(this),this._cache.projectionPlaneTilt=this.projectionPlaneTilt,this.minZ<=0&&(this.minZ=.1);let n;s.useRightHandedSystem?n=P.PerspectiveFovRHToRef:n=P.PerspectiveFovLHToRef,n(this.fov,i.getAspectRatio(this),r?t:this.minZ,r?this.minZ:t,this._projectionMatrix,this.fovMode===J.FOVMODE_VERTICAL_FIXED,i.isNDCHalfZRange,this.projectionPlaneTilt,r)}else{const n=i.getRenderWidth()/2,o=i.getRenderHeight()/2;s.useRightHandedSystem?this.oblique?P.ObliqueOffCenterRHToRef(this.orthoLeft??-n,this.orthoRight??n,this.orthoBottom??-o,this.orthoTop??o,r?t:this.minZ,r?this.minZ:t,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,i.isNDCHalfZRange):P.OrthoOffCenterRHToRef(this.orthoLeft??-n,this.orthoRight??n,this.orthoBottom??-o,this.orthoTop??o,r?t:this.minZ,r?this.minZ:t,this._projectionMatrix,i.isNDCHalfZRange):this.oblique?P.ObliqueOffCenterLHToRef(this.orthoLeft??-n,this.orthoRight??n,this.orthoBottom??-o,this.orthoTop??o,r?t:this.minZ,r?this.minZ:t,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,i.isNDCHalfZRange):P.OrthoOffCenterLHToRef(this.orthoLeft??-n,this.orthoRight??n,this.orthoBottom??-o,this.orthoTop??o,r?t:this.minZ,r?this.minZ:t,this._projectionMatrix,i.isNDCHalfZRange),this._cache.orthoLeft=this.orthoLeft,this._cache.orthoRight=this.orthoRight,this._cache.orthoBottom=this.orthoBottom,this._cache.orthoTop=this.orthoTop,this._cache.obliqueAngle=this.oblique?.angle,this._cache.obliqueLength=this.oblique?.length,this._cache.obliqueOffset=this.oblique?.offset,this._cache.renderWidth=i.getRenderWidth(),this._cache.renderHeight=i.getRenderHeight()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix}getTransformationMatrix(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix}_computeObliqueDistance(e){const t=this,i=this;return(t.radius||(i.target?_.Distance(this.position,i.target):this.position.length()))+e}_updateFrustumPlanes(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),this._frustumPlanes?Gt.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=Gt.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)}isInFrustum(e,t=!1){if(this._updateFrustumPlanes(),t&&this.rigCameras.length>0){let i=!1;for(const s of this.rigCameras)s._updateFrustumPlanes(),i=i||e.isInFrustum(s._frustumPlanes);return i}else return e.isInFrustum(this._frustumPlanes)}isCompletelyInFrustum(e){return this._updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)}getForwardRay(e=100,t,i){throw ie("Ray")}getForwardRayToRef(e,t=100,i,s){throw ie("Ray")}dispose(e,t=!1){for(this.onViewMatrixChangedObservable.clear(),this.onProjectionMatrixChangedObservable.clear(),this.onAfterCheckInputsObservable.clear(),this.onRestoreStateObservable.clear(),this.inputs&&this.inputs.clear(),this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;){const s=this._rigCameras.pop();s&&s.dispose()}if(this._parentContainer){const s=this._parentContainer.cameras.indexOf(this);s>-1&&this._parentContainer.cameras.splice(s,1),this._parentContainer=null}if(this._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses.length=0;else if(this.cameraRigMode!==J.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses.length=0;else{let s=this._postProcesses.length;for(;--s>=0;){const r=this._postProcesses[s];r&&r.dispose(this)}}let i=this.customRenderTargets.length;for(;--i>=0;)this.customRenderTargets[i].dispose();this.customRenderTargets.length=0,this._activeMeshes.dispose(),this.getScene().getEngine().releaseRenderPassId(this.renderPassId),super.dispose(e,t)}get isLeftCamera(){return this._isLeftCamera}get isRightCamera(){return this._isRightCamera}get leftCamera(){return this._rigCameras.length<1?null:this._rigCameras[0]}get rightCamera(){return this._rigCameras.length<2?null:this._rigCameras[1]}getLeftTarget(){return this._rigCameras.length<1?null:this._rigCameras[0].getTarget()}getRightTarget(){return this._rigCameras.length<2?null:this._rigCameras[1].getTarget()}setCameraRigMode(e,t){if(this.cameraRigMode!==e){for(;this._rigCameras.length>0;){const i=this._rigCameras.pop();i&&i.dispose()}if(this.cameraRigMode=e,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=t.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=se.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==J.RIG_MODE_NONE){const i=this.createRigCamera(this.name+"_L",0);i&&(i._isLeftCamera=!0);const s=this.createRigCamera(this.name+"_R",1);s&&(s._isRightCamera=!0),i&&s&&(this._rigCameras.push(i),this._rigCameras.push(s))}this._setRigMode(t),this._cascadePostProcessesToRigCams(),this.update()}}_setRigMode(e){}_getVRProjectionMatrix(){return P.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.ignoreCameraMaxZ?0:this.maxZ,this._cameraRigParams.vrWorkMatrix,!0,this.getEngine().isNDCHalfZRange),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix}setCameraRigParameter(e,t){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[e]=t,e==="interaxialDistance"&&(this._cameraRigParams.stereoHalfAngle=se.ToRadians(t/.0637))}createRigCamera(e,t){return null}_updateRigCameras(){for(let e=0;e<this._rigCameras.length;e++)this._rigCameras[e].minZ=this.minZ,this._rigCameras[e].maxZ=this.ignoreCameraMaxZ?0:this.maxZ,this._rigCameras[e].fov=this.fov,this._rigCameras[e].upVector.copyFrom(this.upVector);this.cameraRigMode===J.RIG_MODE_STEREOSCOPIC_ANAGLYPH&&(this._rigCameras[0].viewport=this._rigCameras[1].viewport=this.viewport)}_setupInputs(){}serialize(){const e=le.Serialize(this);return e.uniqueId=this.uniqueId,e.type=this.getClassName(),this.parent&&this.parent._serializeAsParent(e),this.inputs&&this.inputs.serialize(e),le.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.isEnabled=this.isEnabled(),e}clone(e,t=null){const i=le.Clone(J.GetConstructorFromName(this.getClassName(),e,this.getScene(),this.interaxialDistance,this.isStereoscopicSideBySide),this);return i.name=e,i.parent=t,this.onClonedObservable.notifyObservers(i),i}getDirection(e){const t=_.Zero();return this.getDirectionToRef(e,t),t}get absoluteRotation(){return this.getWorldMatrix().decompose(void 0,this._absoluteRotation),this._absoluteRotation}getDirectionToRef(e,t){_.TransformNormalToRef(e,this.getWorldMatrix(),t)}static GetConstructorFromName(e,t,i,s=0,r=!0){const n=qe.Construct(e,t,i,{interaxial_distance:s,isStereoscopicSideBySide:r});return n||(()=>J._CreateDefaultParsedCamera(t,i))}computeWorldMatrix(){return this.getWorldMatrix()}static Parse(e,t){const i=e.type,s=J.GetConstructorFromName(i,e.name,t,e.interaxial_distance,e.isStereoscopicSideBySide),r=le.Parse(s,e,t);if(e.parentId!==void 0&&(r._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(r._waitingParentInstanceIndex=e.parentInstanceIndex),r.inputs&&(r.inputs.parse(e),r._setupInputs()),e.upVector&&(r.upVector=_.FromArray(e.upVector)),r.setPosition&&(r.position.copyFromFloats(0,0,0),r.setPosition(_.FromArray(e.position))),e.target&&r.setTarget&&r.setTarget(_.FromArray(e.target)),e.cameraRigMode){const n=e.interaxial_distance?{interaxialDistance:e.interaxial_distance}:{};r.setCameraRigMode(e.cameraRigMode,n)}if(e.animations){for(let n=0;n<e.animations.length;n++){const o=e.animations[n],h=Oi("BABYLON.Animation");h&&r.animations.push(h.Parse(o))}qe.ParseAnimationRanges(r,e,t)}return e.autoAnimate&&t.beginAnimation(r,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),e.isEnabled!==void 0&&r.setEnabled(e.isEnabled),r}_calculateHandednessMultiplier(){let e=this.getScene().useRightHandedSystem?-1:1;return this.parent&&this.parent._getWorldMatrixDeterminant()<0&&(e*=-1),e}}J._CreateDefaultParsedCamera=(a,e)=>{throw ie("UniversalCamera")};J.PERSPECTIVE_CAMERA=0;J.ORTHOGRAPHIC_CAMERA=1;J.FOVMODE_VERTICAL_FIXED=0;J.FOVMODE_HORIZONTAL_FIXED=1;J.RIG_MODE_NONE=0;J.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10;J.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11;J.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12;J.RIG_MODE_STEREOSCOPIC_OVERUNDER=13;J.RIG_MODE_STEREOSCOPIC_INTERLACED=14;J.RIG_MODE_VR=20;J.RIG_MODE_CUSTOM=22;J.ForceAttachControlToAlwaysPreventDefault=!1;T([qt("position")],J.prototype,"_position",void 0);T([qt("upVector")],J.prototype,"_upVector",void 0);T([R()],J.prototype,"orthoLeft",null);T([R()],J.prototype,"orthoRight",null);T([R()],J.prototype,"orthoBottom",null);T([R()],J.prototype,"orthoTop",null);T([R()],J.prototype,"fov",void 0);T([R()],J.prototype,"projectionPlaneTilt",void 0);T([R()],J.prototype,"minZ",void 0);T([R()],J.prototype,"maxZ",void 0);T([R()],J.prototype,"inertia",void 0);T([R()],J.prototype,"mode",null);T([R()],J.prototype,"layerMask",void 0);T([R()],J.prototype,"fovMode",void 0);T([R()],J.prototype,"cameraRigMode",void 0);T([R()],J.prototype,"interaxialDistance",void 0);T([R()],J.prototype,"isStereoscopicSideBySide",void 0);T([R()],J.prototype,"ignoreCameraMaxZ",void 0);class ir{get underlyingResource(){return null}constructor(){this.references=0,this.capacity=0,this.is32Bits=!1,this.uniqueId=ir._Counter++}}ir._Counter=0;function Pc(a,e,t,i){switch(e){case 5120:{let s=a.getInt8(t);return i&&(s=Math.max(s/127,-1)),s}case 5121:{let s=a.getUint8(t);return i&&(s=s/255),s}case 5122:{let s=a.getInt16(t,!0);return i&&(s=Math.max(s/32767,-1)),s}case 5123:{let s=a.getUint16(t,!0);return i&&(s=s/65535),s}case 5124:return a.getInt32(t,!0);case 5125:return a.getUint32(t,!0);case 5126:return a.getFloat32(t,!0);default:throw new Error(`Invalid component type ${e}`)}}function vc(a,e,t,i,s){switch(e){case 5120:{i&&(s=Math.round(s*127)),a.setInt8(t,s);break}case 5121:{i&&(s=Math.round(s*255)),a.setUint8(t,s);break}case 5122:{i&&(s=Math.round(s*32767)),a.setInt16(t,s,!0);break}case 5123:{i&&(s=Math.round(s*65535)),a.setUint16(t,s,!0);break}case 5124:{a.setInt32(t,s,!0);break}case 5125:{a.setUint32(t,s,!0);break}case 5126:{a.setFloat32(t,s,!0);break}default:throw new Error(`Invalid component type ${e}`)}}function Ti(a){switch(a){case 5120:case 5121:return 1;case 5122:case 5123:return 2;case 5124:case 5125:case 5126:return 4;default:throw new Error(`Invalid type '${a}'`)}}function Dc(a){switch(a){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array;default:throw new Error(`Invalid component type '${a}'`)}}function es(a,e,t,i,s,r,n,o){const h=new Array(i),l=new Array(i);if(a instanceof Array){let c=e/4;const u=t/4;for(let f=0;f<r;f+=i){for(let d=0;d<i;d++)h[d]=l[d]=a[c+d];o(l,f);for(let d=0;d<i;
23d++)h[d]!==l[d]&&(a[c+d]=l[d]);c+=u}}else{const c=ArrayBuffer.isView(a)?new DataView(a.buffer,a.byteOffset,a.byteLength):new DataView(a),u=Ti(s);for(let f=0;f<r;f+=i){for(let d=0,g=e;d<i;d++,g+=u)h[d]=l[d]=Pc(c,s,g,n);o(l,f);for(let d=0,g=e;d<i;d++,g+=u)h[d]!==l[d]&&vc(c,s,g,n,l[d]);e+=t}}}function ca(a,e,t,i,s,r,n,o){const h=e*Ti(t),l=n*e;if(t!==5126||s!==h){const c=new Float32Array(l);return es(a,i,s,e,t,l,r,(u,f)=>{for(let d=0;d<e;d++)c[f+d]=u[d]}),c}if(!(a instanceof Array||a instanceof Float32Array)||i!==0||a.length!==l)if(a instanceof Array){const c=i/4;return a.slice(c,c+l)}else{if(a instanceof ArrayBuffer)return new Float32Array(a,i,l);{const c=a.byteOffset+i;return(c&3)!==0&&(w.Warn("Float array must be aligned to 4-bytes border"),o=!0),o?new Float32Array(a.buffer.slice(c,c+l*Float32Array.BYTES_PER_ELEMENT)):new Float32Array(a.buffer,c,l)}}return o?a.slice():a}function Oc(a,e,t,i,s,r,n){const o=Ti(t),h=Dc(t),l=r*e;if(Array.isArray(a)){if((i&3)!==0||(s&3)!==0)throw new Error("byteOffset and byteStride must be a multiple of 4 for number[] data.");const g=i/4,p=s/4;if(g+(r-1)*p+e>a.length)throw new Error("Last accessed index is out of bounds.");if(p<e)throw new Error("Data stride cannot be smaller than the component size.");if(p!==e){const A=new h(l);return es(a,i,s,e,t,l,!1,(E,I)=>{for(let M=0;M<e;M++)A[I+M]=E[M]}),A}return new h(a.slice(g,g+l))}let c,u=i;if(a instanceof ArrayBuffer?c=a:(c=a.buffer,u+=a.byteOffset),u+(r-1)*s+e*o>c.byteLength)throw new Error("Last accessed byte is out of bounds.");const d=e*o;if(s<d)throw new Error("Byte stride cannot be smaller than the component's byte size.");if(s!==d){const g=new h(l);return es(c,u,s,e,t,l,!1,(p,m)=>{for(let A=0;A<e;A++)g[m+A]=p[A]}),g}return o!==1&&(u&o-1)!==0&&(w.Warn("Array must be aligned to border of element size. Data will be copied."),n=!0),n?new h(c.slice(u,u+l*o)):new h(c,u,l)}function Fc(a,e,t,i,s,r,n,o){const h=e*Ti(t),l=n*e;if(o.length!==l)throw new Error("Output length is not valid");if(t!==5126||s!==h){es(a,i,s,e,t,l,r,(c,u)=>{for(let f=0;f<e;f++)o[u+f]=c[f]});return}if(a instanceof Array){const c=i/4;o.set(a,c)}else if(a instanceof ArrayBuffer){const c=new Float32Array(a,i,l);o.set(c)}else{const c=a.byteOffset+i;if((c&3)!==0){w.Warn("Float array must be aligned to 4-bytes border"),o.set(new Float32Array(a.buffer.slice(c,c+l*Float32Array.BYTES_PER_ELEMENT)));return}const u=new Float32Array(a.buffer,c,l);o.set(u)}}class Dr{get isDisposed(){return this._isDisposed}constructor(e,t,i,s=0,r=!1,n=!1,o=!1,h,l){this._isAlreadyOwned=!1,this._isDisposed=!1,e&&e.getScene?this._engine=e.getScene().getEngine():this._engine=e,this._updatable=i,this._instanced=n,this._divisor=h||1,this._label=l,t instanceof ir?(this._data=null,this._buffer=t):(this._data=t,this._buffer=null),this.byteStride=o?s:s*Float32Array.BYTES_PER_ELEMENT,r||this.create()}createVertexBuffer(e,t,i,s,r,n=!1,o){const h=n?t:t*Float32Array.BYTES_PER_ELEMENT,l=s?n?s:s*Float32Array.BYTES_PER_ELEMENT:this.byteStride;return new b(this._engine,this,e,this._updatable,!0,l,r===void 0?this._instanced:r,h,i,void 0,void 0,!0,this._divisor||o)}isUpdatable(){return this._updatable}getData(){return this._data}getBuffer(){return this._buffer}getStrideSize(){return this.byteStride/Float32Array.BYTES_PER_ELEMENT}create(e=null){!e&&this._buffer||(e=e||this._data,e&&(this._buffer?this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e),this._data=e):this._updatable?(this._buffer=this._engine.createDynamicVertexBuffer(e,this._label),this._data=e):this._buffer=this._engine.createVertexBuffer(e,void 0,this._label)))}_rebuild(){if(this._data)this._buffer=null,this.create(this._data);else{if(!this._buffer)return;if(this._buffer.capacity>0){this._updatable?this._buffer=this._engine.createDynamicVertexBuffer(this._buffer.capacity,this._label):this._buffer=this._engine.createVertexBuffer(this._buffer.capacity,void 0,this._label);return}w.Warn(`Missing data for buffer "${this._label}" ${this._buffer?"(uniqueId: "+this._buffer.uniqueId+")":""}. Buffer reconstruction failed.`),this._buffer=null}}update(e){this.create(e)}updateDirectly(e,t,i,s=!1){this._buffer&&this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e,s?t:t*Float32Array.BYTES_PER_ELEMENT,i?i*this.byteStride:void 0),t===0&&i===void 0?this._data=e:this._data=null)}_increaseReferences(){if(this._buffer){if(!this._isAlreadyOwned){this._isAlreadyOwned=!0;return}this._buffer.references++}}dispose(){this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._isDisposed=!0,this._data=null,this._buffer=null)}}class b{get isDisposed(){return this._isDisposed}get instanceDivisor(){return this._instanceDivisor}set instanceDivisor(e){const t=e!=0;this._instanceDivisor=e,t!==this._instanced&&(this._instanced=t,this._computeHashCode())}get _maxVerticesCount(){const e=this.getData();return e?Array.isArray(e)?e.length/(this.byteStride/4)-this.byteOffset/4:(e.byteLength-this.byteOffset)/this.byteStride:0}constructor(e,t,i,s,r,n,o,h,l,c,u=!1,f=!1,d=1,g=!1){this._isDisposed=!1;let p=!1;if(this.engine=e,typeof s=="object"&&s!==null?(p=s.updatable??!1,r=s.postponeInternalCreation,n=s.stride,o=s.instanced,h=s.offset,l=s.size,c=s.type,u=s.normalized??!1,f=s.useBytes??!1,d=s.divisor??1,g=s.takeBufferOwnership??!1,this._label=s.label):p=!!s,t instanceof Dr?(this._buffer=t,this._ownsBuffer=g):(this._buffer=new Dr(e,t,p,n,r,o,f,d,this._label),this._ownsBuffer=!0),this.uniqueId=b._Counter++,this._kind=i,c===void 0){const A=this.getData();this.type=A?b.GetDataType(A):b.FLOAT}else this.type=c;const m=Ti(this.type);f?(this._size=l||(n?n/m:b.DeduceStride(i)),this.byteStride=n||this._buffer.byteStride||this._size*m,this.byteOffset=h||0):(this._size=l||n||b.DeduceStride(i),this.byteStride=n?n*m:this._buffer.byteStride||this._size*m,this.byteOffset=(h||0)*m),this.normalized=u,this._instanced=o!==void 0?o:!1,this._instanceDivisor=o?d:0,this._alignBuffer(),this._computeHashCode()}_computeHashCode(){this.hashCode=(this.type-5120<<0)+((this.normalized?1:0)<<3)+(this._size<<4)+((this._instanced?1:0)<<6)+(this.byteStride<<12)}_rebuild(){this._buffer?._rebuild()}getKind(){return this._kind}
vendor: 56,767 bytes, line 23
23isUpdatable(){return this._buffer.isUpdatable()}getData(){return this._buffer.getData()}getFloatData(e,t){const i=this.getData();return i?ca(i,this._size,this.type,this.byteOffset,this.byteStride,this.normalized,e,t):null}getBuffer(){return this._buffer.getBuffer()}getWrapperBuffer(){return this._buffer}getStrideSize(){return this.byteStride/Ti(this.type)}getOffset(){return this.byteOffset/Ti(this.type)}getSize(e=!1){return e?this._size*Ti(this.type):this._size}getIsInstanced(){return this._instanced}getInstanceDivisor(){return this._instanceDivisor}create(e){this._buffer.create(e),this._alignBuffer()}update(e){this._buffer.update(e),this._alignBuffer()}updateDirectly(e,t,i=!1){this._buffer.updateDirectly(e,t,void 0,i),this._alignBuffer()}dispose(){this._ownsBuffer&&this._buffer.dispose(),this._isDisposed=!0}forEach(e,t){es(this._buffer.getData(),this.byteOffset,this.byteStride,this._size,this.type,e,this.normalized,(i,s)=>{for(let r=0;r<this._size;r++)t(i[r],s+r)})}_alignBuffer(){}static DeduceStride(e){switch(e){case b.UVKind:case b.UV2Kind:case b.UV3Kind:case b.UV4Kind:case b.UV5Kind:case b.UV6Kind:return 2;case b.NormalKind:case b.PositionKind:return 3;case b.ColorKind:case b.ColorInstanceKind:case b.MatricesIndicesKind:case b.MatricesIndicesExtraKind:case b.MatricesWeightsKind:case b.MatricesWeightsExtraKind:case b.TangentKind:return 4;default:throw new Error("Invalid kind '"+e+"'")}}static GetDataType(e){return e instanceof Int8Array?b.BYTE:e instanceof Uint8Array?b.UNSIGNED_BYTE:e instanceof Int16Array?b.SHORT:e instanceof Uint16Array?b.UNSIGNED_SHORT:e instanceof Int32Array?b.INT:e instanceof Uint32Array?b.UNSIGNED_INT:b.FLOAT}static GetTypeByteLength(e){return Ti(e)}static ForEach(e,t,i,s,r,n,o,h){es(e,t,i,s,r,n,o,(l,c)=>{for(let u=0;u<s;u++)h(l[u],c+u)})}static GetFloatData(e,t,i,s,r,n,o,h){return ca(e,t,i,s,r,n,o,h)}}b._Counter=0;b.BYTE=5120;b.UNSIGNED_BYTE=5121;b.SHORT=5122;b.UNSIGNED_SHORT=5123;b.INT=5124;b.UNSIGNED_INT=5125;b.FLOAT=5126;b.PositionKind="position";b.NormalKind="normal";b.TangentKind="tangent";b.UVKind="uv";b.UV2Kind="uv2";b.UV3Kind="uv3";b.UV4Kind="uv4";b.UV5Kind="uv5";b.UV6Kind="uv6";b.ColorKind="color";b.ColorInstanceKind="instanceColor";b.MatricesIndicesKind="matricesIndices";b.MatricesWeightsKind="matricesWeights";b.MatricesIndicesExtraKind="matricesIndicesExtra";b.MatricesWeightsExtraKind="matricesWeightsExtra";class ua{constructor(e,t,i){this.bu=e,this.bv=t,this.distance=i,this.faceId=0,this.subMeshId=0,this._internalSubMeshId=0}}class bi{constructor(e,t,i){this.vectors=Ai(8,_.Zero),this.center=_.Zero(),this.centerWorld=_.Zero(),this.extendSize=_.Zero(),this.extendSizeWorld=_.Zero(),this.directions=Ai(3,_.Zero),this.vectorsWorld=Ai(8,_.Zero),this.minimumWorld=_.Zero(),this.maximumWorld=_.Zero(),this.minimum=_.Zero(),this.maximum=_.Zero(),this._drawWrapperFront=null,this._drawWrapperBack=null,this.reConstruct(e,t,i)}reConstruct(e,t,i){const s=e.x,r=e.y,n=e.z,o=t.x,h=t.y,l=t.z,c=this.vectors;this.minimum.copyFromFloats(s,r,n),this.maximum.copyFromFloats(o,h,l),c[0].copyFromFloats(s,r,n),c[1].copyFromFloats(o,h,l),c[2].copyFromFloats(o,r,n),c[3].copyFromFloats(s,h,n),c[4].copyFromFloats(s,r,l),c[5].copyFromFloats(o,h,n),c[6].copyFromFloats(s,h,l),c[7].copyFromFloats(o,r,l),t.addToRef(e,this.center).scaleInPlace(.5),t.subtractToRef(e,this.extendSize).scaleInPlace(.5),this._worldMatrix=i||P.IdentityReadOnly,this._update(this._worldMatrix)}scale(e){const t=bi._TmpVector3,i=this.maximum.subtractToRef(this.minimum,t[0]),s=i.length();i.normalizeFromLength(s);const r=s*e,n=i.scaleInPlace(r*.5),o=this.center.subtractToRef(n,t[1]),h=this.center.addToRef(n,t[2]);return this.reConstruct(o,h,this._worldMatrix),this}getWorldMatrix(){return this._worldMatrix}_update(e){const t=this.minimumWorld,i=this.maximumWorld,s=this.directions,r=this.vectorsWorld,n=this.vectors;if(e.isIdentity()){t.copyFrom(this.minimum),i.copyFrom(this.maximum);for(let o=0;o<8;++o)r[o].copyFrom(n[o]);this.extendSizeWorld.copyFrom(this.extendSize),this.centerWorld.copyFrom(this.center)}else{t.setAll(Number.MAX_VALUE),i.setAll(-Number.MAX_VALUE);for(let o=0;o<8;++o){const h=r[o];_.TransformCoordinatesToRef(n[o],e,h),t.minimizeInPlace(h),i.maximizeInPlace(h)}i.subtractToRef(t,this.extendSizeWorld).scaleInPlace(.5),i.addToRef(t,this.centerWorld).scaleInPlace(.5)}_.FromArrayToRef(e.m,0,s[0]),_.FromArrayToRef(e.m,4,s[1]),_.FromArrayToRef(e.m,8,s[2]),this._worldMatrix=e}isInFrustum(e){return bi.IsInFrustum(this.vectorsWorld,e)}isCompletelyInFrustum(e){return bi.IsCompletelyInFrustum(this.vectorsWorld,e)}intersectsPoint(e){const t=this.minimumWorld,i=this.maximumWorld,s=t.x,r=t.y,n=t.z,o=i.x,h=i.y,l=i.z,c=e.x,u=e.y,f=e.z,d=-Me;return!(o-c<d||d>c-s||h-u<d||d>u-r||l-f<d||d>f-n)}intersectsSphere(e){return bi.IntersectsSphere(this.minimumWorld,this.maximumWorld,e.centerWorld,e.radiusWorld)}intersectsMinMax(e,t){const i=this.minimumWorld,s=this.maximumWorld,r=i.x,n=i.y,o=i.z,h=s.x,l=s.y,c=s.z,u=e.x,f=e.y,d=e.z,g=t.x,p=t.y,m=t.z;return!(h<u||r>g||l<f||n>p||c<d||o>m)}dispose(){this._drawWrapperFront?.dispose(),this._drawWrapperBack?.dispose()}static Intersects(e,t){return e.intersectsMinMax(t.minimumWorld,t.maximumWorld)}static IntersectsSphere(e,t,i,s){const r=bi._TmpVector3[0];return _.ClampToRef(i,e,t,r),_.DistanceSquared(i,r)<=s*s}static IsCompletelyInFrustum(e,t){for(let i=0;i<6;++i){const s=t[i];for(let r=0;r<8;++r)if(s.dotCoordinate(e[r])<0)return!1}return!0}static IsInFrustum(e,t){for(let i=0;i<6;++i){let s=!0;const r=t[i];for(let n=0;n<8;++n)if(r.dotCoordinate(e[n])>=0){s=!1;break}if(s)return!1}return!0}}bi._TmpVector3=Ai(3,_.Zero);class Zi{constructor(e,t,i){this.center=_.Zero(),this.centerWorld=_.Zero(),this.minimum=_.Zero(),this.maximum=_.Zero(),this.reConstruct(e,t,i)}reConstruct(e,t,i){this.minimum.copyFrom(e),this.maximum.copyFrom(t);const s=_.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=s*.5,this._update(i||P.IdentityReadOnly)}scale(e){const t=this.radius*e,i=Zi._TmpVector3,s=i[0].setAll(t),r=this.center.subtractToRef(s,i[1]),n=this.center.addToRef(s,i[2]);return this.reConstruct(r,n,this._worldMatrix),this}getWorldMatrix(){return this._worldMatrix}_update(e){if(e.isIdentity())this.centerWorld.copyFrom(this.center),this.radiusWorld=this.radius;else{_.TransformCoordinatesToRef(this.center,e,this.centerWorld);const t=Zi._TmpVector3[0];_.TransformNormalFromFloatsToRef(1,1,1,e,t),this.radiusWorld=Math.max(Math.abs(t.x),Math.abs(t.y),Math.abs(t.z))*this.radius}}isInFrustum(e){const t=this.centerWorld,i=this.radiusWorld;for(let s=0;s<6;s++)if(e[s].dotCoordinate(t)<=-i)return!1;return!0}isCenterInFrustum(e){const t=this.centerWorld;for(let i=0;i<6;i++)if(e[i].dotCoordinate(t)<0)return!1;return!0}intersectsPoint(e){const t=_.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorld<t)}static Intersects(e,t){const i=_.DistanceSquared(e.centerWorld,t.centerWorld),s=e.radiusWorld+t.radiusWorld;return!(s*s<i)}static CreateFromCenterAndRadius(e,t,i){this._TmpVector3[0].copyFrom(e),this._TmpVector3[1].copyFromFloats(0,0,t),this._TmpVector3[2].copyFrom(e),this._TmpVector3[0].addInPlace(this._TmpVector3[1]),this._TmpVector3[2].subtractInPlace(this._TmpVector3[1]);const s=new Zi(this._TmpVector3[0],this._TmpVector3[2]);return i?s._worldMatrix=i:s._worldMatrix=P.Identity(),s}}Zi._TmpVector3=Ai(3,_.Zero);const Jr={min:0,max:0},en={min:0,max:0},da=(a,e,t)=>{const i=_.Dot(e.centerWorld,a),s=Math.abs(_.Dot(e.directions[0],a))*e.extendSize.x,r=Math.abs(_.Dot(e.directions[1],a))*e.extendSize.y,n=Math.abs(_.Dot(e.directions[2],a))*e.extendSize.z,o=s+r+n;t.min=i-o,t.max=i+o},Rt=(a,e,t)=>(da(a,e,Jr),da(a,t,en),!(Jr.min>en.max||en.min>Jr.max));class Lt{constructor(e,t,i){this._isLocked=!1,this.boundingBox=new bi(e,t,i),this.boundingSphere=new Zi(e,t,i)}reConstruct(e,t,i){this.boundingBox.reConstruct(e,t,i),this.boundingSphere.reConstruct(e,t,i)}get minimum(){return this.boundingBox.minimum}get maximum(){return this.boundingBox.maximum}get isLocked(){return this._isLocked}set isLocked(e){this._isLocked=e}update(e){this._isLocked||(this.boundingBox._update(e),this.boundingSphere._update(e))}centerOn(e,t){const i=Lt._TmpVector3[0].copyFrom(e).subtractInPlace(t),s=Lt._TmpVector3[1].copyFrom(e).addInPlace(t);return this.boundingBox.reConstruct(i,s,this.boundingBox.getWorldMatrix()),this.boundingSphere.reConstruct(i,s,this.boundingBox.getWorldMatrix()),this}encapsulate(e){const t=_.Minimize(this.minimum,e),i=_.Maximize(this.maximum,e);return this.reConstruct(t,i,this.boundingBox.getWorldMatrix()),this}encapsulateBoundingInfo(e){const t=v.Matrix[0];this.boundingBox.getWorldMatrix().invertToRef(t);const i=v.Vector3[0];return _.TransformCoordinatesToRef(e.boundingBox.minimumWorld,t,i),this.encapsulate(i),_.TransformCoordinatesToRef(e.boundingBox.maximumWorld,t,i),this.encapsulate(i),this}scale(e){return this.boundingBox.scale(e),this.boundingSphere.scale(e),this}isInFrustum(e,t=0){return(t===2||t===3)&&this.boundingSphere.isCenterInFrustum(e)?!0:this.boundingSphere.isInFrustum(e)?t===1||t===3?!0:this.boundingBox.isInFrustum(e):!1}get diagonalLength(){const e=this.boundingBox;return e.maximumWorld.subtractToRef(e.minimumWorld,Lt._TmpVector3[0]).length()}isCompletelyInFrustum(e){return this.boundingBox.isCompletelyInFrustum(e)}_checkCollision(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)}intersectsPoint(e){return!(!this.boundingSphere.centerWorld||!this.boundingSphere.intersectsPoint(e)||!this.boundingBox.intersectsPoint(e))}intersects(e,t){if(!Zi.Intersects(this.boundingSphere,e.boundingSphere)||!bi.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;const i=this.boundingBox,s=e.boundingBox;return!(!Rt(i.directions[0],i,s)||!Rt(i.directions[1],i,s)||!Rt(i.directions[2],i,s)||!Rt(s.directions[0],i,s)||!Rt(s.directions[1],i,s)||!Rt(s.directions[2],i,s)||!Rt(_.Cross(i.directions[0],s.directions[0]),i,s)||!Rt(_.Cross(i.directions[0],s.directions[1]),i,s)||!Rt(_.Cross(i.directions[0],s.directions[2]),i,s)||!Rt(_.Cross(i.directions[1],s.directions[0]),i,s)||!Rt(_.Cross(i.directions[1],s.directions[1]),i,s)||!Rt(_.Cross(i.directions[1],s.directions[2]),i,s)||!Rt(_.Cross(i.directions[2],s.directions[0]),i,s)||!Rt(_.Cross(i.directions[2],s.directions[1]),i,s)||!Rt(_.Cross(i.directions[2],s.directions[2]),i,s))}}Lt._TmpVector3=Ai(2,_.Zero);class kr{static extractMinAndMaxIndexed(e,t,i,s,r,n){for(let o=i;o<i+s;o++){const h=t[o]*3,l=e[h],c=e[h+1],u=e[h+2];r.minimizeInPlaceFromFloats(l,c,u),n.maximizeInPlaceFromFloats(l,c,u)}}static extractMinAndMax(e,t,i,s,r,n){for(let o=t,h=t*s;o<t+i;o++,h+=s){const l=e[h],c=e[h+1],u=e[h+2];r.minimizeInPlaceFromFloats(l,c,u),n.maximizeInPlaceFromFloats(l,c,u)}}}T([yi.filter((...[a,e])=>!Array.isArray(a)&&!Array.isArray(e))],kr,"extractMinAndMaxIndexed",null);T([yi.filter((...[a])=>!Array.isArray(a))],kr,"extractMinAndMax",null);function wc(a,e,t,i,s=null){const r=new _(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),n=new _(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return kr.extractMinAndMaxIndexed(a,e,t,i,r,n),s&&(r.x-=r.x*s.x+s.y,r.y-=r.y*s.x+s.y,r.z-=r.z*s.x+s.y,n.x+=n.x*s.x+s.y,n.y+=n.y*s.x+s.y,n.z+=n.z*s.x+s.y),{minimum:r,maximum:n}}function Wo(a,e,t,i=null,s){const r=new _(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),n=new _(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return s||(s=3),kr.extractMinAndMax(a,e,t,s,r,n),i&&(r.x-=r.x*i.x+i.y,r.y-=r.y*i.x+i.y,r.z-=r.z*i.x+i.y,n.x+=n.x*i.x+i.y,n.y+=n.y*i.x+i.y,n.z+=n.z*i.x+i.y),{minimum:r,maximum:n}}class kn{static GetEffect(e){return e.getPipelineContext===void 0?e.effect:e}constructor(e,t=!0){this._wasPreviouslyReady=!1,this._forceRebindOnNextCall=!0,this._wasPreviouslyUsingInstances=null,this.effect=null,this.defines=null,this.drawContext=e.createDrawContext(),t&&(this.materialContext=e.createMaterialContext())}setEffect(e,t,i=!0){this.effect=e,t!==void 0&&(this.defines=t),i&&this.drawContext?.reset()}dispose(e=!1){if(this.effect){const t=this.effect;e?t.dispose():ks.SetImmediate(()=>{t.getEngine().onEndFrameObservable.addOnce(()=>{t.dispose()})}),this.effect=null}this.drawContext?.dispose()}}class zt{get materialDefines(){return this._mainDrawWrapperOverride?this._mainDrawWrapperOverride.defines:this._getDrawWrapper()?.defines}set materialDefines(e){const t=this._mainDrawWrapperOverride??this._getDrawWrapper(void 0,!0);t.defines=e}_getDrawWrapper(e,t=!1){e=e??this._engine.currentRenderPassId;let i=this._drawWrappers[e];return!i&&t&&(this._drawWrappers[e]=i=new kn(this._mesh.getScene().getEngine())),i}_removeDrawWrapper(e,t=!0,i=!1){t&&this._drawWrappers[e]?.dispose(i),this._drawWrappers[e]=void 0}get effect(){return this._mainDrawWrapperOverride?this._mainDrawWrapperOverride.effect:this._getDrawWrapper()?.effect??null}get _drawWrapper(){return this._mainDrawWrapperOverride??this._getDrawWrapper(void 0,!0)}get _drawWrapperOverride(){return this._mainDrawWrapperOverride}_setMainDrawWrapperOverride(e){this._mainDrawWrapperOverride=e}setEffect(e,t=null,i,s=!0){const r=this._drawWrapper;r.setEffect(e,t,s),i!==void 0&&(r.materialContext=i),e||(r.defines=null,r.materialContext=void 0)}resetDrawCache(e,t=!1){if(this._drawWrappers)if(e!==void 0){this._removeDrawWrapper(e,!0,t);return}else for(const i of this._drawWrappers)i?.dispose(t);this._drawWrappers=[]}static AddToMesh(e,t,i,s,r,n,o,h=!0){return new zt(e,t,i,s,r,n,o,h)}constructor(e,t,i,s,r,n,o,h=!0,l=!0){this.materialIndex=e,this.verticesStart=t,this.verticesCount=i,this.indexStart=s,this.indexCount=r,this._mainDrawWrapperOverride=null,this._linesIndexCount=0,this._linesIndexBuffer=null,this._lastColliderWorldVertices=null,this._lastColliderTransformMatrix=null,this._wasDispatched=!1,this._renderId=0,this._alphaIndex=0,this._distanceToCamera=0,this._currentMaterial=null,this._mesh=n,this._renderingMesh=o||n,l&&n.subMeshes.push(this),this._engine=this._mesh.getScene().getEngine(),this.resetDrawCache(),this._trianglePlanes=[],this._id=n.subMeshes.length-1,h&&(this.refreshBoundingInfo(),n.computeWorldMatrix(!0))}get IsGlobal(){return this.verticesStart===0&&this.verticesCount===this._mesh.getTotalVertices()&&this.indexStart===0&&this.indexCount===this._mesh.getTotalIndices()}getBoundingInfo(){return this.IsGlobal||this._mesh.hasThinInstances?this._mesh.getBoundingInfo():this._boundingInfo}setBoundingInfo(e){return this._boundingInfo=e,this}getMesh(){return this._mesh}getRenderingMesh(){return this._renderingMesh}getReplacementMesh(){return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null}getEffectiveMesh(){const e=this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null;return e||this._renderingMesh}getMaterial(e=!0){const t=this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId)??this._renderingMesh.material;if(t){if(this._isMultiMaterial(t)){const i=t.getSubMaterial(this.materialIndex);return this._currentMaterial!==i&&(this._currentMaterial=i,this.resetDrawCache()),i}}else return e&&this._mesh.getScene()._hasDefaultMaterial?this._mesh.getScene().defaultMaterial:null;return t}_isMultiMaterial(e){return e.getSubMaterial!==void 0}refreshBoundingInfo(e=null){if(this._lastColliderWorldVertices=null,this.IsGlobal||!this._renderingMesh||!this._renderingMesh.geometry)return this;if(e||(e=this._renderingMesh.getVerticesData(b.PositionKind)),!e)return this._boundingInfo=this._mesh.getBoundingInfo(),this;const t=this._renderingMesh.getIndices();let i;if(this.indexStart===0&&this.indexCount===t.length){const s=this._renderingMesh.getBoundingInfo();i={minimum:s.minimum.clone(),maximum:s.maximum.clone()}}else i=wc(e,t,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new Lt(i.minimum,i.maximum),this}_checkCollision(e){return this.getBoundingInfo()._checkCollision(e)}updateBoundingInfo(e){let t=this.getBoundingInfo();return t||(this.refreshBoundingInfo(),t=this.getBoundingInfo()),t&&t.update(e),this}isInFrustum(e){const t=this.getBoundingInfo();return t?t.isInFrustum(e,this._mesh.cullingStrategy):!1}isCompletelyInFrustum(e){const t=this.getBoundingInfo();return t?t.isCompletelyInFrustum(e):!1}render(e){return this._renderingMesh.render(this,e,this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:void 0),this}_getLinesIndexBuffer(e,t){if(!this._linesIndexBuffer){const i=Math.floor(this.indexCount/3)*6,r=this.verticesStart+this.verticesCount>65535?new Uint32Array(i):new Uint16Array(i);let n=0;if(e.length===0)for(let o=this.indexStart;o<this.indexStart+this.indexCount;o+=3)r[n++]=o,r[n++]=o+1,r[n++]=o+1,r[n++]=o+2,r[n++]=o+2,r[n++]=o;else for(let o=this.indexStart;o<this.indexStart+this.indexCount;o+=3)r[n++]=e[o],r[n++]=e[o+1],r[n++]=e[o+1],r[n++]=e[o+2],r[n++]=e[o+2],r[n++]=e[o];this._linesIndexBuffer=t.createIndexBuffer(r),this._linesIndexCount=r.length}return this._linesIndexBuffer}canIntersects(e){const t=this.getBoundingInfo();return t?e.intersectsBox(t.boundingBox):!1}intersects(e,t,i,s,r){const n=this.getMaterial();if(!n)return null;let o=3,h=!1;switch(n.fillMode){case 3:case 5:case 6:case 8:return null;case 7:o=1,h=!0;break}return n.fillMode===4?i.length?this._intersectLines(e,t,i,this._mesh.intersectionThreshold,s):this._intersectUnIndexedLines(e,t,i,this._mesh.intersectionThreshold,s):!i.length&&this._mesh._unIndexed?this._intersectUnIndexedTriangles(e,t,i,s,r):this._intersectTriangles(e,t,i,o,h,s,r)}_intersectLines(e,t,i,s,r){let n=null;for(let o=this.indexStart;o<this.indexStart+this.indexCount;o+=2){const h=t[i[o]],l=t[i[o+1]],c=e.intersectionSegment(h,l,s);if(!(c<0)&&(r||!n||c<n.distance)&&(n=new ua(null,null,c),n.faceId=o/2,r))break}return n}_intersectUnIndexedLines(e,t,i,s,r){let n=null;for(let o=this.verticesStart;o<this.verticesStart+this.verticesCount;o+=2){const h=t[o],l=t[o+1],c=e.intersectionSegment(h,l,s);if(!(c<0)&&(r||!n||c<n.distance)&&(n=new ua(null,null,c),n.faceId=o/2,r))break}return n}_intersectTriangles(e,t,i,s,r,n,o){let h=null,l=-1;for(let c=this.indexStart;c<this.indexStart+this.indexCount-(3-s);c+=s){l++;const u=i[c],f=i[c+1],d=i[c+2];if(r&&d===4294967295){c+=2;continue}const g=t[u],p=t[f],m=t[d];if(!g||!p||!m||o&&!o(g,p,m,e,u,f,d))continue;const A=e.intersectsTriangle(g,p,m);if(A){if(A.distance<0)continue;if((n||!h||A.distance<h.distance)&&(h=A,h.faceId=l,n))break}}return h}_intersectUnIndexedTriangles(e,t,i,s,r){let n=null;for(let o=this.verticesStart;o<this.verticesStart+this.verticesCount;o+=3){const h=t[o],l=t[o+1],c=t[o+2];if(r&&!r(h,l,c,e,-1,-1,-1))continue;const u=e.intersectsTriangle(h,l,c);if(u){if(u.distance<0)continue;if((s||!n||u.distance<n.distance)&&(n=u,n.faceId=o/3,s))break}}return n}_rebuild(){this._linesIndexBuffer&&(this._linesIndexBuffer=null)}clone(e,t){const i=new zt(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,e,t,!1);if(!this.IsGlobal){const s=this.getBoundingInfo();if(!s)return i;i._boundingInfo=new Lt(s.minimum,s.maximum)}return i}dispose(e=!1){this._linesIndexBuffer&&(this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer),this._linesIndexBuffer=null);const t=this._mesh.subMeshes.indexOf(this);this._mesh.subMeshes.splice(t,1),this.resetDrawCache(void 0,e)}getClassName(){return"SubMesh"}static CreateFromIndices(e,t,i,s,r,n=!0){let o=Number.MAX_VALUE,h=-Number.MAX_VALUE;const c=(r||s).getIndices();for(let u=t;u<t+i;u++){const f=c[u];f<o&&(o=f),f>h&&(h=f)}return new zt(e,o,h-o+1,t,i,s,r,n)}}class tn{}class ${constructor(){this.uniqueId=0,this.metadata={},this._applyTo=Ic(this._applyToCoroutine.bind(this)),this.uniqueId=$._UniqueIdGenerator,$._UniqueIdGenerator++}set(e,t){switch(e.length||w.Warn(`Setting vertex data kind '${t}' with an empty array`),t){case b.PositionKind:this.positions=e;break;case b.NormalKind:this.normals=e;break;case b.TangentKind:this.tangents=e;break;case b.UVKind:this.uvs=e;break;case b.UV2Kind:this.uvs2=e;break;case b.UV3Kind:this.uvs3=e;break;case b.UV4Kind:this.uvs4=e;break;case b.UV5Kind:this.uvs5=e;break;case b.UV6Kind:this.uvs6=e;break;case b.ColorKind:this.colors=e;break;case b.MatricesIndicesKind:this.matricesIndices=e;break;case b.MatricesWeightsKind:this.matricesWeights=e;break;case b.MatricesIndicesExtraKind:this.matricesIndicesExtra=e;break;case b.MatricesWeightsExtraKind:this.matricesWeightsExtra=e;break}}applyToMesh(e,t){return this._applyTo(e,t,!1),this}applyToGeometry(e,t){return this._applyTo(e,t,!1),this}updateMesh(e){return this._update(e),this}updateGeometry(e){return this._update(e),this}*_applyToCoroutine(e,t=!1,i){if(this.positions&&(e.setVerticesData(b.PositionKind,this.positions,t),i&&(yield)),this.normals&&(e.setVerticesData(b.NormalKind,this.normals,t),i&&(yield)),this.tangents&&(e.setVerticesData(b.TangentKind,this.tangents,t),i&&(yield)),this.uvs&&(e.setVerticesData(b.UVKind,this.uvs,t),i&&(yield)),this.uvs2&&(e.setVerticesData(b.UV2Kind,this.uvs2,t),i&&(yield)),this.uvs3&&(e.setVerticesData(b.UV3Kind,this.uvs3,t),i&&(yield)),this.uvs4&&(e.setVerticesData(b.UV4Kind,this.uvs4,t),i&&(yield)),this.uvs5&&(e.setVerticesData(b.UV5Kind,this.uvs5,t),i&&(yield)),this.uvs6&&(e.setVerticesData(b.UV6Kind,this.uvs6,t),i&&(yield)),this.colors){const s=this.positions&&this.colors.length===this.positions.length?3:4;e.setVerticesData(b.ColorKind,this.colors,t,s),this.hasVertexAlpha&&e.hasVertexAlpha!==void 0&&(e.hasVertexAlpha=!0),i&&(yield)}if(this.matricesIndices&&(e.setVerticesData(b.MatricesIndicesKind,this.matricesIndices,t),i&&(yield)),this.matricesWeights&&(e.setVerticesData(b.MatricesWeightsKind,this.matricesWeights,t),i&&(yield)),this.matricesIndicesExtra&&(e.setVerticesData(b.MatricesIndicesExtraKind,this.matricesIndicesExtra,t),i&&(yield)),this.matricesWeightsExtra&&(e.setVerticesData(b.MatricesWeightsExtraKind,this.matricesWeightsExtra,t),i&&(yield)),this.indices?(e.setIndices(this.indices,null,t),i&&(yield)):e.setIndices([],null),e.subMeshes&&this.materialInfos&&this.materialInfos.length>1){const s=e;s.subMeshes=[];for(const r of this.materialInfos)new zt(r.materialIndex,r.verticesStart,r.verticesCount,r.indexStart,r.indexCount,s)}return this}_update(e,t,i){return this.positions&&e.updateVerticesData(b.PositionKind,this.positions,t,i),this.normals&&e.updateVerticesData(b.NormalKind,this.normals,t,i),this.tangents&&e.updateVerticesData(b.TangentKind,this.tangents,t,i),this.uvs&&e.updateVerticesData(b.UVKind,this.uvs,t,i),this.uvs2&&e.updateVerticesData(b.UV2Kind,this.uvs2,t,i),this.uvs3&&e.updateVerticesData(b.UV3Kind,this.uvs3,t,i),this.uvs4&&e.updateVerticesData(b.UV4Kind,this.uvs4,t,i),this.uvs5&&e.updateVerticesData(b.UV5Kind,this.uvs5,t,i),this.uvs6&&e.updateVerticesData(b.UV6Kind,this.uvs6,t,i),this.colors&&e.updateVerticesData(b.ColorKind,this.colors,t,i),this.matricesIndices&&e.updateVerticesData(b.MatricesIndicesKind,this.matricesIndices,t,i),this.matricesWeights&&e.updateVerticesData(b.MatricesWeightsKind,this.matricesWeights,t,i),this.matricesIndicesExtra&&e.updateVerticesData(b.MatricesIndicesExtraKind,this.matricesIndicesExtra,t,i),this.matricesWeightsExtra&&e.updateVerticesData(b.MatricesWeightsExtraKind,this.matricesWeightsExtra,t,i),this.indices&&e.setIndices(this.indices,null),this}static _TransformVector3Coordinates(e,t,i=0,s=e.length){const r=v.Vector3[0],n=v.Vector3[1];for(let o=i;o<i+s;o+=3)_.FromArrayToRef(e,o,r),_.TransformCoordinatesToRef(r,t,n),e[o]=n.x,e[o+1]=n.y,e[o+2]=n.z}static _TransformVector3Normals(e,t,i=0,s=e.length){const r=v.Vector3[0],n=v.Vector3[1];for(let o=i;o<i+s;o+=3)_.FromArrayToRef(e,o,r),_.TransformNormalToRef(r,t,n),e[o]=n.x,e[o+1]=n.y,e[o+2]=n.z}static _TransformVector4Normals(e,t,i=0,s=e.length){const r=v.Vector4[0],n=v.Vector4[1];for(let o=i;o<i+s;o+=4)ge.FromArrayToRef(e,o,r),ge.TransformNormalToRef(r,t,n),e[o]=n.x,e[o+1]=n.y,e[o+2]=n.z,e[o+3]=n.w}static _FlipFaces(e,t=0,i=e.length){for(let s=t;s<t+i;s+=3){const r=e[s+1];e[s+1]=e[s+2],e[s+2]=r}}transform(e){const t=e.determinant()<0;return this.positions&&$._TransformVector3Coordinates(this.positions,e),this.normals&&$._TransformVector3Normals(this.normals,e),this.tangents&&$._TransformVector4Normals(this.tangents,e),t&&this.indices&&$._FlipFaces(this.indices),this}splitBasedOnMaterialID(){if(!this.materialInfos||this.materialInfos.length<2)return[this];const e=[];for(const t of this.materialInfos){const i=new $;if(this.positions&&(i.positions=this.positions.slice(t.verticesStart*3,(t.verticesCount+t.verticesStart)*3)),this.normals&&(i.normals=this.normals.slice(t.verticesStart*3,(t.verticesCount+t.verticesStart)*3)),this.tangents&&(i.tangents=this.tangents.slice(t.verticesStart*4,(t.verticesCount+t.verticesStart)*4)),this.colors&&(i.colors=this.colors.slice(t.verticesStart*4,(t.verticesCount+t.verticesStart)*4)),this.uvs&&(i.uvs=this.uvs.slice(t.verticesStart*2,(t.verticesCount+t.verticesStart)*2)),this.uvs2&&(i.uvs2=this.uvs2.slice(t.verticesStart*2,(t.verticesCount+t.verticesStart)*2)),this.uvs3&&(i.uvs3=this.uvs3.slice(t.verticesStart*2,(t.verticesCount+t.verticesStart)*2)),this.uvs4&&(i.uvs4=this.uvs4.slice(t.verticesStart*2,(t.verticesCount+t.verticesStart)*2)),this.uvs5&&(i.uvs5=this.uvs5.slice(t.verticesStart*2,(t.verticesCount+t.verticesStart)*2)),this.uvs6&&(i.uvs6=this.uvs6.slice(t.verticesStart*2,(t.verticesCount+t.verticesStart)*2)),this.matricesIndices&&(i.matricesIndices=this.matricesIndices.slice(t.verticesStart*4,(t.verticesCount+t.verticesStart)*4)),this.matricesIndicesExtra&&(i.matricesIndicesExtra=this.matricesIndicesExtra.slice(t.verticesStart*4,(t.verticesCount+t.verticesStart)*4)),this.matricesWeights&&(i.matricesWeights=this.matricesWeights.slice(t.verticesStart*4,(t.verticesCount+t.verticesStart)*4)),this.matricesWeightsExtra&&(i.matricesWeightsExtra=this.matricesWeightsExtra.slice(t.verticesStart*4,(t.verticesCount+t.verticesStart)*4)),this.indices){i.indices=[];for(let r=t.indexStart;r<t.indexStart+t.indexCount;r++)i.indices.push(this.indices[r]-t.verticesStart)}const s=new tn;s.indexStart=0,s.indexCount=i.indices?i.indices.length:0,s.materialIndex=t.materialIndex,s.verticesStart=0,s.verticesCount=(i.positions?i.positions.length:0)/3,i.materialInfos=[s],e.push(i)}return e}merge(e,t=!1,i=!1,s=!1,r=!1){const n=Array.isArray(e)?e.map(o=>({vertexData:o})):[{vertexData:e}];return Un(this._mergeCoroutine(void 0,n,t,!1,i,s,r))}*_mergeCoroutine(e,t,i=!1,s,r,n=!1,o=!1){this._validate();let h=t.map(d=>d.vertexData),l=this;if(o)for(const d of h)d&&(d._validate(),!this.normals&&d.normals&&(this.normals=new Float32Array(this.positions.length)),!this.tangents&&d.tangents&&(this.tangents=new Float32Array(this.positions.length/3*4)),!this.uvs&&d.uvs&&(this.uvs=new Float32Array(this.positions.length/3*2)),!this.uvs2&&d.uvs2&&(this.uvs2=new Float32Array(this.positions.length/3*2)),!this.uvs3&&d.uvs3&&(this.uvs3=new Float32Array(this.positions.length/3*2)),!this.uvs4&&d.uvs4&&(this.uvs4=new Float32Array(this.positions.length/3*2)),!this.uvs5&&d.uvs5&&(this.uvs5=new Float32Array(this.positions.length/3*2)),!this.uvs6&&d.uvs6&&(this.uvs6=new Float32Array(this.positions.length/3*2)),!this.colors&&d.colors&&(this.colors=new Float32Array(this.positions.length/3*4),this.colors.fill(1)),!this.matricesIndices&&d.matricesIndices&&(this.matricesIndices=new Float32Array(this.positions.length/3*4)),!this.matricesWeights&&d.matricesWeights&&(this.matricesWeights=new Float32Array(this.positions.length/3*4)),!this.matricesIndicesExtra&&d.matricesIndicesExtra&&(this.matricesIndicesExtra=new Float32Array(this.positions.length/3*4)),!this.matricesWeightsExtra&&d.matricesWeightsExtra&&(this.matricesWeightsExtra=new Float32Array(this.positions.length/3*4)));for(const d of h)if(d){if(o)this.normals&&!d.normals&&(d.normals=new Float32Array(d.positions.length)),this.tangents&&!d.tangents&&(d.tangents=new Float32Array(d.positions.length/3*4)),this.uvs&&!d.uvs&&(d.uvs=new Float32Array(d.positions.length/3*2)),this.uvs2&&!d.uvs2&&(d.uvs2=new Float32Array(d.positions.length/3*2)),this.uvs3&&!d.uvs3&&(d.uvs3=new Float32Array(d.positions.length/3*2)),this.uvs4&&!d.uvs4&&(d.uvs4=new Float32Array(d.positions.length/3*2)),this.uvs5&&!d.uvs5&&(d.uvs5=new Float32Array(d.positions.length/3*2)),this.uvs6&&!d.uvs6&&(d.uvs6=new Float32Array(d.positions.length/3*2)),this.colors&&!d.colors&&(d.colors=new Float32Array(d.positions.length/3*4),d.colors.fill(1)),this.matricesIndices&&!d.matricesIndices&&(d.matricesIndices=new Float32Array(d.positions.length/3*4)),this.matricesWeights&&!d.matricesWeights&&(d.matricesWeights=new Float32Array(d.positions.length/3*4)),this.matricesIndicesExtra&&!d.matricesIndicesExtra&&(d.matricesIndicesExtra=new Float32Array(d.positions.length/3*4)),this.matricesWeightsExtra&&!d.matricesWeightsExtra&&(d.matricesWeightsExtra=new Float32Array(d.positions.length/3*4));else if(d._validate(),!this.normals!=!d.normals||!this.tangents!=!d.tangents||!this.uvs!=!d.uvs||!this.uvs2!=!d.uvs2||!this.uvs3!=!d.uvs3||!this.uvs4!=!d.uvs4||!this.uvs5!=!d.uvs5||!this.uvs6!=!d.uvs6||!this.colors!=!d.colors||!this.matricesIndices!=!d.matricesIndices||!this.matricesWeights!=!d.matricesWeights||!this.matricesIndicesExtra!=!d.matricesIndicesExtra||!this.matricesWeightsExtra!=!d.matricesWeightsExtra)throw new Error("Cannot merge vertex data that do not have the same set of attributes")}if(n){let d=0,g=0,p=0;const m=[];let A=null;const E=[];for(const M of this.splitBasedOnMaterialID())E.push({vertexData:M,transform:e});for(const M of t)if(M.vertexData)for(const C of M.vertexData.splitBasedOnMaterialID())E.push({vertexData:C,transform:M.transform});E.sort((M,C)=>{const x=M.vertexData.materialInfos?M.vertexData.materialInfos[0].materialIndex:0,S=C.vertexData.materialInfos?C.vertexData.materialInfos[0].materialIndex:0;return x>S?1:x===S?0:-1});for(const M of E){const C=M.vertexData;if(C.materialInfos?d=C.materialInfos[0].materialIndex:d=0,A&&A.materialIndex===d)A.indexCount+=C.indices.length,A.verticesCount+=C.positions.length/3;else{const x=new tn;x.materialIndex=d,x.indexStart=g,x.indexCount=C.indices.length,x.verticesStart=p,x.verticesCount=C.positions.length/3,m.push(x),A=x}g+=C.indices.length,p+=C.positions.length/3}const I=E.splice(0,1)[0];l=I.vertexData,e=I.transform,h=E.map(M=>M.vertexData),t=E,this.materialInfos=m}const c=h.reduce((d,g)=>d+(g.indices?.length??0),l.indices?.length??0);let f=r||h.some(d=>d.indices===l.indices)?l.indices?.slice():l.indices;if(c>0){let d=f?.length??0;if(f||(f=new Array(c)),f.length!==c){if(Array.isArray(f))f.length=c;else{const p=i||f instanceof Uint32Array?new Uint32Array(c):new Uint16Array(c);p.set(f),f=p}e&&e.determinant()<0&&$._FlipFaces(f,0,d)}let g=l.positions?l.positions.length/3:0;for(const{vertexData:p,transform:m}of t)if(p.indices){for(let A=0;A<p.indices.length;A++)f[d+A]=p.indices[A]+g;m&&m.determinant()<0&&$._FlipFaces(f,d,p.indices.length),g+=p.positions.length/3,d+=p.indices.length,s&&(yield)}}return this.indices=f,this.positions=$._MergeElement(b.PositionKind,l.positions,e,t.map(d=>[d.vertexData.positions,d.transform])),s&&(yield),l.normals&&(this.normals=$._MergeElement(b.NormalKind,l.normals,e,t.map(d=>[d.vertexData.normals,d.transform])),s&&(yield)),l.tangents&&(this.tangents=$._MergeElement(b.TangentKind,l.tangents,e,t.map(d=>[d.vertexData.tangents,d.transform])),s&&(yield)),l.uvs&&(this.uvs=$._MergeElement(b.UVKind,l.uvs,e,t.map(d=>[d.vertexData.uvs,d.transform])),s&&(yield)),l.uvs2&&(this.uvs2=$._MergeElement(b.UV2Kind,l.uvs2,e,t.map(d=>[d.vertexData.uvs2,d.transform])),s&&(yield)),l.uvs3&&(this.uvs3=$._MergeElement(b.UV3Kind,l.uvs3,e,t.map(d=>[d.vertexData.uvs3,d.transform])),s&&(yield)),l.uvs4&&(this.uvs4=$._MergeElement(b.UV4Kind,l.uvs4,e,t.map(d=>[d.vertexData.uvs4,d.transform])),s&&(yield)),l.uvs5&&(this.uvs5=$._MergeElement(b.UV5Kind,l.uvs5,e,t.map(d=>[d.vertexData.uvs5,d.transform])),s&&(yield)),l.uvs6&&(this.uvs6=$._MergeElement(b.UV6Kind,l.uvs6,e,t.map(d=>[d.vertexData.uvs6,d.transform])),s&&(yield)),l.colors&&(this.colors=$._MergeElement(b.ColorKind,l.colors,e,t.map(d=>[d.vertexData.colors,d.transform])),(l.hasVertexAlpha!==void 0||t.some(d=>d.vertexData.hasVertexAlpha!==void 0))&&(this.hasVertexAlpha=l.hasVertexAlpha||t.some(d=>d.vertexData.hasVertexAlpha)),s&&(yield)),l.matricesIndices&&(this.matricesIndices=$._MergeElement(b.MatricesIndicesKind,l.matricesIndices,e,t.map(d=>[d.vertexData.matricesIndices,d.transform])),s&&(yield)),l.matricesWeights&&(this.matricesWeights=$._MergeElement(b.MatricesWeightsKind,l.matricesWeights,e,t.map(d=>[d.vertexData.matricesWeights,d.transform])),s&&(yield)),l.matricesIndicesExtra&&(this.matricesIndicesExtra=$._MergeElement(b.MatricesIndicesExtraKind,l.matricesIndicesExtra,e,t.map(d=>[d.vertexData.matricesIndicesExtra,d.transform])),s&&(yield)),l.matricesWeightsExtra&&(this.matricesWeightsExtra=$._MergeElement(b.MatricesWeightsExtraKind,l.matricesWeightsExtra,e,t.map(d=>[d.vertexData.matricesWeightsExtra,d.transform]))),this}static _MergeElement(e,t,i,s){const r=s.filter(h=>h[0]!==null&&h[0]!==void 0);if(!t&&r.length==0)return t;if(!t)return this._MergeElement(e,r[0][0],r[0][1],r.slice(1));const n=r.reduce((h,l)=>h+l[0].length,t.length),o=e===b.PositionKind?$._TransformVector3Coordinates:e===b.NormalKind?$._TransformVector3Normals:e===b.TangentKind?$._TransformVector4Normals:()=>{};if(t instanceof Float32Array){const h=new Float32Array(n);h.set(t),i&&o(h,i,0,t.length);let l=t.length;for(const[c,u]of r)h.set(c,l),u&&o(h,u,l,c.length),l+=c.length;return h}else{const h=new Array(n);for(let c=0;c<t.length;c++)h[c]=t[c];i&&o(h,i,0,t.length);let l=t.length;for(const[c,u]of r){for(let f=0;f<c.length;f++)h[l+f]=c[f];u&&o(h,u,l,c.length),l+=c.length}return h}}_validate(){if(!this.positions)throw new Li("Positions are required",xs.MeshInvalidPositionsError);const e=(s,r)=>{const n=b.DeduceStride(s);if(r.length%n!==0)throw new Error("The "+s+"s array count must be a multiple of "+n);return r.length/n},t=e(b.PositionKind,this.positions),i=(s,r)=>{const n=e(s,r);if(n!==t)throw new Error("The "+s+"s element count ("+n+") does not match the positions count ("+t+")")};this.normals&&i(b.NormalKind,this.normals),this.tangents&&i(b.TangentKind,this.tangents),this.uvs&&i(b.UVKind,this.uvs),this.uvs2&&i(b.UV2Kind,this.uvs2),this.uvs3&&i(b.UV3Kind,this.uvs3),this.uvs4&&i(b.UV4Kind,this.uvs4),this.uvs5&&i(b.UV5Kind,this.uvs5),this.uvs6&&i(b.UV6Kind,this.uvs6),this.colors&&i(b.ColorKind,this.colors),this.matricesIndices&&i(b.MatricesIndicesKind,this.matricesIndices),this.matricesWeights&&i(b.MatricesWeightsKind,this.matricesWeights),this.matricesIndicesExtra&&i(b.MatricesIndicesExtraKind,this.matricesIndicesExtra),this.matricesWeightsExtra&&i(b.MatricesWeightsExtraKind,this.matricesWeightsExtra)}clone(){const e=this.serialize();return $.Parse(e)}serialize(){const e={};if(this.positions&&(e.positions=Array.from(this.positions)),this.normals&&(e.normals=Array.from(this.normals)),this.tangents&&(e.tangents=Array.from(this.tangents)),this.uvs&&(e.uvs=Array.from(this.uvs)),this.uvs2&&(e.uvs2=Array.from(this.uvs2)),this.uvs3&&(e.uvs3=Array.from(this.uvs3)),this.uvs4&&(e.uvs4=Array.from(this.uvs4)),this.uvs5&&(e.uvs5=Array.from(this.uvs5)),this.uvs6&&(e.uvs6=Array.from(this.uvs6)),this.colors&&(e.colors=Array.from(this.colors),e.hasVertexAlpha=this.hasVertexAlpha),this.matricesIndices&&(e.matricesIndices=Array.from(this.matricesIndices),e.matricesIndicesExpanded=!0),this.matricesWeights&&(e.matricesWeights=Array.from(this.matricesWeights)),this.matricesIndicesExtra&&(e.matricesIndicesExtra=Array.from(this.matricesIndicesExtra),e.matricesIndicesExtraExpanded=!0),this.matricesWeightsExtra&&(e.matricesWeightsExtra=Array.from(this.matricesWeightsExtra)),e.indices=this.indices?Array.from(this.indices):[],this.materialInfos){e.materialInfos=[];for(const t of this.materialInfos){const i={indexStart:t.indexStart,indexCount:t.indexCount,materialIndex:t.materialIndex,verticesStart:t.verticesStart,verticesCount:t.verticesCount};e.materialInfos.push(i)}}return e}static ExtractFromMesh(e,t,i){return $._ExtractFrom(e,t,i)}static ExtractFromGeometry(e,t,i){return $._ExtractFrom(e,t,i)}static _ExtractFrom(e,t,i){const s=new $;if(e.isVerticesDataPresent(b.PositionKind)&&(s.positions=e.getVerticesData(b.PositionKind,t,i)),e.isVerticesDataPresent(b.NormalKind)&&(s.normals=e.getVerticesData(b.NormalKind,t,i)),e.isVerticesDataPresent(b.TangentKind)&&(s.tangents=e.getVerticesData(b.TangentKind,t,i)),e.isVerticesDataPresent(b.UVKind)&&(s.uvs=e.getVerticesData(b.UVKind,t,i)),e.isVerticesDataPresent(b.UV2Kind)&&(s.uvs2=e.getVerticesData(b.UV2Kind,t,i)),e.isVerticesDataPresent(b.UV3Kind)&&(s.uvs3=e.getVerticesData(b.UV3Kind,t,i)),e.isVerticesDataPresent(b.UV4Kind)&&(s.uvs4=e.getVerticesData(b.UV4Kind,t,i)),e.isVerticesDataPresent(b.UV5Kind)&&(s.uvs5=e.getVerticesData(b.UV5Kind,t,i)),e.isVerticesDataPresent(b.UV6Kind)&&(s.uvs6=e.getVerticesData(b.UV6Kind,t,i)),e.isVerticesDataPresent(b.ColorKind)){const r=e.geometry||e,n=r.getVertexBuffer(b.ColorKind),o=r.getVerticesData(b.ColorKind,t,i);if(n.getSize()===3){const h=new Float32Array(o.length*4/3);for(let l=0,c=0;l<o.length;l+=3,c+=4)h[c]=o[l],h[c+1]=o[l+1],h[c+2]=o[l+2],h[c+3]=1;s.colors=h}else if(n.getSize()===4)s.colors=o;else throw new Error(`Unexpected number of color components: ${n.getSize()}`)}return e.isVerticesDataPresent(b.MatricesIndicesKind)&&(s.matricesIndices=e.getVerticesData(b.MatricesIndicesKind,t,i)),e.isVerticesDataPresent(b.MatricesWeightsKind)&&(s.matricesWeights=e.getVerticesData(b.MatricesWeightsKind,t,i)),e.isVerticesDataPresent(b.MatricesIndicesExtraKind)&&(s.matricesIndicesExtra=e.getVerticesData(b.MatricesIndicesExtraKind,t,i)),e.isVerticesDataPresent(b.MatricesWeightsExtraKind)&&(s.matricesWeightsExtra=e.getVerticesData(b.MatricesWeightsExtraKind,t,i)),s.indices=e.getIndices(t,i),s}static CreateRibbon(e){throw ie("ribbonBuilder")}static CreateBox(e){throw ie("boxBuilder")}static CreateTiledBox(e){throw ie("tiledBoxBuilder")}static CreateTiledPlane(e){throw ie("tiledPlaneBuilder")}static CreateSphere(e){throw ie("sphereBuilder")}static CreateCylinder(e){throw ie("cylinderBuilder")}static CreateTorus(e){throw ie("torusBuilder")}static CreateLineSystem(e){throw ie("linesBuilder")}static CreateDashedLines(e){throw ie("linesBuilder")}static CreateGround(e){throw ie("groundBuilder")}static CreateTiledGround(e){throw ie("groundBuilder")}static CreateGroundFromHeightMap(e){throw ie("groundBuilder")}static CreatePlane(e){throw ie("planeBuilder")}static CreateDisc(e){throw ie("discBuilder")}static CreatePolygon(e,t,i,s,r,n,o){throw ie("polygonBuilder")}static CreateIcoSphere(e){throw ie("icoSphereBuilder")}static CreatePolyhedron(e){throw ie("polyhedronBuilder")}static CreateCapsule(e={orientation:_.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6}){throw ie("capsuleBuilder")}static CreateTorusKnot(e){throw ie("torusKnotBuilder")}static ComputeNormals(e,t,i,s){let r=0,n=0,o=0,h=0,l=0,c=0,u=0,f=0,d=0,g=0,p=0,m=0,A=0,E=0,I=0,M=0,C=0,x=0,S=0,L=0,N=!1,D=!1,Re=!1,pe=!1,ce=1,oe=0,Ye=null;s&&(N=!!s.facetNormals,D=!!s.facetPositions,Re=!!s.facetPartitioning,ce=s.useRightHandedSystem===!0?-1:1,oe=s.ratio||0,pe=!!s.depthSort,Ye=s.distanceTo,pe&&Ye===void 0&&(Ye=_.Zero()));let Qe=0,ft=0,de=0,Fe=0;for(Re&&s&&s.bbSize&&(Qe=s.subDiv.X*oe/s.bbSize.x,ft=s.subDiv.Y*oe/s.bbSize.y,de=s.subDiv.Z*oe/s.bbSize.z,Fe=s.subDiv.max*s.subDiv.max,s.facetPartitioning.length=0),r=0;r<e.length;r++)i[r]=0;const we=t.length/3|0;for(r=0;r<we;r++){if(m=t[r*3]*3,A=m+1,E=m+2,I=t[r*3+1]*3,M=I+1,C=I+2,x=t[r*3+2]*3,S=x+1,L=x+2,n=e[m]-e[I],o=e[A]-e[M],h=e[E]-e[C],l=e[x]-e[I],c=e[S]-e[M],u=e[L]-e[C],f=ce*(o*u-h*c),d=ce*(h*l-n*u),g=ce*(n*c-o*l),p=Math.sqrt(f*f+d*d+g*g),p=p===0?1:p,f/=p,d/=p,g/=p,N&&s&&(s.facetNormals[r].x=f,s.facetNormals[r].y=d,s.facetNormals[r].z=g),D&&s&&(s.facetPositions[r].x=(e[m]+e[I]+e[x])/3,s.facetPositions[r].y=(e[A]+e[M]+e[S])/3,s.facetPositions[r].z=(e[E]+e[C]+e[L])/3),Re&&s){const $e=Math.floor((s.facetPositions[r].x-s.bInfo.minimum.x*oe)*Qe),at=Math.floor((s.facetPositions[r].y-s.bInfo.minimum.y*oe)*ft),ke=Math.floor((s.facetPositions[r].z-s.bInfo.minimum.z*oe)*de),Ni=Math.floor((e[m]-s.bInfo.minimum.x*oe)*Qe),Ui=Math.floor((e[A]-s.bInfo.minimum.y*oe)*ft),ki=Math.floor((e[E]-s.bInfo.minimum.z*oe)*de),Cs=Math.floor((e[I]-s.bInfo.minimum.x*oe)*Qe),Ze=Math.floor((e[M]-s.bInfo.minimum.y*oe)*ft),Gi=Math.floor((e[C]-s.bInfo.minimum.z*oe)*de),Hi=Math.floor((e[x]-s.bInfo.minimum.x*oe)*Qe),Vi=Math.floor((e[S]-s.bInfo.minimum.y*oe)*ft),zi=Math.floor((e[L]-s.bInfo.minimum.z*oe)*de),ci=Ni+s.subDiv.max*Ui+Fe*ki,ui=Cs+s.subDiv.max*Ze+Fe*Gi,di=Hi+s.subDiv.max*Vi+Fe*zi,fi=$e+s.subDiv.max*at+Fe*ke;s.facetPartitioning[fi]=s.facetPartitioning[fi]?s.facetPartitioning[fi]:[],s.facetPartitioning[ci]=s.facetPartitioning[ci]?s.facetPartitioning[ci]:[],s.facetPartitioning[ui]=s.facetPartitioning[ui]?s.facetPartitioning[ui]:[],s.facetPartitioning[di]=s.facetPartitioning[di]?s.facetPartitioning[di]:[],s.facetPartitioning[ci].push(r),ui!=ci&&s.facetPartitioning[ui].push(r),di==ui||di==ci||s.facetPartitioning[di].push(r),fi==ci||fi==ui||fi==di||s.facetPartitioning[fi].push(r)}if(pe&&s&&s.facetPositions){const $e=s.depthSortedFacets[r];$e.ind=r*3,$e.sqDistance=_.DistanceSquared(s.facetPositions[r],Ye)}i[m]+=f,i[A]+=d,i[E]+=g,i[I]+=f,i[M]+=d,i[C]+=g,i[x]+=f,i[S]+=d,i[L]+=g}for(r=0;r<i.length/3;r++)f=i[r*3],d=i[r*3+1],g=i[r*3+2],p=Math.sqrt(f*f+d*d+g*g),p=p===0?1:p,f/=p,d/=p,g/=p,i[r*3]=f,i[r*3+1]=d,i[r*3+2]=g}static _ComputeSides(e,t,i,s,r,n,o){const h=i.length,l=s.length;let c,u;switch(e=e||$.DEFAULTSIDE,e){case $.FRONTSIDE:break;case $.BACKSIDE:for(c=0;c<h;c+=3){const f=i[c];i[c]=i[c+2],i[c+2]=f}for(u=0;u<l;u++)s[u]=-s[u];break;case $.DOUBLESIDE:{const f=t.length,d=f/3;for(let m=0;m<f;m++)t[f+m]=t[m];for(c=0;c<h;c+=3)i[c+h]=i[c+2]+d,i[c+1+h]=i[c+1]+d,i[c+2+h]=i[c]+d;for(u=0;u<l;u++)s[l+u]=-s[u];const g=r.length;let p=0;for(p=0;p<g;p++)r[p+g]=r[p];for(n=n||new ge(0,0,1,1),o=o||new ge(0,0,1,1),p=0,c=0;c<g/2;c++)r[p]=n.x+(n.z-n.x)*r[p],r[p+1]=n.y+(n.w-n.y)*r[p+1],r[p+g]=o.x+(o.z-o.x)*r[p+g],r[p+g+1]=o.y+(o.w-o.y)*r[p+g+1],p+=2;break}}}static Parse(e){const t=new $,i=e.positions;i&&t.set(i,b.PositionKind);const s=e.normals;s&&t.set(s,b.NormalKind);const r=e.tangents;r&&t.set(r,b.TangentKind);const n=e.uvs;n&&t.set(n,b.UVKind);const o=e.uvs2;o&&t.set(o,b.UV2Kind);const h=e.uvs3;h&&t.set(h,b.UV3Kind);const l=e.uvs4;l&&t.set(l,b.UV4Kind);const c=e.uvs5;c&&t.set(c,b.UV5Kind);const u=e.uvs6;u&&t.set(u,b.UV6Kind);const f=e.colors;f&&(t.set(fe.CheckColors4(f,i.length/3),b.ColorKind),e.hasVertexAlpha!==void 0&&(t.hasVertexAlpha=e.hasVertexAlpha));const d=e.matricesIndices;d&&t.set(d,b.MatricesIndicesKind);const g=e.matricesWeights;g&&t.set(g,b.MatricesWeightsKind);const p=e.indices;p&&(t.indices=p);const m=e.materialInfos;if(m){t.materialInfos=[];for(const A of m){const E=new tn;E.indexCount=A.indexCount,E.indexStart=A.indexStart,E.verticesCount=A.verticesCount,E.verticesStart=A.verticesStart,E.materialIndex=A.materialIndex,t.materialInfos.push(E)}}return t}static ImportVertexData(e,t){const i=$.Parse(e);t.setAllVerticesData(i,e.updatable)}}$.FRONTSIDE=0;$.BACKSIDE=1;$.DOUBLESIDE=2;$.DEFAULTSIDE=0;$._UniqueIdGenerator=0;T([yi.filter((...[a])=>!Array.isArray(a))],$,"_TransformVector3Coordinates",null);T([yi.filter((...[a])=>!Array.isArray(a))],$,"_TransformVector3Normals",null);T([yi.filter((...[a])=>!Array.isArray(a))],$,"_TransformVector4Normals",null);T([yi.filter((...[a])=>!Array.isArray(a))],$,"_FlipFaces",null);class xt{static get ForceFullSceneLoadingForIncremental(){return xt._ForceFullSceneLoadingForIncremental}static set ForceFullSceneLoadingForIncremental(e){xt._ForceFullSceneLoadingForIncremental=e}static get ShowLoadingScreen(){return xt._ShowLoadingScreen}static set ShowLoadingScreen(e){xt._ShowLoadingScreen=e}static get loggingLevel(){return xt._LoggingLevel}static set loggingLevel(e){xt._LoggingLevel=e}static get CleanBoneMatrixWeights(){return xt._CleanBoneMatrixWeights}static set CleanBoneMatrixWeights(e){xt._CleanBoneMatrixWeights=e}}xt._ForceFullSceneLoadingForIncremental=!1;xt._ShowLoadingScreen=!0;xt._CleanBoneMatrixWeights=!1;xt._LoggingLevel=0;class Tt{get boundingBias(){return this._boundingBias}set boundingBias(e){this._boundingBias?this._boundingBias.copyFrom(e):this._boundingBias=e.clone(),this._updateBoundingInfo(!0,null)}static CreateGeometryForMesh(e){const t=new Tt(Tt.RandomId(),e.getScene());return t.applyToMesh(e),t}get meshes(){return this._meshes}constructor(e,t,i,s=!1,r=null,n=null){this.delayLoadState=0,this._totalVertices=0,this._isDisposed=!1,this._extend={minimum:new _(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),maximum:new _(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},this._indexBufferIsUpdatable=!1,this._positionsCache=[],this._parentContainer=null,this.useBoundingInfoFromGeometry=!1,this._scene=t||Te.LastCreatedScene,this._scene&&(this.id=e,this.uniqueId=this._scene.getUniqueId(),this._engine=this._scene.getEngine(),this._meshes=[],this._vertexBuffers={},this._indices=[],this._updatable=s,n!==null&&(this._totalVertices=n),i?this.setAllVerticesData(i,s):n===null&&(this._totalVertices=0),this._engine.getCaps().vertexArrayObject&&(this._vertexArrayObjects={}),r&&(this.applyToMesh(r),r.computeWorldMatrix(!0)))}get extend(){return this._extend}getScene(){return this._scene}getEngine(){return this._engine}isReady(){return this.delayLoadState===1||this.delayLoadState===0}get doNotSerialize(){for(let e=0;e<this._meshes.length;e++)if(!this._meshes[e].doNotSerialize)return!1;return!0}_rebuild(){this._vertexArrayObjects&&(this._vertexArrayObjects={}),this._meshes.length!==0&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,this._updatable,"Geometry_"+this.id+"_IndexBuffer"));const e=new Set;for(const t in this._vertexBuffers)e.add(this._vertexBuffers[t].getWrapperBuffer());e.forEach(t=>{t._rebuild()})}setAllVerticesData(e,t){e.applyToGeometry(this,t),this._notifyUpdate()}setVerticesData(e,t,i=!1,s){i&&Array.isArray(t)&&(t=new Float32Array(t));const r=new b(this._engine,t,e,{updatable:i,postponeInternalCreation:this._meshes.length===0,stride:s,label:"Geometry_"+this.id+"_"+e});this.setVerticesBuffer(r)}removeVerticesData(e){this._vertexBuffers[e]&&(this._vertexBuffers[e].dispose(),delete this._vertexBuffers[e]),this._vertexArrayObjects&&this._disposeVertexArrayObjects()}setVerticesBuffer(e,t=null,i=!0){const s=e.getKind();this._vertexBuffers[s]&&i&&this._vertexBuffers[s].dispose(),e._buffer&&e._ownsBuffer&&e._buffer._increaseReferences(),this._vertexBuffers[s]=e;const r=this._meshes,n=r.length;if(s===b.PositionKind){this._totalVertices=t??e._maxVerticesCount,this._updateExtend(this.useBoundingInfoFromGeometry&&this._boundingInfo?null:e.getFloatData(this._totalVertices)),this._resetPointsArrayCache();const o=this._extend&&this._extend.minimum||new _(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),h=this._extend&&this._extend.maximum||new _(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);for(let l=0;l<n;l++){const c=r[l];c.buildBoundingInfo(o,h),c._createGlobalSubMesh(c.isUnIndexed),c.computeWorldMatrix(!0),c.synchronizeInstances()}}this._notifyUpdate(s)}updateVerticesDataDirectly(e,t,i,s=!1){const r=this.getVertexBuffer(e);r&&(r.updateDirectly(t,i,s),this._notifyUpdate(e))}updateVerticesData(e,t,i=!1){const s=this.getVertexBuffer(e);s&&(s.update(t),e===b.PositionKind&&this._updateBoundingInfo(i,t),this._notifyUpdate(e))}_updateBoundingInfo(e,t){if(e&&this._updateExtend(t),this._resetPointsArrayCache(),e){const i=this._meshes;for(const s of i){s.hasBoundingInfo?s.getBoundingInfo().reConstruct(this._extend.minimum,this._extend.maximum):s.buildBoundingInfo(this._extend.minimum,this._extend.maximum);const r=s.subMeshes;for(const n of r)n.refreshBoundingInfo()}}}_bind(e,t,i,s){if(!e)return;t===void 0&&(t=this._indexBuffer);const r=this.getVertexBuffers();if(!r)return;if(t!=this._indexBuffer||!this._vertexArrayObjects&&!s){this._engine.bindBuffers(r,t,e,i);return}const n=s||this._vertexArrayObjects,o=this._engine;n[e.key]||(n[e.key]=o.recordVertexArrayObject(r,t,e,i)),o.bindVertexArrayObject(n[e.key],t)}getTotalVertices(){return this.isReady()?this._totalVertices:0}getVerticesData(e,t,i){const s=this.getVertexBuffer(e);return s?s.getFloatData(this._totalVertices,i||t&&this._meshes.length!==1):null}copyVerticesData(e,t){const i=this.getVertexBuffer(e);if(!i)return;t[e]||(t[e]=new Float32Array(this._totalVertices*i.getSize()));const s=i.getData();s&&Fc(s,i.getSize(),i.type,i.byteOffset,i.byteStride,i.normalized,this._totalVertices,t[e])}isVertexBufferUpdatable(e){const t=this._vertexBuffers[e];return t?t.isUpdatable():!1}getVertexBuffer(e){return this.isReady()?this._vertexBuffers[e]:null}getVertexBuffers(){return this.isReady()?this._vertexBuffers:null}isVerticesDataPresent(e){return this._vertexBuffers?this._vertexBuffers[e]!==void 0:this._delayInfo?this._delayInfo.indexOf(e)!==-1:!1}getVerticesDataKinds(){const e=[];let t;if(!this._vertexBuffers&&this._delayInfo)for(t in this._delayInfo)e.push(t);else for(t in this._vertexBuffers)e.push(t);return e}updateIndices(e,t,i=!1){if(this._indexBuffer)if(!this._indexBufferIsUpdatable)this.setIndices(e,null,!0);else{const s=e.length!==this._indices.length;if(i||(this._indices=e.slice()),this._engine.updateDynamicIndexBuffer(this._indexBuffer,e,t),s)for(const r of this._meshes)r._createGlobalSubMesh(!0)}}setIndexBuffer(e,t,i,s=null){this._indices=[],this._indexBufferIsUpdatable=!1,this._indexBuffer=e,this._totalVertices=t,this._totalIndices=i,s===null?e.is32Bits=t>65535:e.is32Bits=s;for(const r of this._meshes)r._createGlobalSubMesh(!0),r.synchronizeInstances();this._notifyUpdate()}setIndices(e,t=null,i=!1,s=!1){this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indices=e,this._indexBufferIsUpdatable=i,this._meshes.length!==0&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,i,"Geometry_"+this.id+"_IndexBuffer")),t!=null&&(this._totalVertices=t);for(const r of this._meshes)r._createGlobalSubMesh(!s),r.synchronizeInstances();this._notifyUpdate()}getTotalIndices(){return this.isReady()?this._totalIndices!==void 0?this._totalIndices:this._indices.length:0}getIndices(e,t){if(!this.isReady())return null;const i=this._indices;return!t&&(!e||this._meshes.length===1)?i:i.slice()}getIndexBuffer(){return this.isReady()?this._indexBuffer:null}_releaseVertexArrayObject(e=null){!e||!this._vertexArrayObjects||this._vertexArrayObjects[e.key]&&(this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e.key]),delete this._vertexArrayObjects[e.key])}releaseForMesh(e,t){const i=this._meshes,s=i.indexOf(e);s!==-1&&(i.splice(s,1),this._vertexArrayObjects&&e._invalidateInstanceVertexArrayObject(),e._geometry=null,i.length===0&&t&&this.dispose())}applyToMesh(e){if(e._geometry===this)return;const t=e._geometry;t&&t.releaseForMesh(e),this._vertexArrayObjects&&e._invalidateInstanceVertexArrayObject();const i=this._meshes;e._geometry=this,e._internalAbstractMeshDataInfo._positions=null,this._scene.pushGeometry(this),i.push(e),this.isReady()?this._applyToMesh(e):this._boundingInfo&&e.setBoundingInfo(this._boundingInfo)}_updateExtend(e=null){if(this.useBoundingInfoFromGeometry&&this._boundingInfo)this._extend={minimum:this._boundingInfo.minimum.clone(),maximum:this._boundingInfo.maximum.clone()};else{if(!e&&(e=this.getVerticesData(b.PositionKind),!e))return;this._extend=Wo(e,0,this._totalVertices,this.boundingBias,3)}}_applyToMesh(e){for(const t in this._vertexBuffers){const i=this._vertexBuffers[t];i._buffer.getBuffer()||i.create(),t===b.PositionKind&&(this._extend||this._updateExtend(),e.buildBoundingInfo(this._extend.minimum,this._extend.maximum),e._createGlobalSubMesh(e.isUnIndexed),e._updateBoundingInfo())}!this._indexBuffer&&this._indices&&this._indices.length>0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,this._updatable,"Geometry_"+this.id+"_IndexBuffer")),e._syncGeometryWithMorphTargetManager(),e.synchronizeInstances()}_notifyUpdate(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e),this._vertexArrayObjects&&this._disposeVertexArrayObjects();for(const t of this._meshes)t._markSubMeshesAsAttributesDirty()}load(e,t){if(this.delayLoadState!==2){if(this.isReady()){t&&t();return}this.delayLoadState=2,this._queueLoad(e,t)}}_queueLoad(e,t){this.delayLoadingFile&&(e.addPendingData(this),e._loadFile(this.delayLoadingFile,i=>{if(!this._delayLoadingFunction)return;this._delayLoadingFunction(JSON.parse(i),this),this.delayLoadState=1,this._delayInfo=[],e.removePendingData(this);const s=this._meshes,r=s.length;for(let n=0;n<r;n++)this._applyToMesh(s[n]);t&&t()},void 0,!0))}toLeftHanded(){const e=this.getIndices(!1);if(e!=null&&e.length>0){for(let s=0;s<e.length;s+=3){const r=e[s+0];e[s+0]=e[s+2],e[s+2]=r}this.setIndices(e)}const t=this.getVerticesData(b.PositionKind,!1);if(t!=null&&t.length>0){for(let s=0;s<t.length;s+=3)t[s+2]=-t[s+2];this.setVerticesData(b.PositionKind,t,!1)}const i=this.getVerticesData(b.NormalKind,!1);if(i!=null&&i.length>0){for(let s=0;s<i.length;s+=3)i[s+2]=-i[s+2];this.setVerticesData(b.NormalKind,i,!1)}}_resetPointsArrayCache(){this._positions=null}_generatePointsArray(){if(this._positions)return!0;const e=this.getVerticesData(b.PositionKind);if(!e||e.length===0)return!1;for(let t=this._positionsCache.length*3,i=this._positionsCache.length;t<e.length;t+=3,++i)this._positionsCache[i]=_.FromArray(e,t);for(let t=0,i=0;t<e.length;t+=3,++i)this._positionsCache[i].set(e[0+t],e[1+t],e[2+t]);return this._positionsCache.length=e.length/3,this._positions=this._positionsCache,!0}isDisposed(){return this._isDisposed}_disposeVertexArrayObjects(){if(this._vertexArrayObjects){for(const i in this._vertexArrayObjects)this._engine.releaseVertexArrayObject(this._vertexArrayObjects[i]);this._vertexArrayObjects={};const e=this._meshes,t=e.length;for(let i=0;i<t;i++)e[i]._invalidateInstanceVertexArrayObject()}}dispose(){const e=this._meshes,t=e.length;let i;for(i=0;i<t;i++)this.releaseForMesh(e[i]);this._meshes.length=0,this._disposeVertexArrayObjects();for(const s in this._vertexBuffers)this._vertexBuffers[s].dispose();if(this._vertexBuffers={},this._totalVertices=0,this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null,this._indices=[],this.delayLoadState=0,this.delayLoadingFile=null,this._delayLoadingFunction=null,this._delayInfo=[],this._boundingInfo=null,this._scene.removeGeometry(this),this._parentContainer){const s=this._parentContainer.geometries.indexOf(this);s>-1&&this._parentContainer.geometries.splice(s,1),this._parentContainer=null}this._isDisposed=!0}copy(e){const t=new Tt(e,this._scene),i=this.getIndices(void 0,!0);i&&t.setIndices(i);let s=!1,r;for(r in this._vertexBuffers){const n=this.getVertexBuffer(r),o=n.getData();if(!o)continue;const h=n.isUpdatable(),l=n.getSize(),{type:c,byteOffset:u,byteStride:f,normalized:d}=n;s=s||h;const g=Oc(o,l,c,u,f,this._totalVertices,!0),p=new b(this._engine,g,r,{updatable:h,useBytes:!1,stride:l,size:l,offset:0,type:c,normalized:d,takeBufferOwnership:!0});t.setVerticesBuffer(p,this._totalVertices)}t._updatable=s,t.delayLoadState=this.delayLoadState,t.delayLoadingFile=this.delayLoadingFile,t._delayLoadingFunction=this._delayLoadingFunction;for(r in this._delayInfo)t._delayInfo=t._delayInfo||[],t._delayInfo.push(r);return t._boundingInfo=new Lt(this._extend.minimum,this._extend.maximum),t}serialize(){const e={};return e.id=this.id,e.uniqueId=this.uniqueId,e.updatable=this._updatable,Ae&&Ae.HasTags(this)&&(e.tags=Ae.GetTags(this)),e}_toNumberArray(e){return Array.isArray(e)?e:Array.prototype.slice.call(e)}clearCachedData(){this._totalIndices=this._indices.length,this._indices=[],this._resetPointsArrayCache();for(const e in this._vertexBuffers)Object.prototype.hasOwnProperty.call(this._vertexBuffers,e)&&(this._vertexBuffers[e]._buffer._data=null)}serializeVerticeData(){const e=this.serialize();return this.isVerticesDataPresent(b.PositionKind)&&(e.positions=this._toNumberArray(this.getVerticesData(b.PositionKind)),this.isVertexBufferUpdatable(b.PositionKind)&&(e.positionsUpdatable=!0)),this.isVerticesDataPresent(b.NormalKind)&&(e.normals=this._toNumberArray(this.getVerticesData(b.NormalKind)),this.isVertexBufferUpdatable(b.NormalKind)&&(e.normalsUpdatable=!0)),this.isVerticesDataPresent(b.TangentKind)&&(e.tangents=this._toNumberArray(this.getVerticesData(b.TangentKind)),this.isVertexBufferUpdatable(b.TangentKind)&&(e.tangentsUpdatable=!0)),this.isVerticesDataPresent(b.UVKind)&&(e.uvs=this._toNumberArray(this.getVerticesData(b.UVKind)
23),this.isVertexBufferUpdatable(b.UVKind)&&(e.uvsUpdatable=!0)),this.isVerticesDataPresent(b.UV2Kind)&&(e.uvs2=this._toNumberArray(this.getVerticesData(b.UV2Kind)),this.isVertexBufferUpdatable(b.UV2Kind)&&(e.uvs2Updatable=!0)),this.isVerticesDataPresent(b.UV3Kind)&&(e.uvs3=this._toNumberArray(this.getVerticesData(b.UV3Kind)),this.isVertexBufferUpdatable(b.UV3Kind)&&(e.uvs3Updatable=!0)),this.isVerticesDataPresent(b.UV4Kind)&&(e.uvs4=this._toNumberArray(this.getVerticesData(b.UV4Kind)),this.isVertexBufferUpdatable(b.UV4Kind)&&(e.uvs4Updatable=!0)),this.isVerticesDataPresent(b.UV5Kind)&&(e.uvs5=this._toNumberArray(this.getVerticesData(b.UV5Kind)),this.isVertexBufferUpdatable(b.UV5Kind)&&(e.uvs5Updatable=!0)),this.isVerticesDataPresent(b.UV6Kind)&&(e.uvs6=this._toNumberArray(this.getVerticesData(b.UV6Kind)),this.isVertexBufferUpdatable(b.UV6Kind)&&(e.uvs6Updatable=!0)),this.isVerticesDataPresent(b.ColorKind)&&(e.colors=this._toNumberArray(this.getVerticesData(b.ColorKind)),this.isVertexBufferUpdatable(b.ColorKind)&&(e.colorsUpdatable=!0)),this.isVerticesDataPresent(b.MatricesIndicesKind)&&(e.matricesIndices=this._toNumberArray(this.getVerticesData(b.MatricesIndicesKind)),e.matricesIndicesExpanded=!0,this.isVertexBufferUpdatable(b.MatricesIndicesKind)&&(e.matricesIndicesUpdatable=!0)),this.isVerticesDataPresent(b.MatricesWeightsKind)&&(e.matricesWeights=this._toNumberArray(this.getVerticesData(b.MatricesWeightsKind)),this.isVertexBufferUpdatable(b.MatricesWeightsKind)&&(e.matricesWeightsUpdatable=!0)),e.indices=this._toNumberArray(this.getIndices()),e}static ExtractFromMesh(e,t){const i=e._geometry;return i?i.copy(t):null}static RandomId(){return se.RandomId()}static _GetGeometryByLoadedUniqueId(e,t){for(let i=0;i<t.geometries.length;i++)if(t.geometries[i]._loadedUniqueId===e)return t.geometries[i];return null}static _ImportGeometry(e,t){const i=t.getScene(),s=e.geometryUniqueId,r=e.geometryId;if(s||r){const n=s?this._GetGeometryByLoadedUniqueId(s,i):i.getGeometryById(r);n&&n.applyToMesh(t)}else if(e instanceof ArrayBuffer){const n=t._binaryInfo;if(n.positionsAttrDesc&&n.positionsAttrDesc.count>0){const o=new Float32Array(e,n.positionsAttrDesc.offset,n.positionsAttrDesc.count);t.setVerticesData(b.PositionKind,o,!1)}if(n.normalsAttrDesc&&n.normalsAttrDesc.count>0){const o=new Float32Array(e,n.normalsAttrDesc.offset,n.normalsAttrDesc.count);t.setVerticesData(b.NormalKind,o,!1)}if(n.tangetsAttrDesc&&n.tangetsAttrDesc.count>0){const o=new Float32Array(e,n.tangetsAttrDesc.offset,n.tangetsAttrDesc.count);t.setVerticesData(b.TangentKind,o,!1)}if(n.uvsAttrDesc&&n.uvsAttrDesc.count>0){const o=new Float32Array(e,n.uvsAttrDesc.offset,n.uvsAttrDesc.count);t.setVerticesData(b.UVKind,o,!1)}if(n.uvs2AttrDesc&&n.uvs2AttrDesc.count>0){const o=new Float32Array(e,n.uvs2AttrDesc.offset,n.uvs2AttrDesc.count);t.setVerticesData(b.UV2Kind,o,!1)}if(n.uvs3AttrDesc&&n.uvs3AttrDesc.count>0){const o=new Float32Array(e,n.uvs3AttrDesc.offset,n.uvs3AttrDesc.count);t.setVerticesData(b.UV3Kind,o,!1)}if(n.uvs4AttrDesc&&n.uvs4AttrDesc.count>0){const o=new Float32Array(e,n.uvs4AttrDesc.offset,n.uvs4AttrDesc.count);t.setVerticesData(b.UV4Kind,o,!1)}if(n.uvs5AttrDesc&&n.uvs5AttrDesc.count>0){const o=new Float32Array(e,n.uvs5AttrDesc.offset,n.uvs5AttrDesc.count);t.setVerticesData(b.UV5Kind,o,!1)}if(n.uvs6AttrDesc&&n.uvs6AttrDesc.count>0){const o=new Float32Array(e,n.uvs6AttrDesc.offset,n.uvs6AttrDesc.count);t.setVerticesData(b.UV6Kind,o,!1)}if(n.colorsAttrDesc&&n.colorsAttrDesc.count>0){const o=new Float32Array(e,n.colorsAttrDesc.offset,n.colorsAttrDesc.count);t.setVerticesData(b.ColorKind,o,!1,n.colorsAttrDesc.stride)}if(n.matricesIndicesAttrDesc&&n.matricesIndicesAttrDesc.count>0){const o=new Int32Array(e,n.matricesIndicesAttrDesc.offset,n.matricesIndicesAttrDesc.count),h=[];for(let l=0;l<o.length;l++){const c=o[l];h.push(c&255),h.push((c&65280)>>8),h.push((c&16711680)>>16),h.push(c>>24&255)}t.setVerticesData(b.MatricesIndicesKind,h,!1)}if(n.matricesIndicesExtraAttrDesc&&n.matricesIndicesExtraAttrDesc.count>0){const o=new Int32Array(e,n.matricesIndicesExtraAttrDesc.offset,n.matricesIndicesExtraAttrDesc.count),h=[];for(let l=0;l<o.length;l++){const c=o[l];h.push(c&255),h.push((c&65280)>>8),h.push((c&16711680)>>16),h.push(c>>24&255)}t.setVerticesData(b.MatricesIndicesExtraKind,h,!1)}if(n.matricesWeightsAttrDesc&&n.matricesWeightsAttrDesc.count>0){const o=new Float32Array(e,n.matricesWeightsAttrDesc.offset,n.matricesWeightsAttrDesc.count);t.setVerticesData(b.MatricesWeightsKind,o,!1)}if(n.indicesAttrDesc&&n.indicesAttrDesc.count>0){const o=new Int32Array(e,n.indicesAttrDesc.offset,n.indicesAttrDesc.count);t.setIndices(o,null)}if(n.subMeshesAttrDesc&&n.subMeshesAttrDesc.count>0){const o=new Int32Array(e,n.subMeshesAttrDesc.offset,n.subMeshesAttrDesc.count*5);t.subMeshes=[];for(let h=0;h<n.subMeshesAttrDesc.count;h++){const l=o[h*5+0],c=o[h*5+1],u=o[h*5+2],f=o[h*5+3],d=o[h*5+4];zt.AddToMesh(l,c,u,f,d,t)}}}else if(e.positions&&e.normals&&e.indices){if(t.setVerticesData(b.PositionKind,e.positions,e.positions._updatable||e.positionsUpdatable),t.setVerticesData(b.NormalKind,e.normals,e.normals._updatable||e.normalsUpdatable),e.tangents&&t.setVerticesData(b.TangentKind,e.tangents,e.tangents._updatable||e.tangentsUpdatable),e.uvs&&t.setVerticesData(b.UVKind,e.uvs,e.uvs._updatable||e.uvsUpdatable),e.uvs2&&t.setVerticesData(b.UV2Kind,e.uvs2,e.uvs2._updatable||e.uvs2Updatable),e.uvs3&&t.setVerticesData(b.UV3Kind,e.uvs3,e.uvs3._updatable||e.uvs3Updatable),e.uvs4&&t.setVerticesData(b.UV4Kind,e.uvs4,e.uvs4._updatable||e.uvs4Updatable),e.uvs5&&t.setVerticesData(b.UV5Kind,e.uvs5,e.uvs5._updatable||e.uvs5Updatable),e.uvs6&&t.setVerticesData(b.UV6Kind,e.uvs6,e.uvs6._updatable||e.uvs6Updatable),e.colors&&t.setVerticesData(b.ColorKind,fe.CheckColors4(e.colors,e.positions.length/3),e.colors._updatable),e.matricesIndices)if(!e.matricesIndices._isExpanded&&!e.matricesIndicesExpanded){const n=[];for(let o=0;o<e.matricesIndices.length;o++){const h=e.matricesIndices[o];n.push(h&255),n.push((h&65280)>>8),n.push((h&16711680)>>16),n.push(h>>24&255)}t.setVerticesData(b.MatricesIndicesKind,n,e.matricesIndices._updatable||e.matricesIndicesUpdatable)}else delete e.matricesIndices._isExpanded,delete e.matricesIndicesExpanded,t.setVerticesData(b.MatricesIndicesKind,e.matricesIndices,e.matricesIndices._updatable||e.matricesIndicesUpdatable);if(e.matricesIndicesExtra)if(e.matricesIndicesExtraExpanded||e.matricesIndicesExtra._isExpanded)delete e.matricesIndices._isExpanded,delete e.matricesIndicesExtraExpanded,t.setVerticesData(b.MatricesIndicesExtraKind,e.matricesIndicesExtra,e.matricesIndicesExtra._updatable||e.matricesIndicesExtraUpdatable);else{const n=[];for(let o=0;o<e.matricesIndicesExtra.length;o++){const h=e.matricesIndicesExtra[o];n.push(h&255),n.push((h&65280)>>8),n.push((h&16711680)>>16),n.push(h>>24&255)}t.setVerticesData(b.MatricesIndicesExtraKind,n,e.matricesIndicesExtra._updatable||e.matricesIndicesExtraUpdatable)}e.matricesWeights&&(Tt._CleanMatricesWeights(e,t),t.setVerticesData(b.MatricesWeightsKind,e.matricesWeights,e.matricesWeights._updatable)),e.matricesWeightsExtra&&t.setVerticesData(b.MatricesWeightsExtraKind,e.matricesWeightsExtra,e.matricesWeights._updatable),t.setIndices(e.indices,null)}if(e.subMeshes){t.subMeshes=[];for(let n=0;n<e.subMeshes.length;n++){const o=e.subMeshes[n];zt.AddToMesh(o.materialIndex,o.verticesStart,o.verticesCount,o.indexStart,o.indexCount,t)}}t._shouldGenerateFlatShading&&(t.convertToFlatShadedMesh(),t._shouldGenerateFlatShading=!1),t.computeWorldMatrix(!0),i.onMeshImportedObservable.notifyObservers(t)}static _CleanMatricesWeights(e,t){if(!xt.CleanBoneMatrixWeights)return;let s=0;if(e.skeletonId>
vendor: 24,007 bytes, line 23
23-1){const u=t.getScene().getLastSkeletonById(e.skeletonId);if(!u)return;s=u.bones.length}else return;const r=t.getVerticesData(b.MatricesIndicesKind),n=t.getVerticesData(b.MatricesIndicesExtraKind),o=e.matricesWeights,h=e.matricesWeightsExtra,l=e.numBoneInfluencer,c=o.length;for(let u=0;u<c;u+=4){let f=0,d=-1;for(let g=0;g<4;g++){const p=o[u+g];f+=p,p<.001&&d<0&&(d=g)}if(h)for(let g=0;g<4;g++){const p=h[u+g];f+=p,p<.001&&d<0&&(d=g+4)}if((d<0||d>l-1)&&(d=l-1),f>.001){const g=1/f;for(let p=0;p<4;p++)o[u+p]*=g;if(h)for(let p=0;p<4;p++)h[u+p]*=g}else d>=4?(h[u+d-4]=1-f,n[u+d-4]=s):(o[u+d]=1-f,r[u+d]=s)}t.setVerticesData(b.MatricesIndicesKind,r),e.matricesWeightsExtra&&t.setVerticesData(b.MatricesIndicesExtraKind,n)}static Parse(e,t,i){const s=new Tt(e.id,t,void 0,e.updatable);return s._loadedUniqueId=e.uniqueId,Ae&&Ae.AddTagsTo(s,e.tags),e.delayLoadingFile?(s.delayLoadState=4,s.delayLoadingFile=i+e.delayLoadingFile,s._boundingInfo=new Lt(_.FromArray(e.boundingBoxMinimum),_.FromArray(e.boundingBoxMaximum)),s._delayInfo=[],e.hasUVs&&s._delayInfo.push(b.UVKind),e.hasUVs2&&s._delayInfo.push(b.UV2Kind),e.hasUVs3&&s._delayInfo.push(b.UV3Kind),e.hasUVs4&&s._delayInfo.push(b.UV4Kind),e.hasUVs5&&s._delayInfo.push(b.UV5Kind),e.hasUVs6&&s._delayInfo.push(b.UV6Kind),e.hasColors&&s._delayInfo.push(b.ColorKind),e.hasMatricesIndices&&s._delayInfo.push(b.MatricesIndicesKind),e.hasMatricesWeights&&s._delayInfo.push(b.MatricesWeightsKind),s._delayLoadingFunction=$.ImportVertexData):$.ImportVertexData(e,s),t.pushGeometry(s,!0),s}}class ae extends qe{get billboardMode(){return this._billboardMode}set billboardMode(e){this._billboardMode!==e&&(this._billboardMode=e,this._cache.useBillboardPosition=(this._billboardMode&ae.BILLBOARDMODE_USE_POSITION)!==0)}get infiniteDistance(){return this._infiniteDistance}set infiniteDistance(e){this._infiniteDistance!==e&&(this._infiniteDistance=e)}constructor(e,t=null,i=!0){super(e,t,!1),this._forward=new _(0,0,1),this._up=new _(0,1,0),this._right=new _(1,0,0),this._position=_.Zero(),this._rotation=_.Zero(),this._rotationQuaternion=null,this._scaling=_.One(),this._transformToBoneReferal=null,this._isAbsoluteSynced=!1,this._billboardMode=ae.BILLBOARDMODE_NONE,this.scalingDeterminant=1,this._infiniteDistance=!1,this.ignoreNonUniformScaling=!1,this.reIntegrateRotationIntoRotationQuaternion=!1,this._poseMatrix=null,this._localMatrix=P.Zero(),this._usePivotMatrix=!1,this._absolutePosition=_.Zero(),this._absoluteScaling=_.Zero(),this._absoluteRotationQuaternion=W.Identity(),this._pivotMatrix=P.Identity(),this._postMultiplyPivotMatrix=!1,this._isWorldMatrixFrozen=!1,this._indexInSceneTransformNodesArray=-1,this.onAfterWorldMatrixUpdateObservable=new O,this._nonUniformScaling=!1,i&&this.getScene().addTransformNode(this)}getClassName(){return"TransformNode"}get position(){return this._position}set position(e){this._position=e,this._markAsDirtyInternal()}isUsingPivotMatrix(){return this._usePivotMatrix}isUsingPostMultiplyPivotMatrix(){return this._postMultiplyPivotMatrix}get rotation(){return this._rotation}set rotation(e){this._rotation=e,this._rotationQuaternion=null,this._markAsDirtyInternal()}get scaling(){return this._scaling}set scaling(e){this._scaling=e,this._markAsDirtyInternal()}get rotationQuaternion(){return this._rotationQuaternion}set rotationQuaternion(e){this._rotationQuaternion=e,e&&this._rotation.setAll(0),this._markAsDirtyInternal()}_markAsDirtyInternal(){this._isDirty||(this._isDirty=!0,this.customMarkAsDirty&&this.customMarkAsDirty())}get forward(){return _.TransformNormalFromFloatsToRef(0,0,this.getScene().useRightHandedSystem?-1:1,this.getWorldMatrix(),this._forward),this._forward.normalize()}get up(){return _.TransformNormalFromFloatsToRef(0,1,0,this.getWorldMatrix(),this._up),this._up.normalize()}get right(){return _.TransformNormalFromFloatsToRef(this.getScene().useRightHandedSystem?-1:1,0,0,this.getWorldMatrix(),this._right),this._right.normalize()}updatePoseMatrix(e){return this._poseMatrix?(this._poseMatrix.copyFrom(e),this):(this._poseMatrix=e.clone(),this)}getPoseMatrix(){return this._poseMatrix||(this._poseMatrix=P.Identity()),this._poseMatrix}_isSynchronized(){const e=this._cache;return!(this._billboardMode!==e.billboardMode||this._billboardMode!==ae.BILLBOARDMODE_NONE||e.pivotMatrixUpdated||this._infiniteDistance||this._position._isDirty||this._scaling._isDirty||this._rotationQuaternion&&this._rotationQuaternion._isDirty||this._rotation._isDirty)}_initCache(){super._initCache();const e=this._cache;e.localMatrixUpdated=!1,e.billboardMode=-1,e.infiniteDistance=!1,e.useBillboardPosition=!1}get absolutePosition(){return this.getAbsolutePosition()}get absoluteScaling(){return this._syncAbsoluteScalingAndRotation(),this._absoluteScaling}get absoluteRotationQuaternion(){return this._syncAbsoluteScalingAndRotation(),this._absoluteRotationQuaternion}setPreTransformMatrix(e){return this.setPivotMatrix(e,!1)}setPivotMatrix(e,t=!0){return this._pivotMatrix.copyFrom(e),this._usePivotMatrix=!this._pivotMatrix.isIdentity(),this._cache.pivotMatrixUpdated=!0,this._postMultiplyPivotMatrix=t,this._postMultiplyPivotMatrix&&(this._pivotMatrixInverse?this._pivotMatrix.invertToRef(this._pivotMatrixInverse):this._pivotMatrixInverse=P.Invert(this._pivotMatrix)),this}getPivotMatrix(){return this._pivotMatrix}instantiateHierarchy(e=null,t,i){const s=this.clone("Clone of "+(this.name||this.id),e||this.parent,!0);s&&i&&i(this,s);for(const r of this.getChildTransformNodes(!0))r.instantiateHierarchy(s,t,i);return s}freezeWorldMatrix(e=null,t=!1){return e?t?(this._rotation.setAll(0),this._rotationQuaternion=this._rotationQuaternion||W.Identity(),e.decompose(this._scaling,this._rotationQuaternion,this._position),this.computeWorldMatrix(!0)):(this._worldMatrix=e,this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this._afterComputeWorldMatrix()):(this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0)),this._isDirty=!1,this._isWorldMatrixFrozen=!0,this}unfreezeWorldMatrix(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this}get isWorldMatrixFrozen(){return this._isWorldMatrixFrozen}getAbsolutePosition(){return this.computeWorldMatrix(),this._absolutePosition}setAbsolutePosition(e){if(!e)return this;let t,i,s;if(e.x===void 0){if(arguments.length<3)return this;t=arguments[0],i=arguments[1],s=arguments[2]}else t=e.x,i=e.y,s=e.z;if(this.parent){const r=v.Matrix[0];this.parent.getWorldMatrix().invertToRef(r),_.TransformCoordinatesFromFloatsToRef(t,i,s,r,this.position)}else this.position.x=t,this.position.y=i,this.position.z=s;return this._absolutePosition.copyFrom(e),this}setPositionWithLocalVector(e){return this.computeWorldMatrix(),this.position=_.TransformNormal(e,this._localMatrix),this}getPositionExpressedInLocalSpace(){this.computeWorldMatrix();const e=v.Matrix[0];return this._localMatrix.invertToRef(e),_.TransformNormal(this.position,e)}locallyTranslate(e){return this.computeWorldMatrix(!0),this.position=_.TransformCoordinates(e,this._localMatrix),this}lookAt(e,t=0,i=0,s=0,r=0){const n=ae._LookAtVectorCache,o=r===0?this.position:this.getAbsolutePosition();if(e.subtractToRef(o,n),this.setDirection(n,t,i,s),r===1&&this.parent)if(this.rotationQuaternion){const h=v.Matrix[0];this.rotationQuaternion.toRotationMatrix(h);const l=v.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(l),l.invert(),h.multiplyToRef(l,h),this.rotationQuaternion.fromRotationMatrix(h)}else{const h=v.Quaternion[0];W.FromEulerVectorToRef(this.rotation,h);const l=v.Matrix[0];h.toRotationMatrix(l);const c=v.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(c),c.invert(),l.multiplyToRef(c,l),h.fromRotationMatrix(l),h.toEulerAnglesToRef(this.rotation)}return this}getDirection(e){const t=_.Zero();return this.getDirectionToRef(e,t),t}getDirectionToRef(e,t){return _.TransformNormalToRef(e,this.getWorldMatrix(),t),this}setDirection(e,t=0,i=0,s=0){const r=-Math.atan2(e.z,e.x)+Math.PI/2,n=Math.sqrt(e.x*e.x+e.z*e.z),o=-Math.atan2(e.y,n);return this.rotationQuaternion?W.RotationYawPitchRollToRef(r+t,o+i,s,this.rotationQuaternion):(this.rotation.x=o+i,this.rotation.y=r+t,this.rotation.z=s),this}setPivotPoint(e,t=0){this.getScene().getRenderId()==0&&this.computeWorldMatrix(!0);const i=this.getWorldMatrix();if(t==1){const s=v.Matrix[0];i.invertToRef(s),e=_.TransformCoordinates(e,s)}return this.setPivotMatrix(P.Translation(-e.x,-e.y,-e.z),!0)}getPivotPoint(){const e=_.Zero();return this.getPivotPointToRef(e),e}getPivotPointToRef(e){return e.x=-this._pivotMatrix.m[12],e.y=-this._pivotMatrix.m[13],e.z=-this._pivotMatrix.m[14],this}getAbsolutePivotPoint(){const e=_.Zero();return this.getAbsolutePivotPointToRef(e),e}getAbsolutePivotPointToRef(e){return this.getPivotPointToRef(e),_.TransformCoordinatesToRef(e,this.getWorldMatrix(),e),this}markAsDirty(e){if(this._isDirty)return this;if(this._children)for(const t of this._children)t.markAsDirty(e);return super.markAsDirty(e)}setParent(e,t=!1,i=!1){if(!e&&!this.parent)return this;const s=v.Quaternion[0],r=v.Vector3[0],n=v.Vector3[1],o=v.Matrix[1];P.IdentityToRef(o);const h=v.Matrix[0];this.computeWorldMatrix(!0);let l=this.rotationQuaternion;return l||(l=ae._TmpRotation,W.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,l)),P.ComposeToRef(this.scaling,l,this.position,h),this.parent&&h.multiplyToRef(this.parent.computeWorldMatrix(!0),h),e&&(e.computeWorldMatrix(!0).invertToRef(o),h.multiplyToRef(o,h)),h.decompose(n,s,r,t?this:void 0),this.rotationQuaternion?this.rotationQuaternion.copyFrom(s):s.toEulerAnglesToRef(this.rotation),this.scaling.copyFrom(n),this.position.copyFrom(r),this.parent=e,i&&this.setPivotMatrix(P.Identity()),this}addChild(e,t=!1){return e.setParent(this,t),this}removeChild(e,t=!1){return e.parent!==this?this:(e.setParent(null,t),this)}get nonUniformScaling(){return this._nonUniformScaling}_updateNonUniformScalingState(e){return this._nonUniformScaling===e?!1:(this._nonUniformScaling=e,!0)}attachToBone(e,t){return this._currentParentWhenAttachingToBone=this.parent,this._transformToBoneReferal=t,this.parent=e,e.getSkeleton().prepare(!0),e.getFinalMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this}detachFromBone(e=!1){return this.parent?(this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._transformToBoneReferal=null,e?this.parent=this._currentParentWhenAttachingToBone:this.parent=null,this):(e&&(this.parent=this._currentParentWhenAttachingToBone),this)}rotate(e,t,i){e.normalize(),this.rotationQuaternion||(this.rotationQuaternion=this.rotation.toQuaternion(),this.rotation.setAll(0));let s;if(!i||i===0)s=W.RotationAxisToRef(e,t,ae._RotationAxisCache),this.rotationQuaternion.multiplyToRef(s,this.rotationQuaternion);else{if(this.parent){const r=this.parent.getWorldMatrix(),n=v.Matrix[0];r.invertToRef(n),e=_.TransformNormal(e,n),r.determinant()<0&&(t*=-1)}s=W.RotationAxisToRef(e,t,ae._RotationAxisCache),s.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}return this}rotateAround(e,t,i){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=W.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.setAll(0));const s=v.Vector3[0],r=v.Vector3[1],n=v.Vector3[2],o=v.Quaternion[0],h=v.Matrix[0],l=v.Matrix[1],c=v.Matrix[2],u=v.Matrix[3];return e.subtractToRef(this.position,s),P.TranslationToRef(s.x,s.y,s.z,h),P.TranslationToRef(-s.x,-s.y,-s.z,l),P.RotationAxisToRef(t,i,c),l.multiplyToRef(c,u),u.multiplyToRef(h,u),u.decompose(r,o,n),this.position.addInPlace(n),o.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion),this}translate(e,t,i){const s=e.scale(t);if(!i||i===0){const r=this.getPositionExpressedInLocalSpace().add(s);this.setPositionWithLocalVector(r)}else this.setAbsolutePosition(this.getAbsolutePosition().add(s));return this}addRotation(e,t,i){let s;this.rotationQuaternion?s=this.rotationQuaternion:(s=v.Quaternion[1],W.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,s));const r=v.Quaternion[0];return W.RotationYawPitchRollToRef(t,e,i,r),s.multiplyInPlace(r),this.rotationQuaternion||s.toEulerAnglesToRef(this.rotation),this}_getEffectiveParent(){return this.parent}isWorldMatrixCameraDependent(){return this._infiniteDistance&&!this.parent||this._billboardMode!==ae.BILLBOARDMODE_NONE}computeWorldMatrix(e=!1,t=null){if(this._isWorldMatrixFrozen&&!this._isDirty)return this._worldMatrix;const i=this.getScene().getRenderId();if(!this._isDirty&&!e&&(this._currentRenderId===i||this.isSynchronized()))return this._currentRenderId=i,this._worldMatrix;t=t||this.getScene().activeCamera,this._updateCache();const s=this._cache;s.pivotMatrixUpdated=!1,s.billboardMode=this.billboardMode,s.infiniteDistance=this.infiniteDistance,s.parent=this._parentNode,this._currentRenderId=i,this._childUpdateId+=1,this._isDirty=!1,this._position._isDirty=!1,this._rotation._isDirty=!1,this._scaling._isDirty=!1;const r=this._getEffectiveParent(),n=ae._TmpScaling;let o=this._position;if(this._infiniteDistance&&!this.parent&&t){const l=t.getWorldMatrix(),c=new _(l.m[12],l.m[13],l.m[14]);o=ae._TmpTranslation,o.copyFromFloats(this._position.x+c.x,this._position.y+c.y,this._position.z+c.z)}n.copyFromFloats(this._scaling.x*this.scalingDeterminant,this._scaling.y*this.scalingDeterminant,this._scaling.z*this.scalingDeterminant);let h;if(this._rotationQuaternion?(this._rotationQuaternion._isDirty=!1,h=this._rotationQuaternion,this.reIntegrateRotationIntoRotationQuaternion&&this.rotation.lengthSquared()&&(this._rotationQuaternion.multiplyInPlace(W.RotationYawPitchRoll(this._rotation.y,this._rotation.x,this._rotation.z)),this._rotation.copyFromFloats(0,0,0))):(h=ae._TmpRotation,W.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,h)),this._usePivotMatrix){const l=v.Matrix[1];P.ScalingToRef(n.x,n.y,n.z,l);const c=v.Matrix[0];h.toRotationMatrix(c),this._pivotMatrix.multiplyToRef(l,v.Matrix[4]),v.Matrix[4].multiplyToRef(c,this._localMatrix),this._postMultiplyPivotMatrix&&this._localMatrix.multiplyToRef(this._pivotMatrixInverse,this._localMatrix),this._localMatrix.addTranslationFromFloats(o.x,o.y,o.z)}else P.ComposeToRef(n,h,o,this._localMatrix);if(r&&r.getWorldMatrix){if(e&&r.computeWorldMatrix(e),this.billboardMode){if(this._transformToBoneReferal){const f=this.parent;f.getSkeleton().prepare(),f.getFinalMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),v.Matrix[7])}else v.Matrix[7].copyFrom(r.getWorldMatrix());const l=v.Vector3[5],c=v.Vector3[6],u=v.Quaternion[0];v.Matrix[7].decompose(c,u,l),P.ScalingToRef(c.x,c.y,c.z,v.Matrix[7]),v.Matrix[7].setTranslation(l),ae.BillboardUseParentOrientation&&(this._position.applyRotationQuaternionToRef(u,l),this._localMatrix.setTranslation(l)),this._localMatrix.multiplyToRef(v.Matrix[7],this._worldMatrix)}else if(this._transformToBoneReferal){const l=this.parent;l.getSkeleton().prepare(),this._localMatrix.multiplyToRef(l.getFinalMatrix(),v.Matrix[6]),v.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),this._worldMatrix)}else this._localMatrix.multiplyToRef(r.getWorldMatrix(),this._worldMatrix);this._markSyncedWithParent()}else this._worldMatrix.copyFrom(this._localMatrix);if(t&&this.billboardMode)if(s.useBillboardPosition){const l=v.Vector3[0];this._worldMatrix.getTranslationToRef(l);const c=t.globalPosition;this._worldMatrix.invertToRef(v.Matrix[1]);const u=v.Vector3[1];_.TransformCoordinatesToRef(c,v.Matrix[1],u),u.normalize();const f=-Math.atan2(u.z,u.x)+Math.PI/2,d=Math.sqrt(u.x*u.x+u.z*u.z),g=-Math.atan2(u.y,d);if(W.RotationYawPitchRollToRef(f,g,0,v.Quaternion[0]),(this.billboardMode&ae.BILLBOARDMODE_ALL)!==ae.BILLBOARDMODE_ALL){const p=v.Vector3[1];v.Quaternion[0].toEulerAnglesToRef(p),(this.billboardMode&ae.BILLBOARDMODE_X)!==ae.BILLBOARDMODE_X&&(p.x=0),(this.billboardMode&ae.BILLBOARDMODE_Y)!==ae.BILLBOARDMODE_Y&&(p.y=0),(this.billboardMode&ae.BILLBOARDMODE_Z)!==ae.BILLBOARDMODE_Z&&(p.z=0),P.RotationYawPitchRollToRef(p.y,p.x,p.z,v.Matrix[0])}else P.FromQuaternionToRef(v.Quaternion[0],v.Matrix[0]);this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(v.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(v.Vector3[0])}else{const l=v.Vector3[0];this._worldMatrix.getTranslationToRef(l),v.Matrix[1].copyFrom(t.getViewMatrix());const c=this.getScene().useRightHandedSystem;if(c&&v.Matrix[1].multiplyToRef(ae._TmpRHRestore,v.Matrix[1]),v.Matrix[1].setTranslationFromFloats(0,0,0),v.Matrix[1].invertToRef(v.Matrix[0]),(this.billboardMode&ae.BILLBOARDMODE_ALL)!==ae.BILLBOARDMODE_ALL){v.Matrix[0].decompose(void 0,v.Quaternion[0],void 0);const u=v.Vector3[1];v.Quaternion[0].toEulerAnglesToRef(u),(this.billboardMode&ae.BILLBOARDMODE_X)!==ae.BILLBOARDMODE_X&&(u.x=0),(this.billboardMode&ae.BILLBOARDMODE_Y)!==ae.BILLBOARDMODE_Y&&(u.y=0),(this.billboardMode&ae.BILLBOARDMODE_Z)!==ae.BILLBOARDMODE_Z&&(u.z=0),c&&(u.y+=Math.PI),P.RotationYawPitchRollToRef(u.y,u.x,u.z,v.Matrix[0])}this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(v.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(v.Vector3[0])}return this.ignoreNonUniformScaling?this._updateNonUniformScalingState(!1):this._scaling.isNonUniformWithinEpsilon(1e-6)?this._updateNonUniformScalingState(!0):r&&r._nonUniformScaling?this._updateNonUniformScalingState(r._nonUniformScaling):this._updateNonUniformScalingState(!1),this._afterComputeWorldMatrix(),this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this._isAbsoluteSynced=!1,this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),this._poseMatrix||(this._poseMatrix=P.Invert(this._worldMatrix)),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix}resetLocalMatrix(e=!0){if(this.computeWorldMatrix(),e){const t=this.getChildren();for(let i=0;i<t.length;++i){const s=t[i];if(s){s.computeWorldMatrix();const r=v.Matrix[0];s._localMatrix.multiplyToRef(this._localMatrix,r);const n=v.Quaternion[0];r.decompose(s.scaling,n,s.position),s.rotationQuaternion?s.rotationQuaternion.copyFrom(n):n.toEulerAnglesToRef(s.rotation)}}}this.scaling.copyFromFloats(1,1,1),this.position.copyFromFloats(0,0,0),this.rotation.copyFromFloats(0,0,0),this.rotationQuaternion&&(this.rotationQuaternion=W.Identity()),this._worldMatrix=P.Identity()}_afterComputeWorldMatrix(){}registerAfterWorldMatrixUpdate(e){return this.onAfterWorldMatrixUpdateObservable.add(e),this}unregisterAfterWorldMatrixUpdate(e){return this.onAfterWorldMatrixUpdateObservable.removeCallback(e),this}getPositionInCameraSpace(e=null){return e||(e=this.getScene().activeCamera),_.TransformCoordinates(this.getAbsolutePosition(),e.getViewMatrix())}getDistanceToCamera(e=null){return e||(e=this.getScene().activeCamera),this.getAbsolutePosition().subtract(e.globalPosition).length()}clone(e,t,i){const s=le.Clone(()=>new ae(e,this.getScene()),this);if(s.name=e,s.id=e,t&&(s.parent=t),!i){const r=this.getDescendants(!0);for(let n=0;n<r.length;n++){const o=r[n];o.clone&&o.clone(e+"."+o.name,s)}}return s}serialize(e){const t=le.Serialize(this,e);return t.type=this.getClassName(),t.uniqueId=this.uniqueId,this.parent&&this.parent._serializeAsParent(t),t.localMatrix=this.getPivotMatrix().asArray(),t.isEnabled=this.isEnabled(),le.AppendSerializedAnimations(this,t),t.ranges=this.serializeAnimationRanges(),t}static Parse(e,t,i){const s=le.Parse(()=>new ae(e.name,t),e,t,i);if(e.localMatrix?s.setPreTransformMatrix(P.FromArray(e.localMatrix)):e.pivotMatrix&&s.setPivotMatrix(P.FromArray(e.pivotMatrix)),s.setEnabled(e.isEnabled),s._waitingParsedUniqueId=e.uniqueId,e.parentId!==void 0&&(s._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(s._waitingParentInstanceIndex=e.parentInstanceIndex),e.animations){for(let r=0;r<e.animations.length;r++){const n=e.animations[r],o=Oi("BABYLON.Animation");o&&s.animations.push(o.Parse(n))}qe.ParseAnimationRanges(s,e,t)}return e.autoAnimate&&t.beginAnimation(s,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),s}getChildTransformNodes(e,t){const i=[];return this._getDescendants(i,e,s=>(!t||t(s))&&s instanceof ae),i}dispose(e,t=!1){if(this.getScene().stopAnimation(this),this.getScene().removeTransformNode(this),this._parentContainer){const i=this._parentContainer.transformNodes.indexOf(this);i>-1&&this._parentContainer.transformNodes.splice(i,1),this._parentContainer=null}if(this.onAfterWorldMatrixUpdateObservable.clear(),e){const i=this.getChildTransformNodes(!0);for(const s of i)s.parent=null,s.computeWorldMatrix(!0)}super.dispose(e,t)}normalizeToUnitCube(e=!0,t=!1,i){let s=null,r=null;t&&(this.rotationQuaternion?(r=this.rotationQuaternion.clone(),this.rotationQuaternion.copyFromFloats(0,0,0,1)):this.rotation&&(s=this.rotation.clone(),this.rotation.copyFromFloats(0,0,0)));const n=this.getHierarchyBoundingVectors(e,i),o=n.max.subtract(n.min),h=Math.max(o.x,o.y,o.z);if(h===0)return this;const l=1/h;return this.scaling.scaleInPlace(l),t&&(this.rotationQuaternion&&r?this.rotationQuaternion.copyFrom(r):this.rotation&&s&&this.rotation.copyFrom(s)),this}_syncAbsoluteScalingAndRotation(){this._isAbsoluteSynced||(this._worldMatrix.decompose(this._absoluteScaling,this._absoluteRotationQuaternion),this._isAbsoluteSynced=!0)}}ae.BILLBOARDMODE_NONE=0;ae.BILLBOARDMODE_X=1;ae.BILLBOARDMODE_Y=2;ae.BILLBOARDMODE_Z=4;ae.BILLBOARDMODE_ALL=7;ae.BILLBOARDMODE_USE_POSITION=128;ae.BillboardUseParentOrientation=!1;ae._TmpRotation=W.Zero();ae._TmpScaling=_.Zero();ae._TmpTranslation=_.Zero();ae._TmpRHRestore=P.Scaling(1,1,-1);ae._LookAtVectorCache=new _(0,0,0);ae._RotationAxisCache=new W;T([qt("position")],ae.prototype,"_position",void 0);T([qt("rotation")],ae.prototype,"_rotation",void 0);T([Tl("rotationQuaternion")],ae.prototype,"_rotationQuaternion",void 0);T([qt("scaling")],ae.prototype,"_scaling",void 0);T([R("billboardMode")],ae.prototype,"_billboardMode",void 0);T([R()],ae.prototype,"scalingDeterminant",void 0);T([R("infiniteDistance")],ae.prototype,"_infiniteDistance",void 0);T([R()],ae.prototype,"ignoreNonUniformScaling",void 0);T([R()],ae.prototype,"reIntegrateRotationIntoRotationQuaternion",void 0);class ms{constructor(){this.hit=!1,this.distance=0,this.pickedPoint=null,this.pickedMesh=null,this.bu=0,this.bv=0,this.faceId=-1,this.subMeshFaceId=-1,this.subMeshId=0,this.pickedSprite=null,this.thinInstanceIndex=-1,this.ray=null,this.originMesh=null,this.aimTransform=null,this.gripTransform=null}getNormal(e=!1,t=!0){if(!this.pickedMesh||t&&!this.pickedMesh.isVerticesDataPresent(b.NormalKind))return null;let i=this.pickedMesh.getIndices();i?.length===0&&(i=null);let s;const r=v.Vector3[0],n=v.Vector3[1],o=v.Vector3[2];if(t){const l=this.pickedMesh.getVerticesData(b.NormalKind);let c=i?_.FromArrayToRef(l,i[this.faceId*3]*3,r):r.copyFromFloats(l[this.faceId*3*3],l[this.faceId*3*3+1],l[this.faceId*3*3+2]),u=i?_.FromArrayToRef(l,i[this.faceId*3+1]*3,n):n.copyFromFloats(l[(this.faceId*3+1)*3],l[(this.faceId*3+1)*3+1],l[(this.faceId*3+1)*3+2]),f=i?_.FromArrayToRef(l,i[this.faceId*3+2]*3,o):o.copyFromFloats(l[(this.faceId*3+2)*3],l[(this.faceId*3+2)*3+1],l[(this.faceId*3+2)*3+2]);c=c.scale(this.bu),u=u.scale(this.bv),f=f.scale(1-this.bu-this.bv),s=new _(c.x+u.x+f.x,c.y+u.y+f.y,c.z+u.z+f.z)}else{const l=this.pickedMesh.getVerticesData(b.PositionKind),c=i?_.FromArrayToRef(l,i[this.faceId*3]*3,r):r.copyFromFloats(l[this.faceId*3*3],l[this.faceId*3*3+1],l[this.faceId*3*3+2]),u=i?_.FromArrayToRef(l,i[this.faceId*3+1]*3,n):n.copyFromFloats(l[(this.faceId*3+1)*3],l[(this.faceId*3+1)*3+1],l[(this.faceId*3+1)*3+2]),f=i?_.FromArrayToRef(l,i[this.faceId*3+2]*3,o):o.copyFromFloats(l[(this.faceId*3+2)*3],l[(this.faceId*3+2)*3+1],l[(this.faceId*3+2)*3+2]),d=c.subtract(u),g=f.subtract(u);s=_.Cross(d,g)}const h=(l,c)=>{if(this.thinInstanceIndex!==-1){const f=l.thinInstanceGetWorldMatrices()[this.thinInstanceIndex];f&&_.TransformNormalToRef(c,f,c)}let u=l.getWorldMatrix();
23l.nonUniformScaling&&(v.Matrix[0].copyFrom(u),u=v.Matrix[0],u.setTranslationFromFloats(0,0,0),u.invert(),u.transposeToRef(v.Matrix[1]),u=v.Matrix[1]),_.TransformNormalToRef(c,u,c)};if(e&&h(this.pickedMesh,s),this.ray){const l=v.Vector3[0].copyFrom(s);e||h(this.pickedMesh,l),_.Dot(l,this.ray.direction)>0&&s.negateInPlace()}return s.normalize(),s}getTextureCoordinates(e=b.UVKind){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(e))return null;const t=this.pickedMesh.getIndices();if(!t)return null;const i=this.pickedMesh.getVerticesData(e);if(!i)return null;let s=Q.FromArray(i,t[this.faceId*3]*2),r=Q.FromArray(i,t[this.faceId*3+1]*2),n=Q.FromArray(i,t[this.faceId*3+2]*2);return s=s.scale(this.bu),r=r.scale(this.bv),n=n.scale(1-this.bu-this.bv),new Q(s.x+r.x+n.x,s.y+r.y+n.y)}}class K{constructor(e,t,i=!1,s,r=!1,n){this._uniformNames=[],this._valueCache={},this._engine=e,this._noUBO=!e.supportsUniformBuffers||r,this._dynamic=i,this._name=s??"no-name",this._data=t||[],this._uniformLocations={},this._uniformSizes={},this._uniformArraySizes={},this._uniformLocationPointer=0,this._needSync=!1,this._trackUBOsInFrame=!1,(n===void 0&&this._engine._features.trackUbosInFrame||n===!0)&&(this._buffers=[],this._bufferIndex=-1,this._bufferUpdatedLastFrame=!1,this._createBufferOnWrite=!1,this._currentFrameId=0,this._trackUBOsInFrame=!0),this._noUBO?(this.updateMatrix3x3=this._updateMatrix3x3ForEffect,this.updateMatrix2x2=this._updateMatrix2x2ForEffect,this.updateFloat=this._updateFloatForEffect,this.updateFloat2=this._updateFloat2ForEffect,this.updateFloat3=this._updateFloat3ForEffect,this.updateFloat4=this._updateFloat4ForEffect,this.updateFloatArray=this._updateFloatArrayForEffect,this.updateArray=this._updateArrayForEffect,this.updateIntArray=this._updateIntArrayForEffect,this.updateUIntArray=this._updateUIntArrayForEffect,this.updateMatrix=this._updateMatrixForEffect,this.updateMatrices=this._updateMatricesForEffect,this.updateVector3=this._updateVector3ForEffect,this.updateVector4=this._updateVector4ForEffect,this.updateColor3=this._updateColor3ForEffect,this.updateColor4=this._updateColor4ForEffect,this.updateDirectColor4=this._updateDirectColor4ForEffect,this.updateInt=this._updateIntForEffect,this.updateInt2=this._updateInt2ForEffect,this.updateInt3=this._updateInt3ForEffect,this.updateInt4=this._updateInt4ForEffect,this.updateUInt=this._updateUIntForEffect,this.updateUInt2=this._updateUInt2ForEffect,this.updateUInt3=this._updateUInt3ForEffect,this.updateUInt4=this._updateUInt4ForEffect):(this._engine._uniformBuffers.push(this),this.updateMatrix3x3=this._updateMatrix3x3ForUniform,this.updateMatrix2x2=this._updateMatrix2x2ForUniform,this.updateFloat=this._updateFloatForUniform,this.updateFloat2=this._updateFloat2ForUniform,this.updateFloat3=this._updateFloat3ForUniform,this.updateFloat4=this._updateFloat4ForUniform,this.updateFloatArray=this._updateFloatArrayForUniform,this.updateArray=this._updateArrayForUniform,this.updateIntArray=this._updateIntArrayForUniform,this.updateUIntArray=this._updateUIntArrayForUniform,this.updateMatrix=this._updateMatrixForUniform,this.updateMatrices=this._updateMatricesForUniform,this.updateVector3=this._updateVector3ForUniform,this.updateVector4=this._updateVector4ForUniform,this.updateColor3=this._updateColor3ForUniform,this.updateColor4=this._updateColor4ForUniform,this.updateDirectColor4=this._updateDirectColor4ForUniform,this.updateInt=this._updateIntForUniform,this.updateInt2=this._updateInt2ForUniform,this.updateInt3=this._updateInt3ForUniform,this.updateInt4=this._updateInt4ForUniform,this.updateUInt=this._updateUIntForUniform,this.updateUInt2=this._updateUInt2ForUniform,this.updateUInt3=this._updateUInt3ForUniform,this.updateUInt4=this._updateUInt4ForUniform)}get useUbo(){return!this._noUBO}get isSync(){return!this._needSync}isDynamic(){return this._dynamic}getData(){return this._bufferData}getBuffer(){return this._buffer}getUniformNames(){return this._uniformNames}_fillAlignment(e){let t;if(e<=2?t=e:t=4,this._uniformLocationPointer%t!==0){const i=this._uniformLocationPointer;this._uniformLocationPointer+=t-this._uniformLocationPointer%t;const s=this._uniformLocationPointer-i;for(let r=0;r<s;r++)this._data.push(0)}}
23addUniform(e,t,i=0){if(i>0&&typeof t=="number"&&(this._uniformArraySizes[e]={strideSize:t,arraySize:i}),this._uniformLocations[e]!==void 0||(this._uniformNames.push(e),this._noUBO))return;let s;if(i>0){if(t instanceof Array)throw"addUniform should not be use with Array in UBO: "+e;if(this._fillAlignment(4),t==16)t=t*i;else{const n=(4-t)*i;t=t*i+n}s=[];for(let r=0;r<t;r++)s.push(0)}else{if(t instanceof Array)s=t,t=s.length;else{s=[];for(let r=0;r<t;r++)s.push(0)}this._fillAlignment(t)}this._uniformSizes[e]=t,this._uniformLocations[e]=this._uniformLocationPointer,this._uniformLocationPointer+=t;for(let r=0;r<t;r++)this._data.push(s[r]);this._needSync=!0}addMatrix(e,t){this.addUniform(e,Array.prototype.slice.call(t.asArray()))}addFloat2(e,t,i){const s=[t,i];this.addUniform(e,s)}addFloat3(e,t,i,s){const r=[t,i,s];this.addUniform(e,r)}addColor3(e,t){const i=[t.r,t.g,t.b];this.addUniform(e,i)}addColor4(e,t,i){const s=[t.r,t.g,t.b,i];this.addUniform(e,s)}addVector3(e,t){const i=[t.x,t.y,t.z];this.addUniform(e,i)}addMatrix3x3(e){this.addUniform(e,12)}addMatrix2x2(e){this.addUniform(e,8)}create(){this._noUBO||this._buffer||(this._fillAlignment(4),this._bufferData=new Float32Array(this._data),this._rebuild(),this._needSync=!0)}_getNamesDebug(){const e=[];let t=0;for(const i in this._uniformLocations)if(e.push(i),++t===10)break;return e.join(",")}_rebuild(){this._noUBO||!this._bufferData||(this._dynamic?this._buffer=this._engine.createDynamicUniformBuffer(this._bufferData,this._name+"_UniformList:"+this._getNamesDebug()):this._buffer=this._engine.createUniformBuffer(this._bufferData,this._name+"_UniformList:"+this._getNamesDebug()),this._trackUBOsInFrame&&(this._buffers.push([this._buffer,this._engine._features.checkUbosContentBeforeUpload?this._bufferData.slice():void 0]),this._bufferIndex=this._buffers.length-1,this._createBufferOnWrite=!1))}_rebuildAfterContextLost(){this._trackUBOsInFrame&&(this._buffers=[],this._currentFrameId=0),this._rebuild()}get _numBuffers(){return this._buffers.length}get _indexBuffer(){return this._bufferIndex}get name(){return this._name}set name(e){this._name=e}get currentEffect(){return this._currentEffect}_buffersEqual(e,t){for(let i=0;i<e.length;++i)if(e[i]!==t[i])return!1;return!0}_copyBuffer(e,t){for(let i=0;i<e.length;++i)t[i]=e[i]}update(){if(!this._noUBO){if(this.bindUniformBuffer(),!this._buffer){this.create();return}if(!this._dynamic&&!this._needSync){this._createBufferOnWrite=this._trackUBOsInFrame;return}if(this._buffers&&this._buffers.length>1&&this._buffers[this._bufferIndex][1])if(this._buffersEqual(this._bufferData,this._buffers[this._bufferIndex][1])){this._needSync=!1,this._createBufferOnWrite=this._trackUBOsInFrame;return}else this._copyBuffer(this._bufferData,this._buffers[this._bufferIndex][1]);this._bufferUpdatedLastFrame=!0,this._engine.updateUniformBuffer(this._buffer,this._bufferData),this._engine._features._collectUbosUpdatedInFrame&&(K._UpdatedUbosInFrame[this._name]||(K._UpdatedUbosInFrame[this._name]=0),K._UpdatedUbosInFrame[this._name]++),this._needSync=!1,this._createBufferOnWrite=this._trackUBOsInFrame}}_createNewBuffer(){this._bufferIndex+1<this._buffers.length?(this._bufferIndex++,this._buffer=this._buffers[this._bufferIndex][0],this._createBufferOnWrite=!1,this._needSync=!0):this._rebuild()}_checkNewFrame(){this._trackUBOsInFrame&&this._currentFrameId!==this._engine.frameId&&(this._currentFrameId=this._engine.frameId,this._createBufferOnWrite=!1,this._buffers&&this._buffers.length>0?(this._buffers.length===1?this._needSync=!this._bufferUpdatedLastFrame:this._needSync=this._bufferIndex!==0,this._bufferIndex=0,this._buffer=this._buffers[this._bufferIndex][0]):this._bufferIndex=-1)}updateUniform(e,t,i){this._checkNewFrame();let s=this._uniformLocations[e];if(s===void 0){if(this._buffer){w.Error("Cannot add an uniform after UBO has been created. uniformName="+e);return}this.addUniform(e,i),s=this._uniformLocations[e]}if(this._buffer||this.create(),this._dynamic)for(let r=0;r<i;r++)this._bufferData[s+r]=t[r];else{let r=!1;for(let n=0;n<i;n++)(i===16&&!this._engine._features.uniformBufferHardCheckMatrix||this._bufferData[s+n]!==Math.fround(t[n]))&&(r=!0,this._createBufferOnWrite&&this._createNewBuffer(),this._bufferData[s+n]=t[n]);this._needSync=this._needSync||r}}updateUniformArray(e,t,i){this._checkNewFrame();const s=this._uniformLocations[e];if(s===void 0){w.Error("Cannot add an uniform Array dynamically. Please, add it using addUniform and make sure that uniform buffers are supported by the current engine.");return}this._buffer||this.create();const r=this._uniformArraySizes[e];if(this._dynamic)for(let n=0;n<i;n++)this._bufferData[s+n]=t[n];else{let n=!1,o=0,h=0;for(let l=0;l<i;
23l++)if(this._bufferData[s+h*4+o]!==se.FloatRound(t[l])&&(n=!0,this._createBufferOnWrite&&this._createNewBuffer(),this._bufferData[s+h*4+o]=t[l]),o++,o===r.strideSize){for(;o<4;o++)this._bufferData[s+h*4+o]=0;o=0,h++}this._needSync=this._needSync||n}}_cacheMatrix(e,t){this._checkNewFrame();const i=this._valueCache[e],s=t.updateFlag;return i!==void 0&&i===s?!1:(this._valueCache[e]=s,!0)}_updateMatrix3x3ForUniform(e,t){for(let i=0;i<3;i++)K._TempBuffer[i*4]=t[i*3],K._TempBuffer[i*4+1]=t[i*3+1],K._TempBuffer[i*4+2]=t[i*3+2],K._TempBuffer[i*4+3]=0;this.updateUniform(e,K._TempBuffer,12)}_updateMatrix3x3ForEffect(e,t){this._currentEffect.setMatrix3x3(e,t)}_updateMatrix2x2ForEffect(e,t){this._currentEffect.setMatrix2x2(e,t)}_updateMatrix2x2ForUniform(e,t){for(let i=0;i<2;i++)K._TempBuffer[i*4]=t[i*2],K._TempBuffer[i*4+1]=t[i*2+1],K._TempBuffer[i*4+2]=0,K._TempBuffer[i*4+3]=0;this.updateUniform(e,K._TempBuffer,8)}_updateFloatForEffect(e,t,i=""){this._currentEffect.setFloat(e+i,t)}_updateFloatForUniform(e,t){K._TempBuffer[0]=t,this.updateUniform(e,K._TempBuffer,1)}_updateFloat2ForEffect(e,t,i,s=""){this._currentEffect.setFloat2(e+s,t,i)}_updateFloat2ForUniform(e,t,i){K._TempBuffer[0]=t,K._TempBuffer[1]=i,this.updateUniform(e,K._TempBuffer,2)}_updateFloat3ForEffect(e,t,i,s,r=""){this._currentEffect.setFloat3(e+r,t,i,s)}_updateFloat3ForUniform(e,t,i,s){K._TempBuffer[0]=t,K._TempBuffer[1]=i,K._TempBuffer[2]=s,this.updateUniform(e,K._TempBuffer,3)}_updateFloat4ForEffect(e,t,i,s,r,n=""){this._currentEffect.setFloat4(e+n,t,i,s,r)}_updateFloat4ForUniform(e,t,i,s,r){K._TempBuffer[0]=t,K._TempBuffer[1]=i,K._TempBuffer[2]=s,K._TempBuffer[3]=r,this.updateUniform(e,K._TempBuffer,4)}_updateFloatArrayForEffect(e,t,i=""){switch(this._uniformArraySizes[e]?.strideSize){case 2:this._currentEffect.setFloatArray2(e+i,t);break;case 3:this._currentEffect.setFloatArray3(e+i,t);break;case 4:this._currentEffect.setFloatArray4(e+i,t);break;default:this._currentEffect.setFloatArray(e+i,t);break}}_updateFloatArrayForUniform(e,t){this.updateUniformArray(e,t,t.length)}_updateArrayForEffect(e,t){this._currentEffect.setArray(e,t)}_updateArrayForUniform(e,t){this.updateUniformArray(e,t,t.length)}_updateIntArrayForEffect(e,t){this._currentEffect.setIntArray(e,t)}_updateIntArrayForUniform(e,t){K._TempBufferInt32View.set(t),this.updateUniformArray(e,K._TempBuffer,t.length)}_updateUIntArrayForEffect(e,t){this._currentEffect.setUIntArray(e,t)}_updateUIntArrayForUniform(e,t){K._TempBufferUInt32View.set(t),this.updateUniformArray(e,K._TempBuffer,t.length)}_updateMatrixForEffect(e,t){this._currentEffect.setMatrix(e,t)}_updateMatrixForUniform(e,t){this._cacheMatrix(e,t)&&this.updateUniform(e,t.asArray(),16)}_updateMatricesForEffect(e,t){this._currentEffect.setMatrices(e,t)}_updateMatricesForUniform(e,t){this.updateUniform(e,t,t.length)}_updateVector3ForEffect(e,t){this._currentEffect.setVector3(e,t)}_updateVector3ForUniform(e,t){K._TempBuffer[0]=t.x,K._TempBuffer[1]=t.y,K._TempBuffer[2]=t.z,this.updateUniform(e,K._TempBuffer,3)}_updateVector4ForEffect(e,t){this._currentEffect.setVector4(e,t)}_updateVector4ForUniform(e,t){K._TempBuffer[0]=t.x,K._TempBuffer[1]=t.y,K._TempBuffer[2]=t.z,K._TempBuffer[3]=t.w,this.updateUniform(e,K._TempBuffer,4)}_updateColor3ForEffect(e,t,i=""){this._currentEffect.setColor3(e+i,t)}_updateColor3ForUniform(e,t){K._TempBuffer[0]=t.r,K._TempBuffer[1]=t.g,K._TempBuffer[2]=t.b,this.updateUniform(e,K._TempBuffer,3)}_updateColor4ForEffect(e,t,i,s=""){this._currentEffect.setColor4(e+s,t,i)}_updateDirectColor4ForEffect(e,t,i=""){this._currentEffect.setDirectColor4(e+i,t)}_updateColor4ForUniform(e,t,i){K._TempBuffer[0]=t.r,K._TempBuffer[1]=t.g,K._TempBuffer[2]=t.b,K._TempBuffer[3]=i,this.updateUniform(e,K._TempBuffer,4)}_updateDirectColor4ForUniform(e,t){K._TempBuffer[0]=t.r,K._TempBuffer[1]=t.g,K._TempBuffer[2]=t.b,K._TempBuffer[3]=t.a,this.updateUniform(e,K._TempBuffer,4)}_updateIntForEffect(e,t,i=""){this._currentEffect.setInt(e+i,t)}_updateIntForUniform(e,t){K._TempBufferInt32View[0]=t,this.updateUniform(e,K._TempBuffer,1)}_updateInt2ForEffect(e,t,i,s=""){this._currentEffect.setInt2(e+s,t,i)}_updateInt2ForUniform(e,t,i){K._TempBufferInt32View[0]=t,K._TempBufferInt32View[1]=i,this.updateUniform(e,K._TempBuffer,2)}_updateInt3ForEffect(e,t,i,s,r=""){this._currentEffect.setInt3(e+r,t,i,s)}_updateInt3ForUniform(e,t,i,s){K._TempBufferInt32View[0]=t,K._TempBufferInt32View[1]=i,K._TempBufferInt32View[2]=s,this.updateUniform(e,K._TempBuffer,3)}
23_updateInt4ForEffect(e,t,i,s,r,n=""){this._currentEffect.setInt4(e+n,t,i,s,r)}_updateInt4ForUniform(e,t,i,s,r){K._TempBufferInt32View[0]=t,K._TempBufferInt32View[1]=i,K._TempBufferInt32View[2]=s,K._TempBufferInt32View[3]=r,this.updateUniform(e,K._TempBuffer,4)}_updateUIntForEffect(e,t,i=""){this._currentEffect.setUInt(e+i,t)}_updateUIntForUniform(e,t){K._TempBufferUInt32View[0]=t,this.updateUniform(e,K._TempBuffer,1)}_updateUInt2ForEffect(e,t,i,s=""){this._currentEffect.setUInt2(e+s,t,i)}_updateUInt2ForUniform(e,t,i){K._TempBufferUInt32View[0]=t,K._TempBufferUInt32View[1]=i,this.updateUniform(e,K._TempBuffer,2)}_updateUInt3ForEffect(e,t,i,s,r=""){this._currentEffect.setUInt3(e+r,t,i,s)}_updateUInt3ForUniform(e,t,i,s){K._TempBufferUInt32View[0]=t,K._TempBufferUInt32View[1]=i,K._TempBufferUInt32View[2]=s,this.updateUniform(e,K._TempBuffer,3)}_updateUInt4ForEffect(e,t,i,s,r,n=""){this._currentEffect.setUInt4(e+n,t,i,s,r)}_updateUInt4ForUniform(e,t,i,s,r){K._TempBufferUInt32View[0]=t,K._TempBufferUInt32View[1]=i,K._TempBufferUInt32View[2]=s,K._TempBufferUInt32View[3]=r,this.updateUniform(e,K._TempBuffer,4)}setTexture(e,t){this._currentEffect.setTexture(e,t)}setTextureArray(e,t){this._currentEffect.setTextureArray(e,t)}bindTexture(e,t){this._currentEffect._bindTexture(e,t)}updateUniformDirectly(e,t){this.updateUniform(e,t,t.length),this.update()}bindToEffect(e,t){this._currentEffect=e,this._currentEffectName=t}bindUniformBuffer(){!this._noUBO&&this._buffer&&this._currentEffect&&this._currentEffect.bindUniformBuffer(this._buffer,this._currentEffectName)}unbindEffect(){this._currentEffect=void 0,this._currentEffectName=void 0}setDataBuffer(e){if(!this._buffers)return this._buffer===e;for(let t=0;t<this._buffers.length;++t)if(this._buffers[t][0]===e)return this._bufferIndex=t,this._buffer=e,this._createBufferOnWrite=!1,this._currentEffect=void 0,this._buffers.length>1&&this._buffers[t][1]&&this._bufferData.set(this._buffers[t][1]),this._valueCache={},this._currentFrameId=this._engine.frameId,!0;return!1}has(e){return this._uniformLocations[e]!==void 0}dispose(){if(this._noUBO)return;const e=this._engine._uniformBuffers,t=e.indexOf(this);if(t!==-1&&(e[t]=e[e.length-1],e.pop()),this._trackUBOsInFrame&&this._buffers)for(let i=0;i<this._buffers.length;++i){const s=this._buffers[i][0];this._engine._releaseBuffer(s)}else this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)}}K._UpdatedUbosInFrame={};K._MAX_UNIFORM_SIZE=256;K._TempBuffer=new Float32Array(K._MAX_UNIFORM_SIZE);K._TempBufferInt32View=new Int32Array(K._TempBuffer.buffer);K._TempBufferUInt32View=new Uint32Array(K._TempBuffer.buffer);class Lc{constructor(){this._checkCollisions=!1,this._collisionMask=-1,this._collisionGroup=-1,this._surroundingMeshes=null,this._collider=null,this._oldPositionForCollisions=new _(0,0,0),this._diffPositionForCollisions=new _(0,0,0),this._collisionResponse=!0}}var fa;(function(a){a[a.LOCAL=0]="LOCAL",a[a.WORLD=1]="WORLD",a[a.BONE=2]="BONE"})(fa||(fa={}));class ts{}ts.X=new _(1,0,0);
vendor: 34,981 bytes, line 23
23ts.Y=new _(0,1,0);ts.Z=new _(0,0,1);var _a;(function(a){a[a.X=0]="X",a[a.Y=1]="Y",a[a.Z=2]="Z"})(_a||(_a={}));function Bc(a,e,t){let i=null;switch(e){case b.PositionKind:i=s=>s.getPositions();break;case b.NormalKind:i=s=>s.getNormals();break;case b.TangentKind:i=s=>s.getTangents();break;case b.UVKind:i=s=>s.getUVs();break;case b.UV2Kind:i=s=>s.getUV2s();break;case b.ColorKind:i=s=>s.getColors();break;default:return}for(let s=0;s<a.length;s++){let r=a[s];for(let n=0;n<t.numTargets;n++){const o=t.getTarget(n),h=o.influence;if(h!==0){const l=i(o);l&&(r+=(l[s]-a[s])*h)}}a[s]=r}}function Nc(a,e,t,i,s,r,n){const o=v.Vector3[0],h=v.Matrix[0],l=v.Matrix[1],c=e===b.NormalKind?_.TransformNormalFromFloatsToRef:_.TransformCoordinatesFromFloatsToRef;for(let u=0,f=0;u<a.length;u+=3,f+=4){h.reset();let d,g;for(d=0;d<4;d++)g=s[f+d],g>0&&(P.FromFloat32ArrayToRefScaled(t,Math.floor(i[f+d]*16),g,l),h.addToSelf(l));if(r&&n)for(d=0;d<4;d++)g=n[f+d],g>0&&(P.FromFloat32ArrayToRefScaled(t,Math.floor(r[f+d]*16),g,l),h.addToSelf(l));c(a[u],a[u+1],a[u+2],h,o),o.toArray(a,u)}}class Uc{constructor(){this.facetNb=0,this.partitioningSubdivisions=10,this.partitioningBBoxRatio=1.01,this.facetDataEnabled=!1,this.facetParameters={},this.bbSize=_.Zero(),this.subDiv={max:1,X:1,Y:1,Z:1},this.facetDepthSort=!1,this.facetDepthSortEnabled=!1}}class kc{constructor(){this._hasVertexAlpha=!1,this._useVertexColors=!0,this._numBoneInfluencers=4,this._applyFog=!0,this._receiveShadows=!1,this._facetData=new Uc,this._visibility=1,this._skeleton=null,this._layerMask=268435455,this._computeBonesUsingShaders=!0,this._isActive=!1,this._onlyForInstances=!1,this._isActiveIntermediate=!1,this._onlyForInstancesIntermediate=!1,this._actAsRegularMesh=!1,this._currentLOD=new Map,this._collisionRetryCount=3,this._morphTargetManager=null,this._renderingGroupId=0,this._bakedVertexAnimationManager=null,this._material=null,this._positions=null,this._pointerOverDisableMeshTesting=!1,this._meshCollisionData=new Lc,this._enableDistantPicking=!1,this._rawBoundingInfo=null,this._sideOrientationHint=!1,this._wasActiveLastFrame=!1}}class Ct extends ae{static get BILLBOARDMODE_NONE(){return ae.BILLBOARDMODE_NONE}static get BILLBOARDMODE_X(){return ae.BILLBOARDMODE_X}static get BILLBOARDMODE_Y(){return ae.BILLBOARDMODE_Y}static get BILLBOARDMODE_Z(){return ae.BILLBOARDMODE_Z}static get BILLBOARDMODE_ALL(){return ae.BILLBOARDMODE_ALL}static get BILLBOARDMODE_USE_POSITION(){return ae.BILLBOARDMODE_USE_POSITION}get facetNb(){return this._internalAbstractMeshDataInfo._facetData.facetNb}get partitioningSubdivisions(){return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions}set partitioningSubdivisions(e){this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions=e}get partitioningBBoxRatio(){return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio}set partitioningBBoxRatio(e){this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio=e}get mustDepthSortFacets(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSort}set mustDepthSortFacets(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSort=e}get facetDepthSortFrom(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom}set facetDepthSortFrom(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom=e}get collisionRetryCount(){return this._internalAbstractMeshDataInfo._collisionRetryCount}set collisionRetryCount(e){this._internalAbstractMeshDataInfo._collisionRetryCount=e}get isFacetDataEnabled(){return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled}get morphTargetManager(){return this._internalAbstractMeshDataInfo._morphTargetManager}set morphTargetManager(e){this._internalAbstractMeshDataInfo._morphTargetManager!==e&&(this._internalAbstractMeshDataInfo._morphTargetManager=e,this._syncGeometryWithMorphTargetManager())}get bakedVertexAnimationManager(){return this._internalAbstractMeshDataInfo._bakedVertexAnimationManager}set bakedVertexAnimationManager(e){this._internalAbstractMeshDataInfo._bakedVertexAnimationManager!==e&&(this._internalAbstractMeshDataInfo._bakedVertexAnimationManager=e,this._markSubMeshesAsAttributesDirty())}_syncGeometryWithMorphTargetManager(){}_updateNonUniformScalingState(e){return super._updateNonUniformScalingState(e)?(this._markSubMeshesAsMiscDirty(),!0):!1}get rawBoundingInfo(){return this._internalAbstractMeshDataInfo._rawBoundingInfo}set rawBoundingInfo(e){this._internalAbstractMeshDataInfo._rawBoundingInfo=e}set onCollide(e){this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver&&this.onCollideObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver),this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver=this.onCollideObservable.add(e)}set onCollisionPositionChange(e){this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver),this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)}get visibility(){return this._internalAbstractMeshDataInfo._visibility}set visibility(e){if(this._internalAbstractMeshDataInfo._visibility===e)return;const t=this._internalAbstractMeshDataInfo._visibility;this._internalAbstractMeshDataInfo._visibility=e,(t===1&&e!==1||t!==1&&e===1)&&this._markSubMeshesAsDirty(i=>{i.markAsMiscDirty(),i.markAsPrePassDirty()})}get pointerOverDisableMeshTesting(){return this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting}set pointerOverDisableMeshTesting(e){this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting=e}get renderingGroupId(){return this._internalAbstractMeshDataInfo._renderingGroupId}set renderingGroupId(e){this._internalAbstractMeshDataInfo._renderingGroupId=e}get material(){return this._internalAbstractMeshDataInfo._material}set material(e){this._setMaterial(e)}_setMaterial(e){this._internalAbstractMeshDataInfo._material!==e&&(this._internalAbstractMeshDataInfo._material&&this._internalAbstractMeshDataInfo._material.meshMap&&(this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId]=void 0),this._internalAbstractMeshDataInfo._material=e,e&&e.meshMap&&(e.meshMap[this.uniqueId]=this),this.onMaterialChangedObservable.hasObservers()&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes&&(this.resetDrawCache(void 0,e==null),this._unBindEffect()))}getMaterialForRenderPass(e){return this._internalAbstractMeshDataInfo._materialForRenderPass?.[e]}setMaterialForRenderPass(e,t){this.resetDrawCache(e),this._internalAbstractMeshDataInfo._materialForRenderPass||(this._internalAbstractMeshDataInfo._materialForRenderPass=[]);const i=this._internalAbstractMeshDataInfo._materialForRenderPass[e];i?.meshMap?.[this.uniqueId]&&(i.meshMap[this.uniqueId]=void 0),this._internalAbstractMeshDataInfo._materialForRenderPass[e]=t,t&&t.meshMap&&(t.meshMap[this.uniqueId]=this)}get receiveShadows(){return this._internalAbstractMeshDataInfo._receiveShadows}set receiveShadows(e){this._internalAbstractMeshDataInfo._receiveShadows!==e&&(this._internalAbstractMeshDataInfo._receiveShadows=e,this._markSubMeshesAsLightDirty())}get hasVertexAlpha(){return this._internalAbstractMeshDataInfo._hasVertexAlpha}set hasVertexAlpha(e){this._internalAbstractMeshDataInfo._hasVertexAlpha!==e&&(this._internalAbstractMeshDataInfo._hasVertexAlpha=e,this._markSubMeshesAsAttributesDirty(),this._markSubMeshesAsMiscDirty())}get useVertexColors(){return this._internalAbstractMeshDataInfo._useVertexColors}set useVertexColors(e){this._internalAbstractMeshDataInfo._useVertexColors!==e&&(this._internalAbstractMeshDataInfo._useVertexColors=e,this._markSubMeshesAsAttributesDirty())}get computeBonesUsingShaders(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders}set computeBonesUsingShaders(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())}get numBoneInfluencers(){return this._internalAbstractMeshDataInfo._numBoneInfluencers}set numBoneInfluencers(e){this._internalAbstractMeshDataInfo._numBoneInfluencers!==e&&(this._internalAbstractMeshDataInfo._numBoneInfluencers=e,this._markSubMeshesAsAttributesDirty())}get applyFog(){return this._internalAbstractMeshDataInfo._applyFog}set applyFog(e){this._internalAbstractMeshDataInfo._applyFog!==e&&(this._internalAbstractMeshDataInfo._applyFog=e,this._markSubMeshesAsMiscDirty())}get enableDistantPicking(){return this._internalAbstractMeshDataInfo._enableDistantPicking}set enableDistantPicking(e){this._internalAbstractMeshDataInfo._enableDistantPicking=e}get layerMask(){return this._internalAbstractMeshDataInfo._layerMask}set layerMask(e){e!==this._internalAbstractMeshDataInfo._layerMask&&(this._internalAbstractMeshDataInfo._layerMask=e,this._resyncLightSources())}get collisionMask(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask}set collisionMask(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask=isNaN(e)?-1:e}get collisionResponse(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse}set collisionResponse(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse=e}get collisionGroup(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup}set collisionGroup(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup=isNaN(e)?-1:e}get surroundingMeshes(){return this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes}set surroundingMeshes(e){this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes=e}get lightSources(){return this._lightSources}set skeleton(e){const t=this._internalAbstractMeshDataInfo._skeleton;t&&t.needInitialSkinMatrix&&t._unregisterMeshWithPoseMatrix(this),e&&e.needInitialSkinMatrix&&e._registerMeshWithPoseMatrix(this),this._internalAbstractMeshDataInfo._skeleton=e,this._internalAbstractMeshDataInfo._skeleton||(this._bonesTransformMatrices=null),this._markSubMeshesAsAttributesDirty()}get skeleton(){return this._internalAbstractMeshDataInfo._skeleton}constructor(e,t=null){switch(super(e,t,!1),this._internalAbstractMeshDataInfo=new kc,this._waitingMaterialId=null,this._waitingMorphTargetManagerId=null,this.cullingStrategy=Ct.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,this.onCollideObservable=new O,this.onCollisionPositionChangeObservable=new O,this.onMaterialChangedObservable=new O,this.definedFacingForward=!0,this._occlusionQuery=null,this._renderingGroup=null,this.alphaIndex=Number.MAX_VALUE,this.isPickable=!0,this.isNearPickable=!1,this.isNearGrabbable=!1,this.showSubMeshesBoundingBox=!1,this.isBlocker=!1,this.enablePointerMoveEvents=!1,this.outlineColor=q.Red(),this.outlineWidth=.02,this.overlayColor=q.Red(),this.overlayAlpha=.5,this.useOctreeForRenderingSelection=!0,this.useOctreeForPicking=!0,this.useOctreeForCollisions=!0,this.alwaysSelectAsActiveMesh=!1,this.doNotSyncBoundingInfo=!1,this.actionManager=null,this.ellipsoid=new _(.5,1,.5),this.ellipsoidOffset=new _(0,0,0),this.edgesWidth=1,this.edgesColor=new fe(1,0,0,1),this._edgesRenderer=null,this._masterMesh=null,this._boundingInfo=null,this._boundingInfoIsDirty=!0,this._renderId=0,this._intersectionsInProgress=new Array,this._unIndexed=!1,this._lightSources=new Array,this._waitingData={lods:null,actions:null,freezeWorldMatrix:null},this._bonesTransformMatrices=null,this._transformMatrixTexture=null,this.onRebuildObservable=new O,this._onCollisionPositionChange=(i,s,r=null)=>{s.subtractToRef(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length()>H.CollisionsEpsilon&&this.position.addInPlace(this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),r&&this.onCollideObservable.notifyObservers(r),this.onCollisionPositionChangeObservable.notifyObservers(this.position)},t=this.getScene(),t.addMesh(this),this._resyncLightSources(),this._uniformBuffer=new K(this.getScene().getEngine(),void 0,void 0,e,!this.getScene().getEngine().isWebGPU),this._buildUniformLayout(),t.performancePriority){case 2:this.doNotSyncBoundingInfo=!0;case 1:this.alwaysSelectAsActiveMesh=!0,this.isPickable=!1;break}}_buildUniformLayout(){this._uniformBuffer.addUniform("world",16),this._uniformBuffer.addUniform("visibility",1),this._uniformBuffer.create()}transferToEffect(e){const t=this._uniformBuffer;t.updateMatrix("world",e),t.updateFloat("visibility",this._internalAbstractMeshDataInfo._visibility),t.update()}getMeshUniformBuffer(){return this._uniformBuffer}getClassName(){return"AbstractMesh"}toString(e){let t="Name: "+this.name+", isInstance: "+(this.getClassName()==="InstancedMesh"?"YES":"NO");t+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0);const i=this._internalAbstractMeshDataInfo._skeleton;return i&&(t+=", skeleton: "+i.name),e&&(t+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],t+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingData.freezeWorldMatrix?"YES":"NO")),t}_getEffectiveParent(){return this._masterMesh&&this.billboardMode!==ae.BILLBOARDMODE_NONE?this._masterMesh:super._getEffectiveParent()}_getActionManagerForTrigger(e,t=!0){if(this.actionManager&&(t||this.actionManager.isRecursive))if(e){if(this.actionManager.hasSpecificTrigger(e))return this.actionManager}else return this.actionManager;return this.parent?this.parent._getActionManagerForTrigger(e,!1):null}_rebuild(e=!1){if(this.onRebuildObservable.notifyObservers(this),this._occlusionQuery!==null&&(this._occlusionQuery=null),!!this.subMeshes){for(const t of this.subMeshes)t._rebuild();this.resetDrawCache()}}_resyncLightSources(){this._lightSources.length=0;for(const e of this.getScene().lights)e.isEnabled()&&e.canAffectMesh(this)&&this._lightSources.push(e);this._markSubMeshesAsLightDirty()}_resyncLightSource(e){const t=e.isEnabled()&&e.canAffectMesh(this),i=this._lightSources.indexOf(e);let s=!1;if(i===-1){if(!t)return;this._lightSources.push(e)}else{if(t)return;s=!0,this._lightSources.splice(i,1)}this._markSubMeshesAsLightDirty(s)}_unBindEffect(){for(const e of this.subMeshes)e.setEffect(null)}_removeLightSource(e,t){const i=this._lightSources.indexOf(e);i!==-1&&(this._lightSources.splice(i,1),this._markSubMeshesAsLightDirty(t))}_markSubMeshesAsDirty(e){if(this.subMeshes)for(const t of this.subMeshes)for(let i=0;i<t._drawWrappers.length;++i){const s=t._drawWrappers[i];!s||!s.defines||!s.defines.markAllAsDirty||e(s.defines)}}_markSubMeshesAsLightDirty(e=!1){this._markSubMeshesAsDirty(t=>t.markAsLightDirty(e))}_markSubMeshesAsAttributesDirty(){this._markSubMeshesAsDirty(e=>e.markAsAttributesDirty())}_markSubMeshesAsMiscDirty(){this._markSubMeshesAsDirty(e=>e.markAsMiscDirty())}markAsDirty(e){return this._currentRenderId=Number.MAX_VALUE,super.markAsDirty(e),this._isDirty=!0,this}resetDrawCache(e,t=!1){if(this.subMeshes)for(const i of this.subMeshes)i.resetDrawCache(e,t)}get isBlocked(){return!1}getLOD(e){return this}getTotalVertices(){return 0}getTotalIndices(){return 0}getIndices(){return null}getVerticesData(e){return null}setVerticesData(e,t,i,s){return this}updateVerticesData(e,t,i,s){return this}setIndices(e,t){return this}isVerticesDataPresent(e){return!1}getBoundingInfo(){return this._masterMesh?this._masterMesh.getBoundingInfo():(this._boundingInfoIsDirty&&(this._boundingInfoIsDirty=!1,this._updateBoundingInfo()),this._boundingInfo)}getRawBoundingInfo(){return this.rawBoundingInfo??this.getBoundingInfo()}setBoundingInfo(e){return this._boundingInfo=e,this}get hasBoundingInfo(){return this._boundingInfo!==null}buildBoundingInfo(e,t,i){return this._boundingInfo=new Lt(e,t,i),this._boundingInfo}normalizeToUnitCube(e=!0,t=!1,i){return super.normalizeToUnitCube(e,t,i)}get useBones(){return this.skeleton&&this.getScene().skeletonsEnabled&&this.isVerticesDataPresent(b.MatricesIndicesKind)&&this.isVerticesDataPresent(b.MatricesWeightsKind)}_preActivate(){}_preActivateForIntermediateRendering(e){}_activate(e,t){return this._renderId=e,!0}_postActivate(){}_freeze(){}_unFreeze(){}getWorldMatrix(){return this._masterMesh&&this.billboardMode===ae.BILLBOARDMODE_NONE?this._masterMesh.getWorldMatrix():super.getWorldMatrix()}_getWorldMatrixDeterminant(){return this._masterMesh?this._masterMesh._getWorldMatrixDeterminant():super._getWorldMatrixDeterminant()}get isAnInstance(){return!1}get hasInstances(){return!1}get hasThinInstances(){return!1}movePOV(e,t,i){return this.position.addInPlace(this.calcMovePOV(e,t,i)),this}calcMovePOV(e,t,i){const s=new P;(this.rotationQuaternion?this.rotationQuaternion:W.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(s);const n=_.Zero(),o=this.definedFacingForward?-1:1;return _.TransformCoordinatesFromFloatsToRef(e*o,t,i*o,s,n),n}rotatePOV(e,t,i){return this.rotation.addInPlace(this.calcRotatePOV(e,t,i)),this}calcRotatePOV(e,t,i){const s=this.definedFacingForward?1:-1;return new _(e*s,t,i*s)}_refreshBoundingInfo(e,t){if(e){const i=Wo(e,0,this.getTotalVertices(),t);this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new Lt(i.minimum,i.maximum)}if(this.subMeshes)for(let i=0;i<this.subMeshes.length;i++)this.subMeshes[i].refreshBoundingInfo(e);this._updateBoundingInfo()}_refreshBoundingInfoDirect(e){if(this._boundingInfo?this._boundingInfo.reConstruct(e.minimum,e.maximum):this._boundingInfo=new Lt(e.minimum,e.maximum),this.subMeshes)for(let t=0;t<this.subMeshes.length;t++)this.subMeshes[t].refreshBoundingInfo(null);this._updateBoundingInfo()}static _ApplySkeleton(e,t,i,s,r,n,o){Nc(e,t,i,s,r,n,o)}_getData(e,t,i=b.PositionKind){const s=e.cache,r=n=>{if(s){const o=s._vertexData||(s._vertexData={});return o[n]||this.copyVerticesData(n,o),o[n]}return this.getVerticesData(n)};if(t||(t=r(i)),!t)return null;if(s?(s._outputData?s._outputData.set(t):s._outputData=new Float32Array(t),t=s._outputData):(e.applyMorph&&this.morphTargetManager||e.applySkeleton&&this.skeleton)&&(t=t.slice()),e.applyMorph&&this.morphTargetManager&&Bc(t,i,this.morphTargetManager),e.applySkeleton&&this.skeleton){const n=r(b.MatricesIndicesKind),o=r(b.MatricesWeightsKind);if(o&&n){const h=this.numBoneInfluencers>4,l=h?r(b.MatricesIndicesExtraKind):null,c=h?r(b.MatricesWeightsExtraKind):null,u=this.skeleton.getTransformMatrices(this);Ct._ApplySkeleton(t,i,u,n,o,l,c)}}if(e.updatePositionsArray!==!1&&i===b.PositionKind){const n=this._internalAbstractMeshDataInfo._positions||[],o=n.length;if(n.length=t.length/3,o<n.length)for(let h=o;h<n.length;h++)n[h]=new _;for(let h=0,l=0;h<n.length;h++,l+=3)n[h].copyFromFloats(t[l],t[l+1],t[l+2]);this._internalAbstractMeshDataInfo._positions=n}return t}getNormalsData(e=!1,t=!1){return this._getData({applySkeleton:e,applyMorph:t,updatePositionsArray:!1},null,b.NormalKind)}getPositionData(e=!1,t=!1,i=null){return this._getData({applySkeleton:e,applyMorph:t,updatePositionsArray:!1},i,b.PositionKind)}_updateBoundingInfo(){return this._boundingInfo?this._boundingInfo.update(this.worldMatrixFromCache):this._boundingInfo=new Lt(_.Zero(),_.Zero(),this.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache),this}_updateSubMeshesBoundingInfo(e){if(!this.subMeshes)return this;const t=this.subMeshes.length;for(let i=0;i<t;i++){const s=this.subMeshes[i];(t>1||!s.IsGlobal)&&s.updateBoundingInfo(e)}return this}_afterComputeWorldMatrix(){this.doNotSyncBoundingInfo||(this._boundingInfoIsDirty=!0)}isInFrustum(e){return this.getBoundingInfo().isInFrustum(e,this.cullingStrategy)}isCompletelyInFrustum(e){return this.getBoundingInfo().isCompletelyInFrustum(e)}intersectsMesh(e,t=!1,i){const s=this.getBoundingInfo(),r=e.getBoundingInfo();if(s.intersects(r,t))return!0;if(i){for(const n of this.getChildMeshes())if(n.intersectsMesh(e,t,!0))return!0}return!1}intersectsPoint(e){return this.getBoundingInfo().intersectsPoint(e)}get checkCollisions(){return this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions}set checkCollisions(e){this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions=e}get collider(){return this._internalAbstractMeshDataInfo._meshCollisionData._collider}moveWithCollisions(e,t=!0){this.getAbsolutePosition().addToRef(this.ellipsoidOffset,this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions);const s=this.getScene().collisionCoordinator;return this._internalAbstractMeshDataInfo._meshCollisionData._collider||(this._internalAbstractMeshDataInfo._meshCollisionData._collider=s.createCollider()),this._internalAbstractMeshDataInfo._meshCollisionData._collider._radius=this.ellipsoid,s.getNewPosition(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,e,this._internalAbstractMeshDataInfo._meshCollisionData._collider,this.collisionRetryCount,this,this._onCollisionPositionChange,this.uniqueId,t),this}_collideForSubMesh(e,t,i){if(this._generatePointsArray(),!this._positions)return this;if(!e._lastColliderWorldVertices||!e._lastColliderTransformMatrix.equals(t)){e._lastColliderTransformMatrix=t.clone(),e._lastColliderWorldVertices=[],e._trianglePlanes=[];const s=e.verticesStart,r=e.verticesStart+e.verticesCount;for(let n=s;n<r;n++)e._lastColliderWorldVertices.push(_.TransformCoordinates(this._positions[n],t))}return i._collide(e._trianglePlanes,e._lastColliderWorldVertices,this.getIndices(),e.indexStart,e.indexStart+e.indexCount,e.verticesStart,!!e.getMaterial(),this,this._shouldConvertRHS(),e.getMaterial()?.fillMode===7),this}_processCollisionsForSubMeshes(e,t){const i=this._scene.getCollidingSubMeshCandidates(this,e),s=i.length;for(let r=0;r<s;r++){const n=i.data[r];s>1&&!n._checkCollision(e)||this._collideForSubMesh(n,t,e)}return this}_shouldConvertRHS(){return!1}_checkCollision(e){if(!this.getBoundingInfo()._checkCollision(e))return this;const t=v.Matrix[0],i=v.Matrix[1];return P.ScalingToRef(1/e._radius.x,1/e._radius.y,1/e._radius.z,t),this.worldMatrixFromCache.multiplyToRef(t,i),this._processCollisionsForSubMeshes(e,i),this}_generatePointsArray(){return!1}intersects(e,t,i,s=!1,r,n=!1){const o=new ms,h=this.getClassName(),l=h==="InstancedLinesMesh"||h==="LinesMesh"||h==="GreasedLineMesh"?this.intersectionThreshold:0,c=this.getBoundingInfo();if(!this.subMeshes||!n&&(!e.intersectsSphere(c.boundingSphere,l)||!e.intersectsBox(c.boundingBox,l)))return o;if(s)return o.hit=!n,o.pickedMesh=n?null:this,o.distance=n?0:_.Distance(e.origin,c.boundingSphere.center),o.subMeshId=0,o;if(!this._generatePointsArray())return o;let u=null;const f=this._scene.getIntersectingSubMeshCandidates(this,e),d=f.length;let g=!1;for(let p=0;p<d;p++){const A=f.data[p].getMaterial();if(A&&(A.fillMode==7||A.fillMode==0||A.fillMode==1||A.fillMode==2||A.fillMode==4)){g=!0;break}}if(!g)return o.hit=!0,o.pickedMesh=this,o.distance=_.Distance(e.origin,c.boundingSphere.center),o.subMeshId=-1,o;for(let p=0;p<d;p++){const m=f.data[p];if(d>1&&!n&&!m.canIntersects(e))continue;const A=m.intersects(e,this._positions,this.getIndices(),t,i);if(A&&(t||!u||A.distance<u.distance)&&(u=A,u.subMeshId=m._id,u._internalSubMeshId=p,t))break}if(u){const p=r??this.getWorldMatrix(),m=v.Vector3[0],A=v.Vector3[1];_.TransformCoordinatesToRef(e.origin,p,m),e.direction.scaleToRef(u.distance,A);const I=_.TransformNormal(A,p).addInPlace(m);return o.hit=!0,o.distance=_.Distance(m,I),o.pickedPoint=I,o.pickedMesh=this,o.bu=u.bu||0,o.bv=u.bv||0,o.subMeshFaceId=u.faceId,o.faceId=u.faceId+f.data[u._internalSubMeshId].indexStart/(this.getClassName().indexOf("LinesMesh")!==-1?2:3),o.subMeshId=u.subMeshId,o}return o}clone(e,t,i){return null}releaseSubMeshes(e=!1){if(this.subMeshes)for(;this.subMeshes.length;)this.subMeshes[0].dispose(e);else this.subMeshes=[];return this}dispose(e,t=!1){let i;const s=this.getScene();for(this._scene.useMaterialMeshMap&&this._internalAbstractMeshDataInfo._material&&this._internalAbstractMeshDataInfo._material.meshMap&&(this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId]=void 0),s.freeActiveMeshes(),s.freeRenderingGroups(),s.renderingManager.maintainStateBetweenFrames&&s.renderingManager.restoreDispachedFlags(),this.actionManager!==void 0&&this.actionManager!==null&&(this.actionManager.disposeWhenUnowned&&!this._scene.meshes.some(o=>o!==this&&o.actionManager===this.actionManager)&&this.actionManager.dispose(),this.actionManager=null),this._internalAbstractMeshDataInfo._skeleton=null,this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null),i=0;i<this._intersectionsInProgress.length;i++){const o=this._intersectionsInProgress[i],h=o._intersectionsInProgress.indexOf(this);o._intersectionsInProgress.splice(h,1)}this._intersectionsInProgress.length=0;const r=s.lights;for(const o of r){let h=o.includedOnlyMeshes.indexOf(this);h!==-1&&o.includedOnlyMeshes.splice(h,1),h=o.excludedMeshes.indexOf(this),h!==-1&&o.excludedMeshes.splice(h,1);const l=o.getShadowGenerators();if(l){const c=l.values();for(let u=c.next();u.done!==!0;u=c.next()){const d=u.value.getShadowMap();d&&d.renderList&&(h=d.renderList.indexOf(this),h!==-1&&d.renderList.splice(h,1))}}}(this.getClassName()!=="InstancedMesh"||this.getClassName()!=="InstancedLinesMesh")&&this.releaseSubMeshes(!0);const n=s.getEngine();if(this._occlusionQuery!==null&&(this.isOcclusionQueryInProgress=!1,n.deleteQuery(this._occlusionQuery),this._occlusionQuery=null),n.wipeCaches(),s.removeMesh(this),this._parentContainer){const o=this._parentContainer.meshes.indexOf(this);o>-1&&this._parentContainer.meshes.splice(o,1),this._parentContainer=null}if(t&&this.material&&(this.material.getClassName()==="MultiMaterial"?this.material.dispose(!1,!0,!0):this.material.dispose(!1,!0)),!e)for(i=0;i<s.particleSystems.length;i++)s.particleSystems[i].emitter===this&&(s.particleSystems[i].dispose(),i--);this._internalAbstractMeshDataInfo._facetData.facetDataEnabled&&this.disableFacetData(),this._uniformBuffer.dispose(),this.onAfterWorldMatrixUpdateObservable.clear(),this.onCollideObservable.clear(),this.onCollisionPositionChangeObservable.clear(),this.onRebuildObservable.clear(),super.dispose(e,t)}_initFacetData(){const e=this._internalAbstractMeshDataInfo._facetData;e.facetNormals||(e.facetNormals=[]),e.facetPositions||(e.facetPositions=[]),e.facetPartitioning||(e.facetPartitioning=new Array),e.facetNb=this.getIndices().length/3|0,e.partitioningSubdivisions=e.partitioningSubdivisions?e.partitioningSubdivisions:10,e.partitioningBBoxRatio=e.partitioningBBoxRatio?e.partitioningBBoxRatio:1.01;for(let t=0;t<e.facetNb;t++)e.facetNormals[t]=_.Zero(),e.facetPositions[t]=_.Zero();return e.facetDataEnabled=!0,this}updateFacetData(){const e=this._internalAbstractMeshDataInfo._facetData;e.facetDataEnabled||this._initFacetData();const t=this.getVerticesData(b.PositionKind),i=this.getIndices(),s=this.getVerticesData(b.NormalKind)?.slice(),r=this.getBoundingInfo();if(e.facetDepthSort&&!e.facetDepthSortEnabled){if(e.facetDepthSortEnabled=!0,i instanceof Uint16Array)e.depthSortedIndices=new Uint16Array(i);else if(i instanceof Uint32Array)e.depthSortedIndices=new Uint32Array(i);else{let o=!1;for(let h=0;h<i.length;h++)if(i[h]>65535){o=!0;break}o?e.depthSortedIndices=new Uint32Array(i):e.depthSortedIndices=new Uint16Array(i)}if(e.facetDepthSortFunction=function(o,h){return h.sqDistance-o.sqDistance},!e.facetDepthSortFrom){const o=this.getScene().activeCamera;e.facetDepthSortFrom=o?o.position:_.Zero()}e.depthSortedFacets=[];for(let o=0;o<e.facetNb;o++){const h={ind:o*3,sqDistance:0};e.depthSortedFacets.push(h)}e.invertedMatrix=P.Identity(),e.facetDepthSortOrigin=_.Zero()}e.bbSize.x=r.maximum.x-r.minimum.x>Me?r.maximum.x-r.minimum.x:Me,e.bbSize.y=r.maximum.y-r.minimum.y>Me?r.maximum.y-r.minimum.y:Me,e.bbSize.z=r.maximum.z-r.minimum.z>Me?r.maximum.z-r.minimum.z:Me;let n=e.bbSize.x>e.bbSize.y?e.bbSize.x:e.bbSize.y;if(n=n>e.bbSize.z?n:e.bbSize.z,e.subDiv.max=e.partitioningSubdivisions,e.subDiv.X=Math.floor(e.subDiv.max*e.bbSize.x/n),e.subDiv.Y=Math.floor(e.subDiv.max*e.bbSize.y/n),e.subDiv.Z=Math.floor(e.subDiv.max*e.bbSize.z/n),e.subDiv.X=e.subDiv.X<1?1:e.subDiv.X,e.subDiv.Y=e.subDiv.Y<1?1:e.subDiv.Y,e.subDiv.Z=e.subDiv.Z<1?1:e.subDiv.Z,e.facetParameters.facetNormals=this.getFacetLocalNormals(),e.facetParameters.facetPositions=this.getFacetLocalPositions(),e.facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),e.facetParameters.bInfo=r,e.facetParameters.bbSize=e.bbSize,e.facetParameters.subDiv=e.subDiv,e.facetParameters.ratio=this.partitioningBBoxRatio,e.facetParameters.depthSort=e.facetDepthSort,e.facetDepthSort&&e.facetDepthSortEnabled&&(this.computeWorldMatrix(!0),this._worldMatrix.invertToRef(e.invertedMatrix),_.TransformCoordinatesToRef(e.facetDepthSortFrom,e.invertedMatrix,e.facetDepthSortOrigin),e.facetParameters.distanceTo=e.facetDepthSortOrigin),e.facetParameters.depthSortedFacets=e.depthSortedFacets,s&&$.ComputeNormals(t,i,s,e.facetParameters),e.facetDepthSort&&e.facetDepthSortEnabled){e.depthSortedFacets.sort(e.facetDepthSortFunction);const o=e.depthSortedIndices.length/3|0;for(let h=0;h<o;h++){const l=e.depthSortedFacets[h].ind;e.depthSortedIndices[h*3]=i[l],e.depthSortedIndices[h*3+1]=i[l+1],e.depthSortedIndices[h*3+2]=i[l+2]}this.updateIndices(e.depthSortedIndices,void 0,!0)}return this}getFacetLocalNormals(){const e=this._internalAbstractMeshDataInfo._facetData;return e.facetNormals||this.updateFacetData(),e.facetNormals}getFacetLocalPositions(){const e=this._internalAbstractMeshDataInfo._facetData;return e.facetPositions||this.updateFacetData(),e.facetPositions}getFacetLocalPartitioning(){const e=this._internalAbstractMeshDataInfo._facetData;return e.facetPartitioning||this.updateFacetData(),e.facetPartitioning}getFacetPosition(e){const t=_.Zero();return this.getFacetPositionToRef(e,t),t}getFacetPositionToRef(e,t){const i=this.getFacetLocalPositions()[e],s=this.getWorldMatrix();return _.TransformCoordinatesToRef(i,s,t),this}getFacetNormal(e){const t=_.Zero();return this.getFacetNormalToRef(e,t),t}getFacetNormalToRef(e,t){const i=this.getFacetLocalNormals()[e];return _.TransformNormalToRef(i,this.getWorldMatrix(),t),this}getFacetsAtLocalCoordinates(e,t,i){const s=this.getBoundingInfo(),r=this._internalAbstractMeshDataInfo._facetData,n=Math.floor((e-s.minimum.x*r.partitioningBBoxRatio)*r.subDiv.X*r.partitioningBBoxRatio/r.bbSize.x),o=Math.floor((t-s.minimum.y*r.partitioningBBoxRatio)*r.subDiv.Y*r.partitioningBBoxRatio/r.bbSize.y),h=Math.floor((i-s.minimum.z*r.partitioningBBoxRatio)*r.subDiv.Z*r.partitioningBBoxRatio/r.bbSize.z);return n<0||n>r.subDiv.max||o<0||o>r.subDiv.max||h<0||h>r.subDiv.max?null:r.facetPartitioning[n+r.subDiv.max*o+r.subDiv.max*r.subDiv.max*h]}getClosestFacetAtCoordinates(e,t,i,s,r=!1,n=!0){const o=this.getWorldMatrix(),h=v.Matrix[5];o.invertToRef(h);const l=v.Vector3[8];_.TransformCoordinatesFromFloatsToRef(e,t,i,h,l);const c=this.getClosestFacetAtLocalCoordinates(l.x,l.y,l.z,s,r,n);return s&&_.TransformCoordinatesFromFloatsToRef(s.x,s.y,s.z,o,s),c}getClosestFacetAtLocalCoordinates(e,t,i,s,r=!1,n=!0){let o=null,h=0,l=0,c=0,u=0,f=0,d=0,g=0,p=0;const m=this.getFacetLocalPositions(),A=this.getFacetLocalNormals(),E=this.getFacetsAtLocalCoordinates(e,t,i);if(!E)return null;let I=Number.MAX_VALUE,M=I,C,x,S;for(let L=0;L<E.length;L++)C=E[L],x=A[C],S=m[C],u=(e-S.x)*x.x+(t-S.y)*x.y+(i-S.z)*x.z,(!r||r&&n&&u>=0||r&&!n&&u<=0)&&(u=x.x*S.x+x.y*S.y+x.z*S.z,f=-(x.x*e+x.y*t+x.z*i-u)/(x.x*x.x+x.y*x.y+x.z*x.z),d=e+x.x*f,g=t+x.y*f,p=i+x.z*f,h=d-e,l=g-t,c=p-i,M=h*h+l*l+c*c,M<I&&(I=M,o=C,s&&(s.x=d,s.y=g,s.z=p)));return o}getFacetDataParameters(){return this._internalAbstractMeshDataInfo._facetData.facetParameters}disableFacetData(){const e=this._internalAbstractMeshDataInfo._facetData;return e.facetDataEnabled&&(e.facetDataEnabled=!1,e.facetPositions=[],e.facetNormals=[],e.facetPartitioning=new Array,e.facetParameters={},e.depthSortedIndices=new Uint32Array(0)),this}updateIndices(e,t,i=!1){return this}createNormals(e){const t=this.getVerticesData(b.PositionKind),i=this.getIndices();let s;return this.isVerticesDataPresent(b.NormalKind)?s=this.getVerticesData(b.NormalKind):s=[],$.ComputeNormals(t,i,s,{useRightHandedSystem:this.getScene().useRightHandedSystem}),this.setVerticesData(b.NormalKind,s,e),this}async optimizeIndicesAsync(){const e=this.getIndices();if(!e)return this;const{OptimizeIndices:t}=await G(async()=>{const{OptimizeIndices:i}=await import("./mesh.vertexData.functions-ayNlGC5K.js");return{OptimizeIndices:i}},[],import.meta.url);return t(e),this.setIndices(e,this.getTotalVertices()),this}alignWithNormal(e,t){t||(t=ts.Y);const i=v.Vector3[0],s=v.Vector3[1];return _.CrossToRef(t,e,s),_.CrossToRef(e,s,i),this.rotationQuaternion?W.RotationQuaternionFromAxisToRef(i,e,s,this.rotationQuaternion):_.RotationFromAxisToRef(i,e,s,this.rotation),this}_checkOcclusionQuery(){return!1}disableEdgesRendering(){throw ie("EdgesRenderer")}enableEdgesRendering(e,t,i){throw ie("EdgesRenderer")}getConnectedParticleSystems(){return this._scene.particleSystems.filter(e=>e.emitter===this)}}Ct.OCCLUSION_TYPE_NONE=0;Ct.OCCLUSION_TYPE_OPTIMISTIC=1;Ct.OCCLUSION_TYPE_STRICT=2;Ct.OCCLUSION_ALGORITHM_TYPE_ACCURATE=0;Ct.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE=1;Ct.CULLINGSTRATEGY_STANDARD=0;Ct.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1;Ct.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2;Ct.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3;T([yi.filter((...[a,e,t,i,s])=>!Array.isArray(a)&&!Array.isArray(e)&&!Array.isArray(t)&&!Array.isArray(i)&&!Array.isArray(s))],Ct,"_ApplySkeleton",null);nt("BABYLON.AbstractMesh",Ct);class Bt{constructor(){this.reset()}reset(){this.enabled=!1,this.mask=255,this.funcRef=1,this.funcMask=255,this.func=519,this.opStencilFail=7680,this.opDepthFail=7680,this.opStencilDepthPass=7681,this.backFunc=519,this.backOpStencilFail=7680,this.backOpDepthFail=7680,this.backOpStencilDepthPass=7681}get func(){return this._func}set func(e){this._func=e}get backFunc(){return this._backFunc}set backFunc(e){this._backFunc=e}get funcRef(){return this._funcRef}set funcRef(e){this._funcRef=e}get funcMask(){return this._funcMask}set funcMask(e){this._funcMask=e}get opStencilFail(){return this._opStencilFail}set opStencilFail(e){this._opStencilFail=e}get opDepthFail(){return this._opDepthFail}set opDepthFail(e){this._opDepthFail=e}get opStencilDepthPass(){return this._opStencilDepthPass}set opStencilDepthPass(e){this._opStencilDepthPass=e}get backOpStencilFail(){return this._backOpStencilFail}set backOpStencilFail(e){this._backOpStencilFail=e}get backOpDepthFail(){return this._backOpDepthFail}set backOpDepthFail(e){this._backOpDepthFail=e}
23get backOpStencilDepthPass(){return this._backOpStencilDepthPass}set backOpStencilDepthPass(e){this._backOpStencilDepthPass=e}get mask(){return this._mask}set mask(e){this._mask=e}get enabled(){return this._enabled}set enabled(e){this._enabled=e}getClassName(){return"MaterialStencilState"}copyTo(e){le.Clone(()=>e,this)}serialize(){return le.Serialize(this)}parse(e,t,i){le.Parse(()=>this,e,t,i)}}T([R()],Bt.prototype,"func",null);T([R()],Bt.prototype,"backFunc",null);T([R()],Bt.prototype,"funcRef",null);T([R()],Bt.prototype,"funcMask",null);T([R()],Bt.prototype,"opStencilFail",null);T([R()],Bt.prototype,"opDepthFail",null);T([R()],Bt.prototype,"opStencilDepthPass",null);T([R()],Bt.prototype,"backOpStencilFail",null);T([R()],Bt.prototype,"backOpDepthFail",null);T([R()],Bt.prototype,"backOpStencilDepthPass",null);T([R()],Bt.prototype,"mask",null);T([R()],Bt.prototype,"enabled",null);class Ee{static CompareLightsPriority(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority}}Ee.FALLOFF_DEFAULT=0;Ee.FALLOFF_PHYSICAL=1;Ee.FALLOFF_GLTF=2;Ee.FALLOFF_STANDARD=3;Ee.LIGHTMAP_DEFAULT=0;Ee.LIGHTMAP_SPECULAR=1;Ee.LIGHTMAP_SHADOWSONLY=2;Ee.INTENSITYMODE_AUTOMATIC=0;Ee.INTENSITYMODE_LUMINOUSPOWER=1;Ee.INTENSITYMODE_LUMINOUSINTENSITY=2;Ee.INTENSITYMODE_ILLUMINANCE=3;Ee.INTENSITYMODE_LUMINANCE=4;Ee.LIGHTTYPEID_POINTLIGHT=0;Ee.LIGHTTYPEID_DIRECTIONALLIGHT=1;Ee.LIGHTTYPEID_SPOTLIGHT=2;Ee.LIGHTTYPEID_HEMISPHERICLIGHT=3;Ee.LIGHTTYPEID_RECT_AREALIGHT=4;Ee.LIGHTTYPEID_CLUSTERED_CONTAINER=5;const Nt=new P,Wt=new P,Xt=new P,Gr={getScene:()=>{},eyeAtCamera:!0};function zs(a,e,t){const i=t.asArray(),s=e.asArray();for(let r=0;r<16;r++)i[r]=s[r];return i[12]-=a.x,i[13]-=a.y,i[14]-=a.z,t.markAsUpdated(),t}function Xo(a,e,t){return xr(e,Wt),zs(a,Wt,Xt),xr(Xt,t),t}function Or(a,e,t){if(!Gr.eyeAtCamera)return Xo(a,e,t);const i=t.asArray(),s=e.asArray();for(let r=0;r<16;r++)i[r]=s[r];return i[12]=0,i[13]=0,i[14]=0,t.markAsUpdated(),t}function bn(a,e,t,i){return gs(Or(a,e,i),t,i),i}function g_(a,e,t,i,s){for(let r=0;r<i;++r)Gc(a,e[r],t[r],Wt),Wt.copyToArray(s,r*16);return s}function ga(a,e,t,i){return xr(t,Wt),gs(e,Wt,Xt),zs(a,Xt,Wt),Or(a,t,Xt),gs(Wt,Xt,i),i}function Gc(a,e,t,i){return Xo(a,e,Xt),gs(Xt,t,i),i}function pa(a,e,t,i,s,r){return xr(t,Wt),gs(e,Wt,Xt),zs(a,Xt,Wt),bn(a,i,s,Xt),gs(Wt,Xt,r),r}function ma(a,e){const t=Gr.getScene();if(!t||Nt===e)return e;Nt.updateFlag=e.updateFlag;const i=t.floatingOriginOffset;switch(a){case"world":return zs(i,e,Nt);case"view":return Or(i,e,Nt);case"worldView":return ga(i,e,t.getViewMatrix(),Nt);case"viewProjection":return bn(i,t.getViewMatrix(),t.getProjectionMatrix(),Nt);case"worldViewProjection":return pa(i,e,t.getTransformMatrix(),t.getViewMatrix(),t.getProjectionMatrix(),Nt);default:if(a.startsWith("u_")){const s=a.toLowerCase();if(s.startsWith("u_worldviewprojection"))return pa(i,e,t.getTransformMatrix(),t.getViewMatrix(),t.getProjectionMatrix(),Nt);if(s.startsWith("u_viewprojection"))return bn(i,t.getViewMatrix(),t.getProjectionMatrix(),Nt);if(s.startsWith("u_worldview"))return ga(i,e,t.getViewMatrix(),Nt);if(s.startsWith("u_world"))return zs(i,e,Nt);if(s.startsWith("u_view"))return Or(i,e,Nt)}return e}}const Ws=K,En=ze,Ko=Ws.prototype._updateMatrixForUniform,Yo=ze.prototype.setMatr
23ix;function Hc(){ze.prototype.setMatrix=Yo,En._setMatrixOverride=void 0,Ws.prototype._updateMatrixForUniform=Ko,Ws.prototype._updateMatrixForUniformOverride=void 0}function Vc(){En.prototype._setMatrixOverride=Yo,En.prototype.setMatrix=function(a,e){return this._setMatrixOverride(a,ma(a,e)),this},Ws.prototype._updateMatrixForUniformOverride=Ko,Ws.prototype._updateMatrixForUniform=function(a,e){this._updateMatrixForUniformOverride(a,ma(a,e))}}function qo(a){a.indexOf("vClipPlane")===-1&&a.push("vClipPlane"),a.indexOf("vClipPlane2")===-1&&a.push("vClipPlane2"),a.indexOf("vClipPlane3")===-1&&a.push("vClipPlane3"),a.indexOf("vClipPlane4")===-1&&a.push("vClipPlane4"),a.indexOf("vClipPlane5")===-1&&a.push("vClipPlane5"),a.indexOf("vClipPlane6")===-1&&a.push("vClipPlane6")}function p_(a,e,t){const i=!!(a.clipPlane??e.clipPlane),s=!!(a.clipPlane2??e.clipPlane2),r=!!(a.clipPlane3??e.clipPlane3),n=!!(a.clipPlane4??e.clipPlane4),o=!!(a.clipPlane5??e.clipPlane5),h=!!(a.clipPlane6??e.clipPlane6);i&&t.push("#define CLIPPLANE"),s&&t.push("#define CLIPPLANE2"),r&&t.push("#define CLIPPLANE3"),n&&t.push("#define CLIPPLANE4"),o&&t.push("#define CLIPPLANE5"),h&&t.push("#define CLIPPLANE6")}function zc(a,e,t){let i=!1;const s=!!(a.clipPlane??e.clipPlane),r=!!(a.clipPlane2??e.clipPlane2),n=!!(a.clipPlane3??e.clipPlane3),o=!!(a.clipPlane4??e.clipPlane4),h=!!(a.clipPlane5??e.clipPlane5),l=!!(a.clipPlane6??e.clipPlane6);return t.CLIPPLANE!==s&&(t.CLIPPLANE=s,i=!0),t.CLIPPLANE2!==r&&(t.CLIPPLANE2=r,i=!0),t.CLIPPLANE3!==n&&(t.CLIPPLANE3=n,i=!0),t.CLIPPLANE4!==o&&(t.CLIPPLANE4=o,i=!0),t.CLIPPLANE5!==h&&(t.CLIPPLANE5=h,i=!0),t.CLIPPLANE6!==l&&(t.CLIPPLANE6=l,i=!0),i}function jo(a,e,t){let i=e.clipPlane??t.clipPlane;rs(a,"vClipPlane",i),i=e.clipPlane2??t.clipPlane2,rs(a,"vClipPlane2",i),i=e.clipPlane3??t.clipPlane3,rs(a,"vClipPlane3",i),i=e.clipPlane4??t.clipPlane4,rs(a,"vClipPlane4",i),i=e.clipPlane5??t.clipPlane5,rs(a,"vClipPlane5",i),i=e.clipPlane6??t.clipPlane6,rs(a,"vClipPlane6",i)}function rs(a,e,t){if(t){const i=Gr.getScene()?.floatingOriginOffset||_.ZeroReadOnly;a.setFloat4(e,t.normal.x,t.normal.y,t.normal.z,t.d+_.Dot(t.normal,i))}}class U{static get DiffuseTextureEnabled(){return this._DiffuseTextureEnabled}static set DiffuseTextureEnabled(e){this._DiffuseTextureEnabled!==e&&(this._DiffuseTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get BaseWeightTextureEnabled(){return this._BaseWeightTextureEnabled}static set BaseWeightTextureEnabled(e){this._BaseWeightTextureEnabled!==e&&(this._BaseWeightTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get BaseDiffuseRoughnessTextureEnabled(){return this._BaseDiffuseRoughnessTextureEnabled}static set BaseDiffuseRoughnessTextureEnabled(e){this._BaseDiffuseRoughnessTextureEnabled!==e&&(this._BaseDiffuseRoughnessTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get DetailTextureEnabled(){return this._DetailTextureEnabled}static set DetailTextureEnabled(e){this._DetailTextureEnabled!==e&&(this._DetailTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get DecalMapEnabled(){return this._DecalMapEnabled}static set DecalMapEnabled(e){this._DecalMapEnabled!==e&&(this._DecalMapEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get AmbientTextureEnabled(){return this._AmbientTextureEnabled}static set AmbientTextureEnabled(e){this._AmbientTextureEnabled!==e&&(this._AmbientTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get OpacityTextureEnabled(){return this._OpacityTextureEnabled}static set OpacityTextureEnabled(e){this._OpacityTextureEnabled!==e&&(this._OpacityTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get ReflectionTextureEnabled(){return this._ReflectionTextureEnabled}static set ReflectionTextureEnabled(e){this._ReflectionTextureEnabled!==e&&(this._ReflectionTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get EmissiveTextureEnabled(){return this._EmissiveTextureEnabled}static set EmissiveTextureEnabled(e){this._EmissiveTextureEnabled!==e&&(this._EmissiveTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get SpecularTextureEnabled(){return this._SpecularTextureEnabled}static set SpecularTextureEnabled(e){this._SpecularTextureEnabled!==e&&(this._SpecularTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get BumpTextureEnabled(){return this._BumpTextureEnabled}static set BumpTextureEnabled(e){this._BumpTextureEnabled!==e&&(this._BumpTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get LightmapTextureEnabled(){return this._LightmapTextureEnabled}static set LightmapTextureEnabled(e){this._LightmapTextureEnabled!==e&&(this._LightmapTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get RefractionTextureEnabled(){return this._RefractionTextureEnabled}static set RefractionTextureEnabled(e){this._RefractionTextureEnabled!==e&&(this._RefractionTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get ColorGradingTextureEnabled(){return this._ColorGradingTextureEnabled}static set ColorGradingTextureEnabled(e){this._ColorGradingTextureEnabled!==e&&(this._ColorGradingTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get FresnelEnabled(){return this._FresnelEnabled}static set FresnelEnabled(e){this._FresnelEnabled!==e&&(this._FresnelEnabled=e,H.MarkAllMaterialsAsDirty(4))}static get ClearCoatTextureEnabled(){return this._ClearCoatTextureEnabled}static set ClearCoatTextureEnabled(e){this._ClearCoatTextureEnabled!==e&&(this._ClearCoatTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get ClearCoatBumpTextureEnabled(){return this._ClearCoatBumpTextureEnabled}static set ClearCoatBumpTextureEnabled(e){this._ClearCoatBumpTextureEnabled!==e&&(this._ClearCoatBumpTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get ClearCoatTintTextureEnabled(){return this._ClearCoatTintTextureEnabled}static set ClearCoatTintTextureEnabled(e){this._ClearCoatTintTextureEnabled!==e&&(this._ClearCoatTintTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get SheenTextureEnabled(){return this._SheenTextureEnabled}static set SheenTextureEnabled(e){this._SheenTextureEnabled!==e&&(this._SheenTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get AnisotropicTextureEnabled(){return this._AnisotropicTextureEnabled}static set AnisotropicTextureEnabled(e){this._AnisotropicTextureEnabled!==e&&(this._AnisotropicTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get ThicknessTextureEnabled(){return this._ThicknessTextureEnabled}static set ThicknessTextureEnabled(e){this._ThicknessTextureEnabled!==e&&(this._ThicknessTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get RefractionIntensityTextureEnabled(){return this._ThicknessTextureEnabled}static set RefractionIntensityTextureEnabled(e){this._RefractionIntensityTextureEnabled!==e&&(this._RefractionIntensityTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get TranslucencyIntensityTextureEnabled(){return this._TranslucencyIntensityTextureEnabled}static set TranslucencyIntensityTextureEnabled(e){this._TranslucencyIntensityTextureEnabled!==e&&(this._TranslucencyIntensityTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get TranslucencyColorTextureEnabled(){return this._TranslucencyColorTextureEnabled}static set TranslucencyColorTextureEnabled(e){this._TranslucencyColorTextureEnabled!==e&&(this._TranslucencyColorTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}static get IridescenceTextureEnabled(){return this._IridescenceTextureEnabled}static set IridescenceTextureEnabled(e){this._IridescenceTextureEnabled!==e&&(this._IridescenceTextureEnabled=e,H.MarkAllMaterialsAsDirty(1))}}U._DiffuseTextureEnabled=!0;U._BaseWeightTextureEnabled=!0;U._BaseDiffuseRoughnessTextureEnabled=!0;U._DetailTextureEnabled=!0;U._DecalMapEnabled=!0;U._AmbientTextureEnabled=!0;U._OpacityTextureEnabled=!0;U._ReflectionTextureEnabled=!0;U._EmissiveTextureEnabled=!0;U._SpecularTextureEnabled=!0;U._BumpTextureEnabled=!0;U._LightmapTextureEnabled=!0;U._RefractionTextureEnabled=!0;U._ColorGradingTextureEnabled=!0;U._FresnelEnabled=!0;U._ClearCoatTextureEnabled=!0;U._ClearCoatBumpTextureEnabled=!0;U._ClearCoatTintTextureEnabled=!0;U._SheenTextureEnabled=!0;U._AnisotropicTextureEnabled=!0;U._ThicknessTextureEnabled=!0;U._RefractionIntensityTextureEnabled=!0;U._TranslucencyIntensityTextureEnabled=!0;U._TranslucencyColorTextureEnabled=!0;U._IridescenceTextureEnabled=!0;class Ft{constructor(e,t){this.width=e,this.height=t}toString(){return`{W: ${this.width}, H: ${this.height}}`}getClassName(){return"Size"}getHashCode(){let e=this.width|0;return e=e*397^(this.height|0),e}
vendor: 15,793 bytes, line 23
23copyFrom(e){this.width=e.width,this.height=e.height}copyFromFloats(e,t){return this.width=e,this.height=t,this}set(e,t){return this.copyFromFloats(e,t)}multiplyByFloats(e,t){return new Ft(this.width*e,this.height*t)}clone(){return new Ft(this.width,this.height)}equals(e){return e?this.width===e.width&&this.height===e.height:!1}get surface(){return this.width*this.height}static Zero(){return new Ft(0,0)}add(e){return new Ft(this.width+e.width,this.height+e.height)}subtract(e){return new Ft(this.width-e.width,this.height-e.height)}scale(e){return new Ft(this.width*e,this.height*e)}static Lerp(e,t,i){const s=e.width+(t.width-e.width)*i,r=e.height+(t.height-e.height)*i;return new Ft(s,r)}}class fs{get wrapU(){return this._wrapU}set wrapU(e){this._wrapU=e}get wrapV(){return this._wrapV}set wrapV(e){this._wrapV=e}get coordinatesMode(){return 0}get isCube(){return this._texture?this._texture.isCube:!1}set isCube(e){this._texture&&(this._texture.isCube=e)}get is3D(){return this._texture?this._texture.is3D:!1}set is3D(e){this._texture&&(this._texture.is3D=e)}get is2DArray(){return this._texture?this._texture.is2DArray:!1}set is2DArray(e){this._texture&&(this._texture.is2DArray=e)}getClassName(){return"ThinTexture"}static _IsRenderTargetWrapper(e){return e?.shareDepth!==void 0}constructor(e){this._wrapU=1,this._wrapV=1,this.wrapR=1,this.anisotropicFilteringLevel=4,this.delayLoadState=0,this._texture=null,this._engine=null,this._cachedSize=Ft.Zero(),this._cachedBaseSize=Ft.Zero(),this._initialSamplingMode=2,this._texture=fs._IsRenderTargetWrapper(e)?e.texture:e,this._texture&&(this._engine=this._texture.getEngine(),this.wrapU=this._texture._cachedWrapU??this.wrapU,this.wrapV=this._texture._cachedWrapV??this.wrapV,this.wrapR=this._texture._cachedWrapR??this.wrapR)}isReady(){return this.delayLoadState===4?(this.delayLoad(),!1):this._texture?this._texture.isReady:!1}delayLoad(){}getInternalTexture(){return this._texture}getSize(){if(this._texture){if(this._texture.width)return this._cachedSize.width=this._texture.width,this._cachedSize.height=this._texture.height,this._cachedSize;if(this._texture._size)return this._cachedSize.width=this._texture._size,this._cachedSize.height=this._texture._size,this._cachedSize}return this._cachedSize}getBaseSize(){return!this.isReady()||!this._texture?(this._cachedBaseSize.width=0,this._cachedBaseSize.height=0,this._cachedBaseSize):this._texture._size?(this._cachedBaseSize.width=this._texture._size,this._cachedBaseSize.height=this._texture._size,this._cachedBaseSize):(this._cachedBaseSize.width=this._texture.baseWidth,this._cachedBaseSize.height=this._texture.baseHeight,this._cachedBaseSize)}get samplingMode(){return this._texture?this._texture.samplingMode:this._initialSamplingMode}updateSamplingMode(e,t=!1){this._texture&&this._engine&&this._engine.updateTextureSamplingMode(e,this._texture,this._texture.generateMipMaps&&t)}releaseInternalTexture(){this._texture&&(this._texture.dispose(),this._texture=null)}dispose(){this._texture&&(this.releaseInternalTexture(),this._engine=null)}}class De extends fs{set hasAlpha(e){this._hasAlpha!==e&&(this._hasAlpha=e,this._scene&&this._scene.markAllMaterialsAsDirty(1,t=>t.hasTexture(this)))}get hasAlpha(){return this._hasAlpha}set getAlphaFromRGB(e){this._getAlphaFromRGB!==e&&(this._getAlphaFromRGB=e,this._scene&&this._scene.markAllMaterialsAsDirty(1,t=>t.hasTexture(this)))}get getAlphaFromRGB(){return this._getAlphaFromRGB}set coordinatesIndex(e){this._coordinatesIndex!==e&&(this._coordinatesIndex=e,this._scene&&this._scene.markAllMaterialsAsDirty(1,t=>t.hasTexture(this)))}get coordinatesIndex(){return this._coordinatesIndex}set coordinatesMode(e){this._coordinatesMode!==e&&(this._coordinatesMode=e,this._scene&&this._scene.markAllMaterialsAsDirty(1,t=>t.hasTexture(this)))}get coordinatesMode(){return this._coordinatesMode}get wrapU(){return this._wrapU}set wrapU(e){this._wrapU=e}get wrapV(){return this._wrapV}set wrapV(e){this._wrapV=e}get isCube(){return this._texture?this._texture.isCube:this._isCube}set isCube(e){this._texture?this._texture.isCube=e:this._isCube=e}get is3D(){return this._texture?this._texture.is3D:!1}set is3D(e){this._texture&&(this._texture.is3D=e)}get is2DArray(){return this._texture?this._texture.is2DArray:!1}set is2DArray(e){this._texture&&(this._texture.is2DArray=e)}get gammaSpace(){if(this._texture)this._texture._gammaSpace===null&&(this._texture._gammaSpace=this._gammaSpace);else return this._gammaSpace;return this._texture._gammaSpace&&!this._texture._useSRGBBuffer}set gammaSpace(e){if(this._texture){if(this._texture._gammaSpace===e)return;this._texture._gammaSpace=e}else{if(this._gammaSpace===e)return;this._gammaSpace=e}this.getScene()?.markAllMaterialsAsDirty(1,t=>t.hasTexture(this))}get isRGBD(){return this._texture!=null&&this._texture._isRGBD}set isRGBD(e){e!==this.isRGBD&&(this._texture&&(this._texture._isRGBD=e),this.getScene()?.markAllMaterialsAsDirty(1,t=>t.hasTexture(this)))}get noMipmap(){return!1}get lodGenerationOffset(){return this._texture?this._texture._lodGenerationOffset:0}set lodGenerationOffset(e){this._texture&&(this._texture._lodGenerationOffset=e)}get lodGenerationScale(){return this._texture?this._texture._lodGenerationScale:0}set lodGenerationScale(e){this._texture&&(this._texture._lodGenerationScale=e)}get linearSpecularLOD(){return this._texture?this._texture._linearSpecularLOD:!1}set linearSpecularLOD(e){this._texture&&(this._texture._linearSpecularLOD=e)}get irradianceTexture(){return this._texture?this._texture._irradianceTexture:null}set irradianceTexture(e){this._texture&&(this._texture._irradianceTexture=e)}get uid(){return this._uid||(this._uid=Bn()),this._uid}toString(){return this.name}getClassName(){return"BaseTexture"}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}get isBlocking(){return!0}get loadingError(){return this._loadingError}get errorObject(){return this._errorObject}constructor(e,t=null){super(null),this.metadata=null,this.reservedDataStore=null,this._hasAlpha=!1,this._getAlphaFromRGB=!1,this.level=1,this._coordinatesIndex=0,this.optimizeUVAllocation=!0,this._coordinatesMode=0,this.wrapR=1,this.anisotropicFilteringLevel=De.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,this._isCube=!1,this._gammaSpace=!0,this.invertZ=!1,this.lodLevelInAlpha=!1,this._dominantDirection=null,this.isRenderTarget=!1,this._prefiltered=!1,this._forceSerialize=!1,this.animations=[],this.onDisposeObservable=new O,this._onDisposeObserver=null,this._scene=null,this._uid=null,this._parentContainer=null,this._loadingError=!1,e?De._IsScene(e)?this._scene=e:this._engine=e:this._scene=Te.LastCreatedScene,this._scene&&(this.uniqueId=this._scene.getUniqueId(),this._scene.addTexture(this),this._engine=this._scene.getEngine()),this._texture=t,this._uid=null}getScene(){return this._scene}_getEngine(){return this._engine}getTextureMatrix(){return P.IdentityReadOnly}getReflectionTextureMatrix(){return P.IdentityReadOnly}getRefractionTextureMatrix(){return this.getReflectionTextureMatrix()}isReadyOrNotBlocking(){return!this.isBlocking||this.isReady()||this.loadingError}scale(e){}get canRescale(){return!1}_getFromCache(e,t,i,s,r,n){const o=this._getEngine();if(!o)return null;const h=o._getUseSRGBBuffer(!!r,t),l=o.getLoadedTexturesCache();for(let c=0;c<l.length;c++){const u=l[c];if((r===void 0||h===u._useSRGBBuffer)&&(s===void 0||s===u.invertY)&&u.url===e&&u.generateMipMaps===!t&&(!i||i===u.samplingMode)&&(n===void 0||n===u.isCube))return u.incrementReferences(),u}return null}_rebuild(e=!1){}clone(){return null}get textureType(){return this._texture&&this._texture.type!==void 0?this._texture.type:0}get textureFormat(){return this._texture&&this._texture.format!==void 0?this._texture.format:5}_markAllSubMeshesAsTexturesDirty(){const e=this.getScene();e&&e.markAllMaterialsAsDirty(1)}readPixels(e=0,t=0,i=null,s=!0,r=!1,n=0,o=0,h=Number.MAX_VALUE,l=Number.MAX_VALUE){if(!this._texture)return null;const c=this._getEngine();if(!c)return null;const u=this.getSize();let f=u.width,d=u.height;t!==0&&(f=f/Math.pow(2,t),d=d/Math.pow(2,t),f=Math.round(f),d=Math.round(d)),h=Math.min(f,h),l=Math.min(d,l);try{return this._texture.isCube?c._readTexturePixels(this._texture,h,l,e,t,i,s,r,n,o):c._readTexturePixels(this._texture,h,l,-1,t,i,s,r,n,o)}catch{return null}}_readPixelsSync(e=0,t=0,i=null,s=!0,r=!1){if(!this._texture)return null;const n=this.getSize();let o=n.width,h=n.height;const l=this._getEngine();if(!l)return null;t!=0&&(o=o/Math.pow(2,t),h=h/Math.pow(2,t),o=Math.round(o),h=Math.round(h));try{return this._texture.isCube?l._readTexturePixelsSync(this._texture,o,h,e,t,i,s,r):l._readTexturePixelsSync(this._texture,o,h,-1,t,i,s,r)}catch{return null}}get _lodTextureHigh(){return this._texture?this._texture._lodTextureHigh:null}get _lodTextureMid(){return this._texture?this._texture._lodTextureMid:null}get _lodTextureLow(){return this._texture?this._texture._lodTextureLow:null}dispose(){if(this._scene){this._scene.stopAnimation&&this._scene.stopAnimation(this),this._scene.removePendingData(this);const e=this._scene.textures.indexOf(this);if(e>=0&&this._scene.textures.splice(e,1),this._scene.onTextureRemovedObservable.notifyObservers(this),this._scene=null,this._parentContainer){const t=this._parentContainer.textures.indexOf(this);t>-1&&this._parentContainer.textures.splice(t,1),this._parentContainer=null}}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.metadata=null,super.dispose()}serialize(e=!1){if(!this.name&&!e)return null;const t=le.Serialize(this);return le.AppendSerializedAnimations(this,t),t}static WhenAllReady(e,t){let i=e.length;if(i===0){t();return}for(let s=0;s<e.length;s++){const r=e[s];if(r.isReady())--i===0&&t();else{const n=r.onLoadObservable;n?n.addOnce(()=>{--i===0&&t()}):--i===0&&t()}}}static _IsScene(e){return e.getClassName()==="Scene"}}De.DEFAULT_ANISOTROPIC_FILTERING_LEVEL=4;T([R()],De.prototype,"uniqueId",void 0);T([R()],De.prototype,"name",void 0);T([R()],De.prototype,"displayName",void 0);T([R()],De.prototype,"metadata",void 0);T([R("hasAlpha")],De.prototype,"_hasAlpha",void 0);T([R("getAlphaFromRGB")],De.prototype,"_getAlphaFromRGB",void 0);T([R()],De.prototype,"level",void 0);T([R("coordinatesIndex")],De.prototype,"_coordinatesIndex",void 0);T([R()],De.prototype,"optimizeUVAllocation",void 0);T([R("coordinatesMode")],De.prototype,"_coordinatesMode",void 0);T([R()],De.prototype,"wrapU",null);T([R()],De.prototype,"wrapV",null);T([R()],De.prototype,"wrapR",void 0);T([R()],De.prototype,"anisotropicFilteringLevel",void 0);T([R()],De.prototype,"isCube",null);T([R()],De.prototype,"is3D",null);T([R()],De.prototype,"is2DArray",null);T([R()],De.prototype,"gammaSpace",null);T([R()],De.prototype,"invertZ",void 0);T([R()],De.prototype,"lodLevelInAlpha",void 0);T([R()],De.prototype,"lodGenerationOffset",null);T([R()],De.prototype,"lodGenerationScale",null);T([R()],De.prototype,"linearSpecularLOD",null);T([Oe()],De.prototype,"irradianceTexture",null);T([R()],De.prototype,"isRenderTarget",void 0);function Qo(a,e,t=!1){const i=e.width,s=e.height;if(a instanceof Float32Array){let l=a.byteLength/a.BYTES_PER_ELEMENT;const c=new Uint8Array(l);for(;--l>=0;){let u=a[l];u<0?u=0:u>1&&(u=1),c[l]=u*255}a=c}const r=document.createElement("canvas");r.width=i,r.height=s;const n=r.getContext("2d");if(!n)return null;const o=n.createImageData(i,s);if(o.data.set(a),n.putImageData(o,0,0),t){const l=document.createElement("canvas");l.width=i,l.height=s;const c=l.getContext("2d");return c?(c.translate(0,s),c.scale(1,-1),c.drawImage(r,0,0),l.toDataURL("image/png")):null}return r.toDataURL("image/png")}function Wc(a,e=0,t=0){const i=a.getInternalTexture();if(!i)return null;const s=a._readPixelsSync(e,t);return s?Qo(s,a.getSize(),i.invertY):null}async function Xc(a,e=0,t=0){const i=a.getInternalTexture();if(!i)return null;const s=await a.readPixels(e,t);return s?Qo(s,a.getSize(),i.invertY):null}class z extends De{static _CreateVideoTexture(e,t,i,s=!1,r=!1,n=z.TRILINEAR_SAMPLINGMODE,o={},h,l=5){throw ie("VideoTexture")}get noMipmap(){return this._noMipmap}get mimeType(){return this._mimeType}set isBlocking(e){this._isBlocking=e}get isBlocking(){return this._isBlocking}get invertY(){return this._invertY}constructor(e,t,i,s,r=z.TRILINEAR_SAMPLINGMODE,n=null,o=null,h=null,l=!1,c,u,f,d,g){super(t),this.url=null,this.uOffset=0,this.vOffset=0,this.uScale=1,this.vScale=1,this.uAng=0,this.vAng=0,this.wAng=0,this.uRotationCenter=.5,this.vRotationCenter=.5,this.wRotationCenter=.5,this.homogeneousRotationInUVTransform=!1,this.inspectableCustomProperties=null,this._noMipmap=!1,this._invertY=!1,this._rowGenerationMatrix=null,this._cachedTextureMatrix=null,this._projectionModeMatrix=null,this._t0=null,this._t1=null,this._t2=null,this._cachedUOffset=-1,this._cachedVOffset=-1,this._cachedUScale=0,this._cachedVScale=0,this._cachedUAng=-1,this._cachedVAng=-1,this._cachedWAng=-1,this._cachedReflectionProjectionMatrixId=-1,this._cachedURotationCenter=-1,this._cachedVRotationCenter=-1,this._cachedWRotationCenter=-1,this._cachedHomogeneousRotationInUVTransform=!1,this._cachedIdentity3x2=!0,this._cachedReflectionTextureMatrix=null,this._cachedReflectionUOffset=-1,this._cachedReflectionVOffset=-1,this._cachedReflectionUScale=0,this._cachedReflectionVScale=0,this._cachedReflectionCoordinatesMode=-1,this._buffer=null,this._deleteBuffer=!1,this._format=null,this._delayedOnLoad=null,this._delayedOnError=null,this.onLoadObservable=new O,this._isBlocking=!0,this.name=e||"",this.url=e;let p,m=!1,A=null,E=!0;typeof i=="object"&&i!==null?(p=i.noMipmap??!1,s=i.invertY??!0,r=i.samplingMode??z.TRILINEAR_SAMPLINGMODE,n=i.onLoad??null,o=i.onError??null,h=i.buffer??null,l=i.deleteBuffer??!1,c=i.format,u=i.mimeType,f=i.loaderOptions,d=i.creationFlags,m=i.useSRGBBuffer??!1,A=i.internalTexture??null,E=i.gammaSpace??E,g=i.forcedExtension??g):p=!!i,this._gammaSpace=E,this._noMipmap=p,this._invertY=s===void 0?!0:s,this._initialSamplingMode=r,this._buffer=h,this._deleteBuffer=l,this._mimeType=u,this._loaderOptions=f,this._creationFlags=d,this._useSRGBBuffer=m,this._forcedExtension=g,c!==void 0&&(this._format=c);const I=this.getScene(),M=this._getEngine();if(!M)return;M.onBeforeTextureInitObservable.notifyObservers(this);const C=()=>{this._texture&&(this._texture._invertVScale&&(this.vScale*=-1,this.vOffset+=1),this._texture._cachedWrapU!==null&&(this.wrapU=this._texture._cachedWrapU,this._texture._cachedWrapU=null),this._texture._cachedWrapV!==null&&(this.wrapV=this._texture._cachedWrapV,this._texture._cachedWrapV=null),this._texture._cachedWrapR!==null&&(this.wrapR=this._texture._cachedWrapR,this._texture._cachedWrapR=null)),this.onLoadObservable.hasObservers()&&this.onLoadObservable.notifyObservers(this),n&&n(),!this.isBlocking&&I&&I.resetCachedMaterial()},x=(S,L)=>{this._loadingError=!0,this._errorObject={message:S,exception:L},o&&o(S,L),z.OnTextureLoadErrorObservable.notifyObservers(this)};if(!this.url&&!A){this._delayedOnLoad=C,this._delayedOnError=x;return}if(this._texture=A??this._getFromCache(this.url,p,r,this._invertY,m,this.isCube),this._texture)if(this._texture.isReady)ks.SetImmediate(()=>C());else{const S=this._texture.onLoadedObservable.add(C);this._texture.onErrorObservable.add(L=>{x(L.message,L.exception),this._texture?.onLoadedObservable.remove(S)})}else if(!I||!I.useDelayedTextureLoading){try{this._texture=M.createTexture(this.url,p,this._invertY,I,r,C,x,this._buffer,void 0,this._format,this._forcedExtension,u,f,d,m)}catch(S){throw x("error loading",S),S}l&&(this._buffer=null)}else this.delayLoadState=4,this._delayedOnLoad=C,this._delayedOnError=x}updateURL(e,t=null,i,s){this.url&&(this.releaseInternalTexture(),this.get
23Scene().markAllMaterialsAsDirty(1,o=>o.hasTexture(this))),(!this.name||this.name.startsWith("data:"))&&(this.name=e),this.url=e,this._buffer=t,this._forcedExtension=s,this.delayLoadState=4;const r=this._delayedOnLoad,n=()=>{r?r():this.onLoadObservable.hasObservers()&&this.onLoadObservable.notifyObservers(this),i&&i()};this._delayedOnLoad=n,this.delayLoad()}delayLoad(){if(this.delayLoadState!==4)return;const e=this.getScene();if(!e)return;let t=this.url;!t&&(this.name.indexOf("://")>0||this.name.startsWith("data:"))&&(t=this.name),this.delayLoadState=1,this._texture=this._getFromCache(t,this._noMipmap,this.samplingMode,this._invertY,this._useSRGBBuffer,this.isCube),this._texture?this._delayedOnLoad&&(this._texture.isReady?ks.SetImmediate(this._delayedOnLoad):this._texture.onLoadedObservable.add(this._delayedOnLoad)):(this._texture=e.getEngine().createTexture(t,this._noMipmap,this._invertY,e,this.samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer,null,this._format,this._forcedExtension,this._mimeType,this._loaderOptions,this._creationFlags,this._useSRGBBuffer),this._deleteBuffer&&(this._buffer=null)),this._delayedOnLoad=null,this._delayedOnError=null}_prepareRowForTextureGeneration(e,t,i,s){e*=this._cachedUScale,t*=this._cachedVScale,e-=this.uRotationCenter*this._cachedUScale,t-=this.vRotationCenter*this._cachedVScale,i-=this.wRotationCenter,_.TransformCoordinatesFromFloatsToRef(e,t,i,this._rowGenerationMatrix,s),s.x+=this.uRotationCenter*this._cachedUScale+this._cachedUOffset,s.y+=this.vRotationCenter*this._cachedVScale+this._cachedVOffset,s.z+=this.wRotationCenter}getTextureMatrix(e=1){if(this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale*e===this._cachedUScale&&this.vScale===this._cachedVScale&&this.uAng===this._cachedUAng&&this.vAng===this._cachedVAng&&this.wAng===this._cachedWAng&&this.uRotationCenter===this._cachedURotationCenter&&this.vRotationCenter===this._cachedVRotationCenter&&this.wRotationCenter===this._cachedWRotationCenter&&this.homogeneousRotationInUVTransform===this._cachedHomogeneousRotationInUVTransform)return this._cachedTextureMatrix;this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale*e,this._cachedVScale=this.vScale,this._cachedUAng=this.uAng,this._cachedVAng=this.vAng,this._cachedWAng=this.wAng,this._cachedURotationCenter=this.uRotationCenter,this._cachedVRotationCenter=this.vRotationCenter,this._cachedWRotationCenter=this.wRotationCenter,this._cachedHomogeneousRotationInUVTransform=this.homogeneousRotationInUVTransform,(!this._cachedTextureMatrix||!this._rowGenerationMatrix)&&(this._cachedTextureMatrix=P.Zero(),this._rowGenerationMatrix=new P,this._t0=_.Zero(),this._t1=_.Zero(),this._t2=_.Zero()),P.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this.homogeneousRotationInUVTransform?(P.TranslationToRef(-this._cachedURotationCenter,-this._cachedVRotationCenter,-this._cachedWRotationCenter,v.Matr
vendor: 7,680 bytes, line 23
23ix[0]),P.TranslationToRef(this._cachedURotationCenter,this._cachedVRotationCenter,this._cachedWRotationCenter,v.Matrix[1]),P.ScalingToRef(this._cachedUScale,this._cachedVScale,0,v.Matrix[2]),P.TranslationToRef(this._cachedUOffset,this._cachedVOffset,0,v.Matrix[3]),v.Matrix[0].multiplyToRef(this._rowGenerationMatrix,this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(v.Matrix[1],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(v.Matrix[2],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(v.Matrix[3],this._cachedTextureMatrix),this._cachedTextureMatrix.setRowFromFloats(2,this._cachedTextureMatrix.m[12],this._cachedTextureMatrix.m[13],this._cachedTextureMatrix.m[14],1)):(this._prepareRowForTextureGeneration(0,0,0,this._t0),this._prepareRowForTextureGeneration(1,0,0,this._t1),this._prepareRowForTextureGeneration(0,1,0,this._t2),this._t1.subtractInPlace(this._t0),this._t2.subtractInPlace(this._t0),P.FromValuesToRef(this._t1.x,this._t1.y,this._t1.z,0,this._t2.x,this._t2.y,this._t2.z,0,this._t0.x,this._t0.y,this._t0.z,0,0,0,0,1,this._cachedTextureMatrix));const t=this.getScene();if(!t)return this._cachedTextureMatrix;const i=this._cachedIdentity3x2;return this._cachedIdentity3x2=this._cachedTextureMatrix.isIdentityAs3x2(),this.optimizeUVAllocation&&i!==this._cachedIdentity3x2&&t.markAllMaterialsAsDirty(1,s=>s.hasTexture(this)),this._cachedTextureMatrix}getReflectionTextureMatrix(){const e=this.getScene();if(!e)return this._cachedReflectionTextureMatrix;if(this.uOffset===this._cachedReflectionUOffset&&this.vOffset===this._cachedReflectionVOffset&&this.uScale===this._cachedReflectionUScale&&this.vScale===this._cachedReflectionVScale&&this.coordinatesMode===this._cachedReflectionCoordinatesMode)if(this.coordinatesMode===z.PROJECTION_MODE){if(this._cachedReflectionProjectionMatrixId===e.getProjectionMatrix().updateFlag)return this._cachedReflectionTextureMatrix}else return this._cachedReflectionTextureMatrix;this._cachedReflectionTextureMatrix||(this._cachedReflectionTextureMatrix=P.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=P.Zero());const t=this._cachedReflectionCoordinatesMode!==this.coordinatesMode;switch(this._cachedReflectionUOffset=this.uOffset,this._cachedReflectionVOffset=this.vOffset,this._cachedReflectionUScale=this.uScale,this._cachedReflectionVScale=this.vScale,this._cachedReflectionCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case z.PLANAR_MODE:{P.IdentityToRef(this._cachedReflectionTextureMatrix),this._cachedReflectionTextureMatrix[0]=this.uScale,this._cachedReflectionTextureMatrix[5]=this.vScale,this._cachedReflectionTextureMatrix[12]=this.uOffset,this._cachedReflectionTextureMatrix[13]=this.vOffset;break}case z.PROJECTION_MODE:{P.FromValuesToRef(.5,0,0,0,0,-.5,0,0,0,0,0,0,.5,.5,1,1,this._projectionModeMatrix);const i=e.getProjectionMatrix();this._cachedReflectionProjectionMatrixId=i.updateFlag,i.multiplyToRef(this._projectionModeMatrix,this._cachedReflectionTextureMatrix);break}default:P.IdentityToRef(this._cachedReflectionTextureMatrix);break}return t&&e.markAllMaterialsAsDirty(1,i=>i.hasTexture(this)),this._cachedReflectionTextureMatrix}clone(){const e={noMipmap:this._noMipmap,invertY:this._invertY,samplingMode:this.samplingMode,onLoad:void 0,onError:void 0,buffer:this._texture?this._texture._buffer:void 0,deleteBuffer:this._deleteBuffer,format:this.textureFormat,mimeType:this.mimeType,loaderOptions:this._loaderOptions,creationFlags:this._creationFlags,useSRGBBuffer:this._useSRGBBuffer};return le.Clone(()=>new z(this._texture?this._texture.url:null,this.getScene(),e),this)}serialize(){const e=this.name;z.SerializeBuffers||this.name.startsWith("data:")&&(this.name=""),this.name.startsWith("data:")&&this.url===this.name&&(this.url="");const t=super.serialize(z._SerializeInternalTextureUniqueId);if(!t)return null;if(z.SerializeBuffers||z.ForceSerializeBuffers)if(typeof this._buffer=="string"&&this._buffer.startsWith("data:"))t.base64String=this._buffer,t.name=t.name.replace("data:","");else if(this.url&&this.url.startsWith("data:")&&this._buffer instanceof Uint8Array){const i=this.mimeType||"image/png";t.base64String=`data:${i};base64,${Mo(this._buffer)}`}else(z.ForceSerializeBuffers||this.url&&this.url.startsWith("blob:")||this._forceSerialize)&&(t.base64String=!this._engine||this._engine._features.supportSyncTextureRead?Wc(this):Xc(this));return t.invertY=this._invertY,t.samplingMode=this.samplingMode,t._creationFlags=this._creationFlags,t._useSRGBBuffer=this._useSRGBBuffer,z._SerializeInternalTextureUniqueId&&(t.internalTextureUniqueId=this._texture?.uniqueId),t.internalTextureLabel=this._texture?.label,t.noMipmap=this._noMipmap,this.name=e,t}getClassName(){return"Texture"}dispose(){super.dispose(),this.onLoadObservable.clear(),this._delayedOnLoad=null,this._delayedOnError=null,this._buffer=null}static Parse(e,t,i){if(e.customType){const l=Ls.Instantiate(e.customType).Parse(e,t,i);return e.samplingMode&&l.updateSamplingMode&&l._samplingMode&&l._samplingMode!==e.samplingMode&&l.updateSamplingMode(e.samplingMode),l}if(e.isCube&&!e.isRenderTarget)return z._CubeTextureParser(e,t,i);const s=e.internalTextureUniqueId!==void 0;if(!e.name&&!e.isRenderTarget&&!s)return null;let r;if(s){const h=t.getEngine().getLoadedTexturesCache();for(const l of h)if(l.uniqueId===e.internalTextureUniqueId){r=l;break}}const n=h=>{if(h&&h._texture&&(h._texture._cachedWrapU=null,h._texture._cachedWrapV=null,h._texture._cachedWrapR=null),e.samplingMode){const l=e.samplingMode;h&&h.samplingMode!==l&&h.updateSamplingMode(l)}if(h&&e.animations)for(let l=0;l<e.animations.length;l++){const c=e.animations[l],u=Oi("BABYLON.Animation");u&&h.animations.push(u.Parse(c))}h&&h._texture&&(s&&!r&&h._texture._setUniqueId(e.internalTextureUniqueId),h._texture.label=e.internalTextureLabel)};return le.Parse(()=>{let h=!0;if(e.noMipmap&&(h=!1),e.mirrorPlane){const l=z._CreateMirror(e.name,e.renderTargetSize,t,h);return l._waitingRenderList=e.renderList,l.mirrorPlane=Ht.FromArray(e.mirrorPlane),n(l),l}else if(e.isRenderTarget&&!e.base64String){let l=null;if(e.isCube){if(t.reflectionProbes)for(let c=0;c<t.reflectionProbes.length;c++){const u=t.reflectionProbes[c];if(u.name===e.name)return u.cubeTexture}}else l=z._CreateRenderTargetTexture(e.name,e.renderTargetSize,t,h,e._creationFlags??0),l._waitingRenderList=e.renderList;return n(l),l}else if(e.isVideo){const l=z._CreateVideoTexture(i+(e.url||e.name),i+(e.src||e.url),t,h,e.invertY,e.samplingMode,e.settings||{});return n(l),l}else{let l;if(e.base64String&&!r)l=z.CreateFromBase64String(e.base64String,e.base64String,t,!h,e.invertY,e.samplingMode,()=>{n(l)},e._creationFlags??0,e._useSRGBBuffer??!1),l.name=e.name;else{let c;e.name&&(e.name.indexOf("://")>0||e.name.startsWith("data:"))?c=e.name:c=i+e.name,e.url&&(e.url.startsWith("data:")||z.UseSerializedUrlIfAny)&&(c=e.url);const u={noMipmap:!h,invertY:e.invertY,samplingMode:e.samplingMode,onLoad:()=>{n(l)},internalTexture:r};l=new z(c,t,u)}return l}},e,t)}static CreateFromBase64String(e,t,i,s,r,n=z.TRILINEAR_SAMPLINGMODE,o=null,h=null,l=5,c,u){return new z("data:"+t,i,s,r,n,o,h,e,!1,l,void 0,void 0,c,u)}static LoadFromDataString(e,t,i,s=!1,r,n=!0,o=z.TRILINEAR_SAMPLINGMODE,h=null,l=null,c=5,u,f){return e.substring(0,5)!=="data:"&&(e="data:"+e),new z(e,i,r,n,o,h,l,t,s,c,void 0,void 0,u,f)}}z.SerializeBuffers=!0;z.ForceSerializeBuffers=!1;z.OnTextureLoadErrorObservable=new O;z._SerializeInternalTextureUniqueId=!1;z._CubeTextureParser=(a,e,t)=>{throw ie("CubeTexture")};z._CreateMirror=(a,e,t,i)=>{throw ie("MirrorTexture")};z._CreateRenderTargetTexture=(a,e,t,i,s)=>{throw ie("RenderTargetTexture")};
23z.NEAREST_SAMPLINGMODE=1;z.NEAREST_NEAREST_MIPLINEAR=8;z.BILINEAR_SAMPLINGMODE=2;z.LINEAR_LINEAR_MIPNEAREST=11;z.TRILINEAR_SAMPLINGMODE=3;z.LINEAR_LINEAR_MIPLINEAR=3;z.NEAREST_NEAREST_MIPNEAREST=4;z.NEAREST_LINEAR_MIPNEAREST=5;z.NEAREST_LINEAR_MIPLINEAR=6;z.NEAREST_LINEAR=7;z.NEAREST_NEAREST=1;z.LINEAR_NEAREST_MIPNEAREST=9;z.LINEAR_NEAREST_MIPLINEAR=10;z.LINEAR_LINEAR=2;z.LINEAR_NEAREST=12;z.EXPLICIT_MODE=0;z.SPHERICAL_MODE=1;z.PLANAR_MODE=2;z.CUBIC_MODE=3;z.PROJECTION_MODE=4;z.SKYBOX_MODE=5;z.INVCUBIC_MODE=6;z.EQUIRECTANGULAR_MODE=7;z.FIXED_EQUIRECTANGULAR_MODE=8;z.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9;z.CLAMP_ADDRESSMODE=0;z.WRAP_ADDRESSMODE=1;z.MIRROR_ADDRESSMODE=2;z.UseSerializedUrlIfAny=!1;T([R()],z.prototype,"url",void 0);T([R()],z.prototype,"uOffset",void 0);T([R()],z.prototype,"vOffset",void 0);T([R()],z.prototype,"uScale",void 0);T([R()],z.prototype,"vScale",void 0);T([R()],z.prototype,"uAng",void 0);T([R()],z.prototype,"vAng",void 0);T([R()],z.prototype,"wAng",void 0);T([R()],z.prototype,"uRotationCenter",void 0);T([R()],z.prototype,"vRotationCenter",void 0);T([R()],z.prototype,"wRotationCenter",void 0);T([R()],z.prototype,"homogeneousRotationInUVTransform",void 0);T([R()],z.prototype,"isBlocking",null);nt("BABYLON.Texture",z);le._TextureParser=z.Parse;function Zo(a,e,t){if(!a||a.LOGARITHMICDEPTH||a.indexOf&&a.indexOf("LOGARITHMICDEPTH")>=0){const i=t.activeCamera;i.mode===1&&w.Error("Logarithmic depth is not compatible with orthographic cameras!",20),e.setFloat("logarithmicDepthConstant",2/(Math.log(i.maxZ+1)/Math.LN2))}}const Ta={r:0,g:0,b:0},Xi={NUM_MORPH_INFLUENCERS:0,NORMAL:!1,TANGENT:!1,UV:!1,UV2:!1,COLOR:!1};function $o(a,e,t,i=!1){t&&a.fogEnabled&&(!e||e.applyFog)&&a.fogMode!==0&&(t.setFloat4("vFogInfos",a.fogMode,a.fogStart,a.fogEnd,a.fogDensity),i?(a.fogColor.toLinearSpaceToRef(Ta,a.getEngine().useExactSrgbConversions),t.setColor3("vFogColor",Ta)):t.setColor3("vFogColor",a.fogColor))}function m_(a,e,t,i,s,r,n,o,h,l){const c=a.numMaxInfluencers||a.numInfluencers;return c<=0?0:(e.push("#define MORPHTARGETS"),a.hasPositions&&e.push("#define MORPHTARGETTEXTURE_HASPOSITIONS"),a.hasNormals&&e.push("#define MORPHTARGETTEXTURE_HASNORMALS"),a.hasTangents&&e.push("#define MORPHTARGETTEXTURE_HASTANGENTS"),a.hasUVs&&e.push("#define MORPHTARGETTEXTURE_HASUVS"),a.hasUV2s&&e.push("#define MORPHTARGETTEXTURE_HASUV2S"),a.hasColors&&e.push("#define MORPHTARGETTEXTURE_HASCOLORS"),a.supportsPositions&&s&&e.push("#define MORPHTARGETS_POSITION"),a.supportsNormals&&r&&e.push("#define MORPHTARGETS_NORMAL"),a.supportsTangents&&n&&e.push("#define MORPHTARGETS_TANGENT"),a.supportsUVs&&o&&e.push("#define MORPHTARGETS_UV"),a.supportsUV2s&&h&&e.push("#define MORPHTARGETS_UV2"),a.supportsColors&&l&&e.push("#define MORPHTARGETS_COLOR"),e.push("#define NUM_MORPH_INFLUENCERS "+c),a.isUsingTextureForTargets&&e.push("#define MORPHTARGETS_TEXTURE"),Xi.NUM_MORPH_INFLUENCERS=c,Xi.NORMAL=r,Xi.TANGENT=n,Xi.UV=o,Xi.UV2=h,Xi.COLOR=l,Jo(t,i,Xi,s),c)}function Jo(a,e,t,i=!0){const s=t.NUM_MORPH_INFLUENCERS;if(s>0&&Te.LastCreatedEngine){const r=Te.LastCreatedEngine.getCaps().maxVertexAttribs,n=e.morphTargetManager;if(n?.isUsingTextureForTargets)return;const o=n&&n.supportsPositions&&i,h=n&&n.supportsNormals&&t.NORMAL,l=n&&n.supportsTangents&&t.TANGENT,c=n&&n.supportsUVs&&t.UV1,u=n&&n.supportsUV2s&&t.UV2,f=n&&n.supportsColors&&t.VERTEXCOLOR;for(let d=0;d<s;d++)o&&a.push("position"+d),h&&a.push("normal"+d),l&&a.push("tangent"+d),c&&a.push("uv_"+d),u&&a.push("uv2_"+d),f&&a.push("color"+d),a.length>r&&w.Error("Cannot add more vertex attributes for mesh "+e.name)}}function Kc(a,e=!1){a.push("world0"),a.push("world1"),a.push("world2"),a.push("world3"),e&&(a.push("previousWorld0"),a.push("previousWorld1"),a.push("previousWorld2"),a.push("previousWorld3"))}function eh(a,e){const t=a.morphTargetManager;!a||!t||e.setFloatArray("morphTargetInfluences",t.influences)}function Yc(a,e){e.bindToEffect(a,"Scene")}function th(a,e,t,i,s=null,r=!1,n=!1,o=!1,h=!1,l=!1,c=!1,u=0){if(a.texturesEnabled&&s&&U.ReflectionTextureEnabled){if(t.updateMatrix("reflectionMatrix",s.getReflectionTextureMatrix()),t.updateFloat2("vReflectionInfos",s.level*a.iblIntensity,u),o&&s.boundingBoxSize){const f=s;t.updateVector3("vReflectionPosition",f.boundingBoxPosition),t.updateVector3("vReflectionSize",f.boundingBoxSize)}if(r){const f=s.getSize().width;t.updateFloat2("vReflectionFilteringInfo",f,Math.log2(f))}if(l&&!e.USEIRRADIANCEMAP){const f=s.sphericalPolynomial;if(e.USESPHERICALFROMREFLECTIONMAP&&f)if(e.SPHERICAL_HARMONICS){const d=f.preScaledHarmonics;t.updateVector3("vSphericalL00",d.l00),t.updateVector3("vSphericalL1_1",d.l1_1),t.updateVector3("vSphericalL10",d.l10),t.updateVector3("vSphericalL11",d.l11),t.updateVector3("vSphericalL2_2",d.l2_2),t.updateVector3("vSphericalL2_1",d.l2_1),t.updateVector3("vSphericalL20",d.l20),t.updateVector3("vSphericalL21",d.l21),t.updateVector3("vSphericalL22",d.l22)}else t.updateFloat3("vSphericalX",f.x.x,f.x.y,f.x.z),t.updateFloat3("vSphericalY",f.y.x,f.y.y,f.y.z),t.updateFloat3("vSphericalZ",f.z.x,f.z.y,f.z.z),t.updateFloat3("vSphericalXX_ZZ",f.xx.x-f.zz.x,f.xx.y-f.zz.y,f.xx.z-f.zz.z),t.updateFloat3("vSphericalYY_ZZ",f.yy.x-f.zz.x,f.yy.y-f.zz.y,f.yy.z-f.zz.z),t.updateFloat3("vSphericalZZ",f.zz.x,f.zz.y,f.zz.z),t.updateFloat3("vSphericalXY",f.xy.x,f.xy.y,f.xy.z),t.updateFloat3("vSphericalYZ",f.yz.x,f.yz.y,f.yz.z),t.updateFloat3("vSphericalZX",f.zx.x,f.zx.y,f.zx.z)}else h&&e.USEIRRADIANCEMAP&&e.USE_IRRADIANCE_DOMINANT_DIRECTION&&t.updateVector3("vReflectionDominantDirection",s.irradianceTexture._dominantDirection);n&&t.updateFloat3("vReflectionMicrosurfaceInfos",s.getSize().width,s.lodGenerationScale,s.lodGenerationOffset)}c&&t.updateColor3("vReflectionColor",i)}
23function ih(a,e,t,i=null,s=!1){if(i&&U.ReflectionTextureEnabled){e.LODBASEDMICROSFURACE?t.setTexture("reflectionSampler",i):(t.setTexture("reflectionSampler",i._lodTextureMid||i),t.setTexture("reflectionSamplerLow",i._lodTextureLow||i),t.setTexture("reflectionSamplerHigh",i._lodTextureHigh||i)),e.USEIRRADIANCEMAP&&t.setTexture("irradianceSampler",i.irradianceTexture);const r=a.iblCdfGenerator;s&&r&&t.setTexture("icdfSampler",r.getIcdfTexture())}}function Ne(a,e,t){e._needUVs=!0,e[t]=!0,a.optimizeUVAllocation&&a.getTextureMatrix().isIdentityAs3x2()?(e[t+"DIRECTUV"]=a.coordinatesIndex+1,e["MAINUV"+(a.coordinatesIndex+1)]=!0):e[t+"DIRECTUV"]=0}function Ue(a,e,t){const i=a.getTextureMatrix();e.updateMatrix(t+"Matrix",i)}function qc(a,e,t){t.BAKED_VERTEX_ANIMATION_TEXTURE&&t.INSTANCES&&a.push("bakedVertexAnimationSettingsInstanced")}function jc(a,e){return e.set(a),e}function sh(a,e,t){if(!(!e||!a)&&(a.computeBonesUsingShaders&&e._bonesComputationForcedToCPU&&(a.computeBonesUsingShaders=!1),a.useBones&&a.computeBonesUsingShaders&&a.skeleton)){const i=a.skeleton;if(i.isUsingTextureForMatrices&&e.getUniformIndex("boneTextureWidth")>-1){const s=i.getTransformMatrixTexture(a);e.setTexture("boneSampler",s),e.setFloat("boneTextureWidth",4*(i.bones.length+1))}else{const s=i.getTransformMatrices(a);s&&(e.setMatrices("mBones",s),t&&a.getScene().prePassRenderer&&a.getScene().prePassRenderer.getIndex(2)&&(t.previousBones[a.uniqueId]||(t.previousBones[a.uniqueId]=s.slice()),e.setMatrices("mPreviousBones",t.previousBones[a.uniqueId]),jc(s,t.previousBones[a.uniqueId])))}}}function Qc(a,e,t,i,s,r=!0){a._bindLight(e,t,i,s,r)}function rh(a,e,t,i,s=4){const r=Math.min(e.lightSources.length,s);for(let n=0;n<r;n++){const o=e.lightSources[n];Qc(o,n,a,t,typeof i=="boolean"?i:i.SPECULARTERM,e.receiveShadows)}}function nh(a,e,t,i){t.NUM_BONE_INFLUENCERS>0&&(i.addCPUSkinningFallback(0,e),a.push("matricesIndices"),a.push("matricesWeights"),t.NUM_BONE_INFLUENCERS>4&&(a.push("matricesIndicesExtra"),a.push("matricesWeightsExtra")))}function ah(a,e){(e.INSTANCES||e.THIN_INSTANCES)&&Kc(a,!!e.PREPASS_VELOCITY),e.INSTANCESCOLOR&&a.push("instanceColor")}function oh(a,e,t=4,i=0){let s=0;for(let r=0;r<t&&a["LIGHT"+r];r++)r>0&&(s=i+r,e.addFallback(s,"LIGHT"+r)),a.SHADOWS||(a["SHADOW"+r]&&e.addFallback(i,"SHADOW"+r),a["SHADOWPCF"+r]&&e.addFallback(i,"SHADOWPCF"+r),a["SHADOWPCSS"+r]&&e.addFallback(i,"SHADOWPCSS"+r),a["SHADOWPOISSON"+r]&&e.addFallback(i,"SHADOWPOISSON"+r),a["SHADOWESM"+r]&&e.addFallback(i,"SHADOWESM"+r),a["SHADOWCLOSEESM"+r]&&e.addFallback(i,"SHADOWCLOSEESM"+r));return s++}function Zc(a,e){return e.fogEnabled&&a.applyFog&&e.fogMode!==0}function hh(a,e,t,i,s,r,n,o=!1,h=!1,l,c){if(n._areMiscDirty){n.LOGARITHMICDEPTH=t,n.POINTSIZE=i,n.FOG=s&&Zc(a,e),n.NONUNIFORMSCALING=a.nonUniformScaling,n.ALPHATEST=r,n.DECAL_AFTER_DETAIL=o,n.USE_VERTEX_PULLING=h,n.RIGHT_HANDED=e.useRightHandedSystem;const u=l?.geometry?.getIndexBuffer();n.VERTEX_PULLING_USE_INDEX_BUFFER=!!u,n.VERTEX_PULLING_INDEX_BUFFER_32BITS=u?u.is32Bits:!1,n.VERTEXOUTPUT_INVARIANT=!!c}}function lh(a,e,t,i,s=4,r=!1){if(!t._areLightsDirty)return t._needNormals;let n=0;const o={needNormals:t._needNormals,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};if(a.lightsEnabled&&!r){for(const c of e.lightSources)if($c(a,e,c,n,t,i,o),n++,n===s)break}t.SPECULARTERM=o.specularEnabled,t.SHADOWS=o.shadowEnabled;const h=Math.max(s,t.MAXLIGHTCOUNT||0);for(let c=n;c<h;c++)t["LIGHT"+c]!==void 0&&(t["LIGHT"+c]=!1,t["HEMILIGHT"+c]=!1,t["POINTLIGHT"+c]=!1,t["DIRLIGHT"+c]=!1,t["SPOTLIGHT"+c]=!1,t["AREALIGHT"+c]=!1,t["CLUSTLIGHT"+c]=!1,t["SHADOW"+c]=!1,t["SHADOWCSM"+c]=!1,t["SHADOWCSMDEBUG"+c]=!1,t["SHADOWCSMNUM_CASCADES"+c]=!1,t["SHADOWCSMUSESHADOWMAXZ"+c]=!1,t["SHADOWCSMNOBLEND"+c]=!1,t["SHADOWCSM_RIGHTHANDED"+c]=!1,t["SHADOWPCF"+c]=!1,t["SHADOWPCSS"+c]=!1,t["SHADOWPOISSON"+c]=!1,t["SHADOWESM"+c]=!1,t["SHADOWCLOSEESM"+c]=!1,t["SHADOWCUBE"+c]=!1,t["SHADOWLOWQUALITY"+c]=!1,t["SHADOWMEDIUMQUALITY"+c]=!1);t.MAXLIGHTCOUNT=s;const l=a.getEngine().getCaps();return t.SHADOWFLOAT===void 0&&(o.needRebuild=!0),t.SHADOWFLOAT=o.shadowEnabled&&(l.textureFloatRen
23der&&l.textureFloatLinearFiltering||l.textureHalfFloatRender&&l.textureHalfFloatLinearFiltering),t.LIGHTMAPEXCLUDED=o.lightmapMode,o.needRebuild&&t.rebuild(),o.needNormals}function ch(a,e,t,i=!1,s=8,r=!1){if(e&&U.ReflectionTextureEnabled){if(!e.isReadyOrNotBlocking())return!1;t._needNormals=!0,t.REFLECTION=!0,t.GAMMAREFLECTION=e.gammaSpace,t.RGBDREFLECTION=e.isRGBD,t.LODINREFLECTIONALPHA=e.lodLevelInAlpha,t.LINEARSPECULARREFLECTION=e.linearSpecularLOD,t.USEIRRADIANCEMAP=!1;const n=a.getEngine();switch(i&&s>0?(t.NUM_SAMPLES=""+s,n._features.needTypeSuffixInShaderConstants&&(t.NUM_SAMPLES=t.NUM_SAMPLES+"u"),t.REALTIME_FILTERING=!0,a.iblCdfGenerator&&(t.IBL_CDF_FILTERING=!0)):t.REALTIME_FILTERING=!1,t.INVERTCUBICMAP=e.coordinatesMode===z.INVCUBIC_MODE,t.REFLECTIONMAP_3D=e.isCube,t.REFLECTIONMAP_OPPOSITEZ=t.REFLECTIONMAP_3D&&a.useRightHandedSystem?!e.invertZ:e.invertZ,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,e.coordinatesMode){case z.EXPLICIT_MODE:t.REFLECTIONMAP_EXPLICIT=!0;break;case z.PLANAR_MODE:t.REFLECTIONMAP_PLANAR=!0;break;case z.PROJECTION_MODE:t.REFLECTIONMAP_PROJECTION=!0;break;case z.SKYBOX_MODE:t.REFLECTIONMAP_SKYBOX=!0;break;case z.SPHERICAL_MODE:t.REFLECTIONMAP_SPHERICAL=!0;break;case z.EQUIRECTANGULAR_MODE:t.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case z.FIXED_EQUIRECTANGULAR_MODE:t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case z.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case z.CUBIC_MODE:case z.INVCUBIC_MODE:default:t.REFLECTIONMAP_CUBIC=!0,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!!e.boundingBoxSize;break}e.coordinatesMode!==z.SKYBOX_MODE&&(e.irradianceTexture?(t.USEIRRADIANCEMAP=!0,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USESPHERICALINVERTEX=!1,e.irradianceTexture._dominantDirection&&(t.USE_IRRADIANCE_DOMINANT_DIRECTION=!0)):e.isCube&&(t.USESPHERICALFROMREFLECTIONMAP=!0,t.USEIRRADIANCEMAP=!1,t.USE_IRRADIANCE_DOMINANT_DIRECTION=!1,t.USESPHERICALINVERTEX=r))}else t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USEIRRADIANCEMAP=!1,t.USE_IRRADIANCE_DOMINANT_DIRECTION=!1,t.USESPHERICALINVERTEX=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.RGBDREFLECTION=!1,t.LINEARSPECULARREFLECTION=!1;return!0}function $c(a,e,t,i,s,r,n){switch(n.needNormals=!0,s["LIGHT"+i]===void 0&&(n.needRebuild=!0),s["LIGHT"+i]=!0,s["SPOTLIGHT"+i]=!1,s["HEMILIGHT"+i]=!1,s["POINTLIGHT"+i]=!1,s["DIRLIGHT"+i]=!1,s["AREALIGHT"+i]=!1,s["CLUSTLIGHT"+i]=!1,t.prepareLightSpecificDefines(s,i),s["LIGHT_FALLOFF_PHYSICAL"+i]=!1,s["LIGHT_FALLOFF_GLTF"+i]=!1,s["LIGHT_FALLOFF_STANDARD"+i]=!1,t.falloffType){case Ee.FALLOFF_GLTF:s["LIGHT_FALLOFF_GLTF"+i]=!0;break;case Ee.FALLOFF_PHYSICAL:s["LIGHT_FALLOFF_PHYSICAL"+i]=!0;break;case Ee.FALLOFF_STANDARD:s["LIGHT_FALLOFF_STANDARD"+i]=!0;break}if(r&&!t.specular.equalsFloats(0,0,0)&&(n.specularEnabled=!0),s["SHADOW"+i]=!1,s["SHADOWCSM"+i]=!1,s["SHADOWCSMDEBUG"+i]=!1,s["SHADOWCSMNUM_CASCADES"+i]=!1,s["SHADOWCSMUSESHADOWMAXZ"+i]=!1,s["SHADOWCSMNOBLEND"+i]=!1,s["SHADOWCSM_RIGHTHANDED"+i]=!1,s["SHADOWPCF"+i]=!1,s["SHADOWPCSS"+i]=!1,s["SHADOWPOISSON"+i]=!1,s["SHADOWESM"+i]=!1,s["SHADOWCLOSEESM"+i]=!1,s["SHADOWCUBE"+i]=!1,s["SHADOWLOWQUALITY"+i]=!1,s["SHADOWMEDIUMQUALITY"+i]=!1,e&&e.receiveShadows&&a.shadowsEnabled&&t.shadowEnabled){const o=t.getShadowGenerator(a.activeCamera)??t.getShadowGenerator();if(o){const h=o.getShadowMap();h&&h.renderList&&h.renderList.length>0&&(n.shadowEnabled=!0,o.prepareDefines(s,i))}}t.lightmapMode!=Ee.LIGHTMAP_DEFAULT?(n.lightmapMode=!0,s["LIGHTMAPEXCLUDED"+i]=!0,s["LIGHTMAPNOSPECULAR"
vendor: 6,420 bytes, line 23
23+i]=t.lightmapMode==Ee.LIGHTMAP_SHADOWSONLY):(s["LIGHTMAPEXCLUDED"+i]=!1,s["LIGHTMAPNOSPECULAR"+i]=!1)}function uh(a,e,t,i,s,r=null,n=!1){let o=ru(a,i);r!==!1&&(o=zc(t,a,i)),i.DEPTHPREPASS!==!e.getColorWrite()&&(i.DEPTHPREPASS=!i.DEPTHPREPASS,o=!0),i.INSTANCES!==s&&(i.INSTANCES=s,o=!0),i.THIN_INSTANCES!==n&&(i.THIN_INSTANCES=n,o=!0),o&&i.markAsUnprocessed()}function Jc(a,e){if(a.useBones&&a.computeBonesUsingShaders&&a.skeleton){e.NUM_BONE_INFLUENCERS=a.numBoneInfluencers;const t=e.BONETEXTURE!==void 0;if(a.skeleton.isUsingTextureForMatrices&&t)e.BONETEXTURE=!0;else{e.BonesPerMesh=a.skeleton.bones.length+1,e.BONETEXTURE=t?!1:void 0;const i=a.getScene().prePassRenderer;if(i&&i.enabled){const s=i.excludedSkinnedMesh.indexOf(a)===-1;e.BONES_VELOCITY_ENABLED=s}}}else e.NUM_BONE_INFLUENCERS=0,e.BonesPerMesh=0,e.BONETEXTURE!==void 0&&(e.BONETEXTURE=!1)}function eu(a,e){const t=a.morphTargetManager;t?(e.MORPHTARGETS_UV=t.supportsUVs&&e.UV1,e.MORPHTARGETS_UV2=t.supportsUV2s&&e.UV2,e.MORPHTARGETS_TANGENT=t.supportsTangents&&e.TANGENT,e.MORPHTARGETS_NORMAL=t.supportsNormals&&e.NORMAL,e.MORPHTARGETS_POSITION=t.supportsPositions,e.MORPHTARGETS_COLOR=t.supportsColors,e.MORPHTARGETTEXTURE_HASUVS=t.hasUVs,e.MORPHTARGETTEXTURE_HASUV2S=t.hasUV2s,e.MORPHTARGETTEXTURE_HASTANGENTS=t.hasTangents,e.MORPHTARGETTEXTURE_HASNORMALS=t.hasNormals,e.MORPHTARGETTEXTURE_HASPOSITIONS=t.hasPositions,e.MORPHTARGETTEXTURE_HASCOLORS=t.hasColors,e.NUM_MORPH_INFLUENCERS=t.numMaxInfluencers||t.numInfluencers,e.MORPHTARGETS=e.NUM_MORPH_INFLUENCERS>0,e.MORPHTARGETS_TEXTURE=t.isUsingTextureForTargets):(e.MORPHTARGETS_UV=!1,e.MORPHTARGETS_UV2=!1,e.MORPHTARGETS_TANGENT=!1,e.MORPHTARGETS_NORMAL=!1,e.MORPHTARGETS_POSITION=!1,e.MORPHTARGETS_COLOR=!1,e.MORPHTARGETTEXTURE_HASUVS=!1,e.MORPHTARGETTEXTURE_HASUV2S=!1,e.MORPHTARGETTEXTURE_HASTANGENTS=!1,e.MORPHTARGETTEXTURE_HASNORMALS=!1,e.MORPHTARGETTEXTURE_HASPOSITIONS=!1,e.MORPHTARGETTEXTURE_HAS_COLORS=!1,e.MORPHTARGETS=!1,e.NUM_MORPH_INFLUENCERS=0)}function tu(a,e){const t=a.bakedVertexAnimationManager;e.BAKED_VERTEX_ANIMATION_TEXTURE=!!(t&&t.isEnabled)}function dh(a,e,t,i,s=!1,r=!0,n=!0){if(!e._areAttributesDirty&&e._needNormals===e._normals&&e._needUVs===e._uvs)return!1;e._normals=e._needNormals,e._uvs=e._needUVs,e.NORMAL=e._needNormals&&a.isVerticesDataPresent("normal"),e._needNormals&&a.isVerticesDataPresent("tangent")&&(e.TANGENT=!0);for(let o=1;o<=6;++o)e["UV"+o]=e._needUVs?a.isVerticesDataPresent(`uv${o===1?"":o}`):!1;if(t){const o=a.useVertexColors&&a.isVerticesDataPresent("color");e.VERTEXCOLOR=o,e.VERTEXALPHA=a.hasVertexAlpha&&o&&r}return a.isVerticesDataPresent("instanceColor")&&(a.hasInstances||a.hasThinInstances)&&(e.INSTANCESCOLOR=!0),i&&Jc(a,e),s&&eu(a,e),n&&tu(a,e),!0}function fh(a,e){if(a.activeCamera){const t=e.MULTIVIEW;e.MULTIVIEW=a.activeCamera.outputRenderTarget!==null&&a.activeCamera.outputRenderTarget.getViewCount()>1,e.MULTIVIEW!=t&&e.markAsUnprocessed()}}function iu(a,e,t){const i=e.ORDER_INDEPENDENT_TRANSPARENCY,s=e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;e.ORDER_INDEPENDENT_TRANSPARENCY=a.useOrderIndependentTransparency&&t,e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!a.getEngine().getCaps().textureFloatLinearFiltering,(i!==e.ORDER_INDEPENDENT_TRANSPARENCY||s!==e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS)&&e.markAsUnprocessed()}function su(a,e,t){const i=e.PREPASS;if(!e._arePrePassDirty)return;const s=[{type:1,define:"PREPASS_POSITION",index:"PREPASS_POSITION_INDEX"},{type:9,define:"PREPASS_LOCAL_POSITION",index:"PREPASS_LOCAL_POSITION_INDEX"},{type:2,define:"PREPASS_VELOCITY",index:"PREPASS_VELOCITY_INDEX"},{type:11,define:"PREPASS_VELOCITY_LINEAR",index:"PREPASS_VELOCITY_LINEAR_INDEX"},{type:3,define:"PREPASS_REFLECTIVITY",index:"PREPASS_REFLECTIVITY_INDEX"},{type:0,define:"PREPASS_IRRADIANCE",index:"PREPASS_IRRADIANCE_INDEX"},{type:7,define:"PREPASS_ALBEDO_SQRT",index:"PREPASS_ALBEDO_SQRT_INDEX"},{type:5,define:"PREPASS_DEPTH",index:"PREPASS_DEPTH_INDEX"},{type:10,define:"PREPASS_SCREENSPACE_DEPTH",index:"PREPASS_SCREENSPACE_DEPTH_INDEX"},{type:6,define:"PREPASS_NORMAL",index:"PREPASS_NORMAL_INDEX"},{type:8,define:"PREPASS_WORLD_NORMAL",index:"PREPASS_WORLD_NORMAL_INDEX"}];if(a.prePassRenderer&&a.prePassRenderer.enabled&&t){e.PREPASS=!0,e.SCENE_MRT_COUNT=a.prePassRenderer.mrtCount,e.PREPASS_NORMAL_WORLDSPACE=a.prePassRenderer.generateNormalsInWorldSpace,e.PREPASS_COLOR=!0,e.PREPASS_COLOR_INDEX=0;for(let r=0;r<s.length;r++){const n=a.prePassRenderer.getIndex(s[r].type);n!==-1?(e[s[r].define]=!0,e[s[r].index]=n):e[s[r].define]=!1}}else{e.PREPASS=!1;for(let r=0;r<s.length;r++)e[s[r].define]=!1}e.PREPASS!=i&&(e.markAsUnprocessed(),e.markAsImageProcessingDirty())}function ru(a,e){let t=!1;if(a.activeCamera){const i=e.CAMERA_ORTHOGRAPHIC?1:0,s=e.CAMERA_PERSPECTIVE?1:0,r=a.activeCamera.mode===1?1:0,n=a.activeCamera.mode===0?1:0;(i^r||s^n)&&(e.CAMERA_ORTHOGRAPHIC=r===1,e.CAMERA_PERSPECTIVE=n===1,t=!0)}return t}function nu(a,e,t,i,s=null,r=!1,n=!1,o=!1){s&&s.push("Light"+a),!r&&(e.push("vLightData"+a,"vLightDiffuse"+a,"vLightSpecular"+a,"vLightDirection"+a,"vLightWidth"+a,"vLightHeight"+a,"vLightFalloff"+a,"vLightGround"+a,"vSliceData"+a,"vSliceRanges"+a,"lightMatrix"+a,"shadowsInfo"+a,"depthValues"+a),t.push("shadowTexture"+a),t.push("depthTexture"+a),e.push("viewFrustumZ"+a,"cascadeBlendFactor"+a,"lightSizeUVCorrection"+a,"depthCorrection"+a,"penumbraDarkness"+a,"frustumLengths"+a),i&&(t.push("projectionLightTexture"+a),e.push("textureProjectionMatrix"+a)),n&&t.push("iesLightTexture"+a),o&&(t.push("lightDataTexture"+a),t.push("tileMaskTexture"+a)))}function _h(a,e,t){const i=["vReflectionMicrosurfaceInfos","vReflectionDominantDirection","reflectionMatrix","vReflectionInfos","vReflectionPosition","vReflectionSize","vReflectionColor","vReflectionFilteringInfo"];t&&i.push("vSphericalX","vSphericalY","vSphericalZ","vSphericalXX_ZZ","vSphericalYY_ZZ","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vSphericalL00","vSphericalL1_1","vSphericalL10","vSphericalL11","vSphericalL2_2","vSphericalL2_1","vSphericalL20","vSphericalL21","vSphericalL22"),a.push(...i);const s=["reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","irradianceSampler","icdfSampler"];e.push(...s)}function gh(a,e,t,i=4){let s,r;if(a.uniformsNames){const n=a;s=n.uniformsNames,r=n.uniformBuffersNames,e=n.samplers,t=n.defines,i=n.maxSimultaneousLights||0}else s=a,e||(e=[]);for(let n=0;n<i&&t["LIGHT"+n];
vendor: 6,732 bytes, line 23
23n++)nu(n,s,e,t["PROJECTEDLIGHTTEXTURE"+n],r,!1,t["IESLIGHTTEXTURE"+n],t["CLUSTLIGHT"+n]);t.NUM_MORPH_INFLUENCERS&&(s.push("morphTargetInfluences"),s.push("morphTargetCount")),t.BAKED_VERTEX_ANIMATION_TEXTURE&&(s.push("bakedVertexAnimationSettings"),s.push("bakedVertexAnimationTextureSizeInverted"),s.push("bakedVertexAnimationTime"),e.push("bakedVertexAnimationTexture"))}function ph(a,e=!1,t=!1,i=!1,s=!1,r=!1){a.addUniform("vReflectionInfos",2),a.addUniform("reflectionMatrix",16),e&&a.addUniform("vReflectionMicrosurfaceInfos",3),t&&(a.addUniform("vReflectionPosition",3),a.addUniform("vReflectionSize",3)),i&&(a.addUniform("vReflectionFilteringInfo",2),a.addUniform("vReflectionDominantDirection",3)),r&&a.addUniform("vReflectionColor",3),s&&(a.addUniform("vSphericalL00",3),a.addUniform("vSphericalL1_1",3),a.addUniform("vSphericalL10",3),a.addUniform("vSphericalL11",3),a.addUniform("vSphericalL2_2",3),a.addUniform("vSphericalL2_1",3),a.addUniform("vSphericalL20",3),a.addUniform("vSphericalL21",3),a.addUniform("vSphericalL22",3),a.addUniform("vSphericalX",3),a.addUniform("vSphericalY",3),a.addUniform("vSphericalZ",3),a.addUniform("vSphericalXX_ZZ",3),a.addUniform("vSphericalYY_ZZ",3),a.addUniform("vSphericalZZ",3),a.addUniform("vSphericalXY",3),a.addUniform("vSphericalYZ",3),a.addUniform("vSphericalZX",3))}function mh(a){return a.getPipelineContext===void 0}class F{get useVertexPulling(){return this._useVertexPulling}set useVertexPulling(e){this._useVertexPulling!==e&&(this._useVertexPulling=e,this.markAsDirty(F.MiscDirtyFlag))}get _supportGlowLayer(){return!1}set _glowModeEnabled(e){}get shaderLanguage(){return this._shaderLanguage}get canRenderToMRT(){return!1}set alpha(e){if(this._alpha===e)return;const t=this._alpha;this._alpha=e,(t===1||e===1)&&this.markAsDirty(F.MiscDirtyFlag+F.PrePassDirtyFlag)}get alpha(){return this._alpha}set backFaceCulling(e){this._backFaceCulling!==e&&(this._backFaceCulling=e,this.markAsDirty(F.TextureDirtyFlag))}get backFaceCulling(){return this._backFaceCulling}set cullBackFaces(e){this._cullBackFaces!==e&&(this._cullBackFaces=e,this.markAsDirty(F.TextureDirtyFlag))}get cullBackFaces(){return this._cullBackFaces}get blockDirtyMechanism(){return this._blockDirtyMechanism}set blockDirtyMechanism(e){this._blockDirtyMechanism!==e&&(this._blockDirtyMechanism=e,e||this.markDirty())}atomicMaterialsUpdate(e){this.blockDirtyMechanism=!0;try{e(this)}finally{this.blockDirtyMechanism=!1}}get hasRenderTargetTextures(){return this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._eventInfo.hasRenderTargetTextures}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}get onBindObservable(){return this._onBindObservable||(this._onBindObservable=new O),this._onBindObservable}set onBind(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)}get onUnBindObservable(){return this._onUnBindObservable||(this._onUnBindObservable=new O),this._onUnBindObservable}get onEffectCreatedObservable(){return this._onEffectCreatedObservable||(this._onEffectCreatedObservable=new O),this._onEffectCreatedObservable}set alphaMode(e){this._alphaMode[0]!==e&&(this._alphaMode[0]=e,this.markAsDirty(F.TextureDirtyFlag))}get alphaMode(){return this._alphaMode[0]}get alphaModes(){return this._alphaMode}setAlphaMode(e,t=0){this._alphaMode[t]!==e&&(this._alphaMode[t]=e,this.markAsDirty(F.TextureDirtyFlag))}set needDepthPrePass(e){this._needDepthPrePass!==e&&(this._needDepthPrePass=e,this._needDepthPrePass&&(this.checkReadyOnEveryCall=!0))}get needDepthPrePass(){return this._needDepthPrePass}get isPrePassCapable(){return!1}set fogEnabled(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAsDirty(F.MiscDirtyFlag))}get fogEnabled(){return this._fogEnabled}get wireframe(){switch(this._fillMode){case F.WireFrameFillMode:case F.LineListDrawMode:case F.LineLoopDrawMode:case F.LineStripDrawMode:return!0}return this._scene.forceWireframe}set wireframe(e){this.fillMode=e?F.WireFrameFillMode:F.TriangleFillMode}get pointsCloud(){switch(this._fillMode){case F.PointFillMode:case F.PointListDrawMode:return!0}return this._scene.forcePointsCloud}set pointsCloud(e){this.fillMode=e?F.PointFillMode:F.TriangleFillMode}get fillMode(){return this._fillMode}set fillMode(e){this._fillMode!==e&&(this._fillMode=e,this.markAsDirty(F.MiscDirtyFlag))}get useLogarithmicDepth(){return this._useLogarithmicDepth}set useLogarithmicDepth(e){const t=this.getScene().getEngine().getCaps().fragmentDepthSupported;e&&!t&&w.Warn("Logarithmic depth has been requested for a material on a device that doesn't support it."),this._useLogarithmicDepth=e&&t,this._markAllSubMeshesAsMiscDirty()}get isVertexOutputInvariant(){return this._isVertexOutputInvariant}set isVertexOutputInvariant(e){this._isVertexOutputInvariant!==e&&(this._isVertexOutputInvariant=e,this._markAllSubMeshesAsMiscDirty())}_getDrawWrapper(){return this._drawWrapper}_setDrawWrapper(e){this._drawWrapper=e}constructor(e,t,i,s=!1){this.shadowDepthWrapper=null,this.allowShaderHotSwapping=!0,this._shaderLanguage=0,this._forceGLSL=!1,this._useVertexPulling=!1,this.metadata=null,this.reservedDataStore=null,this.checkReadyOnEveryCall=!1,this.checkReadyOnlyOnce=!1,this.state="",this._alpha=1,this._backFaceCulling=!0,this._cullBackFaces=!0,this._blockDirtyMechanism=!1,this.sideOrientation=null,this.onCompiled=null,this.onError=null,this.getRenderTargetTextures=null,this.doNotSerialize=!1,this._storeEffectOnSubMeshes=!1,this.animations=null,this.onDisposeObservable=new O,this._onDisposeObserver=null,this._onUnBindObservable=null,this._onBindObserver=null,this._alphaMode=[2],this._needDepthPrePass=!1,this.disableDepthWrite=!1,this.disableColorWrite=!1,this.forceDepthWrite=!1,this.depthFunction=0,this.separateCullingPass=!1,this._fogEnabled=!0,this.pointSize=1,this.zOffset=0,this.zOffsetUnits=0,this.stencil=new Bt,this._isVertexOutputInvariant=F.ForceVertexOutputInvariant,this._useUBO=!1,this._fillMode=F.TriangleFillMode,this._cachedDepthWriteState=!1,this._cachedColorWriteState=!1,this._cachedDepthFunctionState=0,this._indexInSceneMaterialArray=-1,this.meshMap=null,this._parentContainer=null,this._uniformBufferLayoutBuilt=!1,this._eventInfo={},this._callbackPluginEventGeneric=()=>{},this._callbackPluginEventIsReadyForSubMesh=()=>{},this._callbackPluginEventPrepareDefines=()=>{},this._callbackPluginEventPrepareDefinesBeforeAttributes=()=>{},this._callbackPluginEventHardBindForSubMesh=()=>{},this._callbackPluginEventBindForSubMesh=()=>{},this._callbackPluginEventHasRenderTargetTextures=()=>{}
vendor: 38,743 bytes, line 23
23,this._callbackPluginEventFillRenderTargetTextures=()=>{},this._transparencyMode=null,this.name=e;const r=t||Te.LastCreatedScene;r&&(this._scene=r,this._dirtyCallbacks={},this._forceGLSL=s,this._dirtyCallbacks[1]=this._markAllSubMeshesAsTexturesDirty.bind(this),this._dirtyCallbacks[2]=this._markAllSubMeshesAsLightsDirty.bind(this),this._dirtyCallbacks[4]=this._markAllSubMeshesAsFresnelDirty.bind(this),this._dirtyCallbacks[8]=this._markAllSubMeshesAsAttributesDirty.bind(this),this._dirtyCallbacks[16]=this._markAllSubMeshesAsMiscDirty.bind(this),this._dirtyCallbacks[32]=this._markAllSubMeshesAsPrePassDirty.bind(this),this._dirtyCallbacks[127]=this._markAllSubMeshesAsAllDirty.bind(this),this.id=e||se.RandomId(),this.uniqueId=this._scene.getUniqueId(),this._materialContext=this._scene.getEngine().createMaterialContext(),this._drawWrapper=new kn(this._scene.getEngine(),!1),this._drawWrapper.materialContext=this._materialContext,this._uniformBuffer=new K(this._scene.getEngine(),void 0,void 0,e),this._useUBO=this.getScene().getEngine().supportsUniformBuffers,this._createUniformBuffer(),i||this._scene.addMaterial(this),this._scene.useMaterialMeshMap&&(this.meshMap={}),F.OnEventObservable.notifyObservers(this,1))}_createUniformBuffer(){const e=this.getScene().getEngine();this._uniformBuffer?.dispose(),e.isWebGPU&&!this._forceGLSL?(this._uniformBuffer=new K(e,void 0,void 0,this.name,!0),this._shaderLanguage=1):this._uniformBuffer=new K(this._scene.getEngine(),void 0,void 0,this.name),this._uniformBufferLayoutBuilt=!1}toString(e){return"Name: "+this.name}getClassName(){return"Material"}get _isMaterial(){return!0}get isFrozen(){return this.checkReadyOnlyOnce}freeze(){this.markDirty(),this.checkReadyOnlyOnce=!0}unfreeze(){this.markDirty(),this.checkReadyOnlyOnce=!1}isReady(e,t){return!0}isReadyForSubMesh(e,t,i){const s=t.materialDefines;return s?(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=s,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),this._eventInfo.isReadyForSubMesh):!1}getEffect(){return this._drawWrapper.effect}getScene(){return this._scene}_getEffectiveOrientation(e){return this.sideOrientation!==null?this.sideOrientation:e.sideOrientation}get transparencyMode(){return this._transparencyMode}set transparencyMode(e){this._transparencyMode!==e&&(this._transparencyMode=e,this._markAllSubMeshesAsTexturesAndMiscDirty())}get _hasTransparencyMode(){return this._transparencyMode!=null}get _transparencyModeIsBlend(){return this._transparencyMode===F.MATERIAL_ALPHABLEND||this._transparencyMode===F.MATERIAL_ALPHATESTANDBLEND}get _transparencyModeIsTest(){return this._transparencyMode===F.MATERIAL_ALPHATEST||this._transparencyMode===F.MATERIAL_ALPHATESTANDBLEND}get _disableAlphaBlending(){return this._transparencyMode===F.MATERIAL_OPAQUE||this._transparencyMode===F.MATERIAL_ALPHATEST}needAlphaBlending(){return this._hasTransparencyMode?this._transparencyModeIsBlend:this._disableAlphaBlending?!1:this.alpha<1}needAlphaBlendingForMesh(e){return this._hasTransparencyMode?this._transparencyModeIsBlend:e.visibility<1?!0:this._disableAlphaBlending?!1:e.hasVertexAlpha||this.needAlphaBlending()}needAlphaTesting(){return this._hasTransparencyMode?this._transparencyModeIsTest:!1}needAlphaTestingForMesh(e){return this._hasTransparencyMode?this._transparencyModeIsTest:!this.needAlphaBlendingForMesh(e)&&this.needAlphaTesting()}getAlphaTestTexture(){return null}markDirty(e=!1){const t=this.getScene().meshes;for(const i of t)if(i.subMeshes){for(const s of i.subMeshes)if(s.getMaterial()===this)for(const r of s._drawWrappers)r&&this._materialContext===r.materialContext&&(r._wasPreviouslyReady=!1,r._wasPreviouslyUsingInstances=null,r._forceRebindOnNextCall=e)}e&&this.markAsDirty(F.AllDirtyFlag)}_preBind(e,t=null){const i=this._scene.getEngine(),r=(t??this.sideOrientation)===F.ClockWiseSideOrientation,n=e||this._getDrawWrapper();return mh(n)&&n.materialContext&&(n.materialContext.useVertexPulling=this.useVertexPulling),i.enableEffect(n),i.setState(this.backFaceCulling,this.zOffset,!1,r,this._scene._mirroredCameraPosition?!this.cullBackFaces:this.cullBackFaces,this.stencil,this.zOffsetUnits),r}bind(e,t){}buildUniformLayout(){const e=this._uniformBuffer;this._eventInfo.ubo=e,this._callbackPluginEventGeneric(8,this._eventInfo),e.create(),this._uniformBufferLayoutBuilt=!0}bindForSubMesh(e,t,i){const s=i._drawWrapper;this._eventInfo.subMesh=i,this._callbackPluginEventBindForSubMesh(this._eventInfo),s._forceRebindOnNextCall=!1}bindOnlyWorldMatrix(e){}bindView(e){this._useUBO?this._needToBindSceneUbo=!0:e.setMatrix("view",this.getScene().getViewMatrix())}bindViewProjection(e){this._useUBO?this._needToBindSceneUbo=!0:(e.setMatrix("viewProjection",this.getScene().getTransformMatrix()),e.setMatrix("projection",this.getScene().getProjectionMatrix()))}bindEyePosition(e,t){this._useUBO?this._needToBindSceneUbo=!0:this._scene.bindEyePosition(e,t)}_afterBind(e,t=null,i){if(this._scene._cachedMaterial=this,this._needToBindSceneUbo&&t&&(this._needToBindSceneUbo=!1,Yc(t,this.getScene().getSceneUniformBuffer()),this._scene.finalizeSceneUbo()),e?this._scene._cachedVisibility=e.visibility:this._scene._cachedVisibility=1,this._onBindObservable&&e&&this._onBindObservable.notifyObservers(e),this.disableDepthWrite){const s=this._scene.getEngine();this._cachedDepthWriteState=s.getDepthWrite(),s.setDepthWrite(!1)}if(this.disableColorWrite){const s=this._scene.getEngine();this._cachedColorWriteState=s.getColorWrite(),s.setColorWrite(!1)}if(this.depthFunction!==0){const s=this._scene.getEngine();this._cachedDepthFunctionState=s.getDepthFunction()||0,s.setDepthFunction(this.depthFunction)}}unbind(){this._scene.getSceneUniformBuffer().unbindEffect(),this._onUnBindObservable&&this._onUnBindObservable.notifyObservers(this),this.depthFunction!==0&&this._scene.getEngine().setDepthFunction(this._cachedDepthFunctionState),this.disableDepthWrite&&this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState),this.disableColorWrite&&this._scene.getEngine().setColorWrite(this._cachedColorWriteState)}getAnimatables(){return this._eventInfo.animatables=[],this._callbackPluginEventGeneric(256,this._eventInfo),this._eventInfo.animatables}getActiveTextures(){return this._eventInfo.activeTextures=[],this._callbackPluginEventGeneric(512,this._eventInfo),this._eventInfo.activeTextures}hasTexture(e){return this._eventInfo.hasTexture=!1,this._eventInfo.texture=e,this._callbackPluginEventGeneric(1024,this._eventInfo),this._eventInfo.hasTexture}clone(e){return null}_clonePlugins(e,t){const i={};if(this._serializePlugins(i),F._ParsePlugins(i,e,this._scene,t),this.pluginManager)for(const s of this.pluginManager._plugins){const r=e.pluginManager.getPlugin(s.name);r&&s.copyTo(r)}}getBindedMeshes(){if(this.meshMap){const e=[];for(const t in this.meshMap){const i=this.meshMap[t];i&&e.push(i)}return e}else return this._scene.meshes.filter(t=>t.material===this)}forceCompilation(e,t,i,s){const r={clipPlane:!1,useInstances:!1,...i},n=this.getScene(),o=this.allowShaderHotSwapping;this.allowShaderHotSwapping=!1;const h=()=>{if(!this._scene||!this._scene.getEngine())return;const l=n.clipPlane;if(r.clipPlane&&(n.clipPlane=new Ht(0,0,0,1)),this._storeEffectOnSubMeshes){let c=!0,u=null;if(e.subMeshes){const f=new zt(0,0,0,0,0,e,void 0,!1,!1);f.materialDefines&&(f.materialDefines._renderId=-1),this.isReadyForSubMesh(e,f,r.useInstances)||(f.effect&&f.effect.getCompilationError()&&f.effect.allFallbacksProcessed()?u=f.effect.getCompilationError():(c=!1,setTimeout(h,16)))}c&&(this.allowShaderHotSwapping=o,u&&s&&s(u),t&&t(this))}else this.isReady()?(this.allowShaderHotSwapping=o,t&&t(this)):setTimeout(h,16);r.clipPlane&&(n.clipPlane=l)};h()}async forceCompilationAsync(e,t){return await new Promise((i,s)=>{this.forceCompilation(e,()=>{i()},t,r=>{s(r)})})}markAsDirty(e){this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism||(F._DirtyCallbackArray.length=0,e&F.ImageProcessingDirtyFlag&&F._DirtyCallbackArray.push(F._ImageProcessingDirtyCallBack),e&F.TextureDirtyFlag&&F._DirtyCallbackArray.push(F._TextureDirtyCallBack),e&F.LightDirtyFlag&&F._DirtyCallbackArray.push(F._LightsDirtyCallBack),e&F.FresnelDirtyFlag&&F._DirtyCallbackArray.push(F._FresnelDirtyCallBack),e&F.AttributesDirtyFlag&&F._DirtyCallbackArray.push(F._AttributeDirtyCallBack),e&F.MiscDirtyFlag&&F._DirtyCallbackArray.push(F._MiscDirtyCallBack),e&F.PrePassDirtyFlag&&F._DirtyCallbackArray.push(F._PrePassDirtyCallBack),F._DirtyCallbackArray.length&&this._markAllSubMeshesAsDirty(F._RunDirtyCallBacks),this.getScene().resetCachedMaterial())}resetDrawCache(){const e=this.getScene().meshes;for(const t of e)if(t.subMeshes)for(const i of t.subMeshes)i.getMaterial()===this&&i.resetDrawCache()}_markAllSubMeshesAsDirty(e){const t=this.getScene();if(t.blockMaterialDirtyMechanism||this._blockDirtyMechanism)return;const i=t.meshes;for(const s of i)if(s.subMeshes){for(const r of s.subMeshes)if((r.getMaterial()||(t._hasDefaultMaterial?t.defaultMaterial:null))===this)for(const o of r._drawWrappers)!o||!o.defines||!o.defines.markAllAsDirty||this._materialContext===o.materialContext&&e(o.defines)}}_markScenePrePassDirty(){if(this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism)return;const e=this.getScene().enablePrePassRenderer();e&&e.markAsDirty()}_markAllSubMeshesAsAllDirty(){this._markAllSubMeshesAsDirty(F._AllDirtyCallBack)}_markAllSubMeshesAsImageProcessingDirty(){this._markAllSubMeshesAsDirty(F._ImageProcessingDirtyCallBack)}_markAllSubMeshesAsTexturesDirty(){this._markAllSubMeshesAsDirty(F._TextureDirtyCallBack)}_markAllSubMeshesAsFresnelDirty(){this._markAllSubMeshesAsDirty(F._FresnelDirtyCallBack)}_markAllSubMeshesAsFresnelAndMiscDirty(){this._markAllSubMeshesAsDirty(F._FresnelAndMiscDirtyCallBack)}_markAllSubMeshesAsLightsDirty(){this._markAllSubMeshesAsDirty(F._LightsDirtyCallBack)}_markAllSubMeshesAsAttributesDirty(){this._markAllSubMeshesAsDirty(F._AttributeDirtyCallBack)}_markAllSubMeshesAsMiscDirty(){this._markAllSubMeshesAsDirty(F._MiscDirtyCallBack)}_markAllSubMeshesAsPrePassDirty(){this._markAllSubMeshesAsDirty(F._PrePassDirtyCallBack)}_markAllSubMeshesAsTexturesAndMiscDirty(){this._markAllSubMeshesAsDirty(F._TextureAndMiscDirtyCallBack)}_checkScenePerformancePriority(){if(this._scene.performancePriority!==0){this.checkReadyOnlyOnce=!0;const e=this._scene.onScenePerformancePriorityChangedObservable.addOnce(()=>{this.checkReadyOnlyOnce=!1});this.onDisposeObservable.add(()=>{this._scene.onScenePerformancePriorityChangedObservable.remove(e)})}}setPrePassRenderer(e){return!1}dispose(e,t,i){const s=this.getScene();if(s.stopAnimation(this),s.freeProcessedMaterials(),s.removeMaterial(this),this._eventInfo.forceDisposeTextures=t,this._callbackPluginEventGeneric(2,this._eventInfo),this._parentContainer){const r=this._parentContainer.materials.indexOf(this);r>-1&&this._parentContainer.materials.splice(r,1),this._parentContainer=null}if(i!==!0)if(this.meshMap)for(const r in this.meshMap){const n=this.meshMap[r];this._disposeMeshResources(n)}else{const r=s.meshes;for(const n of r)this._disposeMeshResources(n)}this._uniformBuffer.dispose(),this._drawWrapper.effect&&(this._storeEffectOnSubMeshes||this._drawWrapper.effect.dispose(),this._drawWrapper.effect=null),this.metadata=null,this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this._onBindObservable&&this._onBindObservable.clear(),this._onUnBindObservable&&this._onUnBindObservable.clear(),this._onEffectCreatedObservable&&this._onEffectCreatedObservable.clear(),this._eventInfo&&(this._eventInfo={})}_disposeMeshResources(e){if(!e)return;const t=e.geometry,i=e._internalAbstractMeshDataInfo._materialForRenderPass;if(this._storeEffectOnSubMeshes){if(e.subMeshes&&i)for(const s of e.subMeshes){const r=s._drawWrappers;for(let n=0;n<r.length;n++){const o=r[n]?.effect;if(!o)continue;i[n]===this&&(t?._releaseVertexArrayObject(o),s._removeDrawWrapper(n,!0,!0))}}}else t?._releaseVertexArrayObject(this._drawWrapper.effect);e.material===this&&!e.sourceMesh&&(e.material=null)}serialize(){const e=le.Serialize(this);return e.stencil=this.stencil.serialize(),e.uniqueId=this.uniqueId,this._serializePlugins(e),e}_serializePlugins(e){if(e.plugins={},this.pluginManager)for(const t of this.pluginManager._plugins)t.doNotSerialize||(e.plugins[t.getClassName()]=t.serialize())}static ParseAlphaMode(e,t){e._alphaMode!==void 0?t._alphaMode=Array.isArray(e._alphaMode)?e._alphaMode:[e._alphaMode]:e.alphaMode!==void 0?t._alphaMode=Array.isArray(e.alphaMode)?e.alphaMode:[e.alphaMode]:t._alphaMode=[2]}static Parse(e,t,i){if(!e.customType)e.customType="BABYLON.StandardMaterial";else if(e.customType==="BABYLON.PBRMaterial"&&e.overloadedAlbedo&&(e.customType="BABYLON.LegacyPBRMaterial",!BABYLON.LegacyPBRMaterial))return w.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."),null;const r=se.Instantiate(e.customType).Parse(e,t,i);return r._loadedUniqueId=e.uniqueId,F.ParseAlphaMode(e,r),r}static _ParsePlugins(e,t,i,s){if(e.plugins)for(const r in e.plugins){const n=e.plugins[r];let o=t.pluginManager?.getPlugin(n.name);if(!o){const h=se.Instantiate("BABYLON."+r);h&&(o=new h(t))}o?.parse(n,i,s)}}}F.TriangleFillMode=0;F.WireFrameFillMode=1;F.PointFillMode=2;F.PointListDrawMode=3;F.LineListDrawMode=4;F.LineLoopDrawMode=5;F.LineStripDrawMode=6;F.TriangleStripDrawMode=7;F.TriangleFanDrawMode=8;F.ClockWiseSideOrientation=0;F.CounterClockWiseSideOrientation=1;F.ImageProcessingDirtyFlag=64;F.TextureDirtyFlag=1;F.LightDirtyFlag=2;F.FresnelDirtyFlag=4;F.AttributesDirtyFlag=8;F.MiscDirtyFlag=16;F.PrePassDirtyFlag=32;F.AllDirtyFlag=127;F.MATERIAL_OPAQUE=0;F.MATERIAL_ALPHATEST=1;F.MATERIAL_ALPHABLEND=2;F.MATERIAL_ALPHATESTANDBLEND=3;F.MATERIAL_NORMALBLENDMETHOD_WHITEOUT=0;F.MATERIAL_NORMALBLENDMETHOD_RNM=1;F.LIGHTFALLOFF_PHYSICAL=0;F.LIGHTFALLOFF_GLTF=1;F.LIGHTFALLOFF_STANDARD=2;F.OnEventObservable=new O;F.ForceVertexOutputInvariant=!1;F._AllDirtyCallBack=a=>a.markAllAsDirty();F._ImageProcessingDirtyCallBack=a=>a.markAsImageProcessingDirty();F._TextureDirtyCallBack=a=>a.markAsTexturesDirty();F._FresnelDirtyCallBack=a=>a.markAsFresnelDirty();F._MiscDirtyCallBack=a=>a.markAsMiscDirty();F._PrePassDirtyCallBack=a=>a.markAsPrePassDirty();F._LightsDirtyCallBack=a=>a.markAsLightDirty();F._AttributeDirtyCallBack=a=>a.markAsAttributesDirty();F._FresnelAndMiscDirtyCallBack=a=>{F._FresnelDirtyCallBack(a),F._MiscDirtyCallBack(a)};F._TextureAndMiscDirtyCallBack=a=>{F._TextureDirtyCallBack(a),F._MiscDirtyCallBack(a)};F._DirtyCallbackArray=[];F._RunDirtyCallBacks=a=>{for(const e of F._DirtyCallbackArray)e(a)};T([R()],F.prototype,"id",void 0);T([R()],F.prototype,"uniqueId",void 0);T([R()],F.prototype,"name",void 0);T([R()],F.prototype,"metadata",void 0);T([R()],F.prototype,"checkReadyOnEveryCall",void 0);T([R()],F.prototype,"checkReadyOnlyOnce",void 0);T([R()],F.prototype,"state",void 0);T([R("alpha")],F.prototype,"_alpha",void 0);T([R("backFaceCulling")],F.prototype,"_backFaceCulling",void 0);T([R("cullBackFaces")],F.prototype,"_cullBackFaces",void 0);T([R()],F.prototype,"sideOrientation",void 0);T([R()],F.prototype,"_alphaMode",void 0);T([R()],F.prototype,"_needDepthPrePass",void 0);T([R()],F.prototype,"disableDepthWrite",void 0);T([R()],F.prototype,"disableColorWrite",void 0);T([R()],F.prototype,"forceDepthWrite",void 0);T([R()],F.prototype,"depthFunction",void 0);T([R()],F.prototype,"separateCullingPass",void 0);T([R("fogEnabled")],F.prototype,"_fogEnabled",void 0);T([R()],F.prototype,"pointSize",void 0);T([R()],F.prototype,"zOffset",void 0);T([R()],F.prototype,"zOffsetUnits",void 0);T([R()],F.prototype,"pointsCloud",null);T([R()],F.prototype,"fillMode",null);T([R()],F.prototype,"useLogarithmicDepth",null);T([R()],F.prototype,"_isVertexOutputInvariant",void 0);T([R()],F.prototype,"transparencyMode",null);class Ts extends F{get subMaterials(){return this._subMaterials}set subMaterials(e){this._subMaterials=e,this._hookArray(e)}getChildren(){return this.subMaterials}constructor(e,t){super(e,t,!0),this._waitingSubMaterialsUniqueIds=[],this.getScene().addMultiMaterial(this),this.subMaterials=[],this._storeEffectOnSubMeshes=!0}_hookArray(e){const t=e.push;e.push=(...s)=>{const r=t.apply(e,s);return this._markAllSubMeshesAsTexturesDirty(),r};const i=e.splice;e.splice=(s,r)=>{const n=i.apply(e,[s,r]);return this._markAllSubMeshesAsTexturesDirty(),n}}getSubMaterial(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]}getActiveTextures(){return super.getActiveTextures().concat(...this.subMaterials.map(e=>e?e.getActiveTextures():[]))}hasTexture(e){if(super.hasTexture(e))return!0;for(let t=0;t<this.subMaterials.length;t++)if(this.subMaterials[t]?.hasTexture(e))return!0;return!1}getClassName(){return"MultiMaterial"}isReadyForSubMesh(e,t,i){for(let s=0;s<this.subMaterials.length;s++){const r=this.subMaterials[s];if(r){if(r._storeEffectOnSubMeshes){if(!r.isReadyForSubMesh(e,t,i))return!1;continue}if(!r.isReady(e))return!1}}return!0}clone(e,t){const i=new Ts(e,this.getScene());for(let s=0;s<this.subMaterials.length;s++){let r=null;const n=this.subMaterials[s];t&&n?r=n.clone(e+"-"+n.name):r=this.subMaterials[s],i.subMaterials.push(r)}return i}serialize(){const e={};e.name=this.name,e.id=this.id,e.uniqueId=this.uniqueId,Ae&&(e.tags=Ae.GetTags(this)),e.materialsUniqueIds=[],e.materials=[];for(let t=0;t<this.subMaterials.length;t++){const i=this.subMaterials[t];i?(e.materialsUniqueIds.push(i.uniqueId),e.materials.push(i.id)):(e.materialsUniqueIds.push(null),e.materials.push(null))}return e}dispose(e,t,i){const s=this.getScene();if(!s)return;if(i)for(let n=0;n<this.subMaterials.length;n++){const o=this.subMaterials[n];o&&o.dispose(e,t)}const r=s.multiMaterials.indexOf(this);r>=0&&s.multiMaterials.splice(r,1),super.dispose(e,t)}static ParseMultiMaterial(e,t){const i=new Ts(e.name,t);if(i.id=e.id,i._loadedUniqueId=e.uniqueId,Ae&&Ae.AddTagsTo(i,e.tags),e.materialsUniqueIds)i._waitingSubMaterialsUniqueIds=e.materialsUniqueIds;else for(const s of e.materials)i.subMaterials.push(t.getLastMaterialById(s));return i}}nt("BABYLON.MultiMaterial",Ts);class re{}re.NAME_EFFECTLAYER="EffectLayer";re.NAME_LAYER="Layer";re.NAME_LENSFLARESYSTEM="LensFlareSystem";re.NAME_BOUNDINGBOXRENDERER="BoundingBoxRenderer";re.NAME_PARTICLESYSTEM="ParticleSystem";re.NAME_GAMEPAD="Gamepad";re.NAME_SIMPLIFICATIONQUEUE="SimplificationQueue";re.NAME_GEOMETRYBUFFERRENDERER="GeometryBufferRenderer";re.NAME_PREPASSRENDERER="PrePassRenderer";re.NAME_DEPTHRENDERER="DepthRenderer";re.NAME_DEPTHPEELINGRENDERER="DepthPeelingRenderer";re.NAME_POSTPROCESSRENDERPIPELINEMANAGER="PostProcessRenderPipelineManager";re.NAME_SPRITE="Sprite";re.NAME_SUBSURFACE="SubSurface";re.NAME_OUTLINERENDERER="Outline";re.NAME_PROCEDURALTEXTURE="ProceduralTexture";re.NAME_SHADOWGENERATOR="ShadowGenerator";re.NAME_OCTREE="Octree";re.NAME_PHYSICSENGINE="PhysicsEngine";re.NAME_AUDIO="Audio";re.NAME_FLUIDRENDERER="FluidRenderer";re.NAME_IBLCDFGENERATOR="iblCDFGenerator";re.NAME_CLUSTEREDLIGHTING="ClusteredLighting";re.STEP_ISREADYFORMESH_EFFECTLAYER=0;re.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER=0;re.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER=0;re.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER=0;re.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER=1;re.STEP_BEFORECAMERADRAW_PREPASS=0;re.STEP_BEFORECAMERADRAW_EFFECTLAYER=1;re.STEP_BEFORECAMERADRAW_LAYER=2;re.STEP_BEFORERENDERTARGETDRAW_PREPASS=0;re.STEP_BEFORERENDERTARGETDRAW_LAYER=1;re.STEP_BEFORERENDERINGMESH_PREPASS=0;re.STEP_BEFORERENDERINGMESH_OUTLINE=1;re.STEP_AFTERRENDERINGMESH_PREPASS=0;re.STEP_AFTERRENDERINGMESH_OUTLINE=1;re.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW=0;re.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER=1;re.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE=0;re.STEP_BEFORECLEAR_PROCEDURALTEXTURE=0;re.STEP_BEFORECLEAR_PREPASS=1;re.STEP_BEFORERENDERTARGETCLEAR_PREPASS=0;re.STEP_AFTERRENDERTARGETDRAW_PREPASS=0;re.STEP_AFTERRENDERTARGETDRAW_LAYER=1;re.STEP_AFTERCAMERADRAW_PREPASS=0;re.STEP_AFTERCAMERADRAW_EFFECTLAYER=1;re.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM=2;re.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW=3;re.STEP_AFTERCAMERADRAW_LAYER=4;re.STEP_AFTERCAMERADRAW_FLUIDRENDERER=5;re.STEP_AFTERCAMERAPOSTPROCESS_LAYER=0;re.STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER=0;re.STEP_AFTERRENDER_AUDIO=0;re.STEP_GATHERRENDERTARGETS_DEPTHRENDERER=0;re.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER=1;re.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR=2;re.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER=3;re.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER=0;re.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER=1;re.STEP_GATHERACTIVECAMERARENDERTARGETS_CLUSTEREDLIGHTING=2;re.STEP_POINTERMOVE_SPRITE=0;re.STEP_POINTERDOWN_SPRITE=0;re.STEP_POINTERUP_SPRITE=0;class Xe extends Array{constructor(e){super(...e)}static Create(){return Object.create(Xe.prototype)}registerStep(e,t,i){let s=0,r=Number.MAX_VALUE;for(;s<this.length&&(r=this[s].index,!(e<r));s++);this.splice(s,0,{index:e,component:t,action:i.bind(t)})}clear(){this.length=0}}class au{constructor(e,t){this.distanceOrScreenCoverage=e,this.mesh=t}}class ou{constructor(){this.batchCache=new ba(this),this.batchCacheReplacementModeInFrozenMode=new ba(this),this.instancesBufferSize=512*4}}class hu{constructor(){this.renderPasses={}}}class ba{constructor(e){this.parent=e,this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=[],this.hardwareInstancedRendering=[]}}class lu{constructor(){this.instancesCount=0,this.matrixBuffer=null,this.previousMatrixBuffer=null,this.matrixBufferSize=512,this.matrixData=null,this.boundingVectors=[],this.worldMatrices=null}}class cu{constructor(){this._areNormalsFrozen=!1,this._source=null,this.meshMap=null,this._preActivateId=-1,this._LODLevels=new Array,this._useLODScreenCoverage=!1,this._effectiveMaterial=null,this._forcedInstanceCount=0,this._overrideRenderingFillMode=null}}const si={source:null,parent:null,doNotCloneChildren:!1,clonePhysicsImpostor:!0,cloneThinInstances:!1};class ne extends Ct{static _GetDefaultSideOrientation(e){return e||ne.FRONTSIDE}get useLODScreenCoverage(){return this._internalMeshDataInfo._useLODScreenCoverage}set useLODScreenCoverage(e){this._internalMeshDataInfo._useLODScreenCoverage=e,this._sortLODLevels()}get computeBonesUsingShaders(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders}set computeBonesUsingShaders(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(e&&this._internalMeshDataInfo._sourcePositions&&(this.setVerticesData(b.PositionKind,this._internalMeshDataInfo._sourcePositions,!0),this._internalMeshDataInfo._sourceNormals&&this.setVerticesData(b.NormalKind,this._internalMeshDataInfo._sourceNormals,!0),this._internalMeshDataInfo._sourcePositions=null,this._internalMeshDataInfo._sourceNormals=null),this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())}get onBeforeRenderObservable(){return this._internalMeshDataInfo._onBeforeRenderObservable||(this._internalMeshDataInfo._onBeforeRenderObservable=new O),this._internalMeshDataInfo._onBeforeRenderObservable}get onBeforeBindObservable(){return this._internalMeshDataInfo._onBeforeBindObservable||(this._internalMeshDataInfo._onBeforeBindObservable=new O),this._internalMeshDataInfo._onBeforeBindObservable}get onAfterRenderObservable(){return this._internalMeshDataInfo._onAfterRenderObservable||(this._internalMeshDataInfo._onAfterRenderObservable=new O),this._internalMeshDataInfo._onAfterRenderObservable}get onBetweenPassObservable(){return this._internalMeshDataInfo._onBetweenPassObservable||(this._internalMeshDataInfo._onBetweenPassObservable=new O),this._internalMeshDataInfo._onBetweenPassObservable}get onBeforeDrawObservable(){return this._internalMeshDataInfo._onBeforeDrawObservable||(this._internalMeshDataInfo._onBeforeDrawObservable=new O),this._internalMeshDataInfo._onBeforeDrawObservable}set onBeforeDraw(e){this._onBeforeDrawObserver&&this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),this._onBeforeDrawObserver=this.onBeforeDrawObservable.add(e)}get hasInstances(){return this.instances.length>0}get hasThinInstances(){return(this.forcedInstanceCount||this._thinInstanceDataStorage.instancesCount||0)>0}get forcedInstanceCount(){return this._internalMeshDataInfo._forcedInstanceCount}set forcedInstanceCount(e){this._internalMeshDataInfo._forcedInstanceCount=e}get sideOrientation(){return this._internalMeshDataInfo._sideOrientation}set sideOrientation(e){this._internalMeshDataInfo._sideOrientation=e,this._internalAbstractMeshDataInfo._sideOrientationHint=this._scene.useRightHandedSystem&&e===1||!this._scene.useRightHandedSystem&&e===0}get _effectiveSideOrientation(){return this._internalMeshDataInfo._effectiveSideOrientation}get overrideMaterialSideOrientation(){return this.sideOrientation}set overrideMaterialSideOrientation(e){this.sideOrientation=e,this.material&&(this.material.sideOrientation=null)}get overrideRenderingFillMode(){return this._internalMeshDataInfo._overrideRenderingFillMode}set overrideRenderingFillMode(e){this._internalMeshDataInfo._overrideRenderingFillMode=e}get material(){return this._internalAbstractMeshDataInfo._material}set material(e){e&&(this.material&&this.material.sideOrientation===null||this._internalAbstractMeshDataInfo._sideOrientationHint)&&(e.sideOrientation=null),this._setMaterial(e)}get source(){return this._internalMeshDataInfo._source}get cloneMeshMap(){return this._internalMeshDataInfo.meshMap}get isUnIndexed(){return this._unIndexed}set isUnIndexed(e){this._unIndexed!==e&&(this._unIndexed=e,this._markSubMeshesAsAttributesDirty())}get worldMatrixInstancedBuffer(){const e=this._instanceDataStorage.renderPasses[this._instanceDataStorage.engine.isWebGPU?this._instanceDataStorage.engine.currentRenderPassId:0];return e?e.instancesData:void 0}get previousWorldMatrixInstancedBuffer(){const e=this._instanceDataStorage.renderPasses[this._instanceDataStorage.engine.isWebGPU?this._instanceDataStorage.engine.currentRenderPassId:0];return e?e.instancesPreviousData:void 0}get manualUpdateOfWorldMatrixInstancedBuffer(){return this._instanceDataStorage.manualUpdate}set manualUpdateOfWorldMatrixInstancedBuffer(e){this._instanceDataStorage.manualUpdate=e}get manualUpdateOfPreviousWorldMatrixInstancedBuffer(){return this._instanceDataStorage.previousManualUpdate}set manualUpdateOfPreviousWorldMatrixInstancedBuffer(e){this._instanceDataStorage.previousManualUpdate=e}get forceWorldMatrixInstancedBufferUpdate(){return this._instanceDataStorage.forceMatrixUpdates}set forceWorldMatrixInstancedBufferUpdate(e){this._instanceDataStorage.forceMatrixUpdates=e}_copySource(e,t,i=!0,s=!1){const r=this.getScene();if(e._geometry&&e._geometry.applyToMesh(this),So.DeepCopy(e,this,["name","material","skeleton","instances","parent","uniqueId","source","metadata","morphTargetManager","hasInstances","worldMatrixInstancedBuffer","previousWorldMatrixInstancedBuffer","hasLODLevels","geometry","isBlocked","areNormalsFrozen","facetNb","isFacetDataEnabled","lightSources","useBones","isAnInstance","collider","edgesRenderer","forward","up","right","absolutePosition","absoluteScaling","absoluteRotationQuaternion","isWorldMatrixFrozen","nonUniformScaling","behaviors","worldMatrixFromCache","hasThinInstances","cloneMeshMap","hasBoundingInfo","physicsBody","physicsImpostor"],["_poseMatrix"]),this._internalMeshDataInfo._source=e,r.useClonedMeshMap&&(e._internalMeshDataInfo.meshMap||(e._internalMeshDataInfo.meshMap={}),e._internalMeshDataInfo.meshMap[this.uniqueId]=this),this._originalBuilderSideOrientation=e._originalBuilderSideOrientation,this._creationDataStorage=e._creationDataStorage,e._ranges){const n=e._ranges;for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&n[o]&&this.createAnimationRange(o,n[o].from,n[o].to)}if(e.metadata&&e.metadata.clone?this.metadata=e.metadata.clone():this.metadata=e.metadata,this._internalMetadata=e._internalMetadata,Ae&&Ae.HasTags(e)&&Ae.AddTagsTo(this,Ae.GetTags(e,!0)),this.setEnabled(e.isEnabled(!1)),this.parent=e.parent,this.setPivotMatrix(e.getPivotMatrix(),this._postMultiplyPivotMatrix),this.id=this.name+"."+e.id,this.material=e.material,!t){const n=e.getDescendants(!0);for(let o=0;o<n.length;o++){const h=n[o];h._isMesh?(si.parent=this,si.doNotCloneChildren=t,si.clonePhysicsImpostor=i,si.cloneThinInstances=s,h.clone(this.name+"."+h.name,si)):h.clone&&h.clone(this.name+"."+h.name,this)}}if(e.morphTargetManager&&(this.morphTargetManager=e.morphTargetManager),r.getPhysicsEngine){const n=r.getPhysicsEngine();if(i&&n)if(n.getPluginVersion()===1){const o=n.getImpostorForPhysicsObject(e);o&&(this.physicsImpostor=o.clone(this))}else n.getPluginVersion()===2&&e.physicsBody&&e.physicsBody.clone(this)}for(let n=0;n<r.particleSystems.length;n++){const o=r.particleSystems[n];o.emitter===e&&o.clone(o.name,this)}if(this.skeleton=e.skeleton,s&&(e._thinInstanceDataStorage.matrixData?(this.thinInstanceSetBuffer("matrix",new Float32Array(e._thinInstanceDataStorage.matrixData),16,!e._thinInstanceDataStorage.matrixBuffer.isUpdatable()),this._thinInstanceDataStorage.matrixBufferSize=e._thinInstanceDataStorage.matrixBufferSize,this._thinInstanceDataStorage.instancesCount=e._thinInstanceDataStorage.instancesCount):this._thinInstanceDataStorage.matrixBufferSize=e._thinInstanceDataStorage.matrixBufferSize,e._userThinInstanceBuffersStorage)){const n=e._userThinInstanceBuffersStorage;for(const o in n.data)this.thinInstanceSetBuffer(o,new Float32Array(n.data[o]),n.strides[o],!n.vertexBuffers?.[o]?.isUpdatable()),this._userThinInstanceBuffersStorage.sizes[o]=n.sizes[o]}this.refreshBoundingInfo(!0,!0),this.computeWorldMatrix(!0)}constructor(e,t=null,i=null,s=null,r,n=!0){super(e,t),this._internalMeshDataInfo=new cu,this.delayLoadState=0,this.instances=[],this._creationDataStorage=null,this._geometry=null,this._thinInstanceDataStorage=new lu,this._shouldGenerateFlatShading=!1,this._originalBuilderSideOrientation=ne.DEFAULTSIDE,this.ignoreCameraMaxZ=!1,t=this.getScene(),this._instanceDataStorage=new hu,this._instanceDataStorage.engine=t.getEngine(),this._scene.useRightHandedSystem?this.sideOrientation=0:this.sideOrientation=1,this._onBeforeDraw=(l,c,u)=>{l&&u&&(this._uniformBuffer?this.transferToEffect(c):u.bindOnlyWorldMatrix(c))};let o=null,h=!1;if(i&&i._addToSceneRootNodes===void 0){const l=i;o=l.parent??null,s=l.source??null,r=l.doNotCloneChildren??!1,n=l.clonePhysicsImpostor??!0,h=l.cloneThinInstances??!1}else o=i;s&&this._copySource(s,r,n,h),o!==null&&(this.parent=o),this._instanceDataStorage.hardwareInstancedRendering=this.getEngine().getCaps().instancedArrays,this._internalMeshDataInfo._onMeshReadyObserverAdded=l=>{l.unregisterOnNextCall=!0,this.isReady(!0)?this.onMeshReadyObservable.notifyObservers(this):this._internalMeshDataInfo._checkReadinessObserver||(this._internalMeshDataInfo._checkReadinessObserver=this._scene.onBeforeRenderObservable.add(()=>{this.isReady(!0)&&(this._scene.onBeforeRenderObservable.remove(this._internalMeshDataInfo._checkReadinessObserver),this._internalMeshDataInfo._checkReadinessObserver=null,this.onMeshReadyObservable.notifyObservers(this))}))},this.onMeshReadyObservable=new O(this._internalMeshDataInfo._onMeshReadyObserverAdded),s&&s.onClonedObservable.notifyObservers(this)}instantiateHierarchy(e=null,t,i){const s=this.getTotalVertices()===0||t&&t.doNotInstantiate&&(t.doNotInstantiate===!0||t.doNotInstantiate(this))?this.clone("Clone of "+(this.name||this.id),e||this.parent,!0):this.createInstance("instance of "+(this.name||this.id));s.parent=e||this.parent,s.position=this.position.clone(),s.scaling=this.scaling.clone(),this.rotationQuaternion?s.rotationQuaternion=this.rotationQuaternion.clone():s.rotation=this.rotation.clone(),i&&i(this,s);for(const r of this.getChildTransformNodes(!0))r.getClassName()==="InstancedMesh"&&s.getClassName()==="Mesh"&&r.sourceMesh===this?r.instantiateHierarchy(s,{doNotInstantiate:t&&t.doNotInstantiate||!1,newSourcedMesh:s},i):r.instantiateHierarchy(s,t,i);return s}getClassName(){return"Mesh"}get _isMesh(){return!0}toString(e){let t=super.toString(e);if(t+=", n vertices: "+this.getTotalVertices(),t+=", parent: "+(this._waitingParentId?this._waitingParentId:this.parent?this.parent.name:"NONE"),this.animations)for(let i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);if(e)if(this._geometry){const i=this.getIndices(),s=this.getVerticesData(b.PositionKind);s&&i&&(t+=", flat shading: "+(s.length/3===i.length?"YES":"NO"))}else t+=", flat shading: UNKNOWN";return t}_unBindEffect(){super._unBindEffect();for(const e of this.instances)e._unBindEffect()}get hasLODLevels(){return this._internalMeshDataInfo._LODLevels.length>0}getLODLevels(){return this._internalMeshDataInfo._LODLevels}_sortLODLevels(){const e=this._internalMeshDataInfo._useLODScreenCoverage?-1:1;this._internalMeshDataInfo._LODLevels.sort((t,i)=>t.distanceOrScreenCoverage<i.distanceOrScreenCoverage?e:t.distanceOrScreenCoverage>i.distanceOrScreenCoverage?-e:0)}addLODLevel(e,t){if(t&&t._masterMesh)return w.Warn("You cannot use a mesh as LOD level twice"),this;const i=new au(e,t);return this._internalMeshDataInfo._LODLevels.push(i),t&&(t._masterMesh=this),this._sortLODLevels(),this}getLODLevelAtDistance(e){const t=this._internalMeshDataInfo;for(let i=0;i<t._LODLevels.length;i++){const s=t._LODLevels[i];if(s.distanceOrScreenCoverage===e)return s.mesh}return null}removeLODLevel(e){const t=this._internalMeshDataInfo;for(let i=0;i<t._LODLevels.length;i++)t._LODLevels[i].mesh===e&&(t._LODLevels.splice(i,1),e&&(e._masterMesh=null));return this._sortLODLevels(),this}getLOD(e,t){const i=this._internalMeshDataInfo;if(!i._LODLevels||i._LODLevels.length===0)return this;const s=t||this.getBoundingInfo().boundingSphere,r=e.mode===J.ORTHOGRAPHIC_CAMERA?e.minZ:s.centerWorld.subtract(e.globalPosition).length();let n=r,o=1;if(i._useLODScreenCoverage){const h=e.screenArea;let l=s.radiusWorld*e.minZ/r;l=l*l*Math.PI,n=l/h,o=-1}if(o*i._LODLevels[i._LODLevels.length-1].distanceOrScreenCoverage>o*n)return this.onLODLevelSelection&&this.onLODLevelSelection(n,this,this),this;for(let h=0;h<i._LODLevels.length;h++){const l=i._LODLevels[h];if(o*l.distanceOrScreenCoverage<o*n){if(l.mesh){if(l.mesh.delayLoadState===4)return l.mesh._checkDelayState(),this;if(l.mesh.delayLoadState===2)return this;l.mesh._preActivate(),l.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)}return this.onLODLevelSelection&&this.onLODLevelSelection(n,this,l.mesh),l.mesh}}return this.onLODLevelSelection&&this.onLODLevelSelection(n,this,this),this}get geometry(){return this._geometry}getTotalVertices(){return this._geometry===null||this._geometry===void 0?0:this._geometry.getTotalVertices()}getVerticesData(e,t,i,s){if(!this._geometry)return null;let r=s?void 0:this._userInstancedBuffersStorage?.vertexBuffers[e]?.getFloatData(this.instances.length+1,i||t&&this._geometry.meshes.length!==1);return r||(r=this._geometry.getVerticesData(e,t,i)),r}copyVerticesData(e,t){this._geometry&&this._geometry.copyVerticesData(e,t)}getVertexBuffer(e,t){return this._geometry?(t?void 0:this._userInstancedBuffersStorage?.vertexBuffers[e])??this._geometry.getVertexBuffer(e):null}isVerticesDataPresent(e,t){return this._geometry?!t&&this._userInstancedBuffersStorage?.vertexBuffers[e]!==void 0||this._geometry.isVerticesDataPresent(e):this._delayInfo?this._delayInfo.indexOf(e)!==-1:!1}isVertexBufferUpdatable(e,t){if(!this._geometry)return this._delayInfo?this._delayInfo.indexOf(e)!==-1:!1;if(!t){const i=this._userInstancedBuffersStorage?.vertexBuffers[e];if(i)return i.isUpdatable()}return this._geometry.isVertexBufferUpdatable(e)}getVerticesDataKinds(e){if(!this._geometry){const i=[];if(this._delayInfo)for(const s of this._delayInfo)i.push(s);return i}const t=this._geometry.getVerticesDataKinds();if(!e&&this._userInstancedBuffersStorage)for(const i in this._userInstancedBuffersStorage.vertexBuffers)t.indexOf(i)===-1&&t.push(i);return t}getTotalIndices(){return this._geometry?this._geometry.getTotalIndices():0}getIndices(e,t){return this._geometry?this._geometry.getIndices(e,t):[]}get isBlocked(){return this._masterMesh!==null&&this._masterMesh!==void 0}isReady(e=!1,t=!1){if(this.delayLoadState===2||!super.isReady(e))return!1;if(!this.subMeshes||this.subMeshes.length===0||!e)return!0;const i=this.getEngine(),s=this.getScene(),r=t||i.getCaps().instancedArrays&&(this.instances.length>0||this.hasThinInstances);this.computeWorldMatrix();const n=this.material||s.defaultMaterial;if(n){if(n._storeEffectOnSubMeshes)for(const h of this.subMeshes){const l=h.getMaterial();if(l){if(l._storeEffectOnSubMeshes){if(!l.isReadyForSubMesh(this,h,r))return!1}else if(!l.isReady(this,r))return!1}}else if(!n.isReady(this,r))return!1}const o=i.currentRenderPassId;for(const h of this.lightSources){const l=h.getShadowGenerators();if(!l)continue;const c=l.values();for(let u=c.next();u.done!==!0;u=c.next()){const f=u.value;if(f&&(!f.getShadowMap()?.renderList||f.getShadowMap()?.renderList&&f.getShadowMap()?.renderList?.indexOf(this)!==-1)){const g=f.getShadowMap().renderPassIds??[i.currentRenderPassId];for(let p=0;p<g.length;++p){i.currentRenderPassId=g[p];for(const m of this.subMeshes)if(!f.isReady(m,r,m.getMaterial()?.needAlphaBlendingForMesh(this)??!1))return i.currentRenderPassId=o,!1}i.currentRenderPassId=o}}}for(const h of this._internalMeshDataInfo._LODLevels)if(h.mesh&&!h.mesh.isReady(r))return!1;return!0}get areNormalsFrozen(){return this._internalMeshDataInfo._areNormalsFrozen}freezeNormals(){return this._internalMeshDataInfo._areNormalsFrozen=!0,this}unfreezeNormals(){return this._internalMeshDataInfo._areNormalsFrozen=!1,this}set overridenInstanceCount(e){this._instanceDataStorage.overridenInstanceCount=e}_getInstanceDataStorage(){const e=this._instanceDataStorage.engine.isWebGPU?this._instanceDataStorage.engine.currentRenderPassId:0;let t=this._instanceDataStorage.renderPasses[e];return t||(t=new ou,this._instanceDataStorage.renderPasses[e]=t),t}_preActivate(){const e=this._internalMeshDataInfo,t=this.getScene().getRenderId();return e._preActivateId===t?this:(e._preActivateId=t,this._getInstanceDataStorage().visibleInstances=null,this)}_preActivateForIntermediateRendering(e){const t=this._getInstanceDataStorage();return t.visibleInstances&&(t.visibleInstances.intermediateDefaultRenderId=e),this}_registerInstanceForRenderId(e,t){const i=this._getInstanceDataStorage();return i.visibleInstances||(i.visibleInstances={defaultRenderId:t,selfDefaultRenderId:this._renderId,intermediateDefaultRenderId:-1}),i.visibleInstances[t]||(i.previousRenderId!==void 0&&this._instanceDataStorage.
23isFrozen&&(i.visibleInstances[i.previousRenderId]=null),i.previousRenderId=t,i.visibleInstances[t]=new Array),i.visibleInstances[t].push(e),this}_afterComputeWorldMatrix(){super._afterComputeWorldMatrix(),this.hasThinInstances&&(this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1))}_postActivate(){this.edgesShareWithInstances&&this.edgesRenderer&&this.edgesRenderer.isEnabled&&this._renderingGroup&&(this._renderingGroup._edgesRenderers.pushNoDuplicate(this.edgesRenderer),this.edgesRenderer.customInstances.push(this.getWorldMatrix()))}refreshBoundingInfo(e=!1,t=!1){if(this.hasBoundingInfo&&this.getBoundingInfo().isLocked)return this;let i;typeof e=="object"?i=e:i={applySkeleton:e,applyMorph:t};const s=this.geometry?this.geometry.boundingBias:null;return this._refreshBoundingInfo(this._getData(i,null,b.PositionKind),s),this}_createGlobalSubMesh(e){const t=this.getTotalVertices();if(!t||!this.getIndices())return null;if(this.subMeshes&&this.subMeshes.length>0){const i=this.getIndices();if(!i)return null;const s=i.length;let r=!1;if(e)r=!0;else for(const n of this.subMeshes){if(n.indexStart+n.indexCount>s){r=!0;break}if(n.verticesStart+n.verticesCount>t){r=!0;break}}if(!r)return this.subMeshes[0]}return this.releaseSubMeshes(),new zt(0,0,t,0,this.getTotalIndices()||(this.isUnIndexed?t:0),this)}subdivide(e){if(e<1)return;const t=this.getTotalIndices();let i=t/e|0,s=0;for(;i%3!==0;)i++;this.releaseSubMeshes();for(let r=0;r<e&&!(s>=t);r++)zt.CreateFromIndices(0,s,r===e-1?t-s:i,this,void 0,!1),s+=i;this.refreshBoundingInfo(),this.synchronizeInstances()}setVerticesData(e,t,i=!1,s){if(this._geometry)this._geometry.setVerticesData(e,t,i,s);else{const r=new $;r.set(t,e);const n=this.getScene();new Tt(Tt.RandomId(),n,r,i,this)}return this}removeVerticesData(e){this._geometry&&this._geometry.removeVerticesData(e)}markVerticesDataAsUpdatable(e,t=!0){const i=this.getVertexBuffer(e);!i||i.isUpdatable()===t||this.setVerticesData(e,this.getVerticesData(e),t)}setVerticesBuffer(e,t=!0,i=null){return this._geometry||(this._geometry=Tt.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e,i,t),this}updateVerticesData(e,t,i,s){return this._geometry?(s?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i),this):this}updateMeshPositions(e,t=!0){const i=this.getVerticesData(b.PositionKind);if(!i)return this;if(e(i),this.updateVerticesData(b.PositionKind,i,!1,!1),t){const s=this.getIndices(),r=this.getVerticesData(b.NormalKind);if(!r)return this;$.ComputeNormals(i,s,r),this.updateVerticesData(b.NormalKind,r,!1,!1)}return this}makeGeometryUnique(){if(!this._geometry)return this;if(this._geometry.meshes.length===1)return this;const e=this._geometry,t=this._geometry.copy(Tt.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this}setIndexBuffer(e,t,i,s=null){let r=this._geometry;r||(r=new Tt(Tt.RandomId(),this.getScene(),void 0,void 0,this)),r.setIndexBuffer(e,t,i,s)}setIndices(e,t=null,i=!1,s=!1){if(this._geometry)this._geometry.setIndices(e,t,i,s);else{const r=new $;r.indices=e;const n=this.getScene();new Tt(Tt.RandomId(),n,r,i,this,t)}return this}updateIndices(e,t,i=!1){return this._geometry?(this._geometry.updateIndices(e,t,i),this):this}toLeftHanded(){return this._geometry?(this._geometry.toLeftHanded(),this):this}_bind(e,t,i,s=!0){if(!this._geometry)return this;const r=this.getScene().getEngine();let n;if(this._unIndexed)this._getRenderingFillMode(i)===F.WireFrameFillMode?n=e._getLinesIndexBuffer(this.getIndices(),r):n=null;else switch(this._getRenderingFillMode(i)){case F.PointFillMode:n=null;break;case F.WireFrameFillMode:n=e._getLinesIndexBuffer(this.getIndices(),r);break;default:case F.TriangleFillMode:n=this._geometry.getIndexBuffer();break}return this._bindDirect(t,n,s)}_bindDirect(e,t,i=!0){if(!this._geometry)return this;if(this.morphTargetManager&&this.morphTargetManager.isUsingTextureForTargets&&this.morphTargetManager._bind(e),!i||!this._userInstancedBuffersStorage||this.hasThinInstances)this._geometry._bind(e,t);else{if(this._instanceDataStorage.engine.isWebGPU&&this._userInstancedBuffersStorage.renderPasses&&this._userInstancedBuffersStorage.renderPasses[this._instanceDataStorage.engine.currentRenderPassId]){const s=this._userInstancedBuffersStorage.renderPasses[this._instanceDataStorage.engine.currentRenderPassId];for(const r in s)this._userInstancedBuffersStorage.vertexBuffers[r]=s[r]}this._geometry._bind(e,t,this._userInstancedBuffersStorage.vertexBuffers,this._userInstancedBuffersStorage.vertexArrayObjects)}return this}_draw(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeDrawObservable&&this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);const r=this.getScene().getEngine(),n=r._currentMaterialContext,o=n&&n.useVertexPulling;return this._unIndexed&&t!==F.WireFrameFillMode||t==F.PointFillMode?r.drawArraysType(t,e.verticesStart,e.verticesCount,this.forcedInstanceCount||i):t==F.WireFrameFillMode?r.drawElementsType(t,0,e._linesIndexCount,this.forcedInstanceCount||i):o?r.drawArraysType(t,e.indexStart,e.indexCount,this.forcedInstanceCount||i):r.drawElementsType(t,e.indexStart,e.indexCount,this.forcedInstanceCount||i),this}registerBeforeRender(e){return this.onBeforeRenderObservable.add(e),this}unregisterBeforeRender(e){return this.onBeforeRenderObservable.removeCallback(e),this}registerAfterRender(e){return this.onAfterRenderObservable.add(e),this}unregisterAfterRender(e){return this.onAfterRenderObservable.removeCallback(e),this}_getInstancesRenderList(e,t=!1){const i=this._getInstanceDataStorage();
23if(this._instanceDataStorage.isFrozen){if(t)return i.batchCacheReplacementModeInFrozenMode.hardwareInstancedRendering[e]=!1,i.batchCacheReplacementModeInFrozenMode.renderSelf[e]=!0,i.batchCacheReplacementModeInFrozenMode;if(i.previousBatch)return i.previousBatch}const s=this.getScene(),r=s._isInIntermediateRendering(),n=r?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,o=i.batchCache;if(o.mustReturn=!1,o.renderSelf[e]=t||!n&&this.isEnabled()&&this.isVisible,o.visibleInstances[e]=null,i.visibleInstances&&!t){const h=i.visibleInstances,l=s.getRenderId(),c=r?h.intermediateDefaultRenderId:h.defaultRenderId;o.visibleInstances[e]=h[l],!o.visibleInstances[e]&&c&&(o.visibleInstances[e]=h[c])}return o.hardwareInstancedRendering[e]=!t&&this._instanceDataStorage.hardwareInstancedRendering&&o.visibleInstances[e]!==null&&o.visibleInstances[e]!==void 0,i.previousBatch=o,o}_updateInstancedBuffers(e,t,i,s,r,n){const o=t.visibleInstances[e._id],h=o?o.length:0,l=t.parent,c=this._instanceDataStorage;let u=l.instancesBuffer,f=l.instancesPreviousBuffer,d=0,g=0;const p=t.renderSelf[e._id],m=this._scene.floatingOriginOffset,A=!u||i!==l.instancesBufferSize||this._scene.needsPreviousWorldMatrices&&!l.instancesPreviousBuffer;if(!this._instanceDataStorage.manualUpdate&&(!c.isFrozen||A)){const E=this.getWorldMatrix();if(p&&(this._scene.needsPreviousWorldMatrices&&(c.masterMeshPreviousWorldMatrix?(c.masterMeshPreviousWorldMatrix.copyToArray(l.instancesPreviousData,d),c.masterMeshPreviousWorldMatrix.copyFrom(E)):(c.masterMeshPreviousWorldMatrix=E.clone(),c.masterMeshPreviousWorldMatrix.copyToArray(l.instancesPreviousData,d))),E.copyToArray(l.instancesData,d),l.instancesData[d+12]-=m.x,l.instancesData[d+13]-=m.y,l.instancesData[d+14]-=m.z,d+=16,g++),o){if(ne.INSTANCEDMESH_SORT_TRANSPARENT&&this._scene.activeCamera&&e.getMaterial()?.needAlphaBlendingForMesh(e.getRenderingMesh())){const I=this._scene.activeCamera.globalPosition;for(let M=0;M<o.length;M++){const C=o[M];C._distanceToCamera=_.Distance(C.getBoundingInfo().boundingSphere.centerWorld,I)}o.sort((M,C)=>M._distanceToCamera>C._distanceToCamera?-1:M._distanceToCamera<C._distanceToCamera?1:0)}for(let I=0;I<o.length;I++){const M=o[I],C=M.getWorldMatrix();C.copyToArray(l.instancesData,d),this._scene.needsPreviousWorldMatrices&&(M._previousWorldMatrix?(M._previousWorldMatrix.copyToArray(l.instancesPreviousData,d),M._previousWorldMatrix.copyFrom(C)):(M._previousWorldMatrix=C.clone(),M._previousWorldMatrix.copyToArray(l.instancesPreviousData,d))),l.instancesData[d+12]-=m.x,l.instancesData[d+13]-=m.y,l.instancesData[d+14]-=m.z,d+=16,g++}}}else g=(p?1:0)+h;if(A){u&&u.dispose(),f&&f.dispose(),u=new Dr(s,l.instancesData,!0,16,!1,!0),l.instancesBuffer=u,this._userInstancedBuffersStorage||(this._userInstancedBuffersStorage={data:{},vertexBuffers:{},strides:{},sizes:{},vertexArrayObjects:this.getEngine().getCaps().vertexArrayObject?{}:void 0});let E;if(this._instanceDataStorage.engine.isWebGPU){this._userInstancedBuffersStorage.renderPasses||(this._userInstancedBuffersStorage.renderPasses={});const I=this._instanceDataStorage.engine.currentRenderPassId;E=this._userInstancedBuffersStorage.renderPasses[I],E||(this._userInstancedBuffersStorage.renderPasses[I]=E={})}else E=this._userInstancedBuffersStorage.vertexBuffers;E.world0=u.createVertexBuffer("world0",0,4),E.world1=u.createVertexBuffer("world1",4,4),E.world2=u.createVertexBuffer("world2",8,4),E.world3=u.createVertexBuffer("world3",12,4),this._scene.needsPreviousWorldMatrices&&(f=new Dr(s,l.instancesPreviousData,!0,16,!1,!0),l.instancesPreviousBuffer=f,E.previousWorld0=f.createVertexBuffer("previousWorld0",0,4),E.previousWorld1=f.createVertexBuffer("previousWorld1",4,4),E.previousWorld2=f.createVertexBuffer("previousWorld2",8,4),E.previousWorld3=f.createVertexBuffer("previousWorld3",12,4)),this._invalidateInstanceVertexArrayObject()}else(!this._instanceDataStorage.isFrozen||this._instanceDataStorage.forceMatrixUpdates)&&(u.updateDirectly(l.instancesData,0,g),this._scene.needsPreviousWorldMatrices&&(!this._instanceDataStorage.manualUpdate||this._instanceDataStorage.previousManualUpdate)&&f.updateDirectly(l.instancesPreviousData,0,g));this._processInstancedBuffers(o,p),n&&r!==void 0&&(this.getScene()._activeIndices.addCount(e.indexCount*g,!1),s._currentDrawContext&&(s._currentDrawContext.useInstancing=!0),this._bind(e,n,r),this._draw(e,r,g)),this._scene.needsPreviousWorldMatrices&&!A&&this._instanceDataStorage.manualUpdate&&(!this._instanceDataStorage.
vendor: 33,895 bytes, lines 23-30
23isFrozen||this._instanceDataStorage.forceMatrixUpdates)&&!this._instanceDataStorage.previousManualUpdate&&f.updateDirectly(l.instancesData,0,g)}_renderWithInstances(e,t,i,s,r){const n=i.visibleInstances[e._id],o=n?n.length:0,h=i.parent,l=h.instancesBufferSize,u=(o+1)*16*4;for(;h.instancesBufferSize<u;)h.instancesBufferSize*=2;return(!h.instancesData||l!=h.instancesBufferSize)&&(h.instancesData=new Float32Array(h.instancesBufferSize/4)),(this._scene.needsPreviousWorldMatrices&&!h.instancesPreviousData||l!=h.instancesBufferSize)&&(h.instancesPreviousData=new Float32Array(h.instancesBufferSize/4)),this._updateInstancedBuffers(e,i,l,r,t,s),r.unbindInstanceAttributes(),this}_renderWithThinInstances(e,t,i,s){const r=this._thinInstanceDataStorage?.instancesCount??0;this.getScene()._activeIndices.addCount(e.indexCount*r,!1),s._currentDrawContext&&(s._currentDrawContext.useInstancing=!0),this._bind(e,i,t),this._draw(e,t,r),this._scene.needsPreviousWorldMatrices&&!this._thinInstanceDataStorage.previousMatrixData&&this._thinInstanceDataStorage.matrixData&&(this._thinInstanceDataStorage.previousMatrixBuffer?this._thinInstanceDataStorage.previousMatrixBuffer.updateDirectly(this._thinInstanceDataStorage.matrixData,0,r):this._thinInstanceDataStorage.previousMatrixBuffer=this._thinInstanceCreateMatrixBuffer("previousWorld",this._thinInstanceDataStorage.matrixData,!1)),s.unbindInstanceAttributes()}_processInstancedBuffers(e,t){}_processRendering(e,t,i,s,r,n,o,h){const l=this.getScene(),c=l.getEngine();if(s=this._getRenderingFillMode(s),n&&t.getRenderingMesh().hasThinInstances)return this._renderWithThinInstances(t,s,i,c),this;if(n)this._renderWithInstances(t,s,r,i,c);else{c._currentDrawContext&&(c._currentDrawContext.useInstancing=!1);let u=0;r.renderSelf[t._id]&&(o&&o(!1,e.getWorldMatrix(),h),u++,this._draw(t,s,this._instanceDataStorage.overridenInstanceCount));const f=r.visibleInstances[t._id];if(f){const d=f.length;u+=d;for(let g=0;g<d;g++){const m=f[g].getWorldMatrix();o&&o(!0,m,h),this._draw(t,s)}}l._activeIndices.addCount(t.indexCount*u,!1)}return this}_rebuild(e=!1){for(const t in this._instanceDataStorage.renderPasses){const i=this._instanceDataStorage.renderPasses[t];i.instancesBuffer&&(e&&i.instancesBuffer.dispose(),i.instancesBuffer=null)}if(this._userInstancedBuffersStorage){for(const t in this._userInstancedBuffersStorage.vertexBuffers){const i=this._userInstancedBuffersStorage.vertexBuffers[t];i&&(e&&i.dispose(),this._userInstancedBuffersStorage.vertexBuffers[t]=null)}this._userInstancedBuffersStorage.vertexArrayObjects&&(this._userInstancedBuffersStorage.vertexArrayObjects={})}this._internalMeshDataInfo._effectiveMaterial=null,super._rebuild(e)}_freeze(){if(this.subMeshes){for(let e=0;e<this.subMeshes.length;e++)this._getInstancesRenderList(e);this._internalMeshDataInfo._effectiveMaterial=null,this._instanceDataStorage.isFrozen=!0}}_unFreeze(){this._instanceDataStorage.isFrozen=!1;for(const e in this._instanceDataStorage.renderPasses){const t=this._instanceDataStorage.renderPasses[e];t.previousBatch=null}}renderWithRenderPassId(e,t,i,s,r=!0){const n=this._scene.getEngine(),o=n.currentRenderPassId;if(e!==void 0&&(n.currentRenderPassId=e),s)(!r||r&&s.isInFrustum(this._scene._frustumPlanes))&&this.render(s,!!t,i);else for(let h=0;h<this.subMeshes.length;h++){const l=this.subMeshes[h];(!r||r&&l.isInFrustum(this._scene._frustumPlanes))&&this.render(l,!!t,i)}return e!==void 0&&(n.currentRenderPassId=o),this}directRender(){if(!this.subMeshes)return this;for(const e of this.subMeshes)this.render(e,!1);return this}render(e,t,i){const s=this.getScene();this._internalAbstractMeshDataInfo._isActiveIntermediate?this._internalAbstractMeshDataInfo._isActiveIntermediate=!1:this._internalAbstractMeshDataInfo._isActive=!1;const r=s.activeCameras?.length??0;if((r>1&&s.activeCamera===s.activeCameras[0]||r<=1)&&this._checkOcclusionQuery()&&!this._occlusionDataStorage.forceRenderingWhenOccluded)return this;const o=this._getInstancesRenderList(e._id,!!i);if(o.mustReturn)return this;if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;const h=s.getEngine();let l=0,c=null;this.ignoreCameraMaxZ&&s.activeCamera&&!s._isInIntermediateRendering()&&(l=s.activeCamera.maxZ,c=s.activeCamera,s.activeCamera.maxZ=0,s.updateTransformMatrix(!0)),this._internalMeshDataInfo._onBeforeRenderObservable&&this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);const u=e.getRenderingMesh(),f=o.hardwareInstancedRendering[e._id]||u.hasThinInstances||!!this._userInstancedBuffersStorage&&!e.getMesh()._internalAbstractMeshDataInfo._actAsRegularMesh,d=this._instanceDataStorage,g=e.getMaterial();if(!g)return c&&(c.maxZ=l,s.updateTransformMatrix(!0)),this;if(!d.isFrozen||!this._internalMeshDataInfo._effectiveMaterial||this._internalMeshDataInfo._effectiveMaterial!==g){if(g._storeEffectOnSubMeshes){if(!g.isReadyForSubMesh(this,e,f))return c&&(c.maxZ=l,s.updateTransformMatrix(!0)),this}else if(!g.isReady(this,f))return c&&(c.maxZ=l,s.updateTransformMatrix(!0)),this;this._internalMeshDataInfo._effectiveMaterial=g}else if(g._storeEffectOnSubMeshes&&!e._drawWrapper?._wasPreviouslyReady||!g._storeEffectOnSubMeshes&&!g._getDrawWrapper()._wasPreviouslyReady)return c&&(c.maxZ=l,s.updateTransformMatrix(!0)),this;if(t){const S=this._internalMeshDataInfo._effectiveMaterial;if(S.alphaModes.length===1)h.setAlphaMode(S.alphaMode);else for(let L=0;L<S.alphaModes.length;L++){const N=S.alphaModes[L];h.setAlphaMode(N!==void 0?N:2,!1,L)}}let p;this._internalMeshDataInfo._effectiveMaterial._storeEffectOnSubMeshes?p=e._drawWrapper:p=this._internalMeshDataInfo._effectiveMaterial._getDrawWrapper();const m=p?.effect??null;for(const S of s._beforeRenderingMeshStage)S.action(this,e,o,m);if(!p||!m)return c&&(c.maxZ=l,s.updateTransformMatrix(!0)),this;const A=i||this;let E;if(!d.isFrozen&&(this._internalMeshDataInfo._effectiveMaterial.backFaceCulling||this._internalMeshDataInfo._effectiveMaterial.sideOrientation!==null||this._internalMeshDataInfo._effectiveMaterial._twoSidedLighting)){const S=A._getWorldMatrixDeterminant();E=this._internalMeshDataInfo._effectiveMaterial._getEffectiveOrientation(this),S<0&&(E=E===F.ClockWiseSideOrientation?F.CounterClockWiseSideOrientation:F.ClockWiseSideOrientation),this._internalMeshDataInfo._effectiveSideOrientation=E}else E=this._internalMeshDataInfo._effectiveSideOrientation;const I=this._internalMeshDataInfo._effectiveMaterial._preBind(p,this._internalMeshDataInfo._effectiveSideOrientation);this._internalMeshDataInfo._effectiveMaterial.forceDepthWrite&&h.setDepthWrite(!0);const M=this._internalMeshDataInfo._effectiveMaterial,C=M.fillMode;this._internalMeshDataInfo._onBeforeBindObservable&&this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this),f||this._bind(e,m,C,!1);const x=A.getWorldMatrix();M._storeEffectOnSubMeshes?M.bindForSubMesh(x,this,e):M.bind(x,this),!M.backFaceCulling&&M.separateCullingPass&&(h.setState(!0,M.zOffset,!1,!I,M.cullBackFaces,M.stencil,M.zOffsetUnits),this._processRendering(this,e,m,C,o,f,this._onBeforeDraw,this._internalMeshDataInfo._effectiveMaterial),h.setState(!0,M.zOffset,!1,I,M.cullBackFaces,M.stencil,M.zOffsetUnits),this._internalMeshDataInfo._onBetweenPassObservable&&this._internalMeshDataInfo._onBetweenPassObservable.notifyObservers(e)),this._processRendering(this,e,m,C,o,f,this._onBeforeDraw,this._internalMeshDataInfo._effectiveMaterial),this._internalMeshDataInfo._effectiveMaterial.unbind();for(const S of s._afterRenderingMeshStage)S.action(this,e,o,m);return this._internalMeshDataInfo._onAfterRenderObservable&&this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this),c&&(c.maxZ=l,s.updateTransformMatrix(!0)),s.performancePriority===2&&!d.isFrozen&&this._freeze(),this}cleanMatrixWeights(){this.isVerticesDataPresent(b.MatricesWeightsKind)&&(this.isVerticesDataPresent(b.MatricesWeightsExtraKind)?this._normalizeSkinWeightsAndExtra():this._normalizeSkinFourWeights())}_normalizeSkinFourWeights(){const e=this.getVerticesData(b.MatricesWeightsKind),t=e.length;for(let i=0;i<t;i+=4){const s=e[i]+e[i+1]+e[i+2]+e[i+3];if(s===0)e[i]=1;else{const r=1/s;e[i]*=r,e[i+1]*=r,e[i+2]*=r,e[i+3]*=r}}this.setVerticesData(b.MatricesWeightsKind,e)}_normalizeSkinWeightsAndExtra(){const e=this.getVerticesData(b.MatricesWeightsExtraKind),t=this.getVerticesData(b.MatricesWeightsKind),i=t.length;for(let s=0;s<i;s+=4){let r=t[s]+t[s+1]+t[s+2]+t[s+3];if(r+=e[s]+e[s+1]+e[s+2]+e[s+3],r===0)t[s]=1;else{const n=1/r;t[s]*=n,t[s+1]*=n,t[s+2]*=n,t[s+3]*=n,e[s]*=n,e[s+1]*=n,e[s+2]*=n,e[s+3]*=n}}this.setVerticesData(b.MatricesWeightsKind,t),this.setVerticesData(b.MatricesWeightsKind,e)}validateSkinning(){const e=this.getVerticesData(b.MatricesWeightsExtraKind),t=this.getVerticesData(b.MatricesWeightsKind);if(t===null||this.skeleton==null)return{skinned:!1,valid:!0,report:"not skinned"};const i=t.length;let s=0,r=0,n=0,o=0;const h=e===null?4:8,l=[];for(let m=0;m<=h;m++)l[m]=0;const c=.001;for(let m=0;m<i;m+=4){let A=t[m],E=A,I=E===0?0:1;for(let M=1;M<h;M++){const C=M<4?t[m+M]:e[m+M-4];C>A&&s++,C!==0&&I++,E+=C,A=C}if(l[I]++,I>n&&(n=I),E===0)r++;else{const M=1/E;let C=0;for(let x=0;x<h;x++)x<4?C+=Math.abs(t[m+x]-t[m+x]*M):C+=Math.abs(e[m+x-4]-e[m+x-4]*M);C>c&&o++}}const u=this.skeleton.bones.length,f=this.getVerticesData(b.MatricesIndicesKind),d=this.getVerticesData(b.MatricesIndicesExtraKind);let g=0;for(let m=0;m<i;m+=4)for(let A=0;A<h;A++){const E=A<4?f[m+A]:d[m+A-4];(E>=u||E<0)&&g++}const p="Number of Weights = "+i/4+`
24Maximum influences = `+n+`
25Missing Weights = `+r+`
26Not Sorted = `+s+`
27Not Normalized = `+o+`
28WeightCounts = [`+l+`]
29Number of bones = `+u+`
30Bad Bone Indices = `+g;return{skinned:!0,valid:r===0&&o===0&&g===0,report:p}}_checkDelayState(){const e=this.getScene();return this._geometry?this._geometry.load(e):this.delayLoadState===4&&(this.delayLoadState=2,this._queueLoad(e)),this}_queueLoad(e){e.addPendingData(this);const t=this.delayLoadingFile.indexOf(".babylonbinarymeshdata")!==-1;return se.LoadFile(this.delayLoadingFile,i=>{i instanceof ArrayBuffer?this._delayLoadingFunction(i,this):this._delayLoadingFunction(JSON.parse(i),this);for(const s of this.instances)s.refreshBoundingInfo(),s._syncSubMeshes();this.delayLoadState=1,e.removePendingData(this)},()=>{},e.offlineProvider,t),this}isInFrustum(e){return this.delayLoadState===2||!super.isInFrustum(e)?!1:(this._checkDelayState(),!0)}setMaterialById(e){const t=this.getScene().materials;let i;for(i=t.length-1;i>-1;i--)if(t[i].id===e)return this.material=t[i],this;const s=this.getScene().multiMaterials;for(i=s.length-1;i>-1;i--)if(s[i].id===e)return this.material=s[i],this;return this}getAnimatables(){const e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e}bakeTransformIntoVertices(e){if(!this.isVerticesDataPresent(b.PositionKind))return this;const t=this.subMeshes.splice(0);this._resetPointsArrayCache();let i=this.getVerticesData(b.PositionKind);const s=_.Zero();let r;for(r=0;r<i.length;r+=3)_.TransformCoordinatesFromFloatsToRef(i[r],i[r+1],i[r+2],e,s).toArray(i,r);if(this.setVerticesData(b.PositionKind,i,this.getVertexBuffer(b.PositionKind).isUpdatable()),this.isVerticesDataPresent(b.NormalKind)){for(i=this.getVerticesData(b.NormalKind),r=0;r<i.length;r+=3)_.TransformNormalFromFloatsToRef(i[r],i[r+1],i[r+2],e,s).normalize().toArray(i,r);this.setVerticesData(b.NormalKind,i,this.getVertexBuffer(b.NormalKind).isUpdatable())}if(this.isVerticesDataPresent(b.TangentKind)){for(i=this.getVerticesData(b.TangentKind),r=0;r<i.length;r+=4)_.TransformNormalFromFloatsToRef(i[r],i[r+1],i[r+2],e,s).normalize().toArray(i,r);this.setVerticesData(b.TangentKind,i,this.getVertexBuffer(b.TangentKind).isUpdatable())}return e.determinant()<0&&this.flipFaces(),this.releaseSubMeshes(),this.subMeshes=t,this}bakeCurrentTransformIntoVertices(e=!0,t=!1){return t&&this.makeGeometryUnique(),this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)),this.resetLocalMatrix(e),this}get _positions(){return this._internalAbstractMeshDataInfo._positions||this._geometry&&this._geometry._positions||null}_resetPointsArrayCache(){return this._geometry&&this._geometry._resetPointsArrayCache(),this}_generatePointsArray(){return this._geometry?this._geometry._generatePointsArray():!1}clone(e="",t=null,i,s=!0){if(t&&t._addToSceneRootNodes===void 0){const r=t;return si.source=this,si.doNotCloneChildren=r.doNotCloneChildren,si.clonePhysicsImpostor=r.clonePhysicsImpostor,si.cloneThinInstances=r.cloneThinInstances,new ne(e,this.getScene(),si)}return new ne(e,this.getScene(),t,this,i,s)}dispose(e,t=!1){this.morphTargetManager=null,this._geometry&&this._geometry.releaseForMesh(this,!0);const i=this._internalMeshDataInfo;if(i._onBeforeDrawObservable&&i._onBeforeDrawObservable.clear(),i._onBeforeBindObservable&&i._onBeforeBindObservable.clear(),i._onBeforeRenderObservable&&i._onBeforeRenderObservable.clear(),i._onAfterRenderObservable&&i._onAfterRenderObservable.clear(),i._onBetweenPassObservable&&i._onBetweenPassObservable.clear(),this._scene.useClonedMeshMap){if(i.meshMap)for(const s in i.meshMap){const r=i.meshMap[s];r&&(r._internalMeshDataInfo._source=null,i.meshMap[s]=void 0)}i._source&&i._source._internalMeshDataInfo.meshMap&&(i._source._internalMeshDataInfo.meshMap[this.uniqueId]=void 0)}else{const s=this.getScene().meshes;for(const r of s){const n=r;n._internalMeshDataInfo&&n._internalMeshDataInfo._source&&n._internalMeshDataInfo._source===this&&(n._internalMeshDataInfo._source=null)}}i._source=null,this._disposeInstanceSpecificData(),this._disposeThinInstanceSpecificData(),this._internalMeshDataInfo._checkReadinessObserver&&this._scene.onBeforeRenderObservable.remove(this._internalMeshDataInfo._checkReadinessObserver),super.dispose(e,t)}_disposeInstanceSpecificData(){}_disposeThinInstanceSpecificData(){}_invalidateInstanceVertexArrayObject(){}applyDisplacementMap(e,t,i,s,r,n,o=!1,h){const l=this.getScene(),c=u=>{const f=u.width,d=u.height,p=this.getEngine().createCanvas(f,d).getContext("2d");p.drawImage(u,0,0);const m=p.getImageData(0,0,f,d).data;this.applyDisplacementMapFromBuffer(m,f,d,t,i,r,n,o),s&&s(this)};return se.LoadImage(e,c,h||(()=>{}),l.offlineProvider),this}applyDisplacementMapFromBuffer(e,t,i,s,r,n,o,h=!1){if(!this.isVerticesDataPresent(b.PositionKind)||!this.isVerticesDataPresent(b.NormalKind)||!this.isVerticesDataPresent(b.UVKind))return w.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),this;const l=this.getVerticesData(b.PositionKind,!0,!0),c=this.getVerticesData(b.NormalKind),u=this.getVerticesData(b.UVKind);let f=_.Zero();const d=_.Zero(),g=Q.Zero();n=n||Q.Zero(),o=o||new Q(1,1);for(let p=0;p<l.length;p+=3){_.FromArrayToRef(l,p,f),_.FromArrayToRef(c,p,d),Q.FromArrayToRef(u,p/3*2,g);const m=Math.abs(g.x*o.x+n.x%1)*(t-1)%t|0,A=Math.abs(g.y*o.y+n.y%1)*(i-1)%i|0,E=(m+A*t)*4,I=e[E]/255,M=e[E+1]/255,C=e[E+2]/255,x=I*.3+M*.59+C*.11;d.normalize(),d.scaleInPlace(s+(r-s)*x),f=f.add(d),f.toArray(l,p)}return $.ComputeNormals(l,this.getIndices(),c),h?(this.setVerticesData(b.PositionKind,l),this.setVerticesData(b.NormalKind,c),this.setVerticesData(b.UVKind,u)):(this.updateVerticesData(b.PositionKind,l),this.updateVerticesData(b.NormalKind,c)),this}_getFlattenedNormals(e,t){const i=new Float32Array(e.length*3);let s=0;const r=this.sideOrientation===(this._scene.useRightHandedSystem?1:0);for(let n=0;n<e.length;n+=3){const o=_.FromArray(t,e[n]*3),h=_.FromArray(t,e[n+1]*3),l=_.FromArray(t,e[n+2]*3),c=o.subtract(h),u=l.subtract(h),f=_.Normalize(_.Cross(c,u));r&&f.scaleInPlace(-1);for(let d=0;d<3;d++)i[s++]=f.x,i[s++]=f.y,i[s++]=f.z}return i}_convertToUnIndexedMesh(e=!1){const t=this.getVerticesDataKinds().filter(h=>!this.getVertexBuffer(h)?.getIsInstanced()),i=this.getIndices(!1,!0),s={},r=(h,l)=>{const c=new Float32Array(i.length*l);let u=0;for(let f=0;f<i.length;f++)for(let d=0;d<l;d++)c[u++]=h[i[f]*l+d];return c},n=this.getBoundingInfo(),o=this.geometry?this.subMeshes.slice(0):[];for(const h of t)s[h]=this.getVerticesData(h);for(const h of t){const l=this.getVertexBuffer(h),c=l.getSize();if(e&&h===b.NormalKind){const u=this._getFlattenedNormals(i,s[b.PositionKind]);this.setVerticesData(b.NormalKind,u,l.isUpdatable(),c)}else this.setVerticesData(h,r(s[h],c),l.isUpdatable(),c)}if(this.morphTargetManager){for(let h=0;h<this.morphTargetManager.numTargets;h++){const l=this.morphTargetManager.getTarget(h),c=l.getPositions();l.setPositions(r(c,3));const u=l.getNormals();u&&l.setNormals(e?this._getFlattenedNormals(i,c):r(u,3));const f=l.getTangents();f&&l.setTangents(r(f,3));const d=l.getUVs();d&&l.setUVs(r(d,2));const g=l.getColors();g&&l.setColors(r(g,4))}this.morphTargetManager.synchronize()}for(let h=0;h<i.length;h++)i[h]=h;this.setIndices(i),this._unIndexed=!0,this.releaseSubMeshes();for(const h of o){const l=h.getBoundingInfo();zt.AddToMesh(h.materialIndex,h.indexStart,h.indexCount,h.indexStart,h.indexCount,this).setBoundingInfo(l)}return this.setBoundingInfo(n),this.synchronizeInstances(),this}convertToFlatShadedMesh(){return this._convertToUnIndexedMesh(!0)}convertToUnIndexedMesh(){return this._convertToUnIndexedMesh()}flipFaces(e=!1){const t=$.ExtractFromMesh(this);let i;if(e&&this.isVerticesDataPresent(b.NormalKind)&&t.normals){for(i=0;i<t.normals.length;i++)t.normals[i]*=-1;this.setVerticesData(b.NormalKind,t.normals,this.isVertexBufferUpdatable(b.NormalKind))}if(t.indices){let s;for(i=0;i<t.indices.length;i+=3)s=t.indices[i+1],t.indices[i+1]=t.indices[i+2],t.indices[i+2]=s;this.setIndices(t.indices,null,this.isVertexBufferUpdatable(b.PositionKind),!0)}return this}increaseVertices(e=1){const t=$.ExtractFromMesh(this),i=t.indices&&!Array.isArray(t.indices)&&Array.from?Array.from(t.indices):t.indices,s=t.positions&&!Array.isArray(t.positions)&&Array.from?Array.from(t.positions):t.positions,r=t.uvs&&!Array.isArray(t.uvs)&&Array.from?Array.from(t.uvs):t.uvs,n=t.normals&&!Array.isArray(t.normals)&&Array.from?Array.from(t.normals):t.normals;if(!i||!s)w.Warn("Couldn't increase number of vertices : VertexData must contain at least indices and positions");else{t.indices=i,t.positions=s,r&&(t.uvs=r),n&&(t.normals=n);const o=e+1,h=[];for(let C=0;C<o+1;C++)h[C]=[];let l,c;const u=new _(0,0,0),f=new _(0,0,0),d=new Q(0,0),g=[],p=[],m=[];let A,E=s.length,I;r&&(I=r.length);let M;n&&(M=n.length);for(let C=0;C<i.length;C+=3){p[0]=i[C],p[1]=i[C+1],p[2]=i[C+2];for(let x=0;x<3;x++)if(l=p[x],c=p[(x+1)%3],m[l]===void 0&&m[c]===void 0?(m[l]=[],m[c]=[]):(m[l]===void 0&&(m[l]=[]),m[c]===void 0&&(m[c]=[])),m[l][c]===void 0&&m[c][l]===void 0){m[l][c]=[],u.x=(s[3*c]-s[3*l])/o,u.y=(s[3*c+1]-s[3*l+1])/o,u.z=(s[3*c+2]-s[3*l+2])/o,n&&(f.x=(n[3*c]-n[3*l])/o,f.y=(n[3*c+1]-n[3*l+1])/o,f.z=(n[3*c+2]-n[3*l+2])/o),r&&(d.x=(r[2*c]-r[2*l])/o,d.y=(r[2*c+1]-r[2*l+1])/o),m[l][c].push(l);for(let S=1;S<o;S++)m[l][c].push(s.length/3),s[E++]=s[3*l]+S*u.x,s[E++]=s[3*l+1]+S*u.y,s[E++]=s[3*l+2]+S*u.z,n&&(n[M++]=n[3*l]+S*f.x,n[M++]=n[3*l+1]+S*f.y,n[M++]=n[3*l+2]+S*f.z),r&&(r[I++]=r[2*l]+S*d.x,r[I++]=r[2*l+1]+S*d.y);m[l][c].push(c),m[c][l]=[],A=m[l][c].length;for(let S=0;S<A;S++)m[c][l][S]=m[l][c][A-1-S]}h[0][0]=i[C],h[1][0]=m[i[C]][i[C+1]][1],h[1][1]=m[i[C]][i[C+2]][1];for(let x=2;x<o;x++){h[x][0]=m[i[C]][i[C+1]][x],h[x][x]=m[i[C]][i[C+2]][x],u.x=(s[3*h[x][x]]-s[3*h[x][0]])/x,u.y=(s[3*h[x][x]+1]-s[3*h[x][0]+1])/x,u.z=(s[3*h[x][x]+2]-s[3*h[x][0]+2])/x,n&&(f.x=(n[3*h[x][x]]-n[3*h[x][0]])/x,f.y=(n[3*h[x][x]+1]-n[3*h[x][0]+1])/x,f.z=(n[3*h[x][x]+2]-n[3*h[x][0]+2])/x),r&&(d.x=(r[2*h[x][x]]-r[2*h[x][0]])/x,d.y=(r[2*h[x][x]+1]-r[2*h[x][0]+1])/x);for(let S=1;S<x;S++)h[x][S]=s.length/3,s[E++]=s[3*h[x][0]]+S*u.x,s[E++]=s[3*h[x][0]+1]+S*u.y,s[E++]=s[3*h[x][0]+2]+S*u.z,n&&(n[M++]=n[3*h[x][0]]+S*f.x,n[M++]=n[3*h[x][0]+1]+S*f.y,n[M++]=n[3*h[x][0]+2]+S*f.z),r&&(r[I++]=r[2*h[x][0]]+S*d.x,r[I++]=r[2*h[x][0]+1]+S*d.y)}h[o]=m[i[C+1]][i[C+2]],g.push(h[0][0],h[1][0],h[1][1]);for(let x=1;x<o;x++){let S;for(S=0;S<x;S++)g.push(h[x][S],h[x+1][S],h[x+1][S+1]),g.push(h[x][S],h[x+1][S+1],h[x][S+1]);g.push(h[x][S],h[x+1][S],h[x+1][S+1])}}t.indices=g,t.applyToMesh(this,this.isVertexBufferUpdatable(b.PositionKind))}}forceSharedVertices(){const e=$.ExtractFromMesh(this),t=e.uvs,i=e.indices,s=e.positions,r=e.colors,n=e.matricesIndices,o=e.matricesWeights,h=e.matricesIndicesExtra,l=e.matricesWeightsExtra;if(i===void 0||s===void 0||i===null||s===null)w.Warn("VertexData contains empty entries");else{const c=[],u=[],f=[],d=[],g=[],p=[],m=[],A=[];let E=[],I=0;const M={};let C,x;for(let L=0;L<i.length;L+=3){x=[i[L],i[L+1],i[L+2]],E=[];for(let N=0;N<3;N++){E[N]="";for(let D=0;D<3;D++)Math.abs(s[3*x[N]+D])<1e-8&&(s[3*x[N]+D]=0),E[N]+=s[3*x[N]+D]+"|"}if(!(E[0]==E[1]||E[0]==E[2]||E[1]==E[2]))for(let N=0;N<3;N++){if(C=M[E[N]],C===void 0){M[E[N]]=I,C=I++;for(let D=0;D<3;D++)c.push(s[3*x[N]+D]);if(r!=null)for(let D=0;D<4;D++)d.push(r[4*x[N]+D]);if(t!=null)for(let D=0;D<2;D++)f.push(t[2*x[N]+D]);if(n!=null)for(let D=0;D<4;D++)g.push(n[4*x[N]+D]);if(o!=null)for(let D=0;D<4;D++)p.push(o[4*x[N]+D]);if(h!=null)for(let D=0;D<4;D++)m.push(h[4*x[N]+D]);if(l!=null)for(let D=0;D<4;D++)A.push(l[4*x[N]+D])}u.push(C)}}const S=[];$.ComputeNormals(c,u,S),e.positions=c,e.indices=u,e.normals=S,t!=null&&(e.uvs=f),r!=null&&(e.colors=d),n!=null&&(e.matricesIndices=g),o!=null&&(e.matricesWeights=p),h!=null&&(e.matricesIndicesExtra=m),o!=null&&(e.matricesWeightsExtra=A),e.applyToMesh(this,this.isVertexBufferUpdatable(b.PositionKind))}}static _instancedMeshFactory(e,t){throw ie("InstancedMesh")}static _PhysicsImpostorParser(e,t,i){throw ie("PhysicsImpostor")}createInstance(e){const t=ne._instancedMeshFactory(e,this);return t.parent=this.parent,t}synchronizeInstances(){for(let e=0;e<this.instances.length;e++)this.instances[e]._syncSubMeshes();return this}optimizeIndices(e){const t=this.getIndices(),i=this.getVerticesData(b.PositionKind);if(!i||!t)return this;const s=[];for(let n=0;n<i.length;n=n+3)s.push(_.FromArray(i,n));const r=[];return vr.SyncAsyncForLoop(s.length,40,n=>{const o=s.length-1-n,h=s[o];for(let l=0;l<o;++l){const c=s[l];if(h.equals(c)){r[o]=l;break}}},()=>{for(let o=0;o<t.length;++o)t[o]=r[t[o]]||t[o];const n=this.subMeshes.slice(0);this.setIndices(t),this.subMeshes=n,e&&e(this)}),this}serialize(e={}){e.name=this.name,e.id=this.id,e.uniqueId=this.uniqueId,e.type=this.getClassName(),Ae&&Ae.HasTags(this)&&(e.tags=Ae.GetTags(this)),e.position=this.position.asArray(),this.rotationQuaternion?e.rotationQuaternion=this.rotationQuaternion.asArray():this.rotation&&(e.rotation=this.rotation.asArray()),e.scaling=this.scaling.asArray(),this._postMultiplyPivotMatrix?e.pivotMatrix=this.getPivotMatrix().asArray():e.localMatrix=this.getPivotMatrix().asArray(),e.isEnabled=this.isEnabled(!1),e.isVisible=this.isVisible,e.infiniteDistance=this.infiniteDistance,e.pickable=this.isPickable,e.receiveShadows=this.receiveShadows,e.billboardMode=this.billboardMode,e.visibility=this.visibility,e.alwaysSelectAsActiveMesh=this.alwaysSelectAsActiveMesh,e.checkCollisions=this.checkCollisions,e.ellipsoid=this.ellipsoid.asArray(),e.ellipsoidOffset=this.ellipsoidOffset.asArray(),e.doNotSyncBoundingInfo=this.doNotSyncBoundingInfo,e.isBlocker=this.isBlocker,e.sideOrientation=this.sideOrientation,this.parent&&this.parent._serializeAsParent(e),e.isUnIndexed=this.isUnIndexed;const t=this._geometry;if(t&&this.subMeshes){e.geometryUniqueId=t.uniqueId,e.geometryId=t.id,e.subMeshes=[];for(let i=0;i<this.subMeshes.length;i++){const s=this.subMeshes[i];e.subMeshes.push({materialIndex:s.materialIndex,verticesStart:s.verticesStart,verticesCount:s.verticesCount,indexStart:s.indexStart,indexCount:s.indexCount})}}if(this.material?this.material.doNotSerialize||(e.materialUniqueId=this.material.uniqueId,e.materialId=this.material.id):(this.material=null,e.materialUniqueId=this._scene.defaultMaterial.uniqueId,e.materialId=this._scene.defaultMaterial.id),this.morphTargetManager&&(e.morphTargetManagerId=this.morphTargetManager.uniqueId),this.skeleton&&(e.skeletonId=this.skeleton.id,e.numBoneInfluencers=this.numBoneInfluencers),this.getScene()._getComponent(re.NAME_PHYSICSENGINE)){const i=this.getPhysicsImpostor();i&&(e.physicsMass=i.getParam("mass"),e.physicsFriction=i.getParam("friction"),e.physicsRestitution=i.getParam("mass"),e.physicsImpostor=i.type)}this.metadata&&(e.metadata=this.metadata),e.instances=[];for(let i=0;i<this.instances.length;i++){const s=this.instances[i];if(s.doNotSerialize)continue;const r={name:s.name,id:s.id,isEnabled:s.isEnabled(!1),isVisible:s.isVisible,isPickable:s.isPickable,checkCollisions:s.checkCollisions,position:s.position.asArray(),scaling:s.scaling.asArray()};if(s.parent&&s.parent._serializeAsParent(r),s.rotationQuaternion?r.rotationQuaternion=s.rotationQuaternion.asArray():s.rotation&&(r.rotation=s.rotation.asArray()),this.getScene()._getComponent(re.NAME_PHYSICSENGINE)){const n=s.getPhysicsImpostor();n&&(r.physicsMass=n.getParam("mass"),r.physicsFriction=n.getParam("friction"),r.physicsRestitution=n.getParam("mass"),r.physicsImpostor=n.type)}s.metadata&&(r.metadata=s.metadata),s.actionManager&&(r.actions=s.actionManager.serialize(s.name)),e.instances.push(r),le.AppendSerializedAnimations(s,r),r.ranges=s.serializeAnimationRanges()}if(this._thinInstanceDataStorage.instancesCount&&this._thinInstanceDataStorage.matrixData&&(e.thinInstances={instancesCount:this._thinInstanceDataStorage.instancesCount,matrixData:Array.from(this._thinInstanceDataStorage.matrixData),matrixBufferSize:this._thinInstanceDataStorage.matrixBufferSize,enablePicking:this.thinInstanceEnablePicking},this._userThinInstanceBuffersStorage)){const i={data:{},sizes:{},strides:{}};for(const s in this._userThinInstanceBuffersStorage.data)i.data[s]=Array.from(this._userThinInstanceBuffersStorage.data[s]),i.sizes[s]=this._userThinInstanceBuffersStorage.sizes[s],i.strides[s]=this._userThinInstanceBuffersStorage.strides[s];e.thinInstances.userThinInstance=i}return le.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.layerMask=this.layerMask,e.alphaIndex=this.alphaIndex,e.hasVertexAlpha=this.hasVertexAlpha,e.overlayAlpha=this.overlayAlpha,e.overlayColor=this.overlayColor.asArray(),e.renderOverlay=this.renderOverlay,e.applyFog=this.applyFog,this.actionManager&&(e.actions=this.actionManager.serialize(this.name)),e}_syncGeometryWithMorphTargetManager(){if(!this.geometry)return;this._markSubMeshesAsAttributesDirty();const e=this._internalAbstractMeshDataInfo._morphTargetManager;if(e&&e.vertexCount){if(e.vertexCount!==this.getTotalVertices()){w.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count."),this.morphTargetManager=null;return}if(e.isUsingTextureForTargets)return;for(let t=0;t<e.numInfluencers;t++){const i=e.getActiveTarget(t),s=i.getPositions();if(!s){w.Error("Invalid morph target. Target must have positions.");return}this.geometry.setVerticesData(b.PositionKind+t,s,!1,3);const r=i.getNormals();r&&this.geometry.setVerticesData(b.NormalKind+t,r,!1,3);const n=i.getTangents();n&&this.geometry.setVerticesData(b.TangentKind+t,n,!1,3);const o=i.getUVs();o&&this.geometry.setVerticesData(b.UVKind+"_"+t,o,!1,2);const h=i.getUV2s();h&&this.geometry.setVerticesData(b.UV2Kind+"_"+t,h,!1,2);const l=i.getColors();l&&this.geometry.setVerticesData(b.ColorKind+t,l,!1,4)}}else{let t=0;for(;this.geometry.isVerticesDataPresent(b.PositionKind+t);)this.geometry.removeVerticesData(b.PositionKind+t),this.geometry.isVerticesDataPresent(b.NormalKind+t)&&this.geometry.removeVerticesData(b.NormalKind+t),this.geometry.isVerticesDataPresent(b.TangentKind+t)&&this.geometry.removeVerticesData(b.TangentKind+t),this.geometry.isVerticesDataPresent(b.UVKind+t)&&this.geometry.removeVerticesData(b.UVKind+"_"+t),this.geometry.isVerticesDataPresent(b.UV2Kind+t)&&this.geometry.removeVerticesData(b.UV2Kind+"_"+t),this.geometry.isVerticesDataPresent(b.ColorKind+t)&&this.geometry.removeVerticesData(b.ColorKind+t),t++}}static Parse(e,t,i){let s;if(e.type&&e.type==="LinesMesh"?s=ne._LinesMeshParser(e,t):e.type&&e.type==="GroundMesh"?s=ne._GroundMeshParser(e,t):e.type&&e.type==="GoldbergMesh"?s=ne._GoldbergMeshParser(e,t):e.type&&e.type==="GreasedLineMesh"?s=ne._GreasedLineMeshParser(e,t):e.type&&e.type==="TrailMesh"?s=ne._TrailMeshParser(e,t):s=new ne(e.name,t),s.id=e.id,s._waitingParsedUniqueId=e.uniqueId,Ae&&Ae.AddTagsTo(s,e.tags),s.position=_.FromArray(e.position),e.metadata!==void 0&&(s.metadata=e.metadata),e.rotationQuaternion?s.rotationQuaternion=W.FromArray(e.rotationQuaternion):e.rotation&&(s.rotation=_.FromArray(e.rotation)),s.scaling=_.FromArray(e.scaling),e.localMatrix?s.setPreTransformMatrix(P.FromArray(e.localMatrix)):e.pivotMatrix&&s.setPivotMatrix(P.FromArray(e.pivotMatrix)),s.setEnabled(e.isEnabled),s.isVisible=e.isVisible,s.infiniteDistance=e.infiniteDistance,s.alwaysSelectAsActiveMesh=!!e.alwaysSelectAsActiveMesh,s.showBoundingBox=e.showBoundingBox,s.showSubMeshesBoundingBox=e.showSubMeshesBoundingBox,e.applyFog!==void 0&&(s.applyFog=e.applyFog),e.pickable!==void 0&&(s.isPickable=e.pickable),e.alphaIndex!==void 0&&(s.alphaIndex=e.alphaIndex),s.receiveShadows=e.receiveShadows,e.billboardMode!==void 0&&(s.billboardMode=e.billboardMode),e.visibility!==void 0&&(s.visibility=e.visibility),s.checkCollisions=e.checkCollisions,s.doNotSyncBoundingInfo=!!e.doNotSyncBoundingInfo,e.ellipsoid&&(s.ellipsoid=_.FromArray(e.ellipsoid)),e.ellipsoidOffset&&(s.ellipsoidOffset=_.FromArray(e.ellipsoidOffset)),e.overrideMaterialSideOrientation!=null&&(s.sideOrientation=e.overrideMaterialSideOrientation),e.sideOrientation!==void 0&&(s.sideOrientation=e.sideOrientation),e.isBlocker!==void 0&&(s.isBlocker=e.isBlocker),s._shouldGenerateFlatShading=e.useFlatShading,e.freezeWorldMatrix&&(s._waitingData.freezeWorldMatrix=e.freezeWorldMatrix),e.parentId!==void 0&&(s._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(s._waitingParentInstanceIndex=e.parentInstanceIndex),e.actions!==void 0&&(s._waitingData.actions=e.actions),e.overlayAlpha!==void 0&&(s.overlayAlpha=e.overlayAlpha),e.overlayColor!==void 0&&(s.overlayColor=q.FromArray(e.overlayColor)),e.renderOverlay!==void 0&&(s.renderOverlay=e.renderOverlay),s.isUnIndexed=!!e.isUnIndexed,s.hasVertexAlpha=e.hasVertexAlpha,e.delayLoadingFile?(s.delayLoadState=4,s.delayLoadingFile=i+e.delayLoadingFile,s.buildBoundingInfo(_.FromArray(e.boundingBoxMinimum),_.FromArray(e.boundingBoxMaximum)),e._binaryInfo&&(s._binaryInfo=e._binaryInfo),s._delayInfo=[],e.hasUVs&&s._delayInfo.push(b.UVKind),e.hasUVs2&&s._delayInfo.push(b.UV2Kind),e.hasUVs3&&s._delayInfo.push(b.UV3Kind),e.hasUVs4&&s._delayInfo.push(b.UV4Kind),e.hasUVs5&&s._delayInfo.push(b.UV5Kind),e.hasUVs6&&s._delayInfo.push(b.UV6Kind),e.hasColors&&s._delayInfo.push(b.ColorKind),e.hasMatricesIndices&&s._delayInfo.push(b.MatricesIndicesKind),e.hasMatricesWeights&&s._delayInfo.push(b.MatricesWeightsKind),s._delayLoadingFunction=Tt._ImportGeometry,xt.ForceFullSceneLoadingForIncremental&&s._checkDelayState()):Tt._ImportGeometry(e,s),e.materialUniqueId?s._waitingMaterialId=e.materialUniqueId:e.materialId&&(s._waitingMaterialId=e.materialId),e.morphTargetManagerId>-1&&(s._waitingMorphTargetManagerId=e.morphTargetManagerId),e.skeletonId!==void 0&&e.skeletonId!==null&&(s.skeleton=t.getLastSkeletonById(e.skeletonId),e.numBoneInfluencers&&(s.numBoneInfluencers=e.numBoneInfluencers)),e.animations){for(let r=0;r<e.animations.length;r++){const n=e.animations[r],o=Oi("BABYLON.Animation");o&&s.animations.push(o.Parse(n))}qe.ParseAnimationRanges(s,e,t)}if(e.autoAnimate&&t.beginAnimation(s,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),e.layerMask&&!isNaN(e.layerMask)?s.layerMask=Math.abs(parseInt(e.layerMask)):s.layerMask=268435455,e.physicsImpostor&&(s.physicsImpostor=ne._PhysicsImpostorParser(t,s,e)),e.lodMeshIds&&(s._waitingData.lods={ids:e.lodMeshIds,distances:e.lodDistances?e.lodDistances:null,coverages:e.lodCoverages?e.lodCoverages:null}),e.instances)for(let r=0;r<e.instances.length;r++){const n=e.instances[r],o=s.createInstance(n.name);if(n.id&&(o.id=n.id),Ae&&(n.tags?Ae.AddTagsTo(o,n.tags):Ae.AddTagsTo(o,e.tags)),o.position=_.FromArray(n.position),n.metadata!==void 0&&(o.metadata=n.metadata),n.parentId!==void 0&&(o._waitingParentId=n.parentId),n.parentInstanceIndex!==void 0&&(o._waitingParentInstanceIndex=n.parentInstanceIndex),n.isEnabled!==void 0&&n.isEnabled!==null&&o.setEnabled(n.isEnabled),n.isVisible!==void 0&&n.isVisible!==null&&(o.isVisible=n.isVisible),n.isPickable!==void 0&&n.isPickable!==null&&(o.isPickable=n.isPickable),n.rotationQuaternion?o.rotationQuaternion=W.FromArray(n.rotationQuaternion):n.rotation&&(o.rotation=_.FromArray(n.rotation)),o.scaling=_.FromArray(n.scaling),n.checkCollisions!=null&&n.checkCollisions!=null&&(o.checkCollisions=n.checkCollisions),n.pickable!=null&&n.pickable!=null&&(o.isPickable=n.pickable),n.showBoundingBox!=null&&n.showBoundingBox!=null&&(o.showBoundingBox=n.showBoundingBox),n.showSubMeshesBoundingBox!=null&&n.showSubMeshesBoundingBox!=null&&(o.showSubMeshesBoundingBox=n.showSubMeshesBoundingBox),n.alphaIndex!=null&&n.showSubMeshesBoundingBox!=null&&(o.alphaIndex=n.alphaIndex),n.physicsImpostor&&(o.physicsImpostor=ne._PhysicsImpostorParser(t,o,n)),n.actions!==void 0&&(o._waitingData.actions=n.actions),n.animations){for(let h=0;h<n.animations.length;h++){const l=n.animations[h],c=Oi("BABYLON.Animation");c&&o.animations.push(c.Parse(l))}qe.ParseAnimationRanges(o,n,t),n.autoAnimate&&t.beginAnimation(o,n.autoAnimateFrom,n.autoAnimateTo,n.autoAnimateLoop,n.autoAnimateSpeed||1)}}if(e.thinInstances){const r=e.thinInstances;if(s.thinInstanceEnablePicking=!!r.enablePicking,r.matrixData?(s.thinInstanceSetBuffer("matrix",new Float32Array(r.matrixData),16,!1),s._thinInstanceDataStorage.matrixBufferSize=r.matrixBufferSize,s._thinInstanceDataStorage.
30instancesCount=r.instancesCount):s._thinInstanceDataStorage.matrixBufferSize=r.matrixBufferSize,e.thinInstances.userThinInstance){const n=e.thinInstances.userThinInstance;for(const o in n.data)s.thinInstanceSetBuffer(o,new Float32Array(n.data[o]),n.strides[o],!1),s._userThinInstanceBuffersStorage.sizes[o]=n.sizes[o]}}return s}setPositionsForCPUSkinning(){const e=this._internalMeshDataInfo;if(!e._sourcePositions){const t=this.getVerticesData(b.PositionKind);if(!t)return e._sourcePositions;e._sourcePositions=new Float32Array(t),this.isVertexBufferUpdatable(b.PositionKind)||this.setVerticesData(b.PositionKind,t,!0)}return e._sourcePositions}setNormalsForCPUSkinning(){const e=this._internalMeshDataInfo;if(!e._sourceNormals){const t=this.getVerticesData(b.NormalKind);if(!t)return e._sourceNormals;e._sourceNormals=new Float32Array(t),this.isVertexBufferUpdatable(b.NormalKind)||this.setVerticesData(b.NormalKind,t,!0)}return e._sourceNormals}applySkeleton(e){if(!this.geometry)return this;if(this.geometry._softwareSkinningFrameId==this.getScene().getFrameId())return this;if(this.geometry._softwareSkinningFrameId=this.getScene().getFrameId(),!this.isVerticesDataPresent(b.PositionKind))return this;if(!this.isVerticesDataPresent(b.MatricesIndicesKind))return this;if(!this.isVerticesDataPresent(b.MatricesWeightsKind))return this;const t=this.isVerticesDataPresent(b.NormalKind),i=this._internalMeshDataInfo;if(!i._sourcePositions){const A=this.subMeshes.slice();this.setPositionsForCPUSkinning(),this.subMeshes=A}t&&!i._sourceNormals&&this.setNormalsForCPUSkinning();let s=this.getVerticesData(b.PositionKind);if(!s)return this;s instanceof Float32Array||(s=new Float32Array(s));let r=this.getVerticesData(b.NormalKind);if(t){if(!r)return this;r instanceof Float32Array||(r=new Float32Array(r))}const n=this.getVerticesData(b.MatricesIndicesKind),o=this.getVerticesData(b.MatricesWeightsKind);if(!o||!n)return this;const h=this.numBoneInfluencers>4,l=h?this.getVerticesData(b.MatricesIndicesExtraKind):null,c=h?this.getVerticesData(b.MatricesWeightsExtraKind):null,u=e.getTransformMatrices(this),f=_.Zero(),d=new P,g=new P;let p=0,m;for(let A=0;A<s.length;A+=3,p+=4){let E;for(m=0;m<4;m++)E=o[p+m],E>0&&(P.FromFloat32ArrayToRefScaled(u,Math.floor(n[p+m]*16),E,g),d.addToSelf(g));if(h)for(m=0;m<4;m++)E=c[p+m],E>0&&(P.FromFloat32ArrayToRefScaled(u,Math.floor(l[p+m]*16),E,g),d.addToSelf(g));_.TransformCoordinatesFromFloatsToRef(i._sourcePositions[A],i._sourcePositions[A+1],i._sourcePositions[A+2],d,f),f.toArray(s,A),t&&(_.TransformNormalFromFloatsToRef(i._sourceNormals[A],i._sourceNormals[A+1],i._sourceNormals[A+2],d,f),f.toArray(r,A)),d.reset()}return this.updateVerticesData(b.PositionKind,s),t&&this.updateVerticesData(b.NormalKind,r),this}static MinMax(e){let t=null,i=null;for(const s of e){const n=s.getBoundingInfo().boundingBox;!t||!i?(t=n.minimumWorld.clone(),i=n.maximumWorld.clone()):(t.minimizeInPlace(n.minimumWorld),i.maximizeInPlace(n.maximumWorld))}return!t||!i?{min:_.Zero(),max:_.Zero()}:{min:t,max:i}}static Center(e){const t=e instanceof Array?ne.MinMax(e):e;return _.Center(t.min,t.max)}static MergeMeshes(e,t=!0,i,s,r,n){return Un(ne._MergeMeshesCoroutine(e,t,i,s,r,n,!1))}static async MergeMeshesAsync(e,t=!0,i,s,r,n){return await Cc(ne._MergeMeshesCoroutine(e,t,i,s,r,n,!0),Mc())}static*_MergeMeshesCoroutine(e,t=!0,i,s,r,n,o){if(e=e.filter(Boolean),e.length===0)return null;let h;if(!i){let S=0;for(h=0;h<e.length;h++)if(S+=e[h].getTotalVertices(),S>=65536)return w.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}n&&(r=!1);const l=new Array,c=new Array,u=new Array,f=e[0].sideOrientation;for(h=0;h<e.length;h++){const S=e[h];if(S.isAnInstance)return w.Warn("Cannot merge instance meshes."),null;if(f!==S.sideOrientation)return w.Warn("Cannot merge meshes with different sideOrientation values."),null;if(r&&u.push({start:0,count:S.getTotalIndices()}),n){const L=u.reduce((N,D)=>Math.max(N,D.start+D.count),0);if(S.material){const N=S.material;if(N instanceof Ts){for(let D=0;D<N.subMaterials.length;D++)l.indexOf(N.subMaterials[D])<0&&l.push(N.subMaterials[D]);for(let D=0;D<S.subMeshes.length;D++)c.push(l.indexOf(N.subMaterials[S.subMeshes[D].materialIndex])),u.push({start:L+S.subMeshes[D].indexStart,count:S.subMeshes[D].indexCount})}
vendor: 1,265 bytes, line 30
30else{l.indexOf(N)<0&&l.push(N);for(let D=0;D<S.subMeshes.length;D++)c.push(l.indexOf(N)),u.push({start:L+S.subMeshes[D].indexStart,count:S.subMeshes[D].indexCount})}}else for(let N=0;N<S.subMeshes.length;N++)c.push(0),u.push({start:L+S.subMeshes[N].indexStart,count:S.subMeshes[N].indexCount})}}const d=e[0],g=S=>{const L=S.computeWorldMatrix(!0);return{vertexData:$.ExtractFromMesh(S,!1,!1),transform:L}},{vertexData:p,transform:m}=g(d);o&&(yield);const A=new Array(e.length-1);for(let S=1;S<e.length;S++)A[S-1]=g(e[S]),o&&(yield);const E=p._mergeCoroutine(m,A,i,o,!t);let I=E.next();for(;!I.done;)o&&(yield),I=E.next();const M=I.value;s||(s=new ne(d.name+"_merged",d.getScene()));const C=M._applyToCoroutine(s,void 0,o);let x=C.next();for(;!x.done;)o&&(yield),x=C.next();if(s.checkCollisions=d.checkCollisions,s.sideOrientation=d.sideOrientation,t)for(h=0;h<e.length;h++)e[h].dispose();if(r||n){for(s.releaseSubMeshes(),h=0;h<u.length;)zt.CreateFromIndices(0,u[h].start,u[h].count,s,void 0,!1),h++;for(const S of s.subMeshes)S.refreshBoundingInfo();s.computeWorldMatrix(!0)}if(n){const S=new Ts(d.name+"_merged",d.getScene());S.subMaterials=l;for(let L=0;L<s.subMeshes.length;L++)s.subMeshes[L].materialIndex=c[L];s.material=S}else s.material=d.material;return s}
vendor: 84,158 bytes, line 30
30addInstance(e){e._indexInSourceMeshInstanceArray=this.instances.length,this.instances.push(e)}removeInstance(e){const t=e._indexInSourceMeshInstanceArray;if(t!=-1){if(t!==this.instances.length-1){const i=this.instances[this.instances.length-1];this.instances[t]=i,i._indexInSourceMeshInstanceArray=t}e._indexInSourceMeshInstanceArray=-1,this.instances.pop()}}_shouldConvertRHS(){return this._scene.useRightHandedSystem&&this.sideOrientation===F.CounterClockWiseSideOrientation}_getRenderingFillMode(e){const t=this.getScene();return t.forcePointsCloud?F.PointFillMode:t.forceWireframe?F.WireFrameFillMode:this.overrideRenderingFillMode??e}setMaterialByID(e){return this.setMaterialById(e)}static CreateRibbon(e,t,i,s,r,n,o,h,l){throw new Error("Import MeshBuilder to populate this function")}static CreateDisc(e,t,i,s,r,n){throw new Error("Import MeshBuilder to populate this function")}static CreateBox(e,t,i,s,r){throw new Error("Import MeshBuilder to populate this function")}static CreateSphere(e,t,i,s,r,n){throw new Error("Import MeshBuilder to populate this function")}static CreateHemisphere(e,t,i,s){throw new Error("Import MeshBuilder to populate this function")}static CreateCylinder(e,t,i,s,r,n,o,h,l){throw new Error("Import MeshBuilder to populate this function")}static CreateTorus(e,t,i,s,r,n,o){throw new Error("Import MeshBuilder to populate this function")}static CreateTorusKnot(e,t,i,s,r,n,o,h,l,c){throw new Error("Import MeshBuilder to populate this function")}static CreateLines(e,t,i,s,r){throw new Error("Import MeshBuilder to populate this function")}static CreateDashedLines(e,t,i,s,r,n,o,h){throw new Error("Import MeshBuilder to populate this function")}static CreatePolygon(e,t,i,s,r,n,o){throw new Error("Import MeshBuilder to populate this function")}static ExtrudePolygon(e,t,i,s,r,n,o,h){throw new Error("Import MeshBuilder to populate this function")}static ExtrudeShape(e,t,i,s,r,n,o,h,l,c){throw new Error("Import MeshBuilder to populate this function")}static ExtrudeShapeCustom(e,t,i,s,r,n,o,h,l,c,u,f){throw new Error("Import MeshBuilder to populate this function")}static CreateLathe(e,t,i,s,r,n,o){throw new Error("Import MeshBuilder to populate this function")}static CreatePlane(e,t,i,s,r){throw new Error("Import MeshBuilder to populate this function")}static CreateGround(e,t,i,s,r,n){throw new Error("Import MeshBuilder to populate this function")}static CreateTiledGround(e,t,i,s,r,n,o,h,l){throw new Error("Import MeshBuilder to populate this function")}static CreateGroundFromHeightMap(e,t,i,s,r,n,o,h,l,c,u){throw new Error("Import MeshBuilder to populate this function")}static CreateTube(e,t,i,s,r,n,o,h,l,c){throw new Error("Import MeshBuilder to populate this function")}static CreatePolyhedron(e,t,i){throw new Error("Import MeshBuilder to populate this function")}static CreateIcoSphere(e,t,i){throw new Error("Import MeshBuilder to populate this function")}static CreateDecal(e,t,i,s,r,n){throw new Error("Import MeshBuilder to populate this function")}static CreateCapsule(e,t,i){throw new Error("Import MeshBuilder to populate this function")}static ExtendToGoldberg(e){throw new Error("Import MeshBuilder to populate this function")}}ne.FRONTSIDE=$.FRONTSIDE;ne.BACKSIDE=$.BACKSIDE;ne.DOUBLESIDE=$.DOUBLESIDE;ne.DEFAULTSIDE=$.DEFAULTSIDE;ne.NO_CAP=0;ne.CAP_START=1;ne.CAP_END=2;ne.CAP_ALL=3;ne.NO_FLIP=0;ne.FLIP_TILE=1;ne.ROTATE_TILE=2;ne.FLIP_ROW=3;ne.ROTATE_ROW=4;ne.FLIP_N_ROTATE_TILE=5;ne.FLIP_N_ROTATE_ROW=6;ne.CENTER=0;ne.LEFT=1;ne.RIGHT=2;ne.TOP=3;ne.BOTTOM=4;ne.INSTANCEDMESH_SORT_TRANSPARENT=!1;ne._GroundMeshParser=(a,e)=>{throw ie("GroundMesh")};ne._GoldbergMeshParser=(a,e)=>{throw ie("GoldbergMesh")};ne._LinesMeshParser=(a,e)=>{throw ie("LinesMesh")};ne._GreasedLineMeshParser=(a,e)=>{throw ie("GreasedLineMesh")};ne._GreasedLineRibbonMeshParser=(a,e)=>{throw ie("GreasedLineRibbonMesh")};ne._TrailMeshParser=(a,e)=>{throw ie("TrailMesh")};nt("BABYLON.Mesh",ne);class te{}te.POINTERDOWN=1;te.POINTERUP=2;te.POINTERMOVE=4;te.POINTERWHEEL=8;te.POINTERPICK=16;te.POINTERTAP=32;te.POINTERDOUBLETAP=64;class Th{constructor(e,t){this.type=e,this.event=t}}class uu extends Th{constructor(e,t,i,s){super(e,t),this.ray=null,this.originalPickingInfo=null,this.skipOnPointerObservable=!1,this.localPosition=new Q(i,s)}}class kt extends Th{get pickInfo(){return this._pickInfo||this._generatePickInfo(),this._pickInfo}constructor(e,t,i,s=null){super(e,t),this._pickInfo=i,this._inputManager=s}_generatePickInfo(){this._inputManager&&(this._pickInfo=this._inputManager._pickMove(this.event),this._inputManager._setRayOnPointerInfo(this._pickInfo,this.event),this._inputManager=null)}}class du{constructor(){this._zoomStopsAnimation=!1,this._idleRotationSpeed=.05,this._idleRotationWaitTime=2e3,this._idleRotationSpinupTime=2e3,this.targetAlpha=null,this._attachedCamera=null,this._isPointerDown=!1,this._lastFrameTime=null,this._lastInteractionTime=-1/0,this._cameraRotationSpeed=0,this._lastFrameRadius=0}get name(){return"AutoRotation"}set zoomStopsAnimation(e){this._zoomStopsAnimation=e}get zoomStopsAnimation(){return this._zoomStopsAnimation}set idleRotationSpeed(e){this._idleRotationSpeed=e}get idleRotationSpeed(){return this._idleRotationSpeed}set idleRotationWaitTime(e){this._idleRotationWaitTime=e}get idleRotationWaitTime(){return this._idleRotationWaitTime}set idleRotationSpinupTime(e){this._idleRotationSpinupTime=e}get idleRotationSpinupTime(){return this._idleRotationSpinupTime}get rotationInProgress(){return Math.abs(this._cameraRotationSpeed)>0}get attachedNode(){return this._attachedCamera}init(){}attach(e){this._attachedCamera=e;const t=this._attachedCamera.getScene();this._onPrePointerObservableObserver=t.onPrePointerObservable.add(i=>{if(i.type===te.POINTERDOWN){this._isPointerDown=!0;return}i.type===te.POINTERUP&&(this._isPointerDown=!1)}),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add(()=>{if(this._reachTargetAlpha())return;const i=vt.Now;let s=0;this._lastFrameTime!=null&&(s=i-this._lastFrameTime),this._lastFrameTime=i,this._applyUserInteraction();const r=i-this._lastInteractionTime-this._idleRotationWaitTime,n=Math.max(Math.min(r/this._idleRotationSpinupTime,1),0);this._cameraRotationSpeed=this._idleRotationSpeed*n,this._attachedCamera&&(this._attachedCamera.alpha-=this._cameraRotationSpeed*(s/1e3))})}detach(){if(!this._attachedCamera)return;const e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._attachedCamera=null,this._lastFrameTime=null}resetLastInteractionTime(e){this._lastInteractionTime=e??vt.Now}_reachTargetAlpha(){return this._attachedCamera&&this.targetAlpha?Math.abs(this._attachedCamera.alpha-this.targetAlpha)<Me:!1}_userIsZooming(){return this._attachedCamera?this._attachedCamera.inertialRadiusOffset!==0:!1}_shouldAnimationStopForInteraction(){if(!this._attachedCamera)return!1;let e=!1;return this._lastFrameRadius===this._attachedCamera.radius&&this._attachedCamera.inertialRadiusOffset!==0&&(e=!0),this._lastFrameRadius=this._attachedCamera.radius,this._zoomStopsAnimation?e:this._userIsZooming()}_applyUserInteraction(){this._userIsMoving()&&!this._shouldAnimationStopForInteraction()&&(this._lastInteractionTime=vt.Now)}_userIsMoving(){return this._attachedCamera?this._attachedCamera.inertialAlphaOffset!==0||this._attachedCamera.inertialBetaOffset!==0||this._attachedCamera.inertialRadiusOffset!==0||this._attachedCamera.inertialPanningX!==0||this._attachedCamera.inertialPanningY!==0||this._isPointerDown:!1}}var Ea;(function(a){a[a.CW=0]="CW",a[a.CCW=1]="CCW"})(Ea||(Ea={}));class fu{static Interpolate(e,t,i,s,r){if(e===0)return 0;const n=1-3*s+3*t,o=3*s-6*t,h=3*t;let l=e;for(let c=0;c<5;c++){const u=l*l,f=u*l,d=n*f+o*u+h*l,g=1/(3*n*u+2*o*l+h);l-=(d-e)*g,l=Math.min(1,Math.max(0,l))}return 3*Math.pow(1-l,2)*l*i+3*(1-l)*Math.pow(l,2)*r+Math.pow(l,3)}}class bt{constructor(){this._easingMode=bt.EASINGMODE_EASEIN}setEasingMode(e){const t=Math.min(Math.max(e,0),2);this._easingMode=t}getEasingMode(){return this._easingMode}easeInCore(e){throw new Error("You must implement this method")}ease(e){switch(this._easingMode){case bt.EASINGMODE_EASEIN:return this.easeInCore(e);case bt.EASINGMODE_EASEOUT:return 1-this.easeInCore(1-e)}return e>=.5?(1-this.easeInCore((1-e)*2))*.5+.5:this.easeInCore(e*2)*.5}}bt.EASINGMODE_EASEIN=0;bt.EASINGMODE_EASEOUT=1;bt.EASINGMODE_EASEINOUT=2;class T_ extends bt{easeInCore(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)}}class _u extends bt{constructor(e=1){super(),this.amplitude=e}easeInCore(e){const t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)}}class b_ extends bt{constructor(e=3,t=2){super(),this.bounces=e,this.bounciness=t}easeInCore(e){const t=Math.max(0,this.bounces);let i=this.bounciness;i<=1&&(i=1.001);const s=Math.pow(i,t),r=1-i,n=(1-s)/r+s*.5,o=e*n,h=Math.log(-o*(1-i)+1)/Math.log(i),l=Math.floor(h),c=l+1,u=(1-Math.pow(i,l))/(r*n),f=(1-Math.pow(i,c))/(r*n),d=(u+f)*.5,g=e-d,p=d-u;return-Math.pow(1/i,t-l)/(p*p)*(g-p)*(g+p)}}class E_ extends bt{easeInCore(e){return e*e*e}}class A_ extends bt{constructor(e=3,t=3){super(),this.oscillations=e,this.springiness=t}easeInCore(e){let t;const i=Math.max(0,this.oscillations),s=Math.max(0,this.springiness);return s==0?t=e:t=(Math.exp(s*e)-1)/(Math.exp(s)-1),t*Math.sin((6.283185307179586*i+1.5707963267948966)*e)}}class gu extends bt{constructor(e=2){super(),this.exponent=e}easeInCore(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)}}class R_ extends bt{constructor(e=0,t=0,i=1,s=1){super(),this.x1=e,this.y1=t,this.x2=i,this.y2=s}easeInCore(e){return fu.Interpolate(e,this.x1,this.y1,this.x2,this.y2)}}class Hr{constructor(e,t,i){this.name=e,this.from=t,this.to=i}clone(){return new Hr(this.name,this.from,this.to)}}const pu=Object.freeze(new W(0,0,0,0)),mu=Object.freeze(_.Zero()),Tu=Object.freeze(Q.Zero()),bu=Object.freeze(Ft.Zero()),Eu=Object.freeze(q.Black()),Au=Object.freeze(new fe(0,0,0,0)),Zt={key:0,repeatCount:0,loopMode:2};class k{static _PrepareAnimation(e,t,i,s,r,n,o,h){let l;if(!isNaN(parseFloat(r))&&isFinite(r)?l=k.ANIMATIONTYPE_FLOAT:r instanceof W?l=k.ANIMATIONTYPE_QUATERNION:r instanceof _?l=k.ANIMATIONTYPE_VECTOR3:r instanceof Q?l=k.ANIMATIONTYPE_VECTOR2:r instanceof q?l=k.ANIMATIONTYPE_COLOR3:r instanceof fe?l=k.ANIMATIONTYPE_COLOR4:r instanceof Ft&&(l=k.ANIMATIONTYPE_SIZE),l==null)return null;const c=new k(e,t,i,l,o),u=[{frame:0,value:r},{frame:s,value:n}];return c.setKeys(u),h!==void 0&&c.setEasingFunction(h),c}static CreateAnimation(e,t,i,s){const r=new k(e+"Animation",e,i,t,k.ANIMATIONLOOPMODE_CONSTANT);return r.setEasingFunction(s),r}static CreateAndStartAnimation(e,t,i,s,r,n,o,h,l,c,u){const f=k._PrepareAnimation(e,i,s,r,n,o,h,l);return!f||(t.getScene&&(u=t.getScene()),!u)?null:u.beginDirectAnimation(t,[f],0,r,f.loopMode!==k.ANIMATIONLOOPMODE_CONSTANT,1,c)}static CreateAndStartHierarchyAnimation(e,t,i,s,r,n,o,h,l,c,u){const f=k._PrepareAnimation(e,s,r,n,o,h,l,c);return f?t.getScene().beginDirectHierarchyAnimation(t,i,[f],0,n,f.loopMode===1,1,u):null}static CreateMergeAndStartAnimation(e,t,i,s,r,n,o,h,l,c){const u=k._PrepareAnimation(e,i,s,r,n,o,h,l);return u?(t.animations.push(u),t.getScene().beginAnimation(t,0,r,u.loopMode===1,1,c)):null}static MakeAnimationAdditive(e,t,i,s=!1,r){let n;typeof t=="object"?n=t:n={referenceFrame:t??0,range:i,cloneOriginalAnimation:s,clonedAnimationName:r};let o=e;if(n.cloneOriginalAnimation&&(o=e.clone(),o.name=n.clonedAnimationName||o.name),!o._keys.length)return o;const h=n.referenceFrame&&n.referenceFrame>=0?n.referenceFrame:0;let l=0;const c=o._keys[0];let u=o._keys.length-1;const f=o._keys[u],d={referenceValue:c.value,referencePosition:v.Vector3[0],referenceQuaternion:v.Quaternion[0],referenceScaling:v.Vector3[1],keyPosition:v.Vector3[2],keyQuaternion:v.Quaternion[1],keyScaling:v.Vector3[3]};let g=c.frame,p=f.frame;if(n.range){const E=o.getRange(n.range);E&&(g=E.from,p=E.to)}else g=n.fromFrame??g,p=n.toFrame??p;if(g!==c.frame&&(l=o.createKeyForFrame(g)),p!==f.frame&&(u=o.createKeyForFrame(p)),o._keys.length===1){const E=o._getKeyValue(o._keys[0]);d.referenceValue=E.clone?E.clone():E}else if(h<=c.frame){const E=o._getKeyValue(c.value);d.referenceValue=E.clone?E.clone():E}else if(h>=f.frame){const E=o._getKeyValue(f.value);d.referenceValue=E.clone?E.clone():E}else{Zt.key=0;const E=o._interpolate(h,Zt);d.referenceValue=E.clone?E.clone():E}o.dataType===k.ANIMATIONTYPE_QUATERNION?d.referenceValue.normalize().conjugateInPlace():o.dataType===k.ANIMATIONTYPE_MATRIX&&(d.referenceValue.decompose(d.referenceScaling,d.referenceQuaternion,d.referencePosition),d.referenceQuaternion.normalize().conjugateInPlace());let m=Number.MAX_VALUE;const A=n.clipKeys?[]:null;for(let E=l;E<=u;E++){let I=o._keys[E];if((A||n.cloneOriginalAnimation)&&(I={frame:I.frame,value:I.value.clone?I.value.clone():I.value,inTangent:I.inTangent,outTangent:I.outTangent,interpolation:I.interpolation,lockedTangent:I.lockedTangent},A&&(m===Number.MAX_VALUE&&(m=I.frame),I.frame-=m,A.push(I))),!(E&&o.dataType!==k.ANIMATIONTYPE_FLOAT&&I.value===c.value))switch(o.dataType){case k.ANIMATIONTYPE_MATRIX:I.value.decompose(d.keyScaling,d.keyQuaternion,d.keyPosition),d.keyPosition.subtractInPlace(d.referencePosition),d.keyScaling.divideInPlace(d.referenceScaling),d.referenceQuaternion.multiplyToRef(d.keyQuaternion,d.keyQuaternion),P.ComposeToRef(d.keyScaling,d.keyQuaternion,d.keyPosition,I.value);break;case k.ANIMATIONTYPE_QUATERNION:d.referenceValue.multiplyToRef(I.value,I.value);break;case k.ANIMATIONTYPE_VECTOR2:case k.ANIMATIONTYPE_VECTOR3:case k.ANIMATIONTYPE_COLOR3:case k.ANIMATIONTYPE_COLOR4:I.value.subtractToRef(d.referenceValue,I.value);break;case k.ANIMATIONTYPE_SIZE:I.value.width-=d.referenceValue.width,I.value.height-=d.referenceValue.height;break;default:I.value-=d.referenceValue}}return A&&o.setKeys(A,!0),o}static TransitionTo(e,t,i,s,r,n,o,h=null,l=!0,c){if(o<=0)return i[e]=t,h&&h(),null;const u=r*(o/1e3);return n.setKeys(c??[{frame:0,value:i[e].clone?i[e].clone():i[e]},{frame:u,value:t}]),i.animations||(i.animations=[]),i.animations.push(n),s.beginAnimation(i,0,u,!1,1,h??void 0,void 0,l)}get runtimeAnimations(){return this._runtimeAnimations}get hasRunningRuntimeAnimations(){for(const e of this._runtimeAnimations)if(!e.isStopped())return!0;return!1}constructor(e,t,i,s,r,n){this.name=e,this.targetProperty=t,this.framePerSecond=i,this.dataType=s,this.loopMode=r,this.enableBlending=n,this._easingFunction=null,this._runtimeAnimations=new Array,this._events=new Array,this.blendingSpeed=.01,this._ranges={},this._coreAnimation=null,this.targetPropertyPath=t.split("."),this.dataType=s,this.loopMode=r===void 0?k.ANIMATIONLOOPMODE_CYCLE:r,this.uniqueId=k._UniqueIdGenerator++}toString(e){let t="Name: "+this.name+", property: "+this.targetProperty;if(t+=", datatype: "+["Float","Vector3","Quaternion","Matrix","Color3","Vector2"][this.dataType],t+=", nKeys: "+(this._keys?this._keys.length:"none"),t+=", nRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";let i=!0;for(const s in this._ranges)i&&(t+=", ",i=!1),t+=s;t+="}"}return t}addEvent(e){this._events.push(e),this._events.sort((t,i)=>t.frame-i.frame)}removeEvents(e){for(let t=0;t<this._events.length;t++)this._events[t].frame===e&&(this._events.splice(t,1),t--)}getEvents(){return this._events}createRange(e,t,i){this._ranges[e]||(this._ranges[e]=new Hr(e,t,i))}deleteRange(e,t=!0){const i=this._ranges[e];if(i){if(t){const s=i.from,r=i.to;for(let n=this._keys.length-1;n>=0;n--)this._keys[n].frame>=s&&this._keys[n].frame<=r&&this._keys.splice(n,1)}this._ranges[e]=null}}getRange(e){return this._ranges[e]}getKeys(){return this._keys}getHighestFrame(){let e=0;for(let t=0,i=this._keys.length;t<i;t++)e<this._keys[t].frame&&(e=this._keys[t].frame);return e}getEasingFunction(){return this._easingFunction}setEasingFunction(e){this._easingFunction=e}floatInterpolateFunction(e,t,i){return Ii(e,t,i)}floatInterpolateFunctionWithTangents(e,t,i,s,r){return po(e,t,i,s,r)}quaternionInterpolateFunction(e,t,i){return W.Slerp(e,t,i)}quaternionInterpolateFunctionWithTangents(e,t,i,s,r){return W.Hermite(e,t,i,s,r).normalize()}vector3InterpolateFunction(e,t,i){return _.Lerp(e,t,i)}vector3InterpolateFunctionWithTangents(e,t,i,s,r){return _.Hermite(e,t,i,s,r)}vector2InterpolateFunction(e,t,i){return Q.Lerp(e,t,i)}vector2InterpolateFunctionWithTangents(e,t,i,s,r){return Q.Hermite(e,t,i,s,r)}sizeInterpolateFunction(e,t,i){return Ft.Lerp(e,t,i)}color3InterpolateFunction(e,t,i){return q.Lerp(e,t,i)}color3InterpolateFunctionWithTangents(e,t,i,s,r){return q.Hermite(e,t,i,s,r)}color4InterpolateFunction(e,t,i){return fe.Lerp(e,t,i)}color4InterpolateFunctionWithTangents(e,t,i,s,r){return fe.Hermite(e,t,i,s,r)}_getKeyValue(e){return typeof e=="function"?e():e}evaluate(e){return Zt.key=0,this._interpolate(e,Zt)}_interpolate(e,t,i=!1){if(t.loopMode===k.ANIMATIONLOOPMODE_CONSTANT&&t.repeatCount>0)return t.highLimitValue.clone?t.highLimitValue.clone():t.highLimitValue;const s=this._keys;let r;if(this._coreAnimation)r=this._coreAnimation._key;else{const g=s.length;for(r=t.key;r>=0&&e<s[r].frame;)--r;for(;r+1<=g-1&&e>=s[r+1].frame;)++r;if(t.key=r,r<0)return i?void 0:this._getKeyValue(s[0].value);if(r+1>g-1)return i?void 0:this._getKeyValue(s[g-1].value);this._key=r}const n=s[r],o=s[r+1];if(i&&(e===n.frame||e===o.frame))return;const h=this._getKeyValue(n.value),l=this._getKeyValue(o.value);if(n.interpolation===1)return o.frame>e?h:l;const c=n.outTangent!==void 0&&o.inTangent!==void 0,u=o.frame-n.frame;let f=(e-n.frame)/u;const d=n.easingFunction||this.getEasingFunction();switch(d&&(f=d.ease(f)),this.dataType){case k.ANIMATIONTYPE_FLOAT:{const g=c?this.floatInterpolateFunctionWithTangents(h,n.outTangent*u,l,o.inTangent*u,f):this.floatInterpolateFunction(h,l,f);switch(t.loopMode){case k.ANIMATIONLOOPMODE_CYCLE:case k.ANIMATIONLOOPMODE_CONSTANT:case k.ANIMATIONLOOPMODE_YOYO:return g;case k.ANIMATIONLOOPMODE_RELATIVE:case k.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return(t.offsetValue??0)*t.repeatCount+g}break}case k.ANIMATIONTYPE_QUATERNION:{const g=c?this.quaternionInterpolateFunctionWithTangents(h,n.outTangent.scale(u),l,o.inTangent.scale(u),f):this.quaternionInterpolateFunction(h,l,f);switch(t.loopMode){case k.ANIMATIONLOOPMODE_CYCLE:case k.ANIMATIONLOOPMODE_CONSTANT:case k.ANIMATIONLOOPMODE_YOYO:return g;case k.ANIMATIONLOOPMODE_RELATIVE:case k.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return g.addInPlace((t.offsetValue||pu).scale(t.repeatCount))}return g}case k.ANIMATIONTYPE_VECTOR3:{const g=c?this.vector3InterpolateFunctionWithTangents(h,n.outTangent.scale(u),l,o.inTangent.scale(u),f):this.vector3InterpolateFunction(h,l,f);switch(t.loopMode){case k.ANIMATIONLOOPMODE_CYCLE:case k.ANIMATIONLOOPMODE_CONSTANT:case k.ANIMATIONLOOPMODE_YOYO:return g;case k.ANIMATIONLOOPMODE_RELATIVE:case k.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return g.add((t.offsetValue||mu).scale(t.repeatCount))}break}case k.ANIMATIONTYPE_VECTOR2:{const g=c?this.vector2InterpolateFunctionWithTangents(h,n.outTangent.scale(u),l,o.inTangent.scale(u),f):this.vector2InterpolateFunction(h,l,f);switch(t.loopMode){case k.ANIMATIONLOOPMODE_CYCLE:case k.ANIMATIONLOOPMODE_CONSTANT:case k.ANIMATIONLOOPMODE_YOYO:return g;case k.ANIMATIONLOOPMODE_RELATIVE:case k.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return g.add((t.offsetValue||Tu).scale(t.repeatCount))}break}case k.ANIMATIONTYPE_SIZE:{switch(t.loopMode){case k.ANIMATIONLOOPMODE_CYCLE:case k.ANIMATIONLOOPMODE_CONSTANT:case k.ANIMATIONLOOPMODE_YOYO:return this.sizeInterpolateFunction(h,l,f);case k.ANIMATIONLOOPMODE_RELATIVE:case k.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return this.sizeInterpolateFunction(h,l,f).add((t.offsetValue||bu).scale(t.repeatCount))}break}case k.ANIMATIONTYPE_COLOR3:{const g=c?this.color3InterpolateFunctionWithTangents(h,n.outTangent.scale(u),l,o.inTangent.scale(u),f):this.color3InterpolateFunction(h,l,f);switch(t.loopMode){case k.ANIMATIONLOOPMODE_CYCLE:case k.ANIMATIONLOOPMODE_CONSTANT:case k.ANIMATIONLOOPMODE_YOYO:return g;case k.ANIMATIONLOOPMODE_RELATIVE:case k.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return g.add((t.offsetValue||Eu).scale(t.repeatCount))}break}case k.ANIMATIONTYPE_COLOR4:{const g=c?this.color4InterpolateFunctionWithTangents(h,n.outTangent.scale(u),l,o.inTangent.scale(u),f):this.color4InterpolateFunction(h,l,f);switch(t.loopMode){case k.ANIMATIONLOOPMODE_CYCLE:case k.ANIMATIONLOOPMODE_CONSTANT:case k.ANIMATIONLOOPMODE_YOYO:return g;case k.ANIMATIONLOOPMODE_RELATIVE:case k.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return g.add((t.offsetValue||Au).scale(t.repeatCount))}break}case k.ANIMATIONTYPE_MATRIX:{switch(t.loopMode){case k.ANIMATIONLOOPMODE_CYCLE:case k.ANIMATIONLOOPMODE_CONSTANT:case k.ANIMATIONLOOPMODE_YOYO:return k.AllowMatricesInterpolation?this.matrixInterpolateFunction(h,l,f,t.workValue):h;case k.ANIMATIONLOOPMODE_RELATIVE:case k.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return h}break}}return 0}matrixInterpolateFunction(e,t,i,s){return k.AllowMatrixDecomposeForInterpolation?s?(P.DecomposeLerpToRef(e,t,i,s),s):P.DecomposeLerp(e,t,i):s?(P.LerpToRef(e,t,i,s),s):P.Lerp(e,t,i)}clone(){const e=new k(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);if(e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed,this._keys&&e.setKeys(this._keys),this._ranges){e._ranges={};for(const t in this._ranges){const i=this._ranges[t];i&&(e._ranges[t]=i.clone())}}return e}setKeys(e,t=!1){this._keys=t?e:e.slice(0)}createKeyForFrame(e){Zt.key=0;const t=this._interpolate(e,Zt,!0);if(!t)return this._keys[Zt.key].frame===e?Zt.key:Zt.key+1;const i={frame:e,value:t.clone?t.clone():t};return this._keys.splice(Zt.key+1,0,i),Zt.key+1}serialize(){const e={};e.name=this.name,e.property=this.targetProperty,e.framePerSecond=this.framePerSecond,e.dataType=this.dataType,e.loopBehavior=this.loopMode,e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed;const t=this.dataType;e.keys=[];const i=this.getKeys();for(let s=0;s<i.length;s++){const r=i[s],n={};switch(n.frame=r.frame,t){case k.ANIMATIONTYPE_FLOAT:n.values=[r.value],r.inTangent!==void 0&&n.values.push(r.inTangent),r.outTangent!==void 0&&(r.inTangent===void 0&&n.values.push(void 0),n.values.push(r.outTangent)),r.interpolation!==void 0&&(r.inTangent===void 0&&n.values.push(void 0),r.outTangent===void 0&&n.values.push(void 0),n.values.push(r.interpolation));break;case k.ANIMATIONTYPE_QUATERNION:case k.ANIMATIONTYPE_MATRIX:case k.ANIMATIONTYPE_VECTOR3:case k.ANIMATIONTYPE_COLOR3:case k.ANIMATIONTYPE_COLOR4:n.values=r.value.asArray(),r.inTangent!=null&&n.values.push(r.inTangent.asArray()),r.outTangent!=null&&(r.inTangent===void 0&&n.values.push(void 0),n.values.push(r.outTangent.asArray())),r.interpolation!==void 0&&(r.inTangent===void 0&&n.values.push(void 0),r.outTangent===void 0&&n.values.push(void 0),n.values.push(r.interpolation));break}e.keys.push(n)}e.ranges=[];for(const s in this._ranges){const r=this._ranges[s];if(!r)continue;const n={};n.name=s,n.from=r.from,n.to=r.to,e.ranges.push(n)}return e}static _UniversalLerp(e,t,i){const s=e.constructor;return s.Lerp?s.Lerp(e,t,i):s.Slerp?s.Slerp(e,t,i):e.toFixed?e*(1-i)+i*t:t}static Parse(e){const t=new k(e.name,e.property,e.framePerSecond,e.dataType,e.loopBehavior),i=e.dataType,s=[];let r,n;for(e.enableBlending&&(t.enableBlending=e.enableBlending),e.blendingSpeed&&(t.blendingSpeed=e.blendingSpeed),n=0;n<e.keys.length;n++){const o=e.keys[n];let h,l,c;switch(i){case k.ANIMATIONTYPE_FLOAT:r=o.values[0],o.values.length>=2&&(h=o.values[1]),o.values.length>=3&&(l=o.values[2]),o.values.length>=4&&(c=o.values[3]);break;case k.ANIMATIONTYPE_QUATERNION:if(r=W.FromArray(o.values),o.values.length>=8){const f=W.FromArray(o.values.slice(4,8));f.equals(W.Zero())||(h=f)}if(o.values.length>=12){const f=W.FromArray(o.values.slice(8,12));f.equals(W.Zero())||(l=f)}o.values.length>=13&&(c=o.values[12]);break;case k.ANIMATIONTYPE_MATRIX:r=P.FromArray(o.values),o.values.length>=17&&(c=o.values[16]);break;case k.ANIMATIONTYPE_COLOR3:r=q.FromArray(o.values),o.values[3]&&(h=q.FromArray(o.values[3])),o.values[4]&&(l=q.FromArray(o.values[4])),o.values[5]&&(c=o.values[5]);break;case k.ANIMATIONTYPE_COLOR4:r=fe.FromArray(o.values),o.values[4]&&(h=fe.FromArray(o.values[4])),o.values[5]&&(l=fe.FromArray(o.values[5])),o.values[6]&&(c=fe.FromArray(o.values[6]));break;case k.ANIMATIONTYPE_VECTOR3:default:r=_.FromArray(o.values),o.values[3]&&(h=_.FromArray(o.values[3])),o.values[4]&&(l=_.FromArray(o.values[4])),o.values[5]&&(c=o.values[5]);break}const u={};u.frame=o.frame,u.value=r,h!=null&&(u.inTangent=h),l!=null&&(u.outTangent=l),c!=null&&(u.interpolation=c),s.push(u)}if(t.setKeys(s),e.ranges)for(n=0;n<e.ranges.length;n++)r=e.ranges[n],t.createRange(r.name,r.from,r.to);return t}static AppendSerializedAnimations(e,t){le.AppendSerializedAnimations(e,t)}static async ParseFromFileAsync(e,t){return await new Promise((i,s)=>{const r=new gt;r.addEventListener("readystatechange",()=>{if(r.readyState==4)if(r.status==200){let n=JSON.parse(r.responseText);if(n.animations&&(n=n.animations),n.length){const o=[];for(const h of n)o.push(this.Parse(h));i(o)}else{const o=this.Parse(n);e&&(o.name=e),i(o)}}else s("Unable to load the animation")}),r.open("GET",t),r.send()})}static async ParseFromSnippetAsync(e){return await new Promise((t,i)=>{const s=new gt;s.addEventListener("readystatechange",()=>{if(s.readyState==4)if(s.status==200){const r=JSON.parse(JSON.parse(s.responseText).jsonPayload);if(r.animations){const n=JSON.parse(r.animations),o=[];for(const h of n.animations){const l=this.Parse(h);l.snippetId=e,o.push(l)}t(o)}else{const n=JSON.parse(r.animation),o=this.Parse(n);o.snippetId=e,t(o)}}else i("Unable to load the snippet "+e)}),s.open("GET",this.SnippetUrl+"/"+e.replace(/#/g,"/")),s.send()})}}k._UniqueIdGenerator=0;k.AllowMatricesInterpolation=!1;k.AllowMatrixDecomposeForInterpolation=!0;k.SnippetUrl="https://snippet.babylonjs.com";k.ANIMATIONTYPE_FLOAT=0;k.ANIMATIONTYPE_VECTOR3=1;k.ANIMATIONTYPE_QUATERNION=2;k.ANIMATIONTYPE_MATRIX=3;k.ANIMATIONTYPE_COLOR3=4;k.ANIMATIONTYPE_COLOR4=7;k.ANIMATIONTYPE_VECTOR2=5;k.ANIMATIONTYPE_SIZE=6;k.ANIMATIONLOOPMODE_RELATIVE=0;k.ANIMATIONLOOPMODE_CYCLE=1;k.ANIMATIONLOOPMODE_CONSTANT=2;k.ANIMATIONLOOPMODE_YOYO=4;k.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT=5;k.CreateFromSnippetAsync=k.ParseFromSnippetAsync;nt("BABYLON.Animation",k);qe._AnimationRangeFactory=(a,e,t)=>new Hr(a,e,t);class $i{constructor(){this.transitionDuration=450,this.lowerRadiusTransitionRange=2,this.upperRadiusTransitionRange=-2,this._autoTransitionRange=!1,this._attachedCamera=null,this._radiusIsAnimating=!1,this._radiusBounceTransition=null,this._animatables=new Array}get name(){return"Bouncing"}get autoTransitionRange(){return this._autoTransitionRange}set autoTransitionRange(e){if(this._autoTransitionRange===e)return;this._autoTransitionRange=e;const t=this._attachedCamera;t&&(e?this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add(i=>{if(i&&(i.computeWorldMatrix(!0),i.getBoundingInfo)){const s=i.getBoundingInfo().diagonalLength;this.lowerRadiusTransitionRange=s*.05,this.upperRadiusTransitionRange=s*.05}}):this._onMeshTargetChangedObserver&&t.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}get attachedNode(){return this._attachedCamera}init(){}attach(e){this._attachedCamera=e,this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add(()=>{this._attachedCamera&&(this._isRadiusAtLimit(this._attachedCamera.lowerRadiusLimit)&&this._applyBoundRadiusAnimation(this.lowerRadiusTransitionRange),this._isRadiusAtLimit(this._attachedCamera.upperRadiusLimit)&&this._applyBoundRadiusAnimation(this.upperRadiusTransitionRange))})}detach(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)}_isRadiusAtLimit(e){return this._attachedCamera?this._attachedCamera.radius===e&&!this._radiusIsAnimating:!1}_applyBoundRadiusAnimation(e){if(!this._attachedCamera)return;this._radiusBounceTransition||($i.EasingFunction.setEasingMode($i.EasingMode),this._radiusBounceTransition=k.CreateAnimation("radius",k.ANIMATIONTYPE_FLOAT,60,$i.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;const t=k.TransitionTo("radius",this._attachedCamera.radius+e,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,()=>this._clearAnimationLocks());t&&this._animatables.push(t)}_clearAnimationLocks(){this._radiusIsAnimating=!1,this._attachedCamera&&(this._attachedCamera.wheelPrecision=this._cachedWheelPrecision)}stopAllAnimations(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()}}$i.EasingFunction=new _u(.3);$i.EasingMode=bt.EASINGMODE_EASEOUT;class yt{constructor(){this.onTargetFramingAnimationEndObservable=new O,this._mode=yt.FitFrustumSidesMode,this._radiusScale=1,this._positionScale=.5,this._defaultElevation=.3,this._elevationReturnTime=1500,this._elevationReturnWaitTime=1e3,this._zoomStopsAnimation=!1,this._framingTime=1500,this.autoCorrectCameraLimitsAndSensibility=!0,this._attachedCamera=null,this._isPointerDown=!1,this._lastInteractionTime=-1/0,this._animatables=new Array,this._betaIsAnimating=!1}get name(){return"Framing"}set mode(e){this._mode=e}get mode(){return this._mode}set radiusScale(e){this._radiusScale=e}get radiusScale(){return this._radiusScale}set positionScale(e){this._positionScale=e}get positionScale(){return this._positionScale}set defaultElevation(e){this._defaultElevation=e}get defaultElevation(){return this._defaultElevation}set elevationReturnTime(e){this._elevationReturnTime=e}get elevationReturnTime(){return this._elevationReturnTime}set elevationReturnWaitTime(e){this._elevationReturnWaitTime=e}get elevationReturnWaitTime(){return this._elevationReturnWaitTime}set zoomStopsAnimation(e){this._zoomStopsAnimation=e}get zoomStopsAnimation(){return this._zoomStopsAnimation}set framingTime(e){this._framingTime=e}get framingTime(){return this._framingTime}get attachedNode(){return this._attachedCamera}init(){}attach(e){this._attachedCamera=e;const t=this._attachedCamera.getScene();yt.EasingFunction.setEasingMode(yt.EasingMode),this._onPrePointerObservableObserver=t.onPrePointerObservable.add(i=>{if(i.type===te.POINTERDOWN){this._isPointerDown=!0;return}i.type===te.POINTERUP&&(this._isPointerDown=!1)}),this._onMeshTargetChangedObserver=e.onMeshTargetChangedObservable.add(i=>{i&&i.getBoundingInfo&&this.zoomOnMesh(i,void 0,()=>{this.onTargetFramingAnimationEndObservable.notifyObservers()})}),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add(()=>{this._applyUserInteraction(),this._maintainCameraAboveGround()})}detach(){if(!this._attachedCamera)return;const e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null}zoomOnMesh(e,t=!1,i=null){e.computeWorldMatrix(!0);const s=e.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(s.minimumWorld,s.maximumWorld,t,i)}zoomOnMeshHierarchy(e,t=!1,i=null){e.computeWorldMatrix(!0);const s=e.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(s.min,s.max,t,i)}zoomOnMeshesHierarchy(e,t=!1,i=null){const s=new _(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r=new _(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(let n=0;n<e.length;n++){const o=e[n].getHierarchyBoundingVectors(!0);_.CheckExtends(o.min,s,r),_.CheckExtends(o.max,s,r)}this.zoomOnBoundingInfo(s,r,t,i)}zoomOnBoundingInfo(e,t,i=!1,s=null){let r;if(!this._attachedCamera)return!1;const n=e.y,o=t.y,h=n+(o-n)*this._positionScale,l=t.subtract(e).scale(.5);if(!isFinite(h))return!1;if(i)r=new _(0,h,0);else{const f=e.add(l);r=new _(f.x,h,f.z)}this._vectorTransition||(this._vectorTransition=k.CreateAnimation("target",k.ANIMATIONTYPE_VECTOR3,60,yt.EasingFunction)),this._betaIsAnimating=!0;let c=k.TransitionTo("target",r,this._attachedCamera,this._attachedCamera.getScene(),60,this._vectorTransition,this._framingTime);c&&this._animatables.push(c);let u=0;if(this._mode===yt.FitFrustumSidesMode){const f=this._calculateLowerRadiusFromModelBoundingSphere(e,t);this.autoCorrectCameraLimitsAndSensibility&&(this._attachedCamera.lowerRadiusLimit=l.length()+this._attachedCamera.minZ),u=f}else this._mode===yt.IgnoreBoundsSizeMode&&(u=this._calculateLowerRadiusFromModelBoundingSphere(e,t),this.autoCorrectCameraLimitsAndSensibility&&this._attachedCamera.lowerRadiusLimit===null&&(this._attachedCamera.lowerRadiusLimit=this._attachedCamera.minZ));if(this.autoCorrectCameraLimitsAndSensibility){const f=t.subtract(e).length();this._attachedCamera.panningSensibility=5e3/f,this._attachedCamera.wheelPrecision=100/u}return this._radiusTransition||(this._radiusTransition=k.CreateAnimation("radius",k.ANIMATIONTYPE_FLOAT,60,yt.EasingFunction)),c=k.TransitionTo("radius",u,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusTransition,this._framingTime,()=>{this.stopAllAnimations(),s&&s(),this._attachedCamera&&this._attachedCamera.useInputToRestoreState&&this._attachedCamera.storeState()}),c&&this._animatables.push(c),!0}_calculateLowerRadiusFromModelBoundingSphere(e,t){const i=this._attachedCamera;if(!i)return 0;let s=i._calculateLowerRadiusFromModelBoundingSphere(e,t,this._radiusScale);return i.lowerRadiusLimit&&this._mode===yt.IgnoreBoundsSizeMode&&(s=s<i.lowerRadiusLimit?i.lowerRadiusLimit:s),i.upperRadiusLimit&&(s=s>i.upperRadiusLimit?i.upperRadiusLimit:s),s}_maintainCameraAboveGround(){if(this._elevationReturnTime<0)return;const e=vt.Now-this._lastInteractionTime,t=Math.PI*.5-this._defaultElevation,i=Math.PI*.5;if(this._attachedCamera&&!this._betaIsAnimating&&this._attachedCamera.beta>i&&e>=this._elevationReturnWaitTime){this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=k.CreateAnimation("beta",k.ANIMATIONTYPE_FLOAT,60,yt.EasingFunction));const s=k.TransitionTo("beta",t,this._attachedCamera,this._attachedCamera.getScene(),60,this._betaTransition,this._elevationReturnTime,()=>{this._clearAnimationLocks(),this.stopAllAnimations()});s&&this._animatables.push(s)}}_clearAnimationLocks(){this._betaIsAnimating=!1}_applyUserInteraction(){this.isUserIsMoving&&(this._lastInteractionTime=vt.Now,this.stopAllAnimations(),this._clearAnimationLocks())}stopAllAnimations(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0]&&(this._animatables[0].onAnimationEnd=null,this._animatables[0].stop()),this._animatables.shift()}get isUserIsMoving(){return this._attachedCamera?this._attachedCamera.inertialAlphaOffset!==0||this._attachedCamera.inertialBetaOffset!==0||this._attachedCamera.inertialRadiusOffset!==0||this._attachedCamera.inertialPanningX!==0||this._attachedCamera.inertialPanningY!==0||this._isPointerDown:!1}}yt.EasingFunction=new gu;yt.EasingMode=bt.EASINGMODE_EASEINOUT;yt.IgnoreBoundsSizeMode=0;yt.FitFrustumSidesMode=1;qe.AddNodeConstructor("TargetCamera",(a,e)=>()=>new et(a,_.Zero(),e));const fr=P.Zero(),sn=W.Identity();class et extends J{constructor(e,t,i,s=!0){super(e,t,i,s),this.cameraDirection=new _(0,0,0),this.cameraRotation=new Q(0,0),this.updateUpVectorFromRotation=!1,this.speed=2,this.noRotationConstraint=!1,this.invertRotation=!1,this.inverseRotationSpeed=.2,this._panningEpsilon=Me,this._rotationEpsilon=Me,this.lockedTarget=null,this._currentTarget=_.Zero(),this._initialFocalDistance=1,this._viewMatrix=P.Zero(),this._cameraTransformMatrix=P.Zero(),this._cameraRotationMatrix=P.Zero(),this._transformedReferencePoint=_.Zero(),this._deferredPositionUpdate=new _,this._deferredRotationQuaternionUpdate=new W,this._deferredRotationUpdate=new _,this._deferredUpdated=!1,this._deferOnly=!1,this._cachedRotationZ=0,this._cachedQuaternionRotationZ=0,this._referencePoint=_.Forward(this.getScene().useRightHandedSystem),this.rotation=new _(0,this.getScene().useRightHandedSystem?Math.PI:0,0)}getFrontPosition(e){this.getWorldMatrix();const t=v.Vector3[0],i=v.Vector3[1];return i.set(0,0,this._scene.useRightHandedSystem?-1:1),this.getDirectionToRef(i,t),t.scaleInPlace(e),this.globalPosition.add(t)}_getLockedTargetPosition(){if(!this.lockedTarget)return null;if(this.lockedTarget.absolutePosition){const e=this.lockedTarget;e.computeWorldMatrix().getTranslationToRef(e.absolutePosition)}return this.lockedTarget.absolutePosition||this.lockedTarget}storeState(){return this._storedPosition=this.position.clone(),this._storedRotation=this.rotation.clone(),this.rotationQuaternion&&(this._storedRotationQuaternion=this.rotationQuaternion.clone()),super.storeState()}_restoreStateValues(){return super._restoreStateValues()?(this.position=this._storedPosition.clone(),this.rotation=this._storedRotation.clone(),this.rotationQuaternion&&this._storedRotationQuaternion&&(this.rotationQuaternion=this._storedRotationQuaternion.clone()),this.cameraDirection.copyFromFloats(0,0,0),this.cameraRotation.copyFromFloats(0,0),!0):!1}_initCache(){super._initCache(),this._cache.lockedTarget=new _(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new _(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new W(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)}_updateCache(e){e||super._updateCache();const t=this._getLockedTargetPosition();t?this._cache.lockedTarget?this._cache.lockedTarget.copyFrom(t):this._cache.lockedTarget=t.clone():this._cache.lockedTarget=null,this._cache.rotation.copyFrom(this.rotation),this.rotationQuaternion&&this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)}_isSynchronizedViewMatrix(){if(!super._isSynchronizedViewMatrix())return!1;const e=this._getLockedTargetPosition();return(this._cache.lockedTarget?this._cache.lockedTarget.equals(e):!e)&&(this.rotationQuaternion?this.rotationQuaternion.equals(this._cache.rotationQuaternion):this._cache.rotation.equals(this.rotation))}_computeLocalCameraSpeed(){const e=this.getEngine();return this.speed*Math.sqrt(e.getDeltaTime()/(e.getFps()*100))}setTarget(e){this.upVector.normalize(),this._initialFocalDistance=e.subtract(this.position).length(),this.position.z===e.z&&(this.position.z+=Me),this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),this.getScene().useRightHandedSystem?P.LookAtRHToRef(this.position,e,_.UpReadOnly,fr):P.LookAtLHToRef(this.position,e,_.UpReadOnly,fr),fr.invert();const t=this.rotationQuaternion||sn;W.FromRotationMatrixToRef(fr,t),t.toEulerAnglesToRef(this.rotation),this.rotation.z=0}get target(){return this.getTarget()}set target(e){this.setTarget(e)}getTarget(){return this._currentTarget}_decideIfNeedsToMove(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0}_updatePosition(){if(this.parent){this.parent.getWorldMatrix().invertToRef(v.Matrix[0]),_.TransformNormalToRef(this.cameraDirection,v.Matrix[0],v.Vector3[0]),this._deferredPositionUpdate.addInPlace(v.Vector3[0]),this._deferOnly?this._deferredUpdated=!0:this.position.copyFrom(this._deferredPositionUpdate);return}this._deferredPositionUpdate.addInPlace(this.cameraDirection),this._deferOnly?this._deferredUpdated=!0:this.position.copyFrom(this._deferredPositionUpdate)}_checkInputs(){const e=this.invertRotation?-this.inverseRotationSpeed:1,t=this._decideIfNeedsToMove(),i=this.cameraRotation.x||this.cameraRotation.y;this._deferredUpdated=!1,this._deferredRotationUpdate.copyFrom(this.rotation),this._deferredPositionUpdate.copyFrom(this.position),this.rotationQuaternion&&this._deferredRotationQuaternionUpdate.copyFrom(this.rotationQuaternion),t&&this._updatePosition(),i&&(this.rotationQuaternion&&this.rotationQuaternion.toEulerAnglesToRef(this._deferredRotationUpdate),this._deferredRotationUpdate.x+=this.cameraRotation.x*e,this._deferredRotationUpdate.y+=this.cameraRotation.y*e,this.noRotationConstraint||(this._deferredRotationUpdate.x>1.570796&&(this._deferredRotationUpdate.x=1.570796),this._deferredRotationUpdate.x<-1.570796&&(this._deferredRotationUpdate.x=-1.570796)),this._deferOnly?this._deferredUpdated=!0:this.rotation.copyFrom(this._deferredRotationUpdate),this.rotationQuaternion&&this._deferredRotationUpdate.lengthSquared()&&(W.RotationYawPitchRollToRef(this._deferredRotationUpdate.y,this._deferredRotationUpdate.x,this._deferredRotationUpdate.z,this._deferredRotationQuaternionUpdate),this._deferOnly?this._deferredUpdated=!0:this.rotationQuaternion.copyFrom(this._deferredRotationQuaternionUpdate)));const s=this.speed*this._panningEpsilon,r=this.speed*this._rotationEpsilon;t&&(Math.abs(this.cameraDirection.x)<s&&(this.cameraDirection.x=0),Math.abs(this.cameraDirection.y)<s&&(this.cameraDirection.y=0),Math.abs(this.cameraDirection.z)<s&&(this.cameraDirection.z=0),this.cameraDirection.scaleInPlace(this.inertia)),i&&(Math.abs(this.cameraRotation.x)<r&&(this.cameraRotation.x=0),Math.abs(this.cameraRotation.y)<r&&(this.cameraRotation.y=0),this.cameraRotation.scaleInPlace(this.inertia)),super._checkInputs()}_updateCameraRotationMatrix(){this.rotationQuaternion?this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix):P.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix)}_rotateUpVectorWithCameraRotationMatrix(){return _.TransformNormalToRef(_.UpReadOnly,this._cameraRotationMatrix,this.upVector),this}_getViewMatrix(){return this.lockedTarget&&this.setTarget(this._getLockedTargetPosition()),this._updateCameraRotationMatrix(),this.rotationQuaternion&&this._cachedQuaternionRotationZ!=this.rotationQuaternion.z?(this._rotateUpVectorWithCameraRotationMatrix(),this._cachedQuaternionRotationZ=this.rotationQuaternion.z):this._cachedRotationZ!==this.rotation.z&&(this._rotateUpVectorWithCameraRotationMatrix(),this._cachedRotationZ=this.rotation.z),_.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget),this.updateUpVectorFromRotation&&(this.rotationQuaternion?ts.Y.rotateByQuaternionToRef(this.rotationQuaternion,this.upVector):(W.FromEulerVectorToRef(this.rotation,sn),ts.Y.rotateByQuaternionToRef(sn,this.upVector))),this._computeViewMatrix(this.position,this._currentTarget,this.upVector),this._viewMatrix}_computeViewMatrix(e,t,i){if(this.getScene().useRightHandedSystem?P.LookAtRHToRef(e,t,i,this._viewMatrix):P.LookAtLHToRef(e,t,i,this._viewMatrix),this.parent){const s=this.parent.getWorldMatrix();this._viewMatrix.invert(),this._viewMatrix.multiplyToRef(s,this._viewMatrix),this._viewMatrix.invert(),this._markSyncedWithParent()}}createRigCamera(e,t){if(this.cameraRigMode!==J.RIG_MODE_NONE){const i=new et(e,this.position.clone(),this.getScene());return i.isRigCamera=!0,i.rigParent=this,this.cameraRigMode===J.RIG_MODE_VR&&(this.rotationQuaternion||(this.rotationQuaternion=new W),i._cameraRigParams={},i.rotationQuaternion=new W),i.mode=this.mode,i.orthoLeft=this.orthoLeft,i.orthoRight=this.orthoRight,i.orthoTop=this.orthoTop,i.orthoBottom=this.orthoBottom,i}return null}_updateRigCameras(){const e=this._rigCameras[0],t=this._rigCameras[1];switch(this.computeWorldMatrix(),this.cameraRigMode){case J.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case J.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case J.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case J.RIG_MODE_STEREOSCOPIC_OVERUNDER:case J.RIG_MODE_STEREOSCOPIC_INTERLACED:{const i=this.cameraRigMode===J.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?1:-1,s=this.cameraRigMode===J.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?-1:1;this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*i,e),this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*s,t);break}case J.RIG_MODE_VR:e.rotationQuaternion&&t.rotationQuaternion&&this.rotationQuaternion?(e.rotationQuaternion.copyFrom(this.rotationQuaternion),t.rotationQuaternion.copyFrom(this.rotationQuaternion)):(e.rotation.copyFrom(this.rotation),t.rotation.copyFrom(this.rotation)),e.position.copyFrom(this.position),t.position.copyFrom(this.position);break}super._updateRigCameras()}_getRigCamPositionAndTarget(e,t){this.getTarget().subtractToRef(this.position,et._TargetFocalPoint),et._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);const s=et._TargetFocalPoint.addInPlace(this.position);P.TranslationToRef(-s.x,-s.y,-s.z,et._TargetTransformMatrix),et._TargetTransformMatrix.multiplyToRef(P.RotationAxis(t.upVector,e),et._RigCamTransformMatrix),P.TranslationToRef(s.x,s.y,s.z,et._TargetTransformMatrix),et._RigCamTransformMatrix.multiplyToRef(et._TargetTransformMatrix,et._RigCamTransformMatrix),_.TransformCoordinatesToRef(this.position,et._RigCamTransformMatrix,t.position),t.setTarget(s)}getClassName(){return"TargetCamera"}}et._RigCamTransformMatrix=new P;et._TargetTransformMatrix=new P;et._TargetFocalPoint=new _;T([R()],et.prototype,"updateUpVectorFromRotation",void 0);T([qt()],et.prototype,"rotation",void 0);T([R()],et.prototype,"speed",void 0);T([uo("lockedTargetId")],et.prototype,"lockedTarget",void 0);var Xs={};class Ru{constructor(e){this.attachedToElement=!1,this.attached={},this.camera=e,this.checkInputs=()=>{}}add(e){const t=e.getSimpleName();if(this.attached[t]){w.Warn("camera input of type "+t+" already exists on camera");return}this.attached[t]=e,e.camera=this.camera,e.checkInputs&&(this.checkInputs=this._addCheckInputs(e.checkInputs.bind(e))),this.attachedToElement&&e.attachControl(this.noPreventDefault)}remove(e){for(const t in this.attached){const i=this.attached[t];if(i===e){i.detachControl(),i.camera=null,delete this.attached[t],this.rebuildInputCheck();return}}}removeByType(e){for(const t in this.attached){const i=this.attached[t];i.getClassName()===e&&(i.detachControl(),i.camera=null,delete this.attached[t],this.rebuildInputCheck())}}_addCheckInputs(e){const t=this.checkInputs;return()=>{t(),e()}}attachInput(e){this.attachedToElement&&e.attachControl(this.noPreventDefault)}attachElement(e=!1){if(!this.attachedToElement){e=J.ForceAttachControlToAlwaysPreventDefault?!1:e,this.attachedToElement=!0,this.noPreventDefault=e;for(const t in this.attached)this.attached[t].attachControl(e)}}detachElement(e=!1){for(const t in this.attached)this.attached[t].detachControl(),e&&(this.attached[t].camera=null);this.attachedToElement=!1}rebuildInputCheck(){this.checkInputs=()=>{};for(const e in this.attached){const t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}}clear(){this.attachedToElement&&this.detachElement(!0),this.attached={},this.attachedToElement=!1,this.checkInputs=()=>{}}serialize(e){const t={};for(const i in this.attached){const s=this.attached[i],r=le.Serialize(s);t[s.getClassName()]=r}e.inputsmgr=t}parse(e){const t=e.inputsmgr;if(t){this.clear();for(const i in t){const s=Xs[i];if(s){const r=t[i],n=le.Parse(()=>new s,r,null);this.add(n)}}}else for(const i in this.attached){const s=Xs[this.attached[i].getClassName()];if(s){const r=le.Parse(()=>new s,e,null);this.remove(this.attached[i]),this.add(r)}}}}class bh{constructor(){this._currentMousePointerIdDown=-1,this.buttons=[0,1,2]}attachControl(e){e=se.BackCompatCameraNoPreventDefault(arguments);const t=this.camera.getEngine(),i=t.getInputElement();let s=0,r=null;this._pointA=null,this._pointB=null,this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0,this._pointerInput=o=>{const h=o.event,l=h.pointerType==="touch";if(o.type!==te.POINTERMOVE&&this.buttons.indexOf(h.button)===-1)return;const c=h.target;if(this._altKey=h.altKey,this._ctrlKey=h.ctrlKey,this._metaKey=h.metaKey,this._shiftKey=h.shiftKey,this._buttonsPressed=h.buttons,t.isPointerLock){const u=h.movementX,f=h.movementY;this.onTouch(null,u,f),this._pointA=null,this._pointB=null}else{if(o.type!==te.POINTERDOWN&&o.type!==te.POINTERDOUBLETAP&&l&&this._pointA?.pointerId!==h.pointerId&&this._pointB?.pointerId!==h.pointerId)return;if(o.type===te.POINTERDOWN&&(this._currentMousePointerIdDown===-1||l)){try{c?.setPointerCapture(h.pointerId)}catch{}if(this._pointA===null)this._pointA={x:h.clientX,y:h.clientY,pointerId:h.pointerId,type:h.pointerType,button:h.button};else if(this._pointB===null)this._pointB={x:h.clientX,y:h.clientY,pointerId:h.pointerId,type:h.pointerType,button:h.button};else return;this._currentMousePointerIdDown===-1&&!l&&(this._currentMousePointerIdDown=h.pointerId),this.onButtonDown(h),e||(h.preventDefault(),i&&i.focus())}else if(o.type===te.POINTERDOUBLETAP)this.onDoubleTap(h.pointerType);else if(o.type===te.POINTERUP&&(this._currentMousePointerIdDown===h.pointerId||l)){try{c?.releasePointerCapture(h.pointerId)}catch{}l||(this._pointB=null),t._badOS?this._pointA=this._pointB=null:this._pointB&&this._pointA&&this._pointA.pointerId==h.pointerId?(this._pointA=this._pointB,this._pointB=null):this._pointA&&this._pointB&&this._pointB.pointerId==h.pointerId?this._pointB=null:this._pointA=this._pointB=null,(s!==0||r)&&(this.onMultiTouch(this._pointA,this._pointB,s,0,r,null),s=0,r=null),this._currentMousePointerIdDown=-1,this.onButtonUp(h),e||h.preventDefault()}else if(o.type===te.POINTERMOVE){if(e||h.preventDefault(),this._pointA&&this._pointB===null){const u=h.clientX-this._pointA.x,f=h.clientY-this._pointA.y;this._pointA.x=h.clientX,this._pointA.y=h.clientY,this.onTouch(this._pointA,u,f)}else if(this._pointA&&this._pointB){const u=this._pointA.pointerId===h.pointerId?this._pointA:this._pointB;u.x=h.clientX,u.y=h.clientY;const f=this._pointA.x-this._pointB.x,d=this._pointA.y-this._pointB.y,g=f*f+d*d,p={x:(this._pointA.x+this._pointB.x)/2,y:(this._pointA.y+this._pointB.y)/2,pointerId:h.pointerId,type:o.type};this.onMultiTouch(this._pointA,this._pointB,s,g,r,p),r=p,s=g}}}},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,te.POINTERDOWN|te.POINTERUP|te.POINTERMOVE|te.POINTERDOUBLETAP),this._onLostFocus=()=>{this._pointA=this._pointB=null,s=0,r=null,this.onLostFocus()},this._contextMenuBind=o=>this.onContextMenu(o),i&&i.addEventListener("contextmenu",this._contextMenuBind,!1);const n=this.camera.getScene().getEngine().getHostWindow();n&&se.RegisterTopRootEvents(n,[{name:"blur",handler:this._onLostFocus}])}detachControl(){if(this._onLostFocus){const e=this.camera.getScene().getEngine().getHostWindow();e&&se.UnregisterTopRootEvents(e,[{name:"blur",handler:this._onLostFocus}])}if(this._observer){if(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._contextMenuBind){const e=this.camera.getScene().getEngine().getInputElement();e&&e.removeEventListener("contextmenu",this._contextMenuBind)}this._onLostFocus=null}this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0,this._currentMousePointerIdDown=-1}getClassName(){return"BaseCameraPointersInput"}getSimpleName(){return"pointers"}onDoubleTap(e){}onTouch(e,t,i){}onMultiTouch(e,t,i,s,r,n){}onContextMenu(e){e.preventDefault()}onButtonDown(e){}onButtonUp(e){}onLostFocus(){}}T([R()],bh.prototype,"buttons",void 0);class Vr extends bh{constructor(){super(...arguments),this.pinchZoom=!0,this.multiTouchPanning=!0,this.multiTouchPanAndZoom=!0,this._isPinching=!1,this._twoFingerActivityCount=0,this._shouldStartPinchZoom=!1}_computePinchZoom(e,t){}_computeMultiTouchPanning(e,t){}onMultiTouch(e,t,i,s,r,n){i===0&&r===null||s===0&&n===null||(this.multiTouchPanAndZoom?(this._computePinchZoom(i,s),this._computeMultiTouchPanning(r,n)):this.multiTouchPanning&&this.pinchZoom?(this._twoFingerActivityCount++,this._isPinching||this._shouldStartPinchZoom?(this._computePinchZoom(i,s),this._isPinching=!0):this._computeMultiTouchPanning(r,n)):this.multiTouchPanning?this._computeMultiTouchPanning(r,n):this.pinchZoom&&this._computePinchZoom(i,s))}onButtonUp(e){this._twoFingerActivityCount=0,this._isPinching=!1}onLostFocus(){this._twoFingerActivityCount=0,this._isPinching=!1}}T([R()],Vr.prototype,"pinchZoom",void 0);T([R()],Vr.prototype,"multiTouchPanning",void 0);T([R()],Vr.prototype,"multiTouchPanAndZoom",void 0);class jt extends Vr{constructor(){super(...arguments),this.buttons=[0,1,2],this.angularSensibilityX=1e3,this.angularSensibilityY=1e3,this.pinchPrecision=12,this.pinchDeltaPercentage=0,this.useNaturalPinchZoom=!1,this.panningSensibility=1e3,this.pinchInwards=!0,this._isPanClick=!1}getClassName(){return"ArcRotateCameraPointersInput"}_computeMultiTouchPanning(e,t){if(this.panningSensibility!==0&&e&&t){const i=t.x-e.x,s=t.y-e.y;this.camera.inertialPanningX+=-i/this.panningSensibility,this.camera.inertialPanningY+=s/this.panningSensibility}}_computePinchZoom(e,t){const i=this.camera.radius||jt.MinimumRadiusForPinch;this.useNaturalPinchZoom?this.camera.radius=i*Math.sqrt(e)/Math.sqrt(t):this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=(t-e)*.001*i*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(t-e)/(this.pinchPrecision*(this.pinchInwards?1:-1)*(this.angularSensibilityX+this.angularSensibilityY)/2)}onTouch(e,t,i){this.panningSensibility!==0&&(this._ctrlKey&&this.camera._useCtrlForPanning||this._isPanClick)?(this.camera.inertialPanningX+=-t/this.panningSensibility,this.camera.inertialPanningY+=i/this.panningSensibility):(this.camera.inertialAlphaOffset-=t/this.angularSensibilityX,this.camera.inertialBetaOffset-=i/this.angularSensibilityY)}onDoubleTap(){this.camera.useInputToRestoreState&&this.camera.restoreState()}onMultiTouch(e,t,i,s,r,n){this._shouldStartPinchZoom=this._twoFingerActivityCount<20&&Math.abs(Math.sqrt(s)-Math.sqrt(i))>this.camera.pinchToPanMaxDistance,super.onMultiTouch(e,t,i,s,r,n)}onButtonDown(e){this._isPanClick=e.button===this.camera._panningMouseButton,super.onButtonDown(e)}onButtonUp(e){super.onButtonUp(e)}onLostFocus(){this._isPanClick=!1,super.onLostFocus()}}jt.MinimumRadiusForPinch=.001;T([R()],jt.prototype,"buttons",void 0);T([R()],jt.prototype,"angularSensibilityX",void 0);T([R()],jt.prototype,"angularSensibilityY",void 0);T([R()],jt.prototype,"pinchPrecision",void 0);T([R()],jt.prototype,"pinchDeltaPercentage",void 0);T([R()],jt.prototype,"useNaturalPinchZoom",void 0);T([R()],jt.prototype,"panningSensibility",void 0);Xs.ArcRotateCameraPointersInput=jt;class Ks{}Ks.KEYDOWN=1;Ks.KEYUP=2;class An{constructor(e,t){this.type=e,this.event=t}}class Aa extends An{get skipOnPointerObservable(){return this.skipOnKeyboardObservable}set skipOnPointerObservable(e){this.skipOnKeyboardObservable=e}constructor(e,t){super(e,t),this.type=e,this.event=t,this.skipOnKeyboardObservable=!1}}class ti{constructor(){this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this.keysReset=[220],this.panningSensibility=50,this.zoomingSensibility=25,this.useAltToZoom=!0,this.angularSpeed=.01,this._keys=new Array}attachControl(e){e=se.BackCompatCameraNoPreventDefault(arguments),!this._onCanvasBlurObserver&&(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add(()=>{this._keys.length=0}),this._onKeyboardObserver=this._scene.onKeyboardObservable.add(t=>{const i=t.event;if(!i.metaKey){if(t.type===Ks.KEYDOWN)this._ctrlPressed=i.ctrlKey,this._altPressed=i.altKey,(this.keysUp.indexOf(i.keyCode)!==-1||this.keysDown.indexOf(i.keyCode)!==-1||this.keysLeft.indexOf(i.keyCode)!==-1||this.keysRight.indexOf(i.keyCode)!==-1||this.keysReset.indexOf(i.keyCode)!==-1)&&(this._keys.indexOf(i.keyCode)===-1&&this._keys.push(i.keyCode),i.preventDefault&&(e||i.preventDefault()));else if(this.keysUp.indexOf(i.keyCode)!==-1||this.keysDown.indexOf(i.keyCode)!==-1||this.keysLeft.indexOf(i.keyCode)!==-1||this.keysRight.indexOf(i.keyCode)!==-1||this.keysReset.indexOf(i.keyCode)!==-1){const s=this._keys.indexOf(i.keyCode);s>=0&&this._keys.splice(s,1),i.preventDefault&&(e||i.preventDefault())}}}))}detachControl(){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys.length=0}checkInputs(){if(this._onKeyboardObserver){const e=this.camera;for(let t=0;t<this._keys.length;t++){const i=this._keys[t];this.keysLeft.indexOf(i)!==-1?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningX-=1/this.panningSensibility:e.inertialAlphaOffset-=this.angularSpeed:this.keysUp.indexOf(i)!==-1?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningY+=1/this.panningSensibility:this._altPressed&&this.useAltToZoom?e.inertialRadiusOffset+=1/this.zoomingSensibility:e.inertialBetaOffset-=this.angularSpeed:this.keysRight.indexOf(i)!==-1?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningX+=1/this.panningSensibility:e.inertialAlphaOffset+=this.angularSpeed:this.keysDown.indexOf(i)!==-1?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningY-=1/this.panningSensibility:this._altPressed&&this.useAltToZoom?e.inertialRadiusOffset-=1/this.zoomingSensibility:e.inertialBetaOffset+=this.angularSpeed:this.keysReset.indexOf(i)!==-1&&e.useInputToRestoreState&&e.restoreState()}}}getClassName(){return"ArcRotateCameraKeyboardMoveInput"}getSimpleName(){return"keyboard"}}T([R()],ti.prototype,"keysUp",void 0);T([R()],ti.prototype,"keysDown",void 0);T([R()],ti.prototype,"keysLeft",void 0);T([R()],ti.prototype,"keysRight",void 0);T([R()],ti.prototype,"keysReset",void 0);T([R()],ti.prototype,"panningSensibility",void 0);T([R()],ti.prototype,"zoomingSensibility",void 0);T([R()],ti.prototype,"useAltToZoom",void 0);T([R()],ti.prototype,"angularSpeed",void 0);Xs.ArcRotateCameraKeyboardMoveInput=ti;var Ra;(function(a){a[a.PointerMove=0]="PointerMove",a[a.PointerDown=1]="PointerDown",a[a.PointerUp=2]="PointerUp"})(Ra||(Ra={}));class sr{}sr.DOM_DELTA_PIXEL=0;sr.DOM_DELTA_LINE=1;sr.DOM_DELTA_PAGE=2;const yu=40;class rr{constructor(){this.wheelPrecision=3,this.zoomToMouseLocation=!1,this.wheelDeltaPercentage=0,this.customComputeDeltaFromMouseWheel=null,this._viewOffset=new _(0,0,0),this._globalOffset=new _(0,0,0),this._inertialPanning=_.Zero()}_computeDeltaFromMouseWheelLegacyEvent(e,t){let i=0;const s=e*.01*this.wheelDeltaPercentage*t;return e>0?i=s/(1+this.wheelDeltaPercentage):i=s*(1+this.wheelDeltaPercentage),i}attachControl(e){e=se.BackCompatCameraNoPreventDefault(arguments),this._wheel=t=>{if(t.type!==te.POINTERWHEEL)return;const i=t.event;let s=0;const r=i.deltaMode===sr.DOM_DELTA_LINE?yu:1,n=-(i.deltaY*r);if(this.customComputeDeltaFromMouseWheel)s=this.customComputeDeltaFromMouseWheel(n,this,i);else if(this.wheelDeltaPercentage){if(s=this._computeDeltaFromMouseWheelLegacyEvent(n,this.camera.radius),s>0){let o=this.camera.radius,h=this.camera.inertialRadiusOffset+s;for(let l=0;l<20&&!(o<=h||Math.abs(h*this.camera.inertia)<.001);l++)o-=h,h*=this.camera.inertia;o=be(o,0,Number.MAX_VALUE),s=this._computeDeltaFromMouseWheelLegacyEvent(n,o)}}else s=n/(this.wheelPrecision*40);s&&(this.zoomToMouseLocation?(this._hitPlane||this._updateHitPlane(),this._zoomToMouse(s)):this.camera.inertialRadiusOffset+=s),i.preventDefault&&(e||i.preventDefault())},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel,te.POINTERWHEEL),this.zoomToMouseLocation&&this._inertialPanning.setAll(0)}detachControl(){this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._wheel=null)}checkInputs(){if(!this.zoomToMouseLocation)return;const e=this.camera;0+e.inertialAlphaOffset+e.inertialBetaOffset+e.inertialRadiusOffset&&(this._updateHitPlane(),e.target.addInPlace(this._inertialPanning),this._inertialPanning.scaleInPlace(e.inertia),this._zeroIfClose(this._inertialPanning))}getClassName(){return"ArcRotateCameraMouseWheelInput"}getSimpleName(){return"mousewheel"}_updateHitPlane(){const e=this.camera,t=e.target.subtract(e.position);this._hitPlane=Ht.FromPositionAndNormal(e.target,t)}_getPosition(){const e=this.camera,t=e.getScene(),i=t.createPickingRay(t.pointerX,t.pointerY,P.Identity(),e,!1);(e.targetScreenOffset.x!==0||e.targetScreenOffset.y!==0)&&(this._viewOffset.set(e.targetScreenOffset.x,e.targetScreenOffset.y,0),e.getViewMatrix().invertToRef(e._cameraTransformMatrix),this._globalOffset=_.TransformNormal(this._viewOffset,e._cameraTransformMatrix),i.origin.addInPlace(this._globalOffset));let s=0;return this._hitPlane&&(s=i.intersectsPlane(this._hitPlane)??0),i.origin.addInPlace(i.direction.scaleInPlace(s))}_zoomToMouse(e){const t=this.camera,i=1-t.inertia;if(t.lowerRadiusLimit){const h=t.lowerRadiusLimit??0;t.radius-(t.inertialRadiusOffset+e)/i<h&&(e=(t.radius-h)*i-t.inertialRadiusOffset)}if(t.upperRadiusLimit){const h=t.upperRadiusLimit??0;t.radius-(t.inertialRadiusOffset+e)/i>h&&(e=(t.radius-h)*i-t.inertialRadiusOffset)}const r=e/i/t.radius,n=this._getPosition(),o=v.Vector3[6];n.subtractToRef(t.target,o),o.scaleInPlace(r),o.scaleInPlace(i),this._inertialPanning.addInPlace(o),t.inertialRadiusOffset+=e}_zeroIfClose(e){Math.abs(e.x)<Me&&(e.x=0),Math.abs(e.y)<Me&&(e.y=0),Math.abs(e.z)<Me&&(e.z=0)}}T([R()],rr.prototype,"wheelPrecision",void 0);T([R()],rr.prototype,"zoomToMouseLocation",void 0);T([R()],rr.prototype,"wheelDeltaPercentage",void 0);Xs.ArcRotateCameraMouseWheelInput=rr;class xu extends Ru{constructor(e){super(e)}addMouseWheel(){return this.add(new rr),this}addPointers(){return this.add(new jt),this}addKeyboard(){return this.add(new ti),this}}qe.AddNodeConstructor("ArcRotateCamera",(a,e)=>()=>new Ie(a,0,0,1,_.Zero(),e));function Eh(a){let e=Math.PI/2;return a.x===0&&a.z===0||(e=Math.acos(a.x/Math.sqrt(Math.pow(a.x,2)+Math.pow(a.z,2)))),a.z<0&&(e=2*Math.PI-e),e}function Ah(a,e){return Math.acos(a/e)}function mt(a,e){return isNaN(a)?e:a}class Ie extends et{get target(){return this._target}set target(e){this.setTarget(e)}get targetHost(){return this._targetHost}set targetHost(e){e&&this.setTarget(e)}getTarget(){return this.target}get position(){return this._position}set position(e){this.setPosition(e)}set upVector(e){this._upToYMatrix||(this._yToUpMatrix=new P,this._upToYMatrix=new P,this._upVector=_.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()}get upVector(){return this._upVector}setMatUp(){P.RotationAlignToRef(_.UpReadOnly,this._upVector,this._yToUpMatrix),P.RotationAlignToRef(this._upVector,_.UpReadOnly,this._upToYMatrix)}get angularSensibilityX(){const e=this.inputs.attached.pointers;return e?e.angularSensibilityX:0}set angularSensibilityX(e){const t=this.inputs.attached.pointers;t&&(t.angularSensibilityX=e)}get angularSensibilityY(){const e=this.inputs.attached.pointers;return e?e.angularSensibilityY:0}set angularSensibilityY(e){const t=this.inputs.attached.pointers;t&&(t.angularSensibilityY=e)}get pinchPrecision(){const e=this.inputs.attached.pointers;return e?e.pinchPrecision:0}set pinchPrecision(e){const t=this.inputs.attached.pointers;t&&(t.pinchPrecision=e)}get pinchDeltaPercentage(){const e=this.inputs.attached.pointers;return e?e.pinchDeltaPercentage:0}set pinchDeltaPercentage(e){const t=this.inputs.attached.pointers;t&&(t.pinchDeltaPercentage=e)}get useNaturalPinchZoom(){const e=this.inputs.attached.pointers;return e?e.useNaturalPinchZoom:!1}set useNaturalPinchZoom(e){const t=this.inputs.attached.pointers;t&&(t.useNaturalPinchZoom=e)}get panningSensibility(){const e=this.inputs.attached.pointers;return e?e.panningSensibility:0}set panningSensibility(e){const t=this.inputs.attached.pointers;t&&(t.panningSensibility=e)}get keysUp(){const e=this.inputs.attached.keyboard;return e?e.keysUp:[]}set keysUp(e){const t=this.inputs.attached.keyboard;t&&(t.keysUp=e)}get keysDown(){const e=this.inputs.attached.keyboard;return e?e.keysDown:[]}set keysDown(e){const t=this.inputs.attached.keyboard;t&&(t.keysDown=e)}get keysLeft(){const e=this.inputs.attached.keyboard;return e?e.keysLeft:[]}set keysLeft(e){const t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)}get keysRight(){const e=this.inputs.attached.keyboard;return e?e.keysRight:[]}set keysRight(e){const t=this.inputs.attached.keyboard;t&&(t.keysRight=e)}get wheelPrecision(){const e=this.inputs.attached.mousewheel;return e?e.wheelPrecision:0}set wheelPrecision(e){const t=this.inputs.attached.mousewheel;t&&(t.wheelPrecision=e)}get zoomToMouseLocation(){const e=this.inputs.attached.mousewheel;return e?e.zoomToMouseLocation:!1}set zoomToMouseLocation(e){const t=this.inputs.attached.mousewheel;t&&(t.zoomToMouseLocation=e)}get wheelDeltaPercentage(){const e=this.inputs.attached.mousewheel;return e?e.wheelDeltaPercentage:0}set wheelDeltaPercentage(e){const t=this.inputs.attached.mousewheel;t&&(t.wheelDeltaPercentage=e)}get isInterpolating(){return this._isInterpolating}get bouncingBehavior(){return this._bouncingBehavior}get useBouncingBehavior(){return this._bouncingBehavior!=null}set useBouncingBehavior(e){e!==this.useBouncingBehavior&&(e?(this._bouncingBehavior=new $i,this.addBehavior(this._bouncingBehavior)):this._bouncingBehavior&&(this.removeBehavior(this._bouncingBehavior),this._bouncingBehavior=null))}get framingBehavior(){return this._framingBehavior}get useFramingBehavior(){return this._framingBehavior!=null}set useFramingBehavior(e){e!==this.useFramingBehavior&&(e?(this._framingBehavior=new yt,this.addBehavior(this._framingBehavior)):this._framingBehavior&&(this.removeBehavior(this._framingBehavior),this._framingBehavior=null))}get autoRotationBehavior(){return this._autoRotationBehavior}get useAutoRotationBehavior(){return this._autoRotationBehavior!=null}set useAutoRotationBehavior(e){e!==this.useAutoRotationBehavior&&(e?(this._autoRotationBehavior=new du,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))}constructor(e,t,i,s,r,n,o=!0){super(e,_.Zero(),n,o),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.lowerAlphaLimit=null,this.upperAlphaLimit=null,this.lowerBetaLimit=.01,this.upperBetaLimit=Math.PI-.01,this.lowerRadiusLimit=null,this.upperRadiusLimit=null,this.lowerTargetYLimit=-1/0,this.inertialPanningX=0,this.inertialPanningY=0,this.pinchToPanMaxDistance=20,this.panningDistanceLimit=null,this.panningOriginTarget=_.Zero(),this.panningInertia=.9,this.zoomOnFactor=1,this.targetScreenOffset=Q.Zero(),this.allowUpsideDown=!0,this.useInputToRestoreState=!0,this.restoreStateInterpolationFactor=0,this._currentInterpolationFactor=0,this._viewMatrix=new P,this.panningAxis=new _(1,1,0),this._transformedDirection=new _,this.mapPanning=!1,this._isInterpolating=!1,this.onMeshTargetChangedObservable=new O,this.checkCollisions=!1,this.collisionRadius=new _(.5,.5,.5),this._previousPosition=_.Zero(),this._collisionVelocity=_.Zero(),this._newPosition=_.Zero(),this._computationVector=_.Zero(),this._goalAlpha=NaN,this._goalBeta=NaN,this._goalRadius=NaN,this._goalTarget=new _(NaN,NaN,NaN),this._goalTargetScreenOffset=new Q(NaN,NaN),this._onCollisionPositionChange=(h,l,c=null)=>{c?(this.setPosition(l),this.onCollide&&this.onCollide(c)):this._previousPosition.copyFrom(this._position);const u=Math.cos(this.alpha),f=Math.sin(this.alpha),d=Math.cos(this.beta);let g=Math.sin(this.beta);g===0&&(g=1e-4);const p=this._getTargetPosition();this._computationVector.copyFromFloats(this.radius*u*g,this.radius*d,this.radius*f*g),p.addToRef(this._computationVector,this._newPosition),this._position.copyFrom(this._newPosition);let m=this.upVector;this.allowUpsideDown&&this.beta<0&&(m=m.clone(),m=m.negate()),this._computeViewMatrix(this._position,p,m),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y),this._collisionTriggered=!1},this._target=_.Zero(),r&&this.setTarget(r),this.alpha=t,this.beta=i,this.radius=s,this.getViewMatrix(),this.inputs=new xu(this),this.inputs.addKeyboard().addMouseWheel().addPointers()}_initCache(){super._initCache(),this._cache._target=new _(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.alpha=void 0,this._cache.beta=void 0,this._cache.radius=void 0,this._cache.targetScreenOffset=Q.Zero()}_updateCache(e){e||super._updateCache(),this._cache._target.copyFrom(this._getTargetPosition()),this._cache.alpha=this.alpha,this._cache.beta=this.beta,this._cache.radius=this.radius,this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset)}_getTargetPosition(){if(this._targetHost&&this._targetHost.getAbsolutePosition){const t=this._targetHost.getAbsolutePosition();this._targetBoundingCenter?t.addToRef(this._targetBoundingCenter,this._target):this._target.copyFrom(t)}const e=this._getLockedTargetPosition();return e||this._target}storeState(){return this._storedAlpha=this.alpha,this._storedBeta=this.beta,this._storedRadius=this.radius,this._storedTarget=this._getTargetPosition().clone(),this._storedTargetScreenOffset=this.targetScreenOffset.clone(),super.storeState()}_restoreStateValues(){return this.hasStateStored()&&this.restoreStateInterpolationFactor>Me&&this.restoreStateInterpolationFactor<1?(this.interpolateTo(this._storedAlpha,this._storedBeta,this._storedRadius,this._storedTarget,this._storedTargetScreenOffset,this.restoreStateInterpolationFactor),!0):super._restoreStateValues()?(this.setTarget(this._storedTarget.clone()),this.alpha=this._storedAlpha,this.beta=this._storedBeta,this.radius=this._storedRadius,this.targetScreenOffset=this._storedTargetScreenOffset.clone(),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,!0):!1}stopInterpolation(){this._goalAlpha=NaN,this._goalBeta=NaN,this._goalRadius=NaN,this._goalTarget.set(NaN,NaN,NaN),this._goalTargetScreenOffset.set(NaN,NaN)}interpolateTo(e=this.alpha,t=this.beta,i=this.radius,s=this.target,r=this.targetScreenOffset,n){this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,n!=null?this._currentInterpolationFactor=n:this.restoreStateInterpolationFactor!==0?this._currentInterpolationFactor=this.restoreStateInterpolationFactor:this._currentInterpolationFactor=.1,this._goalAlpha=mt(e,this._goalAlpha),this._goalBeta=mt(t,this._goalBeta),this._goalRadius=mt(i,this._goalRadius),this._goalTarget.set(mt(s.x,this._goalTarget.x),mt(s.y,this._goalTarget.y),mt(s.z,this._goalTarget.z)),this._goalTargetScreenOffset.set(mt(r.x,this._goalTargetScreenOffset.x),mt(r.y,this._goalTargetScreenOffset.y)),this._goalAlpha=be(this._goalAlpha,this.lowerAlphaLimit??-1/0,this.upperAlphaLimit??1/0),this._goalBeta=be(this._goalBeta,this.lowerBetaLimit??-1/0,this.upperBetaLimit??1/0),this._goalRadius=be(this._goalRadius,this.lowerRadiusLimit??-1/0,this.upperRadiusLimit??1/0),this._goalTarget.y=be(this._goalTarget.y,this.lowerTargetYLimit??-1/0,1/0),this._isInterpolating=!0}_isSynchronizedViewMatrix(){return super._isSynchronizedViewMatrix()?this._cache._target.equals(this._getTargetPosition())&&this._cache.alpha===this.alpha&&this._cache.beta===this.beta&&this._cache.radius===this.radius&&this._cache.targetScreenOffset.equals(this.targetScreenOffset):!1}attachControl(e,t,i=!0,s=2){const r=arguments;t=se.BackCompatCameraNoPreventDefault(r),this._useCtrlForPanning=i,this._panningMouseButton=s,typeof r[0]=="boolean"&&(r.length>1&&(this._useCtrlForPanning=r[1]),r.length>2&&(this._panningMouseButton=r[2])),this.inputs.attachElement(t),this._reset=()=>{this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0}}detachControl(){this.inputs.detachElement(),this._reset&&this._reset()}_checkInputs(){if(this._collisionTriggered)return;this.inputs.checkInputs();let e=!1;if(this.inertialAlphaOffset!==0||this.inertialBetaOffset!==0||this.inertialRadiusOffset!==0){e=!0;const t=this.invertRotation?-1:1,i=this._calculateHandednessMultiplier();let s=this.inertialAlphaOffset*i;this.beta<0&&(s*=-1),this.alpha+=s*t,this.beta+=this.inertialBetaOffset*t,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)<this._rotationEpsilon&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<this._rotationEpsilon&&(this.inertialBetaOffset=0),Math.abs(this.inertialRadiusOffset)<this.speed*this._rotationEpsilon&&(this.inertialRadiusOffset=0)}if(this.inertialPanningX!==0||this.inertialPanningY!==0){e=!0;const t=new _(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY);if(this._viewMatrix.invertToRef(this._cameraTransformMatrix),t.multiplyInPlace(this.panningAxis),_.TransformNormalToRef(t,this._cameraTransformMatrix,this._transformedDirection),this.mapPanning){const s=this.upVector,r=_.CrossToRef(this._transformedDirection,s,this._transformedDirection);_.CrossToRef(s,r,this._transformedDirection)}else this.panningAxis.y||(this._transformedDirection.y=0);if(!this._targetHost)if(this.panningDistanceLimit)this._transformedDirection.addInPlace(this._target),_.DistanceSquared(this._transformedDirection,this.panningOriginTarget)<=this.panningDistanceLimit*this.panningDistanceLimit&&this._target.copyFrom(this._transformedDirection);else{if(this.parent){const s=v.Matrix[0];this.parent.getWorldMatrix().getRotationMatrixToRef(s),s.transposeToRef(s),_.TransformCoordinatesToRef(this._transformedDirection,s,this._transformedDirection)}this._target.addInPlace(this._transformedDirection)}this.inertialPanningX*=this.panningInertia,this.inertialPanningY*=this.panningInertia;const i=this.speed*this._panningEpsilon;Math.abs(this.inertialPanningX)<i&&(this.inertialPanningX=0),Math.abs(this.inertialPanningY)<i&&(this.inertialPanningY=0)}if(e)this.stopInterpolation();else if(this._isInterpolating){let t=!1;const i=this._scene.getEngine().getDeltaTime()/1e3,s=1-Math.pow(2,-i/this._currentInterpolationFactor),r=mt(this._goalRadius,this.radius);if(!isNaN(this._goalTarget.x)||!isNaN(this._goalTarget.y)||!isNaN(this._goalTarget.z)){const n=v.Vector3[0].set(mt(this._goalTarget.x,this._target.x),mt(this._goalTarget.y,this._target.y),mt(this._goalTarget.z,this._target.z));_.LerpToRef(this.target,n,s,this._target),_.Distance(this.target,n)*10/r<Me?(this._goalTarget.set(NaN,NaN,NaN),this.target.copyFrom(n),this.setTarget(this.target,!1,!0,!0)):t=!0}if(!isNaN(this._goalAlpha)||!isNaN(this._goalBeta)){const n=W.RotationAlphaBetaGammaToRef(mt(this._goalAlpha,this.alpha),mt(this._goalBeta,this.beta),0,v.Quaternion[0]),o=W.RotationAlphaBetaGammaToRef(this.alpha,this.beta,0,v.Quaternion[1]),h=W.SlerpToRef(o,n,s,v.Quaternion[2]);h.normalize();const l=h.toAlphaBetaGammaToRef(v.Vector3[0]);if(this.alpha=l.x,this.beta=l.y,h.isApprox(n,Me/5)){this._goalAlpha=NaN,this._goalBeta=NaN;const c=n.toAlphaBetaGammaToRef(v.Vector3[0]);this.alpha=c.x,this.beta=c.y}else t=!0}if(isNaN(this._goalRadius)||(this.radius+=(r-this.radius)*s,Math.abs(r/this.radius-1)<Me?(this._goalRadius=NaN,this.radius=r):t=!0),!isNaN(this._goalTargetScreenOffset.x)||!isNaN(this._goalTargetScreenOffset.y)){const n=v.Vector2[0].set(mt(this._goalTargetScreenOffset.x,this.targetScreenOffset.x),mt(this._goalTargetScreenOffset.y,this.targetScreenOffset.y));Q.LerpToRef(this.targetScreenOffset,n,s,this.targetScreenOffset),Q.Distance(this.targetScreenOffset,n)<Me?(this._goalTargetScreenOffset.set(NaN,NaN),this.targetScreenOffset.copyFrom(n)):t=!0}this._isInterpolating=t}this._checkLimits(),super._checkInputs()}_checkLimits(){this.lowerBetaLimit===null||this.lowerBetaLimit===void 0?this.allowUpsideDown&&this.beta>Math.PI&&(this.beta=this.beta-2*Math.PI):this.beta<this.lowerBetaLimit&&(this.beta=this.lowerBetaLimit),this.upperBetaLimit===null||this.upperBetaLimit===void 0?this.allowUpsideDown&&this.beta<-Math.PI&&(this.beta=this.beta+2*Math.PI):this.beta>this.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit!==null&&this.alpha<this.lowerAlphaLimit&&(this.alpha=this.lowerAlphaLimit),this.upperAlphaLimit!==null&&this.alpha>this.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit!==null&&this.radius<this.lowerRadiusLimit&&(this.radius=this.lowerRadiusLimit,this.inertialRadiusOffset=0),this.upperRadiusLimit!==null&&this.radius>this.upperRadiusLimit&&(this.radius=this.upperRadiusLimit,this.inertialRadiusOffset=0),this.target.y=Math.max(this.target.y,this.lowerTargetYLimit)}rebuildAnglesAndRadius(){this._position.subtractToRef(this._getTargetPosition(),this._computationVector),(this._upVector.x!==0||this._upVector.y!==1||this._upVector.z!==0)&&_.TransformCoordinatesToRef(this._computationVector,this._upToYMatrix,this._computationVector),this.radius=this._computationVector.length(),this.radius===0&&(this.radius=1e-4);const e=this.alpha;this.alpha=Eh(this._computationVector),this.beta=Ah(this._computationVector.y,this.radius);const t=Math.round((e-this.alpha)/(2*Math.PI));this.alpha+=t*2*Math.PI,this._checkLimits()}setPosition(e){this._position.equals(e)||(this._position.copyFrom(e),this.rebuildAnglesAndRadius())}setTarget(e,t=!1,i=!1,s=!1){if(s=this.overrideCloneAlphaBetaRadius??s,e.computeWorldMatrix)t&&e.getBoundingInfo?this._targetBoundingCenter=e.getBoundingInfo().boundingBox.centerWorld.clone():this._targetBoundingCenter=null,e.computeWorldMatrix(),this._targetHost=e,this._target=this._getTargetPosition(),this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);else{const r=e,n=this._getTargetPosition();if(n&&!i&&n.equals(r))return;this._targetHost=null,this._target=r,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}s||this.rebuildAnglesAndRadius()}_getViewMatrix(){const e=Math.cos(this.alpha),t=Math.sin(this.alpha),i=Math.cos(this.beta);let s=Math.sin(this.beta);s===0&&(s=1e-4),this.radius===0&&(this.radius=1e-4);const r=this._getTargetPosition();if(this._computationVector.copyFromFloats(this.radius*e*s,this.radius*i,this.radius*t*s),(this._upVector.x!==0||this._upVector.y!==1||this._upVector.z!==0)&&_.TransformCoordinatesToRef(this._computationVector,this._yToUpMatrix,this._computationVector),r.addToRef(this._computationVector,this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions){const n=this.getScene().collisionCoordinator;this._collider||(this._collider=n.createCollider()),this._collider._radius=this.collisionRadius,this._newPosition.subtractToRef(this._position,this._collisionVelocity),this._collisionTriggered=!0,n.getNewPosition(this._position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}else{this._position.copyFrom(this._newPosition);let n=this.upVector;this.allowUpsideDown&&s<0&&(n=n.negate()),this._computeViewMatrix(this._position,r,n),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y)}return this._currentTarget.copyFrom(r),this._viewMatrix}zoomOn(e,t=!1){e=e||this.getScene().meshes;const i=ne.MinMax(e);let s=this._calculateLowerRadiusFromModelBoundingSphere(i.min,i.max);if(s=Math.max(Math.min(s,this.upperRadiusLimit||Number.MAX_VALUE),this.lowerRadiusLimit||0),this.radius=s*this.zoomOnFactor,this.mode===J.ORTHOGRAPHIC_CAMERA){const r=this.getScene().getEngine().getAspectRatio(this),n=s*this.zoomOnFactor/2;this.orthoLeft=-n*r,this.orthoRight=n*r,this.orthoBottom=-n,this.orthoTop=n}this.focusOn({min:i.min,max:i.max,distance:s},t)}focusOn(e,t=!1){let i,s;if(e.min===void 0){const r=e||this.getScene().meshes;i=ne.MinMax(r),s=_.Distance(i.min,i.max)}else{const r=e;i=r,s=r.distance}this._target=ne.Center(i),t||(this.maxZ=s*2)}createRigCamera(e,t){let i=0;switch(this.cameraRigMode){case J.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case J.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case J.RIG_MODE_STEREOSCOPIC_OVERUNDER:case J.RIG_MODE_STEREOSCOPIC_INTERLACED:case J.RIG_MODE_VR:i=this._cameraRigParams.stereoHalfAngle*(t===0?1:-1);break;case J.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:i=this._cameraRigParams.stereoHalfAngle*(t===0?-1:1);break}const s=new Ie(e,this.alpha+i,this.beta,this.radius,this._target,this.getScene());return s._cameraRigParams={},s.isRigCamera=!0,s.rigParent=this,s.upVector=this.upVector,s.mode=this.mode,s.orthoLeft=this.orthoLeft,s.orthoRight=this.orthoRight,s.orthoBottom=this.orthoBottom,s.orthoTop=this.orthoTop,s}_updateRigCameras(){const e=this._rigCameras[0],t=this._rigCameras[1];switch(e.beta=t.beta=this.beta,this.cameraRigMode){case J.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case J.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case J.RIG_MODE_STEREOSCOPIC_OVERUNDER:case J.RIG_MODE_STEREOSCOPIC_INTERLACED:case J.RIG_MODE_VR:e.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,t.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case J.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:e.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,t.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle;break}super._updateRigCameras()}_calculateLowerRadiusFromModelBoundingSphere(e,t,i=1){const s=_.Distance(e,t),n=this.getScene().getEngine().getAspectRatio(this),o=Math.tan(this.fov/2),h=o*n,c=s*.5*i,u=c*Math.sqrt(1+1/(h*h)),f=c*Math.sqrt(1+1/(o*o));return Math.max(u,f)}dispose(){this.inputs.clear(),super.dispose()}getClassName(){return"ArcRotateCamera"}}T([R()],Ie.prototype,"alpha",void 0);T([R()],Ie.prototype,"beta",void 0);T([R()],Ie.prototype,"radius",void 0);T([R()],Ie.prototype,"overrideCloneAlphaBetaRadius",void 0);T([qt("target")],Ie.prototype,"_target",void 0);T([uo("targetHost")],Ie.prototype,"_targetHost",void 0);T([R()],Ie.prototype,"inertialAlphaOffset",void 0);T([R()],Ie.prototype,"inertialBetaOffset",void 0);T([R()],Ie.prototype,"inertialRadiusOffset",void 0);T([R()],Ie.prototype,"lowerAlphaLimit",void 0);T([R()],Ie.prototype,"upperAlphaLimit",void 0);T([R()],Ie.prototype,"lowerBetaLimit",void 0);T([R()],Ie.prototype,"upperBetaLimit",void 0);T([R()],Ie.prototype,"lowerRadiusLimit",void 0);T([R()],Ie.prototype,"upperRadiusLimit",void 0);T([R()],Ie.prototype,"lowerTargetYLimit",void 0);T([R()],Ie.prototype,"inertialPanningX",void 0);T([R()],Ie.prototype,"inertialPanningY",void 0);T([R()],Ie.prototype,"pinchToPanMaxDistance",void 0);T([R()],Ie.prototype,"panningDistanceLimit",void 0);T([qt()],Ie.prototype,"panningOriginTarget",void 0);T([R()],Ie.prototype,"panningInertia",void 0);T([R()],Ie.prototype,"zoomToMouseLocation",null);T([R()],Ie.prototype,"zoomOnFactor",void 0);T([co()],Ie.prototype,"targetScreenOffset",void 0);T([R()],Ie.prototype,"allowUpsideDown",void 0);T([R()],Ie.prototype,"useInputToRestoreState",void 0);T([R()],Ie.prototype,"restoreStateInterpolationFactor",void 0);nt("BABYLON.ArcRotateCamera",Ie);class y{}y.AUTOSAMPLERSUFFIX="Sampler";y.DISABLEUA="#define DISABLE_UNIFORMITY_ANALYSIS";y.ALPHA_DISABLE=0;y.ALPHA_ADD=1;y.ALPHA_COMBINE=2;y.ALPHA_SUBTRACT=3;y.ALPHA_MULTIPLY=4;y.ALPHA_MAXIMIZED=5;y.ALPHA_ONEONE=6;y.ALPHA_PREMULTIPLIED=7;y.ALPHA_PREMULTIPLIED_PORTERDUFF=8;y.ALPHA_INTERPOLATE=9;y.ALPHA_SCREENMODE=10;y.ALPHA_ONEONE_ONEONE=11;y.ALPHA_ALPHATOCOLOR=12;y.ALPHA_REVERSEONEMINUS=13;y.ALPHA_SRC_DSTONEMINUSSRCALPHA=14;y.ALPHA_ONEONE_ONEZERO=15;y.ALPHA_EXCLUSION=16;y.ALPHA_LAYER_ACCUMULATE=17;y.ALPHA_MIN=18;y.ALPHA_MAX=19;
30y.ALPHA_DUAL_SRC0_ADD_SRC1xDST=20;y.ALPHA_EQUATION_ADD=0;y.ALPHA_EQUATION_SUBSTRACT=1;y.ALPHA_EQUATION_REVERSE_SUBTRACT=2;y.ALPHA_EQUATION_MAX=3;y.ALPHA_EQUATION_MIN=4;y.ALPHA_EQUATION_DARKEN=5;y.DELAYLOADSTATE_NONE=0;y.DELAYLOADSTATE_LOADED=1;y.DELAYLOADSTATE_LOADING=2;y.DELAYLOADSTATE_NOTLOADED=4;y.NEVER=512;y.ALWAYS=519;y.LESS=513;y.EQUAL=514;y.LEQUAL=515;y.GREATER=516;y.GEQUAL=518;y.NOTEQUAL=517;y.KEEP=7680;y.ZERO=0;y.REPLACE=7681;y.INCR=7682;y.DECR=7683;y.INVERT=5386;y.INCR_WRAP=34055;y.DECR_WRAP=34056;y.TEXTURE_CLAMP_ADDRESSMODE=0;y.TEXTURE_WRAP_ADDRESSMODE=1;y.TEXTURE_MIRROR_ADDRESSMODE=2;y.TEXTURE_CREATIONFLAG_STORAGE=1;y.TEXTUREFORMAT_ALPHA=0;y.TEXTUREFORMAT_LUMINANCE=1;y.TEXTUREFORMAT_LUMINANCE_ALPHA=2;y.TEXTUREFORMAT_RGB=4;y.TEXTUREFORMAT_RGBA=5;y.TEXTUREFORMAT_RED=6;y.TEXTUREFORMAT_R=6;y.TEXTUREFORMAT_R16_UNORM=33322;y.TEXTUREFORMAT_RG16_UNORM=33324;y.TEXTUREFORMAT_RGB16_UNORM=32852;y.TEXTUREFORMAT_RGBA16_UNORM=32859;y.TEXTUREFORMAT_R16_SNORM=36760;y.TEXTUREFORMAT_RG16_SNORM=36761;y.TEXTUREFORMAT_RGB16_SNORM=36762;y.TEXTUREFORMAT_RGBA16_SNORM=36763;y.TEXTUREFORMAT_RG=7;y.TEXTUREFORMAT_RED_INTEGER=8;y.TEXTUREFORMAT_R_INTEGER=8;y.TEXTUREFORMAT_RG_INTEGER=9;y.TEXTUREFORMAT_RGB_INTEGER=10;y.TEXTUREFORMAT_RGBA_INTEGER=11;y.TEXTUREFORMAT_BGRA=12;y.TEXTUREFORMAT_DEPTH24_STENCIL8=13;y.TEXTUREFORMAT_DEPTH32_FLOAT=14;y.TEXTUREFORMAT_DEPTH16=15;y.TEXTUREFORMAT_DEPTH24=16;y.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8=17;y.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8=18;y.TEXTUREFORMAT_STENCIL8=19;y.TEXTUREFORMAT_UNDEFINED=4294967295;y.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM=36492;y.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM=36493;y.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT=36495;y.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT=36494;y.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5=33779;y.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919;y.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3=33778;y.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918;y.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1=33777;y.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1=33776;y.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917;y.TEXTUREFORMAT_COMPRESSED_SRGB_S3TC_DXT1_EXT=35916;y.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4=37808;y.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840;y.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL=36196;y.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2=37492;y.TEXTUREFORMAT_COMPRESSED_SRGB8_ETC2=37493;y.TEXTUREFORMAT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494;y.TEXTUREFORMAT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495;y.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC=37496;y.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497;y.TEXTURETYPE_UNSIGNED_BYTE=0;y.TEXTURETYPE_UNSIGNED_INT=0;y.TEXTURETYPE_FLOAT=1;y.TEXTURETYPE_HALF_FLOAT=2;y.TEXTURETYPE_BYTE=3;y.TEXTURETYPE_SHORT=4;y.TEXTURETYPE_UNSIGNED_SHORT=5;y.TEXTURETYPE_INT=6;y.TEXTURETYPE_UNSIGNED_INTEGER=7;y.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8;y.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9;y.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10;y.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11;y.TEXTURETYPE_UNSIGNED_INT_24_8=12;y.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13;y.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14;y.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15;y.TEXTURETYPE_UNDEFINED=16;y.TEXTURE_2D=3553;y.TEXTURE_2D_ARRAY=35866;y.TEXTURE_CUBE_MAP=34067;y.TEXTURE_CUBE_MAP_ARRAY=3735928559;y.TEXTURE_3D=32879;y.TEXTURE_NEAREST_SAMPLINGMODE=1;y.TEXTURE_NEAREST_NEAREST=1;y.TEXTURE_BILINEAR_SAMPLINGMODE=2;y.TEXTURE_LINEAR_LINEAR=2;y.TEXTURE_TRILINEAR_SAMPLINGMODE=3;y.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3;y.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4;y.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5;y.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6;y.TEXTURE_NEAREST_LINEAR=7;y.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8;y.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9;y.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10;y.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11;y.TEXTURE_LINEAR_NEAREST=12;y.TEXTURE_EXPLICIT_MODE=0;y.TEXTURE_SPHERICAL_MODE=1;y.TEXTURE_PLANAR_MODE=2;y.TEXTURE_CUBIC_MODE=3;y.TEXTURE_PROJECTION_MODE=4;y.TEXTURE_SKYBOX_MODE=5;y.TEXTURE_INVCUBIC_MODE=6;y.TEXTURE_EQUIRECTANGULAR_MODE=7;y.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8;y.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9;y.TEXTURE_FILTERING_QUALITY_OFFLINE=4096;y.TEXTURE_FILTERING_QUALITY_HIGH=64;y.TEXTURE_FILTERING_QUALITY_MEDIUM=16;y.TEXTURE_FILTERING_QUALITY_LOW=8;y.SCALEMODE_FLOOR=1;y.SCALEMODE_NEAREST=2;y.SCALEMODE_CEILING=3;y.MATERIAL_TextureDirtyFlag=1;y.MATERIAL_LightDirtyFlag=2;y.MATERIAL_FresnelDirtyFlag=4;y.MATERIAL_AttributesDirtyFlag=8;y.MATERIAL_MiscDirtyFlag=16;y.MATERIAL_PrePassDirtyFlag=32;y.MATERIAL_ImageProcessingDirtyFlag=64;y.MATERIAL_AllDirtyFlag=127;y.MATERIAL_TriangleFillMode=0;y.MATERIAL_WireFrameFillMode=1;y.MATERIAL_PointFillMode=2;y.MATERIAL_PointListDrawMode=3;y.MATERIAL_LineListDrawMode=4;y.MATERIAL_LineLoopDrawMode=5;y.MATERIAL_LineStripDrawMode=6;y.MATERIAL_TriangleStripDrawMode=7;y.MATERIAL_TriangleFanDrawMode=8;y.MATERIAL_ClockWiseSideOrientation=0;y.MATERIAL_CounterClockWiseSideOrientation=1;y.MATERIAL_DIFFUSE_MODEL_E_OREN_NAYAR=0;y.MATERIAL_DIFFUSE_MODEL_BURLEY=1;y.MATERIAL_DIFFUSE_MODEL_LAMBERT=2;y.MATERIAL_DIFFUSE_MODEL_LEGACY=3;y.MATERIAL_DIELECTRIC_SPECULAR_MODEL_GLTF=0;y.MATERIAL_DIELECTRIC_SPECULAR_MODEL_OPENPBR=1;y.MATERIAL_CONDUCTOR_SPECULAR_MODEL_GLTF=0;y.MATERIAL_CONDUCTOR_SPECULAR_MODEL_OPENPBR=1;y.ACTION_NothingTrigger=0;y.ACTION_OnPickTrigger=1;y.ACTION_OnLeftPickTrigger=2;y.ACTION_OnRightPickTrigger=3;y.ACTION_OnCenterPickTrigger=4;y.ACTION_OnPickDownTrigger=5;y.ACTION_OnDoublePickTrigger=6;y.ACTION_OnPickUpTrigger=7;y.ACTION_OnPickOutTrigger=16;y.ACTION_OnLongPressTrigger=8;y.ACTION_OnPointerOverTrigger=9;
30y.ACTION_OnPointerOutTrigger=10;y.ACTION_OnEveryFrameTrigger=11;y.ACTION_OnIntersectionEnterTrigger=12;y.ACTION_OnIntersectionExitTrigger=13;y.ACTION_OnKeyDownTrigger=14;y.ACTION_OnKeyUpTrigger=15;y.PARTICLES_BILLBOARDMODE_Y=2;y.PARTICLES_BILLBOARDMODE_ALL=7;y.PARTICLES_BILLBOARDMODE_STRETCHED=8;y.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL=9;y.MESHES_CULLINGSTRATEGY_STANDARD=0;y.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1;y.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2;y.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3;y.SCENELOADER_NO_LOGGING=0;y.SCENELOADER_MINIMAL_LOGGING=1;y.SCENELOADER_SUMMARY_LOGGING=2;y.SCENELOADER_DETAILED_LOGGING=3;y.PREPASS_IRRADIANCE_TEXTURE_TYPE=0;y.PREPASS_POSITION_TEXTURE_TYPE=1;y.PREPASS_VELOCITY_TEXTURE_TYPE=2;y.PREPASS_REFLECTIVITY_TEXTURE_TYPE=3;y.PREPASS_COLOR_TEXTURE_TYPE=4;y.PREPASS_DEPTH_TEXTURE_TYPE=5;y.PREPASS_NORMAL_TEXTURE_TYPE=6;y.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE=7;y.PREPASS_WORLD_NORMAL_TEXTURE_TYPE=8;y.PREPASS_LOCAL_POSITION_TEXTURE_TYPE=9;y.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE=10;y.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE=11;y.PREPASS_ALBEDO_TEXTURE_TYPE=12;y.PREPASS_NORMALIZED_VIEW_DEPTH_TEXTURE_TYPE=13;y.BUFFER_CREATIONFLAG_READ=1;y.BUFFER_CREATIONFLAG_WRITE=2;y.BUFFER_CREATIONFLAG_READWRITE=3;y.BUFFER_CREATIONFLAG_UNIFORM=4;y.BUFFER_CREATIONFLAG_VERTEX=8;y.BUFFER_CREATIONFLAG_INDEX=16;y.BUFFER_CREATIONFLAG_STORAGE=32;y.BUFFER_CREATIONFLAG_INDIRECT=64;y.RENDERPASS_MAIN=0;y.INPUT_ALT_KEY=18;y.INPUT_CTRL_KEY=17;y.INPUT_META_KEY1=91;y.INPUT_META_KEY2=92;y.INPUT_META_KEY3=93;y.INPUT_SHIFT_KEY=16;y.SNAPSHOTRENDERING_STANDARD=0;y.SNAPSHOTRENDERING_FAST=1;y.PERSPECTIVE_CAMERA=0;y.ORTHOGRAPHIC_CAMERA=1;y.FOVMODE_VERTICAL_FIXED=0;y.FOVMODE_HORIZONTAL_FIXED=1;y.RIG_MODE_NONE=0;y.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10;y.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11;y.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12;y.RIG_MODE_STEREOSCOPIC_OVERUNDER=13;y.RIG_MODE_STEREOSCOPIC_INTERLACED=14;y.RIG_MODE_VR=20;y.RIG_MODE_CUSTOM=22;y.MAX_SUPPORTED_UV_SETS=6;y.GL_ALPHA_EQUATION_ADD=32774;y.GL_ALPHA_EQUATION_MIN=32775;y.GL_ALPHA_EQUATION_MAX=32776;y.GL_ALPHA_EQUATION_SUBTRACT=32778;y.GL_ALPHA_EQUATION_REVERSE_SUBTRACT=32779;y.GL_ALPHA_FUNCTION_SRC=768;y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR=769;y.GL_ALPHA_FUNCTION_SRC_ALPHA=770;y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA=771;y.GL_ALPHA_FUNCTION_DST_ALPHA=772;y.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA=773;y.GL_ALPHA_FUNCTION_DST_COLOR=774;y.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR=775;y.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED=776;y.GL_ALPHA_FUNCTION_CONSTANT_COLOR=32769;y.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR=32770;y.GL_ALPHA_FUNCTION_CONSTANT_ALPHA=32771;y.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA=32772;y.GL_ALPHA_FUNCTION_SRC1_COLOR=35065;y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC1_COLOR=35066;y.GL_ALPHA_FUNCTION_SRC1_ALPHA=34185;y.GL_ALPHA_FUNCTION_ONE_MINUS_SRC1_ALPHA=35067;y.SnippetUrl="https://snippet.babylonjs.com";y.FOGMODE_NONE=0;y.FOGMODE_EXP=1;y.FOGMODE_EXP2=2;y.FOGMODE_LINEAR=3;y.BYTE=5120;y.UNSIGNED_BYTE=5121;y.SHORT=5122;y.UNSIGNED_SHORT=5123;y.INT=5124;y.UNSIGNED_INT=5125;y.FLOAT=5126;y.PositionKind="position";y.NormalKind="normal";y.TangentKind="tangent";y.UVKind="uv";y.UV2Kind="uv2";y.UV3Kind="uv3";y.UV4Kind="uv4";y.UV5Kind="uv5";y.UV6Kind="uv6";y.ColorKind="color";y.ColorInstanceKind="instanceColor";y.MatricesIndicesKind="matricesIndices";y.MatricesWeightsKind="matricesWeights";y.MatricesIndicesExtraKind="matricesIndicesExtra";y.MatricesWeightsExtraKind="matricesWeightsExtra";y.ANIMATIONTYPE_FLOAT=0;y.ANIMATIONTYPE_VECTOR3=1;y.ANIMATIONTYPE_QUATERNION=2;y.ANIMATIONTYPE_MATRIX=3;y.ANIMATIONTYPE_COLOR3=4;y.ANIMATIONTYPE_COLOR4=7;y.ANIMATIONTYPE_VECTOR2=5;y.ANIMATIONTYPE_SIZE=6;y.ShadowMinZ=0;y.ShadowMaxZ=1e4;class me extends qe{get range(){return this._range}set range(e){this._range=e,this._inverseSquaredRange=1/(this.range*this.range)}get intensityMode(){return this._intensityMode}set intensityMode(e){this._intensityMode=e,this._computePhotometricScale()}get radius(){return this._radius}set radius(e){this._radius=e,this._computePhotometricScale()}get shadowEnabled(){return this._shadowEnabled}set shadowEnabled(e){this._shadowEnabled!==e&&(this._shadowEnabled=e,this._markMeshesAsLightDirty())}get includedOnlyMeshes(){return this._includedOnlyMeshes}set includedOnlyMeshes(e){this._includedOnlyMeshes=e,this._hookArrayForIncludedOnly(e)}get excludedMeshes(){return this._excludedMeshes}set excludedMeshes(e){this._excludedMeshes=e,this._hookArrayForExcluded(e)}get excludeWithLayerMask(){return this._excludeWithLayerMask}set excludeWithLayerMask(e){this._excludeWithLayerMask=e,this._resyncMeshes()}get includeOnlyWithLayerMask(){return this._includeOnlyWithLayerMask}set includeOnlyWithLayerMask(e){this._includeOnlyWithLayerMask=e,this._resyncMeshes()}get lightmapMode(){return this._lightmapMode}set lightmapMode(e){this._lightmapMode!==e&&(this._lightmapMode=e,this._markMeshesAsLightDirty())}getViewMatrix(e){return null}getProjectionMatrix(e,t){return null}constructor(e,t,i){super(e,t,!1),this.diffuse=new q(1,1,1),this.specular=new q(1,1,1),this.falloffType=me.FALLOFF_DEFAULT,this.intensity=1,this._range=Number.MAX_VALUE,this._inverseSquaredRange=0,this._photometricScale=1,this._intensityMode=me.INTENSITYMODE_AUTOMATIC,this._radius=1e-5,this.renderPri
vendor: 6,218 bytes, line 30
30ority=0,this._shadowEnabled=!0,this._excludeWithLayerMask=0,this._includeOnlyWithLayerMask=0,this._lightmapMode=0,this._shadowGenerators=null,this._excludedMeshesIds=new Array,this._includedOnlyMeshesIds=new Array,this._currentViewDepth=0,this._isLight=!0,i||this.getScene().addLight(this),this._uniformBuffer=new K(this.getScene().getEngine(),void 0,void 0,e),this._buildUniformLayout(),this.includedOnlyMeshes=[],this.excludedMeshes=[],i||this._resyncMeshes()}transferTexturesToEffect(e,t){return this}_bindLight(e,t,i,s,r=!0){const n=e.toString();let o=!1;if(this._uniformBuffer.bindToEffect(i,"Light"+n),this._renderId!==t.getRenderId()||this._lastUseSpecular!==s||!this._uniformBuffer.useUbo){this._renderId=t.getRenderId(),this._lastUseSpecular=s;const h=this.getScaledIntensity();this.transferToEffect(i,n),this.diffuse.scaleToRef(h,Vt.Color3[0]),this._uniformBuffer.updateColor4("vLightDiffuse",Vt.Color3[0],this.range,n),s&&(this.specular.scaleToRef(h,Vt.Color3[1]),this._uniformBuffer.updateColor4("vLightSpecular",Vt.Color3[1],this.radius,n)),o=!0}if(this.transferTexturesToEffect(i,n),t.shadowsEnabled&&this.shadowEnabled&&r){const h=this.getShadowGenerator(t.activeCamera)??this.getShadowGenerator();h&&(h.bindShadowLight(n,i),o=!0)}o?this._uniformBuffer.update():this._uniformBuffer.bindUniformBuffer()}getClassName(){return"Light"}toString(e){let t="Name: "+this.name;if(t+=", type: "+["Point","Directional","Spot","Hemispheric","Clustered"][this.getTypeID()],this.animations)for(let i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);return t}_syncParentEnabledState(){super._syncParentEnabledState(),this.isDisposed()||this._resyncMeshes()}setEnabled(e){super.setEnabled(e),this._resyncMeshes()}getShadowGenerator(e=null){return this._shadowGenerators===null?null:this._shadowGenerators.get(e)??null}getShadowGenerators(){return this._shadowGenerators}getAbsolutePosition(){return _.Zero()}canAffectMesh(e){return e?!(this.includedOnlyMeshes&&this.includedOnlyMeshes.length>0&&this.includedOnlyMeshes.indexOf(e)===-1||this.excludedMeshes&&this.excludedMeshes.length>0&&this.excludedMeshes.indexOf(e)!==-1||this.includeOnlyWithLayerMask!==0&&(this.includeOnlyWithLayerMask&e.layerMask)===0||this.excludeWithLayerMask!==0&&this.excludeWithLayerMask&e.layerMask):!0}dispose(e,t=!1){if(this._shadowGenerators){const i=this._shadowGenerators.values();for(let s=i.next();s.done!==!0;s=i.next())s.value.dispose();this._shadowGenerators=null}if(this.getScene().stopAnimation(this),this._parentContainer){const i=this._parentContainer.lights.indexOf(this);i>-1&&this._parentContainer.lights.splice(i,1),this._parentContainer=null}for(const i of this.getScene().meshes)i._removeLightSource(this,!0);this._uniformBuffer.dispose(),this.getScene().removeLight(this),super.dispose(e,t)}getTypeID(){return 0}getScaledIntensity(){return this._photometricScale*this.intensity}clone(e,t=null){const i=me.GetConstructorFromName(this.getTypeID(),e,this.getScene());if(!i)return null;const s=le.Clone(i,this);return e&&(s.name=e),t&&(s.parent=t),s.setEnabled(this.isEnabled()),this.onClonedObservable.notifyObservers(s),s}serialize(){const e=le.Serialize(this);if(e.uniqueId=this.uniqueId,e.type=this.getTypeID(),this.parent&&this.parent._serializeAsParent(e),this.excludedMeshes.length>0){e.excludedMeshesIds=[];for(const t of this.excludedMeshes)e.excludedMeshesIds.push(t.id)}if(this.includedOnlyMeshes.length>0){e.includedOnlyMeshesIds=[];for(const t of this.includedOnlyMeshes)e.includedOnlyMeshesIds.push(t.id)}return le.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.isEnabled=this.isEnabled(),e}static GetConstructorFromName(e,t,i){const s=qe.Construct("Light_Type_"+e,t,i);return s||null}static Parse(e,t){const i=me.GetConstructorFromName(e.type,e.name,t);if(!i)return null;const s=le.Parse(i,e,t);if(e.excludedMeshesIds&&(s._excludedMeshesIds=e.excludedMeshesIds),e.includedOnlyMeshesIds&&(s._includedOnlyMeshesIds=e.includedOnlyMeshesIds),e.parentId!==void 0&&(s._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(s._waitingParentInstanceIndex=e.parentInstanceIndex),e.falloffType!==void 0&&(s.falloffType=e.falloffType),e.lightmapMode!==void 0&&(s.lightmapMode=e.lightmapMode),e.animations){for(let r=0;r<e.animations.length;r++){const n=e.animations[r],o=Oi("BABYLON.Animation");o&&s.animations.push(o.Parse(n))}qe.ParseAnimationRanges(s,e,t)}return e.autoAnimate&&t.beginAnimation(s,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),e.isEnabled!==void 0&&s.setEnabled(e.isEnabled),s}_hookArrayForExcluded(e){const t=e.push;e.push=(...s)=>{const r=t.apply(e,s);for(const n of s)n._resyncLightSource(this);return r};const i=e.splice;e.splice=(s,r)=>{const n=i.apply(e,[s,r]);for(const o of n)o._resyncLightSource(this);return n};for(const s of e)s._resyncLightSource(this)}_hookArrayForIncludedOnly(e){const t=e.push;e.push=(...s)=>{const r=t.apply(e,s);return this._resyncMeshes(),r};const i=e.splice;e.splice=(s,r)=>{const n=i.apply(e,[s,r]);return this._resyncMeshes(),n},this._resyncMeshes()}_resyncMeshes(){for(const e of this.getScene().meshes)e._resyncLightSource(this)}_markMeshesAsLightDirty(){for(const e of this.getScene().meshes)e.lightSources.indexOf(this)!==-1&&e._markSubMeshesAsLightDirty()}_computePhotometricScale(){this._photometricScale=this._getPhotometricScale(),this.getScene().resetCachedMaterial()}_getPhotometricScale(){let e=0;const t=this.getTypeID();let i=this.intensityMode;switch(i===me.INTENSITYMODE_AUTOMATIC&&(t===me.LIGHTTYPEID_DIRECTIONALLIGHT?i=me.INTENSITYMODE_ILLUMINANCE:i=me.INTENSITYMODE_LUMINOUSINTENSITY),t){case me.LIGHTTYPEID_POINTLIGHT:case me.LIGHTTYPEID_SPOTLIGHT:switch(i){case me.INTENSITYMODE_LUMINOUSPOWER:e=1/(4*Math.PI);break;case me.INTENSITYMODE_LUMINOUSINTENSITY:e=1;break;case me.INTENSITYMODE_LUMINANCE:e=this.radius*this.radius;break}break;case me.LIGHTTYPEID_DIRECTIONALLIGHT:switch(i){case me.INTENSITYMODE_ILLUMINANCE:e=1;break;case me.INTENSITYMODE_LUMINANCE:{let s=this.radius;s=Math.max(s,.001),e=2*Math.PI*(1-Math.cos(s));break}}break;case me.LIGHTTYPEID_HEMISPHERICLIGHT:e=1;break}return e}_reorderLightsInScene(){const e=this.getScene();
30this._renderPriority!=0&&(e.requireLightSorting=!0),this.getScene().sortLightsByPriority()}_isReady(){return!0}}me.FALLOFF_DEFAULT=Ee.FALLOFF_DEFAULT;me.FALLOFF_PHYSICAL=Ee.FALLOFF_PHYSICAL;me.FALLOFF_GLTF=Ee.FALLOFF_GLTF;me.FALLOFF_STANDARD=Ee.FALLOFF_STANDARD;me.LIGHTMAP_DEFAULT=Ee.LIGHTMAP_DEFAULT;me.LIGHTMAP_SPECULAR=Ee.LIGHTMAP_SPECULAR;me.LIGHTMAP_SHADOWSONLY=Ee.LIGHTMAP_SHADOWSONLY;me.INTENSITYMODE_AUTOMATIC=Ee.INTENSITYMODE_AUTOMATIC;me.INTENSITYMODE_LUMINOUSPOWER=Ee.INTENSITYMODE_LUMINOUSPOWER;me.INTENSITYMODE_LUMINOUSINTENSITY=Ee.INTENSITYMODE_LUMINOUSINTENSITY;me.INTENSITYMODE_ILLUMINANCE=Ee.INTENSITYMODE_ILLUMINANCE;me.INTENSITYMODE_LUMINANCE=Ee.INTENSITYMODE_LUMINANCE;me.LIGHTTYPEID_POINTLIGHT=Ee.LIGHTTYPEID_POINTLIGHT;me.LIGHTTYPEID_DIRECTIONALLIGHT=Ee.LIGHTTYPEID_DIRECTIONALLIGHT;me.LIGHTTYPEID_SPOTLIGHT=Ee.LIGHTTYPEID_SPOTLIGHT;me.LIGHTTYPEID_HEMISPHERICLIGHT=Ee.LIGHTTYPEID_HEMISPHERICLIGHT;me.LIGHTTYPEID_RECT_AREALIGHT=Ee.LIGHTTYPEID_RECT_AREALIGHT;T([At()],me.prototype,"diffuse",void 0);T([At()],me.prototype,"specular",void 0);T([R()],me.prototype,"falloffType",void 0);T([R()],me.prototype,"intensity",void 0);T([R()],me.prototype,"range",null);T([R()],me.prototype,"intensityMode",null);T([R()],me.prototype,"radius",null);T([R()],me.prototype,"_renderPriority",void 0);T([B("_reorderLightsInScene")],me.prototype,"renderPriority",void 0);T([R("shadowEnabled")],me.prototype,"_shadowEnabled",void 0);T([R("excludeWithLayerMask")],me.prototype,"_excludeWithLayerMask",void 0);T([R("includeOnlyWithLayerMask")],me.prototype,"_includeOnlyWithLayerMask",void 0);T([R("lightmapMode")],me.prototype,"_lightmapMode",void 0);class nr extends me{constructor(){super(...arguments),this._needProjectionMatrixCompute=!0,this._viewMatrix=P.Identity(),this._projectionMatrix=P.Identity()}_setPosition(e){this._position=e}get position(){return this._position}set position(e){this._setPosition(e)}_setDirection(e){this._direction=e}get direction(){return this._direction}set direction(e){this._setDirection(e)}get shadowMinZ(){return this._shadowMinZ}set shadowMinZ(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()}get shadowMaxZ(){return this._shadowMaxZ}set shadowMaxZ(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()}computeTransformedInformation(){return this.parent&&this.parent.getWorldMatrix?(this.transformedPosition||(this.transformedPosition=_.Zero()),_.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=_.Zero()),_.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this.transformedDirection)),!0):!1}getDepthScale(){return 50}getShadowDirection(e){return this.transformedDirection?this.transformedDirection:this.direction}getAbsolutePosition(){return this.transformedPosition?this.transformedPosition:this.position}setDirectionToTarget(e){return this.direction=_.Normalize(e.subtract(this.position)),this.direction}getRotation(){this.direction.normalize();const e=_.Cross(this.direction,ts.Y),t=_.Cross(e,this.direction);return _.RotationFromAxis(e,t,this.direction)}needCube(){return!1}needProjectionMatrixCompute(){return this._needProjectionMatrixCompute}forceProjectionMatrixCompute(){this._needProjectionMatrixCompute=!0}_initCache(){super._initCache(),this._cache.position=_.Zero()}_isSynchronized(){return!!this._cache.position.equals(this.position)}computeWorldMatrix(e){return!e&&this.isSynchronized()?(this._currentRenderId=this.getScene().getRenderId(),this._worldMatrix):(this._updateCache(),this._cache.position.copyFrom(this.position),this._worldMatrix||(this._worldMatrix=P.Identity()),P.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this.parent&&this.parent.getWorldMatrix&&(this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix),this._markSyncedWithParent()),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix)}getDepthMinZ(e){return this.shadowMinZ!==void 0?this.shadowMinZ:e?.minZ||0}getDepthMaxZ(e){return this.shadowMaxZ!==void 0?this.shadowMaxZ:e?.maxZ||1e4}setShadowProjectionMatrix(e,t,i){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,i,e):this._setDefaultShadowProjectionMatrix(e,t,i),this}_syncParentEnabledState(){super._syncParentEnabledState(),(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition=null,this.transformedDirection=null)}getViewMatrix(e){const t=v.Vector3[0];let i=this.position;this.computeTransformedInformation()&&(i=this.transformedPosition),_.NormalizeToRef(this.getShadowDirection(e),t),Math.abs(_.Dot(t,_.Up()))===1&&(t.z=1e-13);const s=v.Vector3[1];return i.addToRef(t,s),P.LookAtLHToRef(i,s,_.Up(),this._viewMatrix),this._viewMatrix}getProjectionMatrix(e,t){return this.setShadowProjectionMatrix(this._projectionMatrix,e??this._viewMatrix,t??[]),this._projectionMatrix}}T([qt()],nr.prototype,"position",null);T([qt()],nr.prototype,"direction",null);T([R()],nr.prototype,"shadowMinZ",null);T([R()],nr.prototype,"shadowMaxZ",null);qe.AddNodeConstructor("Light_Type_1",(a,e)=>()=>new ii(a,_.Zero(),e));class ii extends nr{get shadowFrustumSize(){return this._shadowFrustumSize}set shadowFrustumSize(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()}get shadowOrthoScale(){return this._shadowOrthoScale}set shadowOrthoScale(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()}get orthoLeft(){return this._orthoLeft}set orthoLeft(e){this._orthoLeft=e}get orthoRight(){return this._orthoRight}set orthoRight(e){this._orthoRight=e}get orthoTop(){return this._orthoTop}set orthoTop(e){this._orthoTop=e}get orthoBottom(){return this._orthoBottom}set orthoBottom(e){this._orthoBottom=e}constructor(e,t,i,s){super(e,i,s),this._shadowFrustumSize=0,this._shadowOrthoScale=.1,this.autoUpdateExtends=!0,this.autoCalcShadowZBounds=!1,this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE,this.position=t.scale(-1),this.direction=t}getClassName(){return"DirectionalLight"}getTypeID(){return me.LIGHTTYPEID_DIRECTIONALLIGHT}_setDefaultShadowProjectionMatrix(e,t,i){this.shadowFrustumSize>0?this._setDefaultFixedFrustumShadowProjectionMatrix(e):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,i)}_setDefaultFixedFrustumShadowProjectionMatrix(e){const t=this.getScene().activeCamera;P.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,this.shadowMinZ!==void 0?this.shadowMinZ:t?t.minZ:0,this.shadowMaxZ!==void 0?this.shadowMaxZ:t?t.maxZ:1e4,e,this.get
30Scene().getEngine().isNDCHalfZRange)}_setDefaultAutoExtendShadowProjectionMatrix(e,t,i){const s=this.getScene().activeCamera;if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){const c=_.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=-Number.MAX_VALUE,this._orthoTop=-Number.MAX_VALUE,this._orthoBottom=Number.MAX_VALUE;let u=Number.MAX_VALUE,f=-Number.MAX_VALUE;for(let d=0;d<i.length;d++){const g=i[d];if(!g)continue;const m=g.getBoundingInfo().boundingBox;for(let A=0;A<m.vectorsWorld.length;A++)_.TransformCoordinatesToRef(m.vectorsWorld[A],t,c),c.x<this._orthoLeft&&(this._orthoLeft=c.x),c.y<this._orthoBottom&&(this._orthoBottom=c.y),c.x>this._orthoRight&&(this._orthoRight=c.x),c.y>this._orthoTop&&(this._orthoTop=c.y),this.autoCalcShadowZBounds&&(c.z<u&&(u=c.z),c.z>f&&(f=c.z))}this.autoCalcShadowZBounds&&(this._shadowMinZ=u,this._shadowMaxZ=f)}const r=this._orthoRight-this._orthoLeft,n=this._orthoTop-this._orthoBottom,o=this.shadowMinZ!==void 0?this.shadowMinZ:s?.minZ||0,h=this.shadowMaxZ!==void 0?this.shadowMaxZ:s?.maxZ||1e4,l=this.getScene().getEngine().useReverseDepthBuffer;P.OrthoOffCenterLHToRef(this._orthoLeft-r*this.shadowOrthoScale,this._orthoRight+r*this.shadowOrthoScale,this._orthoBottom-n*this.shadowOrthoScale,this._orthoTop+n*this.shadowOrthoScale,l?h:o,l?o:h,e,this.getScene().getEngine().isNDCHalfZRange)}_buildUniformLayout(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()}transferToEffect(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)}transferToNodeMaterialEffect(e,t){return this.computeTransformedInformation()?(e.setFloat3(t,this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z),this):(e.setFloat3(t,this.direction.x,this.direction.y,this.direction.z),this)}getDepthMinZ(e){const t=this._scene.getEngine();return!t.useReverseDepthBuffer&&t.isNDCHalfZRange?0:1}getDepthMaxZ(e){const t=this._scene.getEngine();return t.useReverseDepthBuffer&&t.isNDCHalfZRange?0:1}prepareLightSpecificDefines(e,t){e["DIRLIGHT"+t]=!0}}T([R()],ii.prototype,"shadowFrustumSize",null);T([R()],ii.prototype,"shadowOrthoScale",null);T([R()],ii.prototype,"autoUpdateExtends",void 0);T([R()],ii.prototype,"autoCalcShadowZBounds",void 0);T([R("orthoLeft")],ii.prototype,"_orthoLeft",void 0);T([R("orthoRight")],ii.prototype,"_orthoRight",void 0);T([R("orthoTop")],ii.prototype,"_orthoTop",void 0);T([R("orthoBottom")],ii.prototype,"_orthoBottom",void 0);nt("BABYLON.DirectionalLight",ii);qe.AddNodeConstructor("Light_Type_3",(a,e)=>()=>new Ss(a,_.Zero(),e));class Ss extends me{constructor(e,t,i,s){super(e,i,s),this.groundColor=new q(0,0,0),this.direction=t||_.Up()}_buildUniformLayout(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("vLightGround",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()}getClassName(){return"HemisphericLight"}setDirectionToTarget(e){return this.direction=_.Normalize(e.subtract(_.Zero())),this.direction}getShadowGenerator(){return null}transferToEffect(e,t){const i=_.Normalize(this.direction);return this._uniformBuffer.updateFloat4("vLightData",i.x,i.y,i.z,0,t),this._uniformBuffer.updateColor3("vLightGround",this.groundColor.scale(this.intensity),t),this}transferToNodeMaterialEffect(e,t){const i=_.Normalize(this.direction);return e.setFloat3(t,i.x,i.y,i.z),this}computeWorldMatrix(){return this._worldMatrix||(this._worldMatrix=P.Identity()),this._worldMatrix}getTypeID(){return me.LIGHTTYPEID_HEMISPHERICLIGHT}prepareLightSpecificDefines(e,t){e["HEMILIGHT"+t]=!0}}T([At()],Ss.prototype,"groundColor",void 0);T([qt()],Ss.prototype,"direction",void 0);nt("BABYLON.HemisphericLight",Ss);class ya{constructor(){this._count=0,this._data={}}copyFrom(e){this.clear(),e.forEach((t,i)=>this.add(t,i))}get(e){const t=this._data[e];if(t!==void 0)return t}getOrAddWithFactory(e,t){let i=this.get(e);return i!==void 0||(i=t(e),i&&this.add(e,i)),i}getOrAdd(e,t){const i=this.get(e);return i!==void 0?i:(this.add(e,t),t)}contains(e){return this._data[e]!==void 0}
vendor: 17,129 bytes, line 30
30add(e,t){return this._data[e]!==void 0?!1:(this._data[e]=t,++this._count,!0)}set(e,t){return this._data[e]===void 0?!1:(this._data[e]=t,!0)}getAndRemove(e){const t=this.get(e);return t!==void 0?(delete this._data[e],--this._count,t):null}remove(e){return this.contains(e)?(delete this._data[e],--this._count,!0):!1}clear(){this._data={},this._count=0}get count(){return this._count}forEach(e){for(const t in this._data){const i=this._data[t];e(t,i)}}first(e){for(const t in this._data){const i=this._data[t],s=e(t,i);if(s)return s}return null}}function Rh(a){a.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")}class Le{constructor(){this._dirty=!0,this._tempColor=new fe(0,0,0,0),this._globalCurve=new fe(0,0,0,0),this._highlightsCurve=new fe(0,0,0,0),this._midtonesCurve=new fe(0,0,0,0),this._shadowsCurve=new fe(0,0,0,0),this._positiveCurve=new fe(0,0,0,0),this._negativeCurve=new fe(0,0,0,0),this._globalHue=30,this._globalDensity=0,this._globalSaturation=0,this._globalExposure=0,this._highlightsHue=30,this._highlightsDensity=0,this._highlightsSaturation=0,this._highlightsExposure=0,this._midtonesHue=30,this._midtonesDensity=0,this._midtonesSaturation=0,this._midtonesExposure=0,this._shadowsHue=30,this._shadowsDensity=0,this._shadowsSaturation=0,this._shadowsExposure=0}get globalHue(){return this._globalHue}set globalHue(e){this._globalHue=e,this._dirty=!0}get globalDensity(){return this._globalDensity}set globalDensity(e){this._globalDensity=e,this._dirty=!0}get globalSaturation(){return this._globalSaturation}set globalSaturation(e){this._globalSaturation=e,this._dirty=!0}get globalExposure(){return this._globalExposure}set globalExposure(e){this._globalExposure=e,this._dirty=!0}get highlightsHue(){return this._highlightsHue}set highlightsHue(e){this._highlightsHue=e,this._dirty=!0}get highlightsDensity(){return this._highlightsDensity}set highlightsDensity(e){this._highlightsDensity=e,this._dirty=!0}get highlightsSaturation(){return this._highlightsSaturation}set highlightsSaturation(e){this._highlightsSaturation=e,this._dirty=!0}get highlightsExposure(){return this._highlightsExposure}set highlightsExposure(e){this._highlightsExposure=e,this._dirty=!0}get midtonesHue(){return this._midtonesHue}set midtonesHue(e){this._midtonesHue=e,this._dirty=!0}get midtonesDensity(){return this._midtonesDensity}set midtonesDensity(e){this._midtonesDensity=e,this._dirty=!0}get midtonesSaturation(){return this._midtonesSaturation}set midtonesSaturation(e){this._midtonesSaturation=e,this._dirty=!0}get midtonesExposure(){return this._midtonesExposure}set midtonesExposure(e){this._midtonesExposure=e,this._dirty=!0}get shadowsHue(){return this._shadowsHue}set shadowsHue(e){this._shadowsHue=e,this._dirty=!0}get shadowsDensity(){return this._shadowsDensity}set shadowsDensity(e){this._shadowsDensity=e,this._dirty=!0}get shadowsSaturation(){return this._shadowsSaturation}set shadowsSaturation(e){this._shadowsSaturation=e,this._dirty=!0}get shadowsExposure(){return this._shadowsExposure}set shadowsExposure(e){this._shadowsExposure=e,this._dirty=!0}getClassName(){return"ColorCurves"}static Bind(e,t,i="vCameraColorCurvePositive",s="vCameraColorCurveNeutral",r="vCameraColorCurveNegative"){e._dirty&&(e._dirty=!1,e._getColorGradingDataToRef(e._globalHue,e._globalDensity,e._globalSaturation,e._globalExposure,e._globalCurve),e._getColorGradingDataToRef(e._highlightsHue,e._highlightsDensity,e._highlightsSaturation,e._highlightsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._highlightsCurve),e._getColorGradingDataToRef(e._midtonesHue,e._midtonesDensity,e._midtonesSaturation,e._midtonesExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._midtonesCurve),e._getColorGradingDataToRef(e._shadowsHue,e._shadowsDensity,e._shadowsSaturation,e._shadowsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._shadowsCurve),e._highlightsCurve.subtractToRef(e._midtonesCurve,e._positiveCurve),e._midtonesCurve.subtractToRef(e._shadowsCurve,e._negativeCurve)),t&&(t.setFloat4(i,e._positiveCurve.r,e._positiveCurve.g,e._positiveCurve.b,e._positiveCurve.a),t.setFloat4(s,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(r,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))}_getColorGradingDataToRef(e,t,i,s,r){e!=null&&(e=Le._Clamp(e,0,360),t=Le._Clamp(t,-100,100),i=Le._Clamp(i,-100,100),s=Le._Clamp(s,-100,100),t=Le._ApplyColorGradingSliderNonlinear(t),t*=.5,s=Le._ApplyColorGradingSliderNonlinear(s),t<0&&(t*=-1,e=(e+180)%360),Le._FromHSBToRef(e,t,50+.25*s,r),r.scaleToRef(2,r),r.a=1+.01*i)}static _ApplyColorGradingSliderNonlinear(e){e/=100;let t=Math.abs(e);return t=Math.pow(t,2),e<0&&(t*=-1),t*=100,t}static _FromHSBToRef(e,t,i,s){let r=Le._Clamp(e,0,360);const n=Le._Clamp(t/100,0,1),o=Le._Clamp(i/100,0,1);if(n===0)s.r=o,s.g=o,s.b=o;else{r/=60;const h=Math.floor(r),l=r-h,c=o*(1-n),u=o*(1-n*l),f=o*(1-n*(1-l));switch(h){case 0:s.r=o,s.g=f,s.b=c;break;case 1:s.r=u,s.g=o,s.b=c;break;case 2:s.r=c,s.g=o,s.b=f;break;case 3:s.r=c,s.g=u,s.b=o;break;case 4:s.r=f,s.g=c,s.b=o;break;default:s.r=o,s.g=c,s.b=u;break}}s.a=1}static _Clamp(e,t,i){return Math.min(Math.max(e,t),i)}clone(){return le.Clone(()=>new Le,this)}serialize(){return le.Serialize(this)}static Parse(e){return le.Parse(()=>new Le,e,null,null)}}Le.PrepareUniforms=Rh;T([R()],Le.prototype,"_globalHue",void 0);T([R()],Le.prototype,"_globalDensity",void 0);T([R()],Le.prototype,"_globalSaturation",void 0);T([R()],Le.prototype,"_globalExposure",void 0);T([R()],Le.prototype,"_highlightsHue",void 0);T([R()],Le.prototype,"_highlightsDensity",void 0);T([R()],Le.prototype,"_highlightsSaturation",void 0);T([R()],Le.prototype,"_highlightsExposure",void 0);T([R()],Le.prototype,"_midtonesHue",void 0);T([R()],Le.prototype,"_midtonesDensity",void 0);T([R()],Le.prototype,"_midtonesSaturation",void 0);T([R()],Le.prototype,"_midtonesExposure",void 0);le._ColorCurvesParser=Le.Parse;function Su(a,e){e.EXPOSURE&&a.push("exposureLinear"),e.CONTRAST&&a.push("contrast"),e.COLORGRADING&&a.push("colorTransformSettings"),(e.VIGNETTE||e.DITHER)&&a.push("vInverseScreenSize"),e.VIGNETTE&&(a.push("vignetteSettings1"),a.push("vignetteSettings2")),e.COLORCURVES&&Rh(a),e.DITHER&&a.push("ditherIntensity")}function Mu(a,e){e.COLORGRADING&&a.push("txColorTransform")}class ue{constructor(){this.colorCurves=new Le,this._colorCurvesEnabled=!1,this._colorGradingEnabled=!1,this._colorGradingWithGreenDepth=!0,this._colorGradingBGR=!0,this._exposure=1,this._toneMappingEnabled=!1,this._toneMappingType=ue.TONEMAPPING_STANDARD,this._contrast=1,this.vignetteStretch=0,this.vignetteCenterX=0,this.vignetteCenterY=0,this.vignetteWeight=1.5,this.vignetteColor=new fe(0,0,0,0),this.vignetteCameraFov=.5,this._vignetteBlendMode=ue.VIGNETTEMODE_MULTIPLY,this._vignetteEnabled=!1,this._ditheringEnabled=!1,this._ditheringIntensity=1/255,this._skipFinalColorClamp=!1,this._applyByPostProcess=!1,this._isEnabled=!0,this.outputTextureWidth=0,this.outputTextureHeight=0,this.onUpdateParameters=new O}get colorCurvesEnabled(){return this._colorCurvesEnabled}set colorCurvesEnabled(e){this._colorCurvesEnabled!==e&&(this._colorCurvesEnabled=e,this._updateParameters())}get colorGradingTexture(){return this._colorGradingTexture}set colorGradingTexture(e){this._colorGradingTexture!==e&&(this._colorGradingTexture=e,this._updateParameters())}get colorGradingEnabled(){return this._colorGradingEnabled}set colorGradingEnabled(e){this._colorGradingEnabled!==e&&(this._colorGradingEnabled=e,this._updateParameters())}get colorGradingWithGreenDepth(){return this._colorGradingWithGreenDepth}set colorGradingWithGreenDepth(e){this._colorGradingWithGreenDepth!==e&&(this._colorGradingWithGreenDepth=e,this._updateParameters())}get colorGradingBGR(){return this._colorGradingBGR}set colorGradingBGR(e){this._colorGradingBGR!==e&&(this._colorGradingBGR=e,this._updateParameters())}get exposure(){return this._exposure}set exposure(e){this._exposure!==e&&(this._exposure=e,this._updateParameters())}get toneMappingEnabled(){return this._toneMappingEnabled}set toneMappingEnabled(e){this._toneMappingEnabled!==e&&(this._toneMappingEnabled=e,this._updateParameters())}get toneMappingType(){return this._toneMappingType}set toneMappingType(e){this._toneMappingType!==e&&(this._toneMappingType=e,this._updateParameters())}get contrast(){return this._contrast}set contrast(e){this._contrast!==e&&(this._contrast=e,this._updateParameters())}get vignetteCentreY(){return this.vignetteCenterY}set vignetteCentreY(e){this.vignetteCenterY=e}get vignetteCentreX(){return this.vignetteCenterX}set vignetteCentreX(e){this.vignetteCenterX=e}get vignetteBlendMode(){return this._vignetteBlendMode}set vignetteBlendMode(e){this._vignetteBlendMode!==e&&(this._vignetteBlendMode=e,this._updateParameters())}get vignetteEnabled(){return this._vignetteEnabled}set vignetteEnabled(e){this._vignetteEnabled!==e&&(this._vignetteEnabled=e,this._updateParameters())}get ditheringEnabled(){return this._ditheringEnabled}set ditheringEnabled(e){this._ditheringEnabled!==e&&(this._ditheringEnabled=e,this._updateParameters())}get ditheringIntensity(){return this._ditheringIntensity}set ditheringIntensity(e){this._ditheringIntensity!==e&&(this._ditheringIntensity=e,this._updateParameters())}get skipFinalColorClamp(){return this._skipFinalColorClamp}set skipFinalColorClamp(e){this._skipFinalColorClamp!==e&&(this._skipFinalColorClamp=e,this._updateParameters())}get applyByPostProcess(){return this._applyByPostProcess}set applyByPostProcess(e){this._applyByPostProcess!==e&&(this._applyByPostProcess=e,this._updateParameters())}get isEnabled(){return this._isEnabled}set isEnabled(e){this._isEnabled!==e&&(this._isEnabled=e,this._updateParameters())}_updateParameters(){this.onUpdateParameters.notifyObservers(this)}getClassName(){return"ImageProcessingConfiguration"}prepareDefines(e,t=!1){if(t!==this.applyByPostProcess||!this._isEnabled){e.VIGNETTE=!1,e.TONEMAPPING=0,e.CONTRAST=!1,e.EXPOSURE=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.DITHER=!1,e.IMAGEPROCESSING=!1,e.SKIPFINALCOLORCLAMP=this.skipFinalColorClamp,e.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess&&this._isEnabled;return}if(e.VIGNETTE=this.vignetteEnabled,e.VIGNETTEBLENDMODEMULTIPLY=this.vignetteBlendMode===ue._VIGNETTEMODE_MULTIPLY,e.VIGNETTEBLENDMODEOPAQUE=!e.VIGNETTEBLENDMODEMULTIPLY,!this._toneMappingEnabled)e.TONEMAPPING=0;else switch(this._toneMappingType){case ue.TONEMAPPING_KHR_PBR_NEUTRAL:e.TONEMAPPING=3;break;case ue.TONEMAPPING_ACES:e.TONEMAPPING=2;break;default:e.TONEMAPPING=1;break}e.CONTRAST=this.contrast!==1,e.EXPOSURE=this.exposure!==1,e.COLORCURVES=this.colorCurvesEnabled&&!!this.colorCurves,e.COLORGRADING=this.colorGradingEnabled&&!!this.colorGradingTexture,e.COLORGRADING?e.COLORGRADING3D=this.colorGradingTexture.is3D:e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=this.colorGradingWithGreenDepth,e.SAMPLER3DBGRMAP=this.colorGradingBGR,e.DITHER=this._ditheringEnabled,e.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess,e.SKIPFINALCOLORCLAMP=this.skipFinalColorClamp,e.IMAGEPROCESSING=e.VIGNETTE||!!e.TONEMAPPING||e.CONTRAST||e.EXPOSURE||e.COLORCURVES||e.COLORGRADING||e.DITHER}isReady(){return!this.colorGradingEnabled||!this.colorGradingTexture||this.colorGradingTexture.isReady()}bind(e,t){if(this._colorCurvesEnabled&&this.colorCurves&&Le.Bind(this.colorCurves,e),this._vignetteEnabled||this._ditheringEnabled){const i=1/(this.outputTextureWidth||e.getEngine().getRenderWidth()),s=1/(this.outputTextureHeight||e.getEngine().getRenderHeight());if(e.setFloat2("vInverseScreenSize",i,s),this._ditheringEnabled&&e.setFloat("ditherIntensity",.5*this._ditheringIntensity),this._vignetteEnabled){const r=t??s/i;let n=Math.tan(this.vignetteCameraFov*.5),o=n*r;const h=Math.sqrt(o*n);o=mn(o,h,this.vignetteStretch),n=mn(n,h,this.vignetteStretch),e.setFloat4("vignetteSettings1",o,n,-o*this.vignetteCenterX,-n*this.vignetteCenterY);const l=-2*this.vignetteWeight;e.setFloat4("vignetteSettings2",this.vignetteColor.r,this.vignetteColor.g,this.vignetteColor.b,l)}}if(e.setFloat("exposureLinear",this.exposure),e.setFloat("contrast",this.contrast),this.colorGradingTexture){e.setTexture("txColorTransform",this.colorGradingTexture);const i=this.colorGradingTexture.getSize().height;e.setFloat4("colorTransformSettings",(i-1)/i,.5/i,i,this.colorGradingTexture.level)}}clone(){return le.Clone(()=>new ue,this)}serialize(){return le.Serialize(this)}static Parse(e){const t=le.Parse(()=>new ue,e,null,null);return e.vignetteCentreX!==void 0&&(t.vignetteCenterX=e.vignetteCentreX),e.vignetteCentreY!==void 0&&(t.vignetteCenterY=e.vignetteCentreY),t}static get VIGNETTEMODE_MULTIPLY(){return this._VIGNETTEMODE_MULTIPLY}static get VIGNETTEMODE_OPAQUE(){return this._VIGNETTEMODE_OPAQUE}}ue.TONEMAPPING_STANDARD=0;ue.TONEMAPPING_ACES=1;ue.TONEMAPPING_KHR_PBR_NEUTRAL=2;ue.PrepareUniforms=Su;ue.PrepareSamplers=Mu;ue._VIGNETTEMODE_MULTIPLY=0;ue._VIGNETTEMODE_OPAQUE=1;T([pl()],ue.prototype,"colorCurves",void 0);T([R()],ue.prototype,"_colorCurvesEnabled",void 0);T([Oe("colorGradingTexture")],ue.prototype,"_colorGradingTexture",void 0);T([R()],ue.prototype,"_colorGradingEnabled",void 0);T([R()],ue.prototype,"_colorGradingWithGreenDepth",void 0);T([R()],ue.prototype,"_colorGradingBGR",void 0);T([R()],ue.prototype,"_exposure",void 0);T([R()],ue.prototype,"_toneMappingEnabled",void 0);T([R()],ue.prototype,"_toneMappingType",void 0);T([R()],ue.prototype,"_contrast",void 0);T([R()],ue.prototype,"vignetteStretch",void 0);T([R()],ue.prototype,"vignetteCenterX",void 0);T([R()],ue.prototype,"vignetteCenterY",void 0);T([R()],ue.prototype,"vignetteWeight",void 0);T([fo()],ue.prototype,"vignetteColor",void 0);T([R()],ue.prototype,"vignetteCameraFov",void 0);T([R()],ue.prototype,"_vignetteBlendMode",void 0);T([R()],ue.prototype,"_vignetteEnabled",void 0);T([R()],ue.prototype,"_ditheringEnabled",void 0);T([R()],ue.prototype,"_ditheringIntensity",void 0);T([R()],ue.prototype,"_skipFinalColorClamp",void 0);T([R()],ue.prototype,"_applyByPostProcess",void 0);T([R()],ue.prototype,"_isEnabled",void 0);T([R()],ue.prototype,"outputTextureWidth",void 0);T([R()],ue.prototype,"outputTextureHeight",void 0);le._ImageProcessingConfigurationParser=ue.Parse;nt("BABYLON.ImageProcessingConfiguration",ue);class lt{constructor(e,t,i,s,r,n){this.source=e,this.pointerX=t,this.pointerY=i,this.meshUnderPointer=s,this.sourceEvent=r,this.additionalData=n}static CreateNew(e,t,i){const s=e.getScene();return new lt(e,s.pointerX,s.pointerY,s.meshUnderPointer||e,t,i)}static CreateNewFromSprite(e,t,i,s){return new lt(e,t.pointerX,t.pointerY,t.meshUnderPointer,i,s)}static CreateNewFromScene(e,t){return new lt(null,e.pointerX,e.pointerY,e.meshUnderPointer,t)}static CreateNewFromPrimitive(e,t,i,s){return new lt(e,t.x,t.y,null,i,s)}}class Rn{constructor(e){this._vertexBuffers={},this.onBeforeRenderObservable=new O,this._scene=e}_prepareBuffers(){if(this._vertexBuffers[b.PositionKind])return;const e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffers[b.PositionKind]=new b(this._scene.getEngine(),e,b.PositionKind,!1,!1,2),this._buildIndexBuffer()}_buildIndexBuffer(){const e=[];e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(e)}_rebuild(){const e=this._vertexBuffers[b.PositionKind];e&&(e._rebuild(),this._buildIndexBuffer())}_prepareFrame(e=null,t=null){const i=this._scene.activeCamera;return!i||(t=t||i._postProcesses.filter(s=>s!=null),!t||t.length===0||!this._scene.postProcessesEnabled)?!1:(t[0].activate(i,e,t!=null),!0)}directRender(e,t=null,i=!1,s=0,r=0,n=!1,o=e.length){const h=this._scene.getEngine();for(let l=0;l<o;l++){l<e.length-1?e[l+1].activate(this._scene.activeCamera||this._scene,t?.texture):(t?h.bindFramebuffer(t,s,void 0,void 0,i,r):n||h.restoreDefaultFramebuffer(),h._debugInsertMarker?.(`post process ${e[l].name} output`));const c=e[l],u=c.apply();u&&(c.onBeforeRenderObservable.notifyObservers(u),this._prepareBuffers(),h.bindBuffers(this._vertexBuffers,this._indexBuffer,u),h.drawElementsType(0,0,6),c.onAfterRenderObservable.notifyObservers(u))}h.setDepthBuffer(!0),h.setDepthWrite(!0)}_finalizeFrame(e,t,i,s,r=!1){const n=this._scene.activeCamera;if(!n||(this.onBeforeRenderObservable.notifyObservers(this),s=s||n._postProcesses.filter(h=>h!=null),s.length===0||!this._scene.postProcessesEnabled))return;const o=this._scene.getEngine();for(let h=0,l=s.length;h<l;h++){const c=s[h];if(h<l-1?c._outputTexture=s[h+1].activate(n,t?.texture):(t?(o.bindFramebuffer(t,i,void 0,void 0,r),c._outputTexture=t):(o.restoreDefaultFramebuffer(),c._outputTexture=null),o._debugInsertMarker?.(`post process ${s[h].name} output`)),e)break;const u=c.apply();u&&(c.onBeforeRenderObservable.notifyObservers(u),this._prepareBuffers(),o.bindBuffers(this._vertexBuffers,this._indexBuffer,u),o.drawElementsType(0,0,6),c.onAfterRenderObservable.notifyObservers(u))}o.setDepthBuffer(!0),o.setDepthWrite(!0),o.setAlphaMode(0)}dispose(){const e=this._vertexBuffers[b.PositionKind];
30e&&(e.dispose(),this._vertexBuffers[b.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null)}}class Jt{set opaqueSortCompareFn(e){e?this._opaqueSortCompareFn=e:this._opaqueSortCompareFn=Jt.PainterSortCompare,this._renderOpaque=this._renderOpaqueSorted}set alphaTestSortCompareFn(e){e?this._alphaTestSortCompareFn=e:this._alphaTestSortCompareFn=Jt.PainterSortCompare,this._renderAlphaTest=this._renderAlphaTestSorted}set transparentSortCompareFn(e){e?this._transparentSortCompareFn=e:this._transparentSortCompareFn=Jt.defaultTransparentSortCompare,this._renderTransparent=this._renderTransparentSorted}constructor(e,t,i=null,s=null,r=null){this.index=e,this._opaqueSubMeshes=new it(256),this._transparentSubMeshes=new it(256),this._alphaTestSubMeshes=new it(256),this._depthOnlySubMeshes=new it(256),this._particleSystems=new it(256),this._spriteManagers=new it(256),this._empty=!0,this._edgesRenderers=new Yi(16),this.disableDepthPrePass=!1,this._scene=t,this.opaqueSortCompareFn=i,this.alphaTestSortCompareFn=s,this.transparentSortCompareFn=r}render(e,t,i,s,r=!0,n=!0,o=!0,h=!0,l){if(e){e(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);return}const c=this._scene.getEngine();r&&this._depthOnlySubMeshes.length!==0&&(c.setColorWrite(!1),this._renderAlphaTest(this._depthOnlySubMeshes),c.setColorWrite(!0)),n&&this._opaqueSubMeshes.length!==0&&this._renderOpaque(this._opaqueSubMeshes),o&&this._alphaTestSubMeshes.length!==0&&this._renderAlphaTest(this._alphaTestSubMeshes);const u=c.getStencilBuffer();if(c.setStencilBuffer(!1),t&&this._renderSprites(),i&&this._renderParticles(s),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),h&&(l||this._transparentSubMeshes.length!==0||this._scene.useOrderIndependentTransparency)){if(c.setStencilBuffer(u),l)l(this._transparentSubMeshes);else if(this._scene.useOrderIndependentTransparency){const f=this._scene.depthPeelingRenderer.render(this._transparentSubMeshes);
vendor: 62,957 bytes, line 30
30f.length&&this._renderTransparent(f)}else this._renderTransparent(this._transparentSubMeshes);c.setAlphaMode(0)}if(c.setStencilBuffer(!1),n&&this._edgesRenderers.length){for(let f=0;f<this._edgesRenderers.length;f++)this._edgesRenderers.data[f].render();c.setAlphaMode(0)}c.setStencilBuffer(u)}_renderOpaqueSorted(e){Jt._RenderSorted(e,this._opaqueSortCompareFn,this._scene.activeCamera,!1,this.disableDepthPrePass)}_renderAlphaTestSorted(e){Jt._RenderSorted(e,this._alphaTestSortCompareFn,this._scene.activeCamera,!1,this.disableDepthPrePass)}_renderTransparentSorted(e){Jt._RenderSorted(e,this._transparentSortCompareFn,this._scene.activeCamera,!0,this.disableDepthPrePass)}static _RenderSorted(e,t,i,s,r){let n=0,o;const h=i?i.globalPosition:Jt._ZeroVector;if(s)for(;n<e.length;n++)o=e.data[n],o._alphaIndex=o.getMesh().alphaIndex,o._distanceToCamera=_.Distance(o.getBoundingInfo().boundingSphere.centerWorld,h);const l=e.length===e.data.length?e.data:e.data.slice(0,e.length);t&&l.sort(t);const c=l[0].getMesh().getScene();for(n=0;n<l.length;n++)if(o=l[n],!(c._activeMeshesFrozenButKeepClipping&&!o.isInFrustum(c._frustumPlanes))){if(s){const u=o.getMaterial();if(u&&u.needDepthPrePass&&!r){const f=u.getScene().getEngine();f.setColorWrite(!1),f.setAlphaMode(0),o.render(!1),f.setColorWrite(!0)}}o.render(s)}}static defaultTransparentSortCompare(e,t){return e._alphaIndex>t._alphaIndex?1:e._alphaIndex<t._alphaIndex?-1:Jt.backToFrontSortCompare(e,t)}static backToFrontSortCompare(e,t){return e._distanceToCamera<t._distanceToCamera?1:e._distanceToCamera>t._distanceToCamera?-1:0}static frontToBackSortCompare(e,t){return e._distanceToCamera<t._distanceToCamera?-1:e._distanceToCamera>t._distanceToCamera?1:0}static PainterSortCompare(e,t){const i=e.getMesh(),s=t.getMesh();return i.material&&s.material?i.material.uniqueId-s.material.uniqueId:i.uniqueId-s.uniqueId}prepare(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._depthOnlySubMeshes.reset(),this._particleSystems.reset(),this.prepareSprites(),this._edgesRenderers.reset(),this._empty=!0}prepareSprites(){this._spriteManagers.reset()}dispose(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._depthOnlySubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()}dispatch(e,t,i){t===void 0&&(t=e.getMesh()),i===void 0&&(i=e.getMaterial()),i!=null&&(i.needAlphaBlendingForMesh(t)?this._transparentSubMeshes.push(e):i.needAlphaTestingForMesh(t)?(i.needDepthPrePass&&!this.disableDepthPrePass&&this._depthOnlySubMeshes.push(e),this._alphaTestSubMeshes.push(e)):(i.needDepthPrePass&&!this.disableDepthPrePass&&this._depthOnlySubMeshes.push(e),this._opaqueSubMeshes.push(e)),t._renderingGroup=this,t._edgesRenderer&&t.isEnabled()&&t.isVisible&&t._edgesRenderer.isEnabled&&this._edgesRenderers.pushNoDuplicate(t._edgesRenderer),this._empty=!1)}dispatchSprites(e){this._spriteManagers.push(e),this._empty=!1}dispatchParticles(e){this._particleSystems.push(e),this._empty=!1}_renderParticles(e){if(this._particleSystems.length===0)return;const t=this._scene.activeCamera;this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);for(let i=0;i<this._particleSystems.length;i++){const s=this._particleSystems.data[i];if((t&&t.layerMask&s.layerMask)===0)continue;const r=s.emitter;(!r.position||!e||e.indexOf(r)!==-1)&&this._scene._activeParticles.addCount(s.render(),!1)}this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene)}_renderSprites(){if(!this._scene.spritesEnabled||this._spriteManagers.length===0)return;const e=this._scene.activeCamera;this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);for(let t=0;t<this._spriteManagers.length;t++){const i=this._spriteManagers.data[t];(e&&e.layerMask&i.layerMask)!==0&&i.render()}this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene)}}Jt._ZeroVector=_.Zero();class Cu{}class ct{get disableDepthPrePass(){return this._disableDepthPrePass}set disableDepthPrePass(e){this._disableDepthPrePass=e;for(const t of this._renderingGroups)t.disableDepthPrePass=e}get maintainStateBetweenFrames(){return this._maintainStateBetweenFrames}set maintainStateBetweenFrames(e){e!==this._maintainStateBetweenFrames&&(this._maintainStateBetweenFrames=e,this._maintainStateBetweenFrames||this.restoreDispachedFlags())}restoreDispachedFlags(){for(const e of this._scene.meshes)if(e.subMeshes)for(const t of e.subMeshes)t._wasDispatched=!1;if(this._scene.spriteManagers)for(const e of this._scene.spriteManagers)e._wasDispatched=!1;for(const e of this._scene.particleSystems)e._wasDispatched=!1}constructor(e){this._useSceneAutoClearSetup=!1,this._disableDepthPrePass=!1,this._renderingGroups=new Array,this._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderingGroupInfo=new Cu,this._maintainStateBetweenFrames=!1,this._scene=e;for(let t=ct.MIN_RENDERINGGROUPS;t<ct.MAX_RENDERINGGROUPS;t++)this._autoClearDepthStencil[t]={autoClear:!0,depth:!0,stencil:!0}}get renderingGroups(){return this._renderingGroups}getRenderingGroup(e){const t=e||0;return this._prepareRenderingGroup(t),this._renderingGroups[t]}_clearDepthStencilBuffer(e=!0,t=!0){this._depthStencilBufferAlreadyCleaned||(this._scene.getEngine().clear(null,!1,e,t),this._depthStencilBufferAlreadyCleaned=!0)}render(e,t,i,s,r=!0,n=!0,o=!0,h=!0,l){const c=this._renderingGroupInfo;if(c.scene=this._scene,c.camera=this._scene.activeCamera,c.renderingManager=this,this._scene.spriteManagers&&s)for(let u=0;u<this._scene.spriteManagers.length;u++){const f=this._scene.spriteManagers[u];this.dispatchSprites(f)}for(let u=ct.MIN_RENDERINGGROUPS;u<ct.MAX_RENDERINGGROUPS;u++){this._depthStencilBufferAlreadyCleaned=u===ct.MIN_RENDERINGGROUPS;const f=this._renderingGroups[u];if(!f||f._empty)continue;const d=1<<u;if(c.renderingGroupId=u,this._scene.onBeforeRenderingGroupObservable.notifyObservers(c,d),ct.AUTOCLEAR){const g=this._useSceneAutoClearSetup?this._scene.getAutoClearDepthStencilSetup(u):this._autoClearDepthStencil[u];g&&g.autoClear&&this._clearDepthStencilBuffer(g.depth,g.stencil)}for(const g of this._scene._beforeRenderingGroupDrawStage)g.action(u);f.render(e,s,i,t,r,n,o,h,l);for(const g of this._scene._afterRenderingGroupDrawStage)g.action(u);this._scene.onAfterRenderingGroupObservable.notifyObservers(c,d)}}reset(){if(!this.maintainStateBetweenFrames)for(let e=ct.MIN_RENDERINGGROUPS;e<ct.MAX_RENDERINGGROUPS;e++){const t=this._renderingGroups[e];t&&t.prepare()}}resetSprites(){if(!this.maintainStateBetweenFrames)for(let e=ct.MIN_RENDERINGGROUPS;e<ct.MAX_RENDERINGGROUPS;e++){const t=this._renderingGroups[e];t&&t.prepareSprites()}}dispose(){this.freeRenderingGroups(),this._renderingGroups.length=0,this._renderingGroupInfo=null}freeRenderingGroups(){for(let e=ct.MIN_RENDERINGGROUPS;e<ct.MAX_RENDERINGGROUPS;e++){const t=this._renderingGroups[e];t&&t.dispose()}}_prepareRenderingGroup(e){this._renderingGroups[e]===void 0&&(this._renderingGroups[e]=new Jt(e,this._scene,this._customOpaqueSortCompareFn[e],this._customAlphaTestSortCompareFn[e],this._customTransparentSortCompareFn[e]),this._renderingGroups[e].disableDepthPrePass=this._disableDepthPrePass)}dispatchSprites(e){this.maintainStateBetweenFrames&&e._wasDispatched||(e._wasDispatched=!0,this.getRenderingGroup(e.renderingGroupId).dispatchSprites(e))}dispatchParticles(e){this.maintainStateBetweenFrames&&e._wasDispatched||(e._wasDispatched=!0,this.getRenderingGroup(e.renderingGroupId).dispatchParticles(e))}dispatch(e,t,i){t===void 0&&(t=e.getMesh()),!(this.maintainStateBetweenFrames&&e._wasDispatched)&&(e._wasDispatched=!0,this.getRenderingGroup(t.renderingGroupId).dispatch(e,t,i))}setRenderingOrder(e,t=null,i=null,s=null){if(this._customOpaqueSortCompareFn[e]=t,this._customAlphaTestSortCompareFn[e]=i,this._customTransparentSortCompareFn[e]=s,this._renderingGroups[e]){const r=this._renderingGroups[e];r.opaqueSortCompareFn=this._customOpaqueSortCompareFn[e],r.alphaTestSortCompareFn=this._customAlphaTestSortCompareFn[e],r.transparentSortCompareFn=this._customTransparentSortCompareFn[e]}}setRenderingAutoClearDepthStencil(e,t,i=!0,s=!0){this._autoClearDepthStencil[e]={autoClear:t,depth:i,stencil:s}}getAutoClearDepthStencilSetup(e){return this._autoClearDepthStencil[e]}}ct.MAX_RENDERINGGROUPS=4;ct.MIN_RENDERINGGROUPS=0;ct.AUTOCLEAR=!0;class wt{constructor(){this.hoverCursor="",this.actions=[],this.isRecursive=!1,this.disposeWhenUnowned=!0}static get HasTriggers(){for(const e in wt.Triggers)if(Object.prototype.hasOwnProperty.call(wt.Triggers,e))return!0;return!1}static get HasPickTriggers(){for(const e in wt.Triggers)if(Object.prototype.hasOwnProperty.call(wt.Triggers,e)){const t=parseInt(e);if(t>=1&&t<=7)return!0}return!1}static HasSpecificTrigger(e){for(const t in wt.Triggers)if(Object.prototype.hasOwnProperty.call(wt.Triggers,t)&&parseInt(t)===e)return!0;return!1}}wt.Triggers={};var Y;(function(a){a[a.Generic=0]="Generic",a[a.Keyboard=1]="Keyboard",a[a.Mouse=2]="Mouse",a[a.Touch=3]="Touch",a[a.DualShock=4]="DualShock",a[a.Xbox=5]="Xbox",a[a.Switch=6]="Switch",a[a.DualSense=7]="DualSense"})(Y||(Y={}));var ee;(function(a){a[a.Horizontal=0]="Horizontal",a[a.Vertical=1]="Vertical",a[a.LeftClick=2]="LeftClick",a[a.MiddleClick=3]="MiddleClick",a[a.RightClick=4]="RightClick",a[a.BrowserBack=5]="BrowserBack",a[a.BrowserForward=6]="BrowserForward",a[a.MouseWheelX=7]="MouseWheelX",a[a.MouseWheelY=8]="MouseWheelY",a[a.MouseWheelZ=9]="MouseWheelZ",a[a.Move=12]="Move"})(ee||(ee={}));var xa;(function(a){a[a.Horizontal=0]="Horizontal",a[a.Vertical=1]="Vertical",a[a.LeftClick=2]="LeftClick",a[a.MiddleClick=3]="MiddleClick",a[a.RightClick=4]="RightClick",a[a.BrowserBack=5]="BrowserBack",a[a.BrowserForward=6]="BrowserForward",a[a.MouseWheelX=7]="MouseWheelX",a[a.MouseWheelY=8]="MouseWheelY",a[a.MouseWheelZ=9]="MouseWheelZ",a[a.DeltaHorizontal=10]="DeltaHorizontal",a[a.DeltaVertical=11]="DeltaVertical"})(xa||(xa={}));var Sa;(function(a){a[a.Cross=0]="Cross",a[a.Circle=1]="Circle",a[a.Square=2]="Square",a[a.Triangle=3]="Triangle",a[a.L1=4]="L1",a[a.R1=5]="R1",a[a.L2=6]="L2",a[a.R2=7]="R2",a[a.Share=8]="Share",a[a.Options=9]="Options",a[a.L3=10]="L3",a[a.R3=11]="R3",a[a.DPadUp=12]="DPadUp",a[a.DPadDown=13]="DPadDown",a[a.DPadLeft=14]="DPadLeft",a[a.DPadRight=15]="DPadRight",a[a.Home=16]="Home",a[a.TouchPad=17]="TouchPad",a[a.LStickXAxis=18]="LStickXAxis",a[a.LStickYAxis=19]="LStickYAxis",a[a.RStickXAxis=20]="RStickXAxis",a[a.RStickYAxis=21]="RStickYAxis"})(Sa||(Sa={}));var Ma;(function(a){a[a.Cross=0]="Cross",a[a.Circle=1]="Circle",a[a.Square=2]="Square",a[a.Triangle=3]="Triangle",a[a.L1=4]="L1",a[a.R1=5]="R1",a[a.L2=6]="L2",a[a.R2=7]="R2",a[a.Create=8]="Create",a[a.Options=9]="Options",a[a.L3=10]="L3",a[a.R3=11]="R3",a[a.DPadUp=12]="DPadUp",a[a.DPadDown=13]="DPadDown",a[a.DPadLeft=14]="DPadLeft",a[a.DPadRight=15]="DPadRight",a[a.Home=16]="Home",a[a.TouchPad=17]="TouchPad",a[a.LStickXAxis=18]="LStickXAxis",a[a.LStickYAxis=19]="LStickYAxis",a[a.RStickXAxis=20]="RStickXAxis",a[a.RStickYAxis=21]="RStickYAxis"})(Ma||(Ma={}));var Ca;(function(a){a[a.A=0]="A",a[a.B=1]="B",a[a.X=2]="X",a[a.Y=3]="Y",a[a.LB=4]="LB",a[a.RB=5]="RB",a[a.LT=6]="LT",a[a.RT=7]="RT",a[a.Back=8]="Back",a[a.Start=9]="Start",a[a.LS=10]="LS",a[a.RS=11]="RS",a[a.DPadUp=12]="DPadUp",a[a.DPadDown=13]="DPadDown",a[a.DPadLeft=14]="DPadLeft",a[a.DPadRight=15]="DPadRight",a[a.Home=16]="Home",a[a.LStickXAxis=17]="LStickXAxis",a[a.LStickYAxis=18]="LStickYAxis",a[a.RStickXAxis=19]="RStickXAxis",a[a.RStickYAxis=20]="RStickYAxis"})(Ca||(Ca={}));var Ia;(function(a){a[a.B=0]="B",a[a.A=1]="A",a[a.Y=2]="Y",a[a.X=3]="X",a[a.L=4]="L",a[a.R=5]="R",a[a.ZL=6]="ZL",a[a.ZR=7]="ZR",a[a.Minus=8]="Minus",a[a.Plus=9]="Plus",a[a.LS=10]="LS",a[a.RS=11]="RS",a[a.DPadUp=12]="DPadUp",a[a.DPadDown=13]="DPadDown",a[a.DPadLeft=14]="DPadLeft",a[a.DPadRight=15]="DPadRight",a[a.Home=16]="Home",a[a.Capture=17]="Capture",a[a.LStickXAxis=18]="LStickXAxis",a[a.LStickYAxis=19]="LStickYAxis",a[a.RStickXAxis=20]="RStickXAxis",a[a.RStickYAxis=21]="RStickYAxis"})(Ia||(Ia={}));class qi{static CreateDeviceEvent(e,t,i,s,r,n,o){switch(e){case Y.Keyboard:return this._CreateKeyboardEvent(i,s,r,n);case Y.Mouse:if(i===ee.MouseWheelX||i===ee.MouseWheelY||i===ee.MouseWheelZ)return this._CreateWheelEvent(e,t,i,s,r,n);case Y.Touch:return this._CreatePointerEvent(e,t,i,s,r,n,o);default:throw`Unable to generate event for device ${Y[e]}`}}static _CreatePointerEvent(e,t,i,s,r,n,o){const h=this._CreateMouseEvent(e,t,i,s,r,n);e===Y.Mouse?(h.deviceType=Y.Mouse,h.pointerId=1,h.pointerType="mouse"):(h.deviceType=Y.Touch,h.pointerId=o??t,h.pointerType="touch");let l=0;return l+=r.pollInput(e,t,ee.LeftClick),l+=r.pollInput(e,t,ee.RightClick)*2,l+=r.pollInput(e,t,ee.MiddleClick)*4,h.buttons=l,i===ee.Move?h.type="pointermove":i>=ee.LeftClick&&i<=ee.RightClick&&(h.type=s===1?"pointerdown":"pointerup",h.button=i-2),h}static _CreateWheelEvent(e,t,i,s,r,n){const o=this._CreateMouseEvent(e,t,i,s,r,n);switch(o.pointerId=1,o.type="wheel",o.deltaMode=sr.DOM_DELTA_PIXEL,o.deltaX=0,o.deltaY=0,o.deltaZ=0,i){case ee.MouseWheelX:o.deltaX=s;break;case ee.MouseWheelY:o.deltaY=s;break;case ee.MouseWheelZ:o.deltaZ=s;break}return o}static _CreateMouseEvent(e,t,i,s,r,n){const o=this._CreateEvent(n),h=r.pollInput(e,t,ee.Horizontal),l=r.pollInput(e,t,ee.Vertical);return n?(o.movementX=0,o.movementY=0,o.offsetX=o.movementX-n.getBoundingClientRect().x,o.offsetY=o.movementY-n.getBoundingClientRect().y):(o.movementX=r.pollInput(e,t,10),o.movementY=r.pollInput(e,t,11),o.offsetX=0,o.offsetY=0),this._CheckNonCharacterKeys(o,r),o.clientX=h,o.clientY=l,o.x=h,o.y=l,o.deviceType=e,o.deviceSlot=t,o.inputIndex=i,o}static _CreateKeyboardEvent(e,t,i,s){const r=this._CreateEvent(s);return this._CheckNonCharacterKeys(r,i),r.deviceType=Y.Keyboard,r.deviceSlot=0,r.inputIndex=e,r.type=t===1?"keydown":"keyup",r.key=String.fromCharCode(e),r.keyCode=e,r}static _CheckNonCharacterKeys(e,t){const i=t.isDeviceAvailable(Y.Keyboard),s=i&&t.pollInput(Y.Keyboard,0,18)===1,r=i&&t.pollInput(Y.Keyboard,0,17)===1,n=i&&(t.pollInput(Y.Keyboard,0,91)===1||t.pollInput(Y.Keyboard,0,92)===1||t.pollInput(Y.Keyboard,0,93)===1),o=i&&t.pollInput(Y.Keyboard,0,16)===1;e.altKey=s,e.ctrlKey=r,e.metaKey=n,e.shiftKey=o}static _CreateEvent(e){const t={};return t.preventDefault=()=>{},t.target=e,t}}class Iu{constructor(e,t,i){this._nativeInput=_native.DeviceInputSystem?new _native.DeviceInputSystem(e,t,(s,r,n,o)=>{const h=qi.CreateDeviceEvent(s,r,n,o,this);i(s,r,h)}):this._createDummyNativeInput()}pollInput(e,t,i){return this._nativeInput.pollInput(e,t,i)}isDeviceAvailable(e){return e===Y.Mouse||e===Y.Touch}dispose(){this._nativeInput.dispose()}_createDummyNativeInput(){return{pollInput:()=>0,isDeviceAvailable:()=>!1,dispose:()=>{}}}}const Pa=255,va=Object.keys(ee).length/2;class Pu{constructor(e,t,i,s){this._inputs=[],this._keyboardActive=!1,this._pointerActive=!1,this._usingSafari=se.IsSafari(),this._usingMacOs=hs()&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),this._keyboardDownEvent=r=>{},this._keyboardUpEvent=r=>{},this._keyboardBlurEvent=r=>{},this._pointerMoveEvent=r=>{},this._pointerDownEvent=r=>{},this._pointerUpEvent=r=>{},this._pointerCancelEvent=r=>{},this._pointerCancelTouch=r=>{},this._pointerLeaveEvent=r=>{},this._pointerWheelEvent=r=>{},this._pointerBlurEvent=r=>{},this._pointerMacOsChromeOutEvent=r=>{},this._eventsAttached=!1,this._mouseId=-1,this._isUsingFirefox=hs()&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox")!==-1,this._isUsingChromium=hs()&&navigator.userAgent&&navigator.userAgent.indexOf("Chrome")!==-1,this._maxTouchPoints=0,this._pointerInputClearObserver=null,this._gamepadConnectedEvent=r=>{},this._gamepadDisconnectedEvent=r=>{},this._eventPrefix=se.GetPointerPrefix(e),this._engine=e,this._onDeviceConnected=t,this._onDeviceDisconnected=i,this._onInputChanged=s,this._mouseId=this._isUsingFirefox?0:1,this._enableEvents(),this._usingMacOs&&(this._metaKeys=[]),this._engine._onEngineViewChanged||(this._engine._onEngineViewChanged=()=>{this._enableEvents()})}pollInput(e,t,i){const s=this._inputs[e][t];if(!s)throw`Unable to find device ${Y[e]}`;e>=Y.DualShock&&e<=Y.DualSense&&this._updateDevice(e,t,i);const r=s[i];if(r===void 0)throw`Unable to find input ${i} for device ${Y[e]} in slot ${t}`;return i===ee.Move&&se.Warn("Unable to provide information for PointerInput.Move.  Try using PointerInput.Horizontal or PointerInput.Vertical for move data."),r}isDeviceAvailable(e){return this._inputs[e]!==void 0}dispose(){this._onDeviceConnected=()=>{},this._onDeviceDisconnected=()=>{},this._onInputChanged=()=>{},delete this._engine._onEngineViewChanged,this._elementToAttachTo&&this._disableEvents()}_enableEvents(){const e=this?._engine.getInputElement();if(e&&(!this._eventsAttached||this._elementToAttachTo!==e)){if(this._disableEvents(),this._inputs){for(const t of this._inputs)if(t)for(const i in t){const s=+i,r=t[s];if(r)for(let n=0;n<r.length;n++)r[n]=0}}this._elementToAttachTo=e,this._elementToAttachTo.tabIndex=this._elementToAttachTo.tabIndex!==-1?this._elementToAttachTo.tabIndex:this._engine.canvasTabIndex,this._handleKeyActions(),this._handlePointerActions(),this._handleGamepadActions(),this._eventsAttached=!0,this._checkForConnectedDevices()}}_disableEvents(){this._elementToAttachTo&&(this._elementToAttachTo.removeEventListener("blur",this._keyboardBlurEvent),this._elementToAttachTo.removeEventListener("blur",this._pointerBlurEvent),this._elementToAttachTo.removeEventListener("keydown",this._keyboardDownEvent),this._elementToAttachTo.removeEventListener("keyup",this._keyboardUpEvent),this._elementToAttachTo.removeEventListener(this._eventPrefix+"move",this._pointerMoveEvent),this._elementToAttachTo.removeEventListener(this._eventPrefix+"down",this._pointerDownEvent),this._elementToAttachTo.removeEventListener(this._eventPrefix+"up",this._pointerUpEvent),this._elementToAttachTo.removeEventListener(this._eventPrefix+"cancel",this._pointerCancelEvent),this._elementToAttachTo.removeEventListener(this._eventPrefix+"leave",this._pointerLeaveEvent),this._elementToAttachTo.removeEventListener(this._wheelEventName,this._pointerWheelEvent),this._usingMacOs&&this._isUsingChromium&&this._elementToAttachTo.removeEventListener("lostpointercapture",this._pointerMacOsChromeOutEvent),window.removeEventListener("gamepadconnected",this._gamepadConnectedEvent),window.removeEventListener("gamepaddisconnected",this._gamepadDisconnectedEvent)),this._pointerInputClearObserver&&this._engine.onEndFrameObservable.remove(this._pointerInputClearObserver),this._eventsAttached=!1}_checkForConnectedDevices(){if(navigator.getGamepads){const e=navigator.getGamepads();for(const t of e)t&&this._addGamePad(t)}typeof matchMedia=="function"&&matchMedia("(pointer:fine)").matches&&this._addPointerDevice(Y.Mouse,0,0,0)}_addGamePad(e){const t=this._getGamepadDeviceType(e.id),i=e.index;this._gamepads=this._gamepads||new Array(e.index+1),this._registerDevice(t,i,e.buttons.length+e.axes.length),this._gamepads[i]=t}_addPointerDevice(e,t,i,s){this._pointerActive||(this._pointerActive=!0),this._registerDevice(e,t,va);const r=this._inputs[e][t];r[0]=i,r[1]=s}_registerDevice(e,t,i){if(t===void 0)throw`Unable to register device ${Y[e]} to undefined slot.`;if(this._inputs[e]||(this._inputs[e]={}),!this._inputs[e][t]){const s=new Array(i);s.fill(0),this._inputs[e][t]=s,this._onDeviceConnected(e,t)}}_unregisterDevice(e,t){this._inputs[e][t]&&(delete this._inputs[e][t],this._onDeviceDisconnected(e,t))}_handleKeyActions(){this._keyboardDownEvent=e=>{this._keyboardActive||(this._keyboardActive=!0,this._registerDevice(Y.Keyboard,0,Pa));const t=this._inputs[Y.Keyboard][0];if(t){t[e.keyCode]=1;const i=e;i.inputIndex=e.keyCode,this._usingMacOs&&e.metaKey&&e.key!=="Meta"&&(this._metaKeys.includes(e.keyCode)||this._metaKeys.push(e.keyCode)),this._onInputChanged(Y.Keyboard,0,i)}},this._keyboardUpEvent=e=>{this._keyboardActive||(this._keyboardActive=!0,this._registerDevice(Y.Keyboard,0,Pa));const t=this._inputs[Y.Keyboard][0];if(t){t[e.keyCode]=0;const i=e;if(i.inputIndex=e.keyCode,this._usingMacOs&&e.key==="Meta"&&this._metaKeys.length>0){for(const s of this._metaKeys){const r=qi.CreateDeviceEvent(Y.Keyboard,0,s,0,this,this._elementToAttachTo);t[s]=0,this._onInputChanged(Y.Keyboard,0,r)}this._metaKeys.splice(0,this._metaKeys.length)}this._onInputChanged(Y.Keyboard,0,i)}},this._keyboardBlurEvent=()=>{if(this._keyboardActive){const e=this._inputs[Y.Keyboard][0];for(let t=0;t<e.length;t++)if(e[t]!==0){e[t]=0;const i=qi.CreateDeviceEvent(Y.Keyboard,0,t,0,this,this._elementToAttachTo);this._onInputChanged(Y.Keyboard,0,i)}this._usingMacOs&&this._metaKeys.splice(0,this._metaKeys.length)}},this._elementToAttachTo.addEventListener("keydown",this._keyboardDownEvent),this._elementToAttachTo.addEventListener("keyup",this._keyboardUpEvent),this._elementToAttachTo.addEventListener("blur",this._keyboardBlurEvent)}_handlePointerActions(){this._maxTouchPoints=hs()&&navigator.maxTouchPoints||2,this._activeTouchIds||(this._activeTouchIds=new Array(this._maxTouchPoints));for(let i=0;i<this._maxTouchPoints;i++)this._activeTouchIds[i]=-1;this._pointerMoveEvent=i=>{const s=this._getPointerType(i);let r=s===Y.Mouse?0:this._activeTouchIds.indexOf(i.pointerId);if(s===Y.Touch&&r===-1){const o=this._activeTouchIds.indexOf(-1);if(o>=0)r=o,this._activeTouchIds[o]=i.pointerId,this._onDeviceConnected(s,r);else{se.Warn(`Max number of touches exceeded.  Ignoring touches in excess of ${this._maxTouchPoints}`);return}}this._inputs[s]||(this._inputs[s]={}),this._inputs[s][r]||this._addPointerDevice(s,r,i.clientX,i.clientY);const n=this._inputs[s][r];if(n){const o=i;o.inputIndex=ee.Move,n[ee.Horizontal]=i.clientX,n[ee.Vertical]=i.clientY,s===Y.Touch&&n[ee.LeftClick]===0&&(n[ee.LeftClick]=1),i.pointerId===void 0&&(i.pointerId=this._mouseId),this._onInputChanged(s,r,o),!this._usingSafari&&i.button!==-1&&(o.inputIndex=i.button+2,n[i.button+2]=n[i.button+2]?0:1,this._onInputChanged(s,r,o))}},this._pointerDownEvent=i=>{const s=this._getPointerType(i);let r=s===Y.Mouse?0:i.pointerId;if(s===Y.Touch){let o=this._activeTouchIds.indexOf(i.pointerId);if(o===-1&&(o=this._activeTouchIds.indexOf(-1)),o>=0)r=o,this._activeTouchIds[o]=i.pointerId;else{se.Warn(`Max number of touches exceeded.  Ignoring touches in excess of ${this._maxTouchPoints}`);return}}this._inputs[s]||(this._inputs[s]={}),this._inputs[s][r]?s===Y.Touch&&this._onDeviceConnected(s,r):this._addPointerDevice(s,r,i.clientX,i.clientY);const n=this._inputs[s][r];if(n){const o=n[ee.Horizontal],h=n[ee.Vertical];if(s===Y.Mouse){if(i.pointerId===void 0&&(i.pointerId=this._mouseId),!document.pointerLockElement)try{this._elementToAttachTo.setPointerCapture(this._mouseId)}catch{}}else if(i.pointerId&&!document.pointerLockElement)try{this._elementToAttachTo.setPointerCapture(i.pointerId)}catch{}n[ee.Horizontal]=i.clientX,n[ee.Vertical]=i.clientY,n[i.button+2]=1;const l=i;l.inputIndex=i.button+2,this._onInputChanged(s,r,l),(o!==i.clientX||h!==i.clientY)&&(l.inputIndex=ee.Move,this._onInputChanged(s,r,l))}},this._pointerUpEvent=i=>{const s=this._getPointerType(i),r=s===Y.Mouse?0:this._activeTouchIds.indexOf(i.pointerId);if(s===Y.Touch){if(r===-1)return;this._activeTouchIds[r]=-1}const n=this._inputs[s]?.[r];let o=i.button,h=n&&n[o+2]!==0;if(!h&&this._isUsingFirefox&&this._usingMacOs&&n&&(o=o===2?0:2,h=n[o+2]!==0),h){const l=n[ee.Horizontal],c=n[ee.Vertical];n[ee.Horizontal]=i.clientX,n[ee.Vertical]=i.clientY,n[o+2]=0;const u=i;i.pointerId===void 0&&(i.pointerId=this._mouseId),(l!==i.clientX||c!==i.clientY)&&(u.inputIndex=ee.Move,this._onInputChanged(s,r,u)),u.inputIndex=o+2,s===Y.Mouse&&this._mouseId>=0&&this._elementToAttachTo.hasPointerCapture?.(this._mouseId)?this._elementToAttachTo.releasePointerCapture(this._mouseId):i.pointerId&&this._elementToAttachTo.hasPointerCapture?.(i.pointerId)&&this._elementToAttachTo.releasePointerCapture(i.pointerId),this._onInputChanged(s,r,u),s===Y.Touch&&this._onDeviceDisconnected(s,r)}},this._pointerCancelTouch=i=>{const s=this._activeTouchIds.indexOf(i);if(s===-1)return;this._elementToAttachTo.hasPointerCapture?.(i)&&this._elementToAttachTo.releasePointerCapture(i),this._inputs[Y.Touch][s][ee.LeftClick]=0;const r=qi.CreateDeviceEvent(Y.Touch,s,ee.LeftClick,0,this,this._elementToAttachTo,i);this._onInputChanged(Y.Touch,s,r),this._activeTouchIds[s]=-1,this._onDeviceDisconnected(Y.Touch,s)},this._pointerCancelEvent=i=>{if(i.pointerType==="mouse"){const s=this._inputs[Y.Mouse][0];this._mouseId>=0&&this._elementToAttachTo.hasPointerCapture?.(this._mouseId)&&this._elementToAttachTo.releasePointerCapture(this._mouseId);for(let r=ee.LeftClick;r<=ee.BrowserForward;r++)if(s[r]===1){s[r]=0;const n=qi.CreateDeviceEvent(Y.Mouse,0,r,0,this,this._elementToAttachTo);this._onInputChanged(Y.Mouse,0,n)}}else this._pointerCancelTouch(i.pointerId)},this._pointerLeaveEvent=i=>{i.pointerType==="pen"&&this._pointerCancelTouch(i.pointerId)},this._wheelEventName="onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll";let e=!1;const t=function(){};try{const i=Object.defineProperty({},"passive",{get:function(){e=!0}});this._elementToAttachTo.addEventListener("test",t,i),this._elementToAttachTo.removeEventListener("test",t,i)}catch{}this._pointerBlurEvent=()=>{if(this.isDeviceAvailable(Y.Mouse)){const i=this._inputs[Y.Mouse][0];this._mouseId>=0&&this._elementToAttachTo.hasPointerCapture?.(this._mouseId)&&this._elementToAttachTo.releasePointerCapture(this._mouseId);for(let s=ee.LeftClick;s<=ee.BrowserForward;s++)if(i[s]===1){i[s]=0;const r=qi.CreateDeviceEvent(Y.Mouse,0,s,0,this,this._elementToAttachTo);this._onInputChanged(Y.Mouse,0,r)}}if(this.isDeviceAvailable(Y.Touch)){const i=this._inputs[Y.Touch];for(let s=0;s<this._activeTouchIds.length;s++){const r=this._activeTouchIds[s];if(this._elementToAttachTo.hasPointerCapture?.(r)&&this._elementToAttachTo.releasePointerCapture(r),r!==-1&&i[s]?.[ee.LeftClick]===1){i[s][ee.LeftClick]=0;const n=qi.CreateDeviceEvent(Y.Touch,s,ee.LeftClick,0,this,this._elementToAttachTo,r);this._onInputChanged(Y.Touch,s,n),this._activeTouchIds[s]=-1,this._onDeviceDisconnected(Y.Touch,s)}}}},this._pointerWheelEvent=i=>{const s=Y.Mouse,r=0;this._inputs[s]||(this._inputs[s]=[]),this._inputs[s][r]||(this._pointerActive=!0,this._registerDevice(s,r,va));const n=this._inputs[s][r];if(n){n[ee.MouseWheelX]=i.deltaX||0,n[ee.MouseWheelY]=i.deltaY||i.wheelDelta||0,n[ee.MouseWheelZ]=i.deltaZ||0;const o=i;i.pointerId===void 0&&(i.pointerId=this._mouseId),n[ee.MouseWheelX]!==0&&(o.inputIndex=ee.MouseWheelX,this._onInputChanged(s,r,o)),n[ee.MouseWheelY]!==0&&(o.inputIndex=ee.MouseWheelY,this._onInputChanged(s,r,o)),n[ee.MouseWheelZ]!==0&&(o.inputIndex=ee.MouseWheelZ,this._onInputChanged(s,r,o))}},this._usingMacOs&&this._isUsingChromium&&(this._pointerMacOsChromeOutEvent=i=>{i.buttons>1&&this._pointerCancelEvent(i)},this._elementToAttachTo.addEventListener("lostpointercapture",this._pointerMacOsChromeOutEvent)),this._elementToAttachTo.addEventListener(this._eventPrefix+"move",this._pointerMoveEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"down",this._pointerDownEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"up",this._pointerUpEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"cancel",this._pointerCancelEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"leave",this._pointerLeaveEvent),this._elementToAttachTo.addEventListener("blur",this._pointerBlurEvent),this._elementToAttachTo.addEventListener(this._wheelEventName,this._pointerWheelEvent,e?{passive:!1}:!1),this._pointerInputClearObserver=this._engine.onEndFrameObservable.add(()=>{if(this.isDeviceAvailable(Y.Mouse)){const i=this._inputs[Y.Mouse][0];i[ee.MouseWheelX]=0,i[ee.MouseWheelY]=0,i[ee.MouseWheelZ]=0}})}_handleGamepadActions(){this._gamepadConnectedEvent=e=>{this._addGamePad(e.gamepad)},this._gamepadDisconnectedEvent=e=>{if(this._gamepads){const t=this._getGamepadDeviceType(e.gamepad.id),i=e.gamepad.index;this._unregisterDevice(t,i),delete this._gamepads[i]}},window.addEventListener("gamepadconnected",this._gamepadConnectedEvent),window.addEventListener("gamepaddisconnected",this._gamepadDisconnectedEvent)}_updateDevice(e,t,i){const s=navigator.getGamepads()[t];if(s&&e===this._gamepads[t]){const r=this._inputs[e][t];i>=s.buttons.length?r[i]=s.axes[i-s.buttons.length].valueOf():r[i]=s.buttons[i].value}}_getGamepadDeviceType(e){return e.indexOf("054c")!==-1?e.indexOf("0ce6")!==-1?Y.DualSense:Y.DualShock:e.indexOf("Xbox One")!==-1||e.search("Xbox 360")!==-1||e.search("xinput")!==-1?Y.Xbox:e.indexOf("057e")!==-1?Y.Switch:Y.Generic}_getPointerType(e){let t=Y.Mouse;return(e.pointerType==="touch"||e.pointerType==="pen"||e.touches)&&(t=Y.Touch),t}}class Da{constructor(e,t,i=0){this.deviceType=t,this.deviceSlot=i,this.onInputChangedObservable=new O,this._deviceInputSystem=e}getInput(e){return this._deviceInputSystem.pollInput(this.deviceType,this.deviceSlot,e)}}class vu{constructor(e){this._registeredManagers=new Array,this._refCount=0,this.registerManager=n=>{for(let o=0;o<this._devices.length;o++){const h=this._devices[o];for(const l in h){const c=+l;n._addDevice(new Da(this._deviceInputSystem,o,c))}}this._registeredManagers.push(n)},this.unregisterManager=n=>{const o=this._registeredManagers.indexOf(n);o>-1&&this._registeredManagers.splice(o,1)};const t=Object.keys(Y).length/2;this._devices=new Array(t);const i=(n,o)=>{this._devices[n]||(this._devices[n]=new Array),this._devices[n][o]||(this._devices[n][o]=o);for(const h of this._registeredManagers){const l=new Da(this._deviceInputSystem,n,o);h._addDevice(l)}},s=(n,o)=>{this._devices[n]?.[o]&&delete this._devices[n][o];for(const h of this._registeredManagers)h._removeDevice(n,o)},r=(n,o,h)=>{if(h)for(const l of this._registeredManagers)l._onInputChanged(n,o,h)};typeof _native<"u"?this._deviceInputSystem=new Iu(i,s,r):this._deviceInputSystem=new Pu(e,i,s,r)}dispose(){this._deviceInputSystem.dispose()}}class Du{getDeviceSource(e,t){if(t===void 0){if(this._firstDevice[e]===void 0)return null;t=this._firstDevice[e]}return!this._devices[e]||this._devices[e][t]===void 0?null:this._devices[e][t]}getDeviceSources(e){return this._devices[e]?this._devices[e].filter(t=>!!t):[]}constructor(e){const t=Object.keys(Y).length/2;this._devices=new Array(t),this._firstDevice=new Array(t),this._engine=e,this._engine._deviceSourceManager||(this._engine._deviceSourceManager=new vu(e)),this._engine._deviceSourceManager._refCount++,this.onDeviceConnectedObservable=new O(i=>{for(const s of this._devices)if(s)for(const r of s)r&&this.onDeviceConnectedObservable.notifyObserver(i,r)}),this.onDeviceDisconnectedObservable=new O,this._engine._deviceSourceManager.registerManager(this),this._onDisposeObserver=e.onDisposeObservable.add(()=>{this.dispose()})}dispose(){this.onDeviceConnectedObservable.clear(),this.onDeviceDisconnectedObservable.clear(),this._engine._deviceSourceManager&&(this._engine._deviceSourceManager.unregisterManager(this),--this._engine._deviceSourceManager._refCount<1&&(this._engine._deviceSourceManager.dispose(),delete this._engine._deviceSourceManager)),this._engine.onDisposeObservable.remove(this._onDisposeObserver)}_addDevice(e){this._devices[e.deviceType]||(this._devices[e.deviceType]=[]),this._devices[e.deviceType][e.deviceSlot]||(this._devices[e.deviceType][e.deviceSlot]=e,this._updateFirstDevices(e.deviceType)),this.onDeviceConnectedObservable.notifyObservers(e)}_removeDevice(e,t){const i=this._devices[e]?.[t];this.onDeviceDisconnectedObservable.notifyObservers(i),this._devices[e]?.[t]&&delete this._devices[e][t],this._updateFirstDevices(e)}_onInputChanged(e,t,i){this._devices[e]?.[t]?.onInputChangedObservable.notifyObservers(i)}_updateFirstDevices(e){switch(e){case Y.Keyboard:case Y.Mouse:this._firstDevice[e]=0;break;case Y.Touch:case Y.DualSense:case Y.DualShock:case Y.Xbox:case Y.Switch:case Y.Generic:{delete this._firstDevice[e];const t=this._devices[e];if(t){for(let i=0;i<t.length;i++)if(t[i]){this._firstDevice[e]=i;break}}break}}}}class yh{}yh._IsPickingAvailable=!1;class Oa{constructor(){this._singleClick=!1,this._doubleClick=!1,this._hasSwiped=!1,this._ignore=!1}get singleClick(){return this._singleClick}get doubleClick(){return this._doubleClick}get hasSwiped(){return this._hasSwiped}get ignore(){return this._ignore}set singleClick(e){this._singleClick=e}set doubleClick(e){this._doubleClick=e}set hasSwiped(e){this._hasSwiped=e}set ignore(e){this._ignore=e}}class Ke{constructor(e){this._alreadyAttached=!1,this._meshPickProceed=!1,this._currentPickResult=null,this._previousPickResult=null,this._activePointerIds=new Array,this._activePointerIdsCount=0,this._doubleClickOccured=!1,this._isSwiping=!1,this._swipeButtonPressed=-1,this._skipPointerTap=!1,this._isMultiTouchGesture=!1,this._pointerX=0,this._pointerY=0,this._startingPointerPosition=new Q(0,0),this._previousStartingPointerPosition=new Q(0,0),this._startingPointerTime=0,this._previousStartingPointerTime=0,this._pointerCaptures={},this._meshUnderPointerId={},this._movePointerInfo=null,this._cameraObserverCount=0,this._delayedClicks=[null,null,null,null,null],this._deviceSourceManager=null,this._scene=e||Te.LastCreatedScene,this._scene}get meshUnderPointer(){return this._movePointerInfo&&(this._movePointerInfo._generatePickInfo(),this._movePointerInfo=null),this._pointerOverMesh}getMeshUnderPointerByPointerId(e){return this._meshUnderPointerId[e]||null}get unTranslatedPointer(){return new Q(this._unTranslatedPointerX,this._unTranslatedPointerY)}get pointerX(){return this._pointerX}set pointerX(e){this._pointerX=e}get pointerY(){return this._pointerY}set pointerY(e){this._pointerY=e}_updatePointerPosition(e){const t=this._scene.getEngine().getInputElementClientRect();t&&(this._pointerX=e.clientX-t.left,this._pointerY=e.clientY-t.top,this._unTranslatedPointerX=this._pointerX,this._unTranslatedPointerY=this._pointerY)}_processPointerMove(e,t){const i=this._scene,s=i.getEngine(),r=s.getInputElement();r&&(r.tabIndex=s.canvasTabIndex,i.doNotHandleCursors||(r.style.cursor=i.defaultCursor)),this._setCursorAndPointerOverMesh(e,t,i);for(const h of i._pointerMoveStage){e=e||this._pickMove(t);const l=!!e?.pickedMesh;e=h.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,l,r)}const n=t.inputIndex>=ee.MouseWheelX&&t.inputIndex<=ee.MouseWheelZ?te.POINTERWHEEL:te.POINTERMOVE;i.onPointerMove&&(e=e||this._pickMove(t),i.onPointerMove(t,e,n));let o;e?(o=new kt(n,t,e),this._setRayOnPointerInfo(e,t)):(o=new kt(n,t,null,this),this._movePointerInfo=o),i.onPointerObservable.hasObservers()&&i.onPointerObservable.notifyObservers(o,n)}_setRayOnPointerInfo(e,t){const i=this._scene;e&&yh._IsPickingAvailable&&(e.ray||(e.ray=i.createPickingRay(t.offsetX,t.offsetY,P.Identity(),i.activeCamera)))}_addCameraPointerObserver(e,t){return this._cameraObserverCount++,this._scene.onPointerObservable.add(e,t)}_removeCameraPointerObserver(e){return this._cameraObserverCount--,this._scene.onPointerObservable.remove(e)}_checkForPicking(){return!!(this._scene.onPointerObservable.observers.length>this._cameraObserverCount||this._scene.onPointerPick)}_checkPrePointerObservable(e,t,i){const s=this._scene,r=new uu(i,t,this._unTranslatedPointerX,this._unTranslatedPointerY);return e&&(r.originalPickingInfo=e,r.ray=e.ray,t.pointerType==="xr-near"&&e.originMesh&&(r.nearInteractionPickingInfo=e)),s.onPrePointerObservable.notifyObservers(r,i),!!r.skipOnPointerObservable}_pickMove(e){const t=this._scene,i=t.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,t.pointerMovePredicate,t.pointerMoveFastCheck,t.cameraToUseForPointers,t.pointerMoveTrianglePredicate);return this._setCursorAndPointerOverMesh(i,e,t),i}_setCursorAndPointerOverMesh(e,t,i){const r=i.getEngine().getInputElement();if(e?.pickedMesh){if(this.setPointerOverMesh(e.pickedMesh,t.pointerId,e,t),!i.doNotHandleCursors&&r&&this._pointerOverMesh){const n=this._pointerOverMesh._getActionManagerForTrigger();n&&n.hasPointerTriggers&&(r.style.cursor=n.hoverCursor||i.hoverCursor)}}else this.setPointerOverMesh(null,t.pointerId,e,t)}simulatePointerMove(e,t){const i=new PointerEvent("pointermove",t);i.inputIndex=ee.Move,!this._checkPrePointerObservable(e,i,te.POINTERMOVE)&&this._processPointerMove(e,i)}simulatePointerDown(e,t){const i=new PointerEvent("pointerdown",t);i.inputIndex=i.button+2,!this._checkPrePointerObservable(e,i,te.POINTERDOWN)&&this._processPointerDown(e,i)}_processPointerDown(e,t){const i=this._scene;if(e?.pickedMesh){this._pickedDownMesh=e.pickedMesh;const n=e.pickedMesh._getActionManagerForTrigger();if(n){if(n.hasPickTriggers)switch(n.processTrigger(5,new lt(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e)),t.button){case 0:n.processTrigger(2,new lt(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e));break;case 1:n.processTrigger(4,new lt(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e));break;case 2:n.processTrigger(3,new lt(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e));break}n.hasSpecificTrigger(8)&&window.setTimeout(()=>{const o=i.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,h=>h.isPickable&&h.isVisible&&h.isReady()&&h.actionManager&&h.actionManager.hasSpecificTrigger(8)&&h===this._pickedDownMesh,!1,i.cameraToUseForPointers);o?.pickedMesh&&n&&this._activePointerIdsCount!==0&&Date.now()-this._startingPointerTime>Ke.LongPressDelay&&!this._isPointerSwiping()&&(this._startingPointerTime=0,n.processTrigger(8,lt.CreateNew(o.pickedMesh,t)))},Ke.LongPressDelay)}}else for(const n of i._pointerDownStage)e=n.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t,!1);let s;const r=te.POINTERDOWN;e?(i.onPointerDown&&i.onPointerDown(t,e,r),s=new kt(r,t,e),this._setRayOnPointerInfo(e,t)):s=new kt(r,t,null,this),i.onPointerObservable.hasObservers()&&i.onPointerObservable.notifyObservers(s,r)}_isPointerSwiping(){return this._isSwiping}simulatePointerUp(e,t,i){const s=new PointerEvent("pointerup",t);s.inputIndex=ee.Move;const r=new Oa;i?r.doubleClick=!0:r.singleClick=!0,!this._checkPrePointerObservable(e,s,te.POINTERUP)&&this._processPointerUp(e,s,r)}_processPointerUp(e,t,i){const s=this._scene;if(e?.pickedMesh){if(this._pickedUpMesh=e.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(s.onPointerPick&&s.onPointerPick(t,e),i.singleClick&&!i.ignore&&s.onPointerObservable.observers.length>this._cameraObserverCount)){const n=te.POINTERPICK,o=new kt(n,t,e);this._setRayOnPointerInfo(e,t),s.onPointerObservable.notifyObservers(o,n)}const r=e.pickedMesh._getActionManagerForTrigger();if(r&&!i.ignore){r.processTrigger(7,lt.CreateNew(e.pickedMesh,t,e)),!i.hasSwiped&&i.singleClick&&r.processTrigger(1,lt.CreateNew(e.pickedMesh,t,e));const n=e.pickedMesh._getActionManagerForTrigger(6);i.doubleClick&&n&&n.processTrigger(6,lt.CreateNew(e.pickedMesh,t,e))}}else if(!i.ignore)for(const r of s._pointerUpStage)e=r.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t,i.doubleClick);if(this._pickedDownMesh&&this._pickedDownMesh!==this._pickedUpMesh){const r=this._pickedDownMesh._getActionManagerForTrigger(16);r&&r.processTrigger(16,lt.CreateNew(this._pickedDownMesh,t))}if(!i.ignore){const r=new kt(te.POINTERUP,t,e);if(this._setRayOnPointerInfo(e,t),s.onPointerObservable.notifyObservers(r,te.POINTERUP),s.onPointerUp&&s.onPointerUp(t,e,te.POINTERUP),!i.hasSwiped&&!this._skipPointerTap&&!this._isMultiTouchGesture){let n=0;if(i.singleClick?n=te.POINTERTAP:i.doubleClick&&(n=te.POINTERDOUBLETAP),n){const o=new kt(n,t,e);s.onPointerObservable.hasObservers()&&s.onPointerObservable.hasSpecificMask(n)&&s.onPointerObservable.notifyObservers(o,n)}}}}isPointerCaptured(e=0){return this._pointerCaptures[e]}attachControl(e=!0,t=!0,i=!0,s=null){const r=this._scene,n=r.getEngine();s||(s=n.getInputElement()),this._alreadyAttached&&this.detachControl(),s&&(this._alreadyAttachedTo=s),this._deviceSourceManager=new Du(n),this._initActionManager=o=>{if(!this._meshPickProceed){const h=r.skipPointerUpPicking||r._registeredActions===0&&!this._checkForPicking()&&!r.onPointerUp?null:r.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,r.pointerUpPredicate,r.pointerUpFastCheck,r.cameraToUseForPointers,r.pointerUpTrianglePredicate);this._currentPickResult=h,h&&(o=h.hit&&h.pickedMesh?h.pickedMesh._getActionManagerForTrigger():null),this._meshPickProceed=!0}return o},this._delayedSimpleClick=(o,h,l)=>{if((Date.now()-this._previousStartingPointerTime>Ke.DoubleClickDelay&&!this._doubleClickOccured||o!==this._previousButtonPressed)&&(this._doubleClickOccured=!1,h.singleClick=!0,h.ignore=!1,this._delayedClicks[o])){const c=this._delayedClicks[o].evt,u=te.POINTERTAP,f=new kt(u,c,this._currentPickResult);r.onPointerObservable.hasObservers()&&r.onPointerObservable.hasSpecificMask(u)&&r.onPointerObservable.notifyObservers(f,u),this._delayedClicks[o]=null}},this._initClickEvent=(o,h,l,c)=>{const u=new Oa;this._currentPickResult=null;let f=null,d=o.hasSpecificMask(te.POINTERPICK)||h.hasSpecificMask(te.POINTERPICK)||o.hasSpecificMask(te.POINTERTAP)||h.hasSpecificMask(te.POINTERTAP)||o.hasSpecificMask(te.POINTERDOUBLETAP)||h.hasSpecificMask(te.POINTERDOUBLETAP);!d&&wt&&(f=this._initActionManager(f,u),f&&(d=f.hasPickTriggers));let g=!1;if(d=d&&!this._isMultiTouchGesture,d){const p=l.button;if(u.hasSwiped=this._isPointerSwiping(),!u.hasSwiped){let m=!Ke.ExclusiveDoubleClickMode;if(m||(m=!o.hasSpecificMask(te.POINTERDOUBLETAP)&&!h.hasSpecificMask(te.POINTERDOUBLETAP),m&&!wt.HasSpecificTrigger(6)&&(f=this._initActionManager(f,u),f&&(m=!f.hasSpecificTrigger(6)))),m)(Date.now()-this._previousStartingPointerTime>Ke.DoubleClickDelay||p!==this._previousButtonPressed)&&(u.singleClick=!0,c(u,this._currentPickResult),g=!0);else{const E={evt:l,clickInfo:u,timeoutId:window.setTimeout(this._delayedSimpleClick.bind(this,p,u,c),Ke.DoubleClickDelay)};this._delayedClicks[p]=E}let A=o.hasSpecificMask(te.POINTERDOUBLETAP)||h.hasSpecificMask(te.POINTERDOUBLETAP);!A&&wt.HasSpecificTrigger(6)&&(f=this._initActionManager(f,u),f&&(A=f.hasSpecificTrigger(6))),A&&(p===this._previousButtonPressed&&Date.now()-this._previousStartingPointerTime<Ke.DoubleClickDelay&&!this._doubleClickOccured?(!u.hasSwiped&&!this._isPointerSwiping()?(this._previousStartingPointerTime=0,this._doubleClickOccured=!0,u.doubleClick=!0,u.ignore=!1,Ke.ExclusiveDoubleClickMode&&this._delayedClicks[p]&&(clearTimeout(this._delayedClicks[p]?.timeoutId),this._delayedClicks[p]=null),c(u,this._currentPickResult)):(this._doubleClickOccured=!1,this._previousStartingPointerTime=this._startingPointerTime,this._previousStartingPointerPosition.x=this._startingPointerPosition.x,this._previousStartingPointerPosition.y=this._startingPointerPosition.y,this._previousButtonPressed=p,Ke.ExclusiveDoubleClickMode?(this._delayedClicks[p]&&(clearTimeout(this._delayedClicks[p]?.timeoutId),this._delayedClicks[p]=null),c(u,this._previousPickResult)):c(u,this._currentPickResult)),g=!0):(this._doubleClickOccured=!1,this._previousStartingPointerTime=this._startingPointerTime,this._previousStartingPointerPosition.x=this._startingPointerPosition.x,this._previousStartingPointerPosition.y=this._startingPointerPosition.y,this._previousButtonPressed=p))}}g||c(u,this._currentPickResult)},this._onPointerMove=o=>{if(this._updatePointerPosition(o),!this._isSwiping&&this._swipeButtonPressed!==-1&&(this._isSwiping=Math.abs(this._startingPointerPosition.x-this._pointerX)>Ke.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>Ke.DragMovementThreshold),n.isPointerLock&&n._verifyPointerLock(),this._checkPrePointerObservable(null,o,o.inputIndex>=ee.MouseWheelX&&o.inputIndex<=ee.MouseWheelZ?te.POINTERWHEEL:te.POINTERMOVE)||!r.cameraToUseForPointers&&!r.activeCamera)return;if(r.skipPointerMovePicking){this._processPointerMove(new ms,o);return}r.pointerMovePredicate||(r.pointerMovePredicate=l=>l.isPickable&&l.isVisible&&l.isReady()&&l.isEnabled()&&(l.enablePointerMoveEvents||r.constantlyUpdateMeshUnderPointer||l._getActionManagerForTrigger()!==null)&&(!r.cameraToUseForPointers||(r.cameraToUseForPointers.layerMask&l.layerMask)!==0));const h=r._registeredActions>0||r.constantlyUpdateMeshUnderPointer?this._pickMove(o):null;this._processPointerMove(h,o)},this._onPointerDown=o=>{const h=this._activePointerIds.indexOf(-1);if(h===-1?this._activePointerIds.push(o.pointerId):this._activePointerIds[h]=o.pointerId,this._activePointerIdsCount++,this._pickedDownMesh=null,this._meshPickProceed=!1,Ke.ExclusiveDoubleClickMode){for(let c=0;c<this._delayedClicks.length;c++)if(this._delayedClicks[c])if(o.button===c)clearTimeout(this._delayedClicks[c]?.timeoutId);else{const u=this._delayedClicks[c].clickInfo;this._doubleClickOccured=!1,u.singleClick=!0,u.ignore=!1;const f=this._delayedClicks[c].evt,d=te.POINTERTAP,g=new kt(d,f,this._currentPickResult);r.onPointerObservable.hasObservers()&&r.onPointerObservable.hasSpecificMask(d)&&r.onPointerObservable.notifyObservers(g,d),this._delayedClicks[c]=null}}if(this._updatePointerPosition(o),this._swipeButtonPressed===-1&&(this._swipeButtonPressed=o.button),r.preventDefaultOnPointerDown&&s&&(o.preventDefault(),s.focus()),this._startingPointerPosition.x=this._pointerX,this._startingPointerPosition.y=this._pointerY,this._startingPointerTime=Date.now(),this._checkPrePointerObservable(null,o,te.POINTERDOWN)||!r.cameraToUseForPointers&&!r.activeCamera)return;this._pointerCaptures[o.pointerId]=!0,r.pointerDownPredicate||(r.pointerDownPredicate=c=>c.isPickable&&c.isVisible&&c.isReady()&&c.isEnabled()&&(!r.cameraToUseForPointers||(r.cameraToUseForPointers.layerMask&c.layerMask)!==0)),this._pickedDownMesh=null;let l;r.skipPointerDownPicking||r._registeredActions===0&&!this._checkForPicking()&&!r.onPointerDown?l=new ms:l=r.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,r.pointerDownPredicate,r.pointerDownFastCheck,r.cameraToUseForPointers,r.pointerDownTrianglePredicate),this._processPointerDown(l,o)},this._onPointerUp=o=>{const h=this._activePointerIds.indexOf(o.pointerId);h!==-1&&(this._activePointerIds[h]=-1,this._activePointerIdsCount--,this._pickedUpMesh=null,this._meshPickProceed=!1,this._updatePointerPosition(o),r.preventDefaultOnPointerUp&&s&&(o.preventDefault(),s.focus()),this._initClickEvent(r.onPrePointerObservable,r.onPointerObservable,o,(l,c)=>{if(r.onPrePointerObservable.hasObservers()&&(this._skipPointerTap=!1,!l.ignore)){if(this._checkPrePointerObservable(null,o,te.POINTERUP)){this._swipeButtonPressed===o.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1),o.buttons===0&&(this._pointerCaptures[o.pointerId]=!1);return}l.hasSwiped||(l.singleClick&&r.onPrePointerObservable.hasSpecificMask(te.POINTERTAP)&&this._checkPrePointerObservable(null,o,te.POINTERTAP)&&(this._skipPointerTap=!0),l.doubleClick&&r.onPrePointerObservable.hasSpecificMask(te.POINTERDOUBLETAP)&&this._checkPrePointerObservable(null,o,te.POINTERDOUBLETAP)&&(this._skipPointerTap=!0))}if(!this._pointerCaptures[o.pointerId]){this._swipeButtonPressed===o.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1);return}o.buttons===0&&(this._pointerCaptures[o.pointerId]=!1),!(!r.cameraToUseForPointers&&!r.activeCamera)&&(r.pointerUpPredicate||(r.pointerUpPredicate=u=>u.isPickable&&u.isVisible&&u.isReady()&&u.isEnabled()&&(!r.cameraToUseForPointers||(r.cameraToUseForPointers.layerMask&u.layerMask)!==0)),!this._meshPickProceed&&(wt&&wt.HasTriggers||this._checkForPicking()||r.onPointerUp)&&this._initActionManager(null,l),c||(c=this._currentPickResult),this._processPointerUp(c,o,l),this._previousPickResult=this._currentPickResult,this._swipeButtonPressed===o.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1))}))},this._onKeyDown=o=>{const h=Ks.KEYDOWN;if(r.onPreKeyboardObservable.hasObservers()){const l=new Aa(h,o);if(r.onPreKeyboardObservable.notifyObservers(l,h),l.skipOnKeyboardObservable)return}if(r.onKeyboardObservable.hasObservers()){const l=new An(h,o);r.onKeyboardObservable.notifyObservers(l,h)}r.actionManager&&r.actionManager.processTrigger(14,lt.CreateNewFromScene(r,o))},this._onKeyUp=o=>{const h=Ks.KEYUP;if(r.onPreKeyboardObservable.hasObservers()){const l=new Aa(h,o);if(r.onPreKeyboardObservable.notifyObservers(l,h),l.skipOnKeyboardObservable)return}if(r.onKeyboardObservable.hasObservers()){const l=new An(h,o);r.onKeyboardObservable.notifyObservers(l,h)}r.actionManager&&r.actionManager.processTrigger(15,lt.CreateNewFromScene(r,o))},this._deviceSourceManager.onDeviceConnectedObservable.add(o=>{o.deviceType===Y.Mouse?o.onInputChangedObservable.add(h=>{this._originMouseEvent=h,h.inputIndex===ee.LeftClick||h.inputIndex===ee.MiddleClick||h.inputIndex===ee.RightClick||h.inputIndex===ee.BrowserBack||h.inputIndex===ee.BrowserForward?t&&o.getInput(h.inputIndex)===1?this._onPointerDown(h):e&&o.getInput(h.inputIndex)===0&&this._onPointerUp(h):i&&(h.inputIndex===ee.Move?this._onPointerMove(h):(h.inputIndex===ee.MouseWheelX||h.inputIndex===ee.MouseWheelY||h.inputIndex===ee.MouseWheelZ)&&this._onPointerMove(h))}):o.deviceType===Y.Touch?o.onInputChangedObservable.add(h=>{h.inputIndex===ee.LeftClick&&(t&&o.getInput(h.inputIndex)===1?(this._onPointerDown(h),this._activePointerIdsCount>1&&(this._isMultiTouchGesture=!0)):e&&o.getInput(h.inputIndex)===0&&(this._onPointerUp(h),this._activePointerIdsCount===0&&(this._isMultiTouchGesture=!1))),i&&h.inputIndex===ee.Move&&this._onPointerMove(h)}):o.deviceType===Y.Keyboard&&o.onInputChangedObservable.add(h=>{h.type==="keydown"?this._onKeyDown(h):h.type==="keyup"&&this._onKeyUp(h)})}),this._alreadyAttached=!0}detachControl(){this._alreadyAttached&&(this._deviceSourceManager.dispose(),this._deviceSourceManager=null,this._alreadyAttachedTo&&!this._scene.doNotHandleCursors&&(this._alreadyAttachedTo.style.cursor=this._scene.defaultCursor),this._alreadyAttached=!1,this._alreadyAttachedTo=null)}setPointerOverMesh(e,t=0,i,s){if(this._meshUnderPointerId[t]===e&&(!e||!e._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting))return;const r=this._meshUnderPointerId[t];let n;r&&(n=r._getActionManagerForTrigger(10),n&&n.processTrigger(10,new lt(r,this._pointerX,this._pointerY,e,s,{pointerId:t}))),e?(this._meshUnderPointerId[t]=e,this._pointerOverMesh=e,n=e._getActionManagerForTrigger(9),n&&n.processTrigger(9,new lt(e,this._pointerX,this._pointerY,e,s,{pointerId:t,pickResult:i}))):(delete this._meshUnderPointerId[t],this._pointerOverMesh=null),this._scene.onMeshUnderPointerUpdatedObservable.hasObservers()&&this._scene.onMeshUnderPointerUpdatedObservable.notifyObservers({mesh:e,pointerId:t})}getPointerOverMesh(){return this.meshUnderPointer}_invalidateMesh(e){this._pointerOverMesh===e&&(this._pointerOverMesh=null),this._pickedDownMesh===e&&(this._pickedDownMesh=null),this._pickedUpMesh===e&&(this._pickedUpMesh=null);for(const t in this._meshUnderPointerId)this._meshUnderPointerId[t]===e&&delete this._meshUnderPointerId[t]}}Ke.DragMovementThreshold=10;Ke.LongPressDelay=500;Ke.DoubleClickDelay=300;Ke.ExclusiveDoubleClickMode=!1;class oi{get min(){return this._min}get max(){return this._max}get average(){return this._average}get lastSecAverage(){return this._lastSecAverage}get current(){return this._current}get total(){return this._totalAccumulated}get count(){return this._totalValueCount}constructor(){this._startMonitoringTime=0,this._min=0,this._max=0,this._average=0,this._lastSecAverage=0,this._current=0,this._totalValueCount=0,this._totalAccumulated=0,this._lastSecAccumulated=0,this._lastSecTime=0,this._lastSecValueCount=0}fetchNewFrame(){this._totalValueCount++,this._current=0,this._lastSecValueCount++}addCount(e,t){oi.Enabled&&(this._current+=e,t&&this._fetchResult())}beginMonitoring(){oi.Enabled&&(this._startMonitoringTime=vt.Now)}endMonitoring(e=!0){if(!oi.Enabled)return;e&&this.fetchNewFrame();const t=vt.Now;this._current=t-this._startMonitoringTime,e&&this._fetchResult()}endFrame(){this._fetchResult()}_fetchResult(){this._totalAccumulated+=this._current,this._lastSecAccumulated+=this._current,this._min=Math.min(this._min,this._current),this._max=Math.max(this._max,this._current),this._average=this._totalAccumulated/this._totalValueCount;const e=vt.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)}}oi.Enabled=!0;class xh{static get UniqueId(){const e=this._UniqueIdCounter;return this._UniqueIdCounter++,e}}xh._UniqueIdCounter=1;class Ou{constructor(){this.pointerDownFastCheck=!1,this.pointerUpFastCheck=!1,this.pointerMoveFastCheck=!1,this.skipPointerMovePicking=!1,this.skipPointerDownPicking=!1,this.skipPointerUpPicking=!1}}const Fu=new ge,wu=new ge;var Fa;(function(a){a[a.BackwardCompatible=0]="BackwardCompatible",a[a.Intermediate=1]="Intermediate",a[a.Aggressive=2]="Aggressive"})(Fa||(Fa={}));class tt{static DefaultMaterialFactory(e){throw ie("StandardMaterial")}static CollisionCoordinatorFactory(){throw ie("DefaultCollisionCoordinator")}get clearColor(){return this._clearColor}set clearColor(e){e!==this._clearColor&&(this._clearColor=e,this.onClearColorChangedObservable.notifyObservers(this._clearColor))}get imageProcessingConfiguration(){return this._imageProcessingConfiguration}get performancePriority(){return this._performancePriority}set performancePriority(e){if(e!==this._performancePriority){switch(this._performancePriority=e,e){case 0:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!1,this.autoClear=!0;break;case 1:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!0,this.autoClear=!1;break;case 2:this.skipFrustumClipping=!0,this._renderingManager.maintainStateBetweenFrames=!0,this.skipPointerMovePicking=!0,this.autoClear=!1;break}this.onScenePerformancePriorityChangedObservable.notifyObservers(e)}}set forceWireframe(e){this._forceWireframe!==e&&(this._forceWireframe=e,this.markAllMaterialsAsDirty(16))}get forceWireframe(){return this._forceWireframe}set skipFrustumClipping(e){this._skipFrustumClipping!==e&&(this._skipFrustumClipping=e)}get skipFrustumClipping(){return this._skipFrustumClipping}set forcePointsCloud(e){this._forcePointsCloud!==e&&(this._forcePointsCloud=e,this.markAllMaterialsAsDirty(16))}get forcePointsCloud(){return this._forcePointsCloud}get environmentTexture(){return this._environmentTexture}set environmentTexture(e){this._environmentTexture!==e&&(this._environmentTexture=e,this.onEnvironmentTextureChangedObservable.notifyObservers(e),this.markAllMaterialsAsDirty(1))}getNodes(){let e=[];e=e.concat(this.meshes),e=e.concat(this.lights),e=e.concat(this.cameras),e=e.concat(this.transformNodes);for(const t of this.skeletons)e=e.concat(t.bones);return e}get animationPropertiesOverride(){return this._animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}set beforeRender(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),e&&(this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e))}set afterRender(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),e&&(this._onAfterRenderObserver=this.onAfterRenderObservable.add(e))}set beforeCameraRender(e){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(e)}set afterCameraRender(e){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(e)}get pointerDownPredicate(){return this._pointerPickingConfiguration.pointerDownPredicate}set pointerDownPredicate(e){this._pointerPickingConfiguration.pointerDownPredicate=e}get pointerUpPredicate(){return this._pointerPickingConfiguration.pointerUpPredicate}set pointerUpPredicate(e){this._pointerPickingConfiguration.pointerUpPredicate=e}get pointerMovePredicate(){return this._pointerPickingConfiguration.pointerMovePredicate}set pointerMovePredicate(e){this._pointerPickingConfiguration.pointerMovePredicate=e}get pointerDownFastCheck(){return this._pointerPickingConfiguration.pointerDownFastCheck}set pointerDownFastCheck(e){this._pointerPickingConfiguration.pointerDownFastCheck=e}get pointerUpFastCheck(){return this._pointerPickingConfiguration.pointerUpFastCheck}set pointerUpFastCheck(e){this._pointerPickingConfiguration.pointerUpFastCheck=e}get pointerMoveFastCheck(){return this._pointerPickingConfiguration.pointerMoveFastCheck}set pointerMoveFastCheck(e){this._pointerPickingConfiguration.pointerMoveFastCheck=e}get skipPointerMovePicking(){return this._pointerPickingConfiguration.skipPointerMovePicking}set skipPointerMovePicking(e){this._pointerPickingConfiguration.skipPointerMovePicking=e}get skipPointerDownPicking(){return this._pointerPickingConfiguration.skipPointerDownPicking}set skipPointerDownPicking(e){this._pointerPickingConfiguration.skipPointerDownPicking=e}get skipPointerUpPicking(){return this._pointerPickingConfiguration.skipPointerUpPicking}set skipPointerUpPicking(e){this._pointerPickingConfiguration.skipPointerUpPicking=e}get unTranslatedPointer(){return this._inputManager.unTranslatedPointer}static get DragMovementThreshold(){return Ke.DragMovementThreshold}static set DragMovementThreshold(e){Ke.DragMovementThreshold=e}static get LongPressDelay(){return Ke.LongPressDelay}static set LongPressDelay(e){Ke.LongPressDelay=e}static get DoubleClickDelay(){return Ke.DoubleClickDelay}static set DoubleClickDelay(e){Ke.DoubleClickDelay=e}static get ExclusiveDoubleClickMode(){return Ke.ExclusiveDoubleClickMode}static set ExclusiveDoubleClickMode(e){Ke.ExclusiveDoubleClickMode=e}get _eyePosition(){return this._forcedViewPosition??this.activeCamera?.globalPosition??_.ZeroReadOnly}bindEyePosition(e,t="vEyePosition",i=!1){const s=this._eyePosition,r=this.useRightHandedSystem===(this._mirroredCameraPosition!=null),n=this.floatingOriginOffset,o=Fu.set(s.x,s.y,s.z,r?-1:1),h=o.subtractFromFloatsToRef(n.x,n.y,n.z,0,wu);return e&&(i?e.setFloat3(t,h.x,h.y,h.z):e.setVector4(t,h)),o}finalizeSceneUbo(){const e=this.getSceneUniformBuffer(),t=this.bindEyePosition(null),i=this.floatingOriginOffset;return e.updateFloat4("vEyePosition",t.x-i.x,t.y-i.y,t.z-i.z,t.w),e.update(),e}set useRightHandedSystem(e){this._useRightHandedSystem!==e&&(this._useRightHandedSystem=e,this.markAllMaterialsAsDirty(16))}get useRightHandedSystem(){return this._useRightHandedSystem}setStepId(e){this._currentStepId=e}getStepId(){return this._currentStepId}getInternalStep(){return this._currentInternalStep}set fogEnabled(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAllMaterialsAsDirty(16))}get fogEnabled(){return this._fogEnabled}set fogMode(e){this._fogMode!==e&&(this._fogMode=e,this.markAllMaterialsAsDirty(16))}get fogMode(){return this._fogMode}get prePass(){return!!this.prePassRenderer&&this.prePassRenderer.defaultRT.enabled}set shadowsEnabled(e){this._shadowsEnabled!==e&&(this._shadowsEnabled=e,this.markAllMaterialsAsDirty(2))}get shadowsEnabled(){return this._shadowsEnabled}set lightsEnabled(e){this._lightsEnabled!==e&&(this._lightsEnabled=e,this.markAllMaterialsAsDirty(2))}get lightsEnabled(){return this._lightsEnabled}get activeCameras(){return this._activeCameras}set activeCameras(e){this._unObserveActiveCameras&&(this._unObserveActiveCameras(),this._unObserveActiveCameras=null),e&&(this._unObserveActiveCameras=_o(e,()=>{this.onActiveCamerasChanged.notifyObservers(this)})),this._activeCameras=e}get activeCamera(){return this._activeCamera}set activeCamera(e){e!==this._activeCamera&&(this._activeCamera=e,this.onActiveCameraChanged.notifyObservers(this))}get _hasDefaultMaterial(){return tt.DefaultMaterialFactory!==tt._OriginalDefaultMaterialFactory}get defaultMaterial(){return this._defaultMaterial||(this._defaultMaterial=tt.DefaultMaterialFactory(this)),this._defaultMaterial}set defaultMaterial(e){this._defaultMaterial=e}set texturesEnabled(e){this._texturesEnabled!==e&&(this._texturesEnabled=e,this.markAllMaterialsAsDirty(1))}get texturesEnabled(){return this._texturesEnabled}get frameGraph(){return this._frameGraph}set frameGraph(e){if(this._frameGraph){this._frameGraph=e,e||(this.customRenderFunction=this._currentCustomRenderFunction);return}this._frameGraph=e,e&&(this._currentCustomRenderFunction=this.customRenderFunction,this.customRenderFunction=this._renderWithFrameGraph,this.activeCamera=null)}set skeletonsEnabled(e){this._skeletonsEnabled!==e&&(this._skeletonsEnabled=e,this.markAllMaterialsAsDirty(8))}get skeletonsEnabled(){return this._skeletonsEnabled}get collisionCoordinator(){return this._collisionCoordinator||(this._collisionCoordinator=tt.CollisionCoordinatorFactory(),this._collisionCoordinator.init(this)),this._collisionCoordinator}get renderingManager(){return this._renderingManager}get frustumPlanes(){return this._frustumPlanes}_registerTransientComponents(){if(this._transientComponents.length>0){for(const e of this._transientComponents)e.register();this._transientComponents.length=0}}_addComponent(e){this._components.push(e),this._transientComponents.push(e);const t=e;t.addFromContainer&&t.serialize&&this._serializableComponents.push(t)}_getComponent(e){for(const t of this._components)if(t.name===e)return t;return null}get uniqueId(){return this._uniqueId}constructor(e,t){this._inputManager=new Ke(this),this.cameraToUseForPointers=null,this._isScene=!0,this._blockEntityCollection=!1,this.autoClear=!0,this.autoClearDepthAndStencil=!0,this._clearColor=new fe(.2,.2,.3,1),this.onClearColorChangedObservable=new O,this.ambientColor=new q(0,0,0),this.environmentIntensity=1,this.iblIntensity=1,this._performancePriority=0,this.onScenePerformancePriorityChangedObservable=new O,this._forceWireframe=!1,this._skipFrustumClipping=!1,this._forcePointsCloud=!1,this.rootNodes=[],this.cameras=[],this.lights=[],this.meshes=[],this.skeletons=[],this.particleSystems=[],this.animations=[],this.animationGroups=[],this.multiMaterials=[],this.materials=[],this.morphTargetManagers=[],this.geometries=[],this.transformNodes=[],this.actionManagers=[],this.objectRenderers=[],this.textures=[],this._environmentTexture=null,this.postProcesses=[],this.effectLayers=[],this.sounds=null,this.layers=[],this.lensFlareSystems=[],this.proceduralTextures=[],this.animationsEnabled=!0,this._animationPropertiesOverride=null,this.useConstantAnimationDeltaTime=!1,this.constantlyUpdateMeshUnderPointer=!1,this.hoverCurs
vendor: 9,959 bytes, line 30
30or="pointer",this.defaultCursor="",this.doNotHandleCursors=!1,this.preventDefaultOnPointerDown=!0,this.preventDefaultOnPointerUp=!0,this.metadata=null,this.reservedDataStore=null,this.disableOfflineSupportExceptionRules=[],this.onDisposeObservable=new O,this._onDisposeObserver=null,this.onBeforeRenderObservable=new O,this._onBeforeRenderObserver=null,this.onAfterRenderObservable=new O,this.onAfterRenderCameraObservable=new O,this._onAfterRenderObserver=null,this.onBeforeAnimationsObservable=new O,this.onAfterAnimationsObservable=new O,this.onBeforeDrawPhaseObservable=new O,this.onAfterDrawPhaseObservable=new O,this.onReadyObservable=new O,this.onBeforeCameraRenderObservable=new O,this._onBeforeCameraRenderObserver=null,this.onAfterCameraRenderObservable=new O,this._onAfterCameraRenderObserver=null,this.onBeforeActiveMeshesEvaluationObservable=new O,this.onAfterActiveMeshesEvaluationObservable=new O,this.onBeforeParticlesRenderingObservable=new O,this.onAfterParticlesRenderingObservable=new O,this.onDataLoadedObservable=new O,this.onNewCameraAddedObservable=new O,this.onCameraRemovedObservable=new O,this.onNewLightAddedObservable=new O,this.onLightRemovedObservable=new O,this.onNewGeometryAddedObservable=new O,this.onGeometryRemovedObservable=new O,this.onNewTransformNodeAddedObservable=new O,this.onTransformNodeRemovedObservable=new O,this.onNewMeshAddedObservable=new O,this.onMeshRemovedObservable=new O,this.onNewSkeletonAddedObservable=new O,this.onSkeletonRemovedObservable=new O,this.onNewParticleSystemAddedObservable=new O,this.onParticleSystemRemovedObservable=new O,this.onNewAnimationGroupAddedObservable=new O,this.onAnimationGroupRemovedObservable=new O,this.onNewMaterialAddedObservable=new O,this.onNewMultiMaterialAddedObservable=new O,this.onMaterialRemovedObservable=new O,this.onMultiMaterialRemovedObservable=new O,this.onNewTextureAddedObservable=new O,this.onTextureRemovedObservable=new O,this.onNewFrameGraphAddedObservable=new O,this.onFrameGraphRemovedObservable=new O,this.onNewObjectRendererAddedObservable=new O,this.onObjectRendererRemovedObservable=new O,this.onNewPostProcessAddedObservable=new O,this.onPostProcessRemovedObservable=new O,this.onNewEffectLayerAddedObservable=new O,this.onEffectLayerRemovedObservable=new O,this.onBeforeRenderTargetsRenderObservable=new O,this.onAfterRenderTargetsRenderObservable=new O,this.onBeforeStepObservable=new O,this.onAfterStepObservable=new O,this.onActiveCameraChanged=new O,this.onActiveCamerasChanged=new O,this.onBeforeRenderingGroupObservable=new O,this.onAfterRenderingGroupObservable=new O,this.onMeshImportedObservable=new O,this.onAnimationFileImportedObservable=new O,this.onEnvironmentTextureChangedObservable=new O,this.onMeshUnderPointerUpdatedObservable=new O,this._registeredForLateAnimationBindings=new Yi(256),this._pointerPickingConfiguration=new Ou,this.onPrePointerObservable=new O,this.onPointerObservable=new O,this.onPreKeyboardObservable=new O,this.onKeyboardObservable=new O,this._useRightHandedSystem=!1,this._timeAccumulator=0,this._currentStepId=0,this._currentInternalStep=0,this._fogEnabled=!0,this._fogMode=tt.FOGMODE_NONE,this.fogColor=new q(.2,.2,.3),this.fogDensity=.1,this.fogStart=0,this.fogEnd=1e3,this.needsPreviousWorldMatrices=!1,this._shadowsEnabled=!0,this._lightsEnabled=!0,this._unObserveActiveCameras=null,this._texturesEnabled=!0,this._frameGraph=null,this.frameGraphs=[],this.physicsEnabled=!0,this.particlesEnabled=!0,this.spritesEnabled=!0,this._skeletonsEnabled=!0,this.lensFlaresEnabled=!0,this.collisionsEnabled=!0,this.gravity=new _(0,-9.807,0),this.postProcessesEnabled=!0,this.renderTargetsEnabled=!0,this.dumpNextRenderTargets=!1,this.customRenderTargets=[],this.importedMeshesFiles=[],this.probesEnabled=!0,this._meshesForIntersections=new Yi(256),this.proceduralTexturesEnabled=!0,this._totalVertices=new oi,this._activeIndices=new oi,this._activeParticles=new oi,this._activeBones=new oi,this._animationTime=0,this.animationTimeScale=1,this._renderId=0,this._frameId=0,this._executeWhenReadyTimeoutId=null,this._intermediateRendering=!1,this._defaultFrameBufferCleared=!1,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1,this._toBeDisposed=new Array(256),this._activeRequests=new Array,this._pendingData=[],this._isDisposed=!1,this.dispatchAllSubMeshesOfActiveMeshes=!1,this._activeMeshes=new it(256),this._processedMaterials=new it(256),this._renderTargets=new Yi(256),this._materialsRenderTargets=new Yi(256),this._activeParticleSystems=new it(256),this._activeSkeletons=new Yi(32),this._softwareSkinnedMeshes=new Yi(32),this._activeAnimatables=new Array,this._transformMatrix=P.Zero(),this.requireLightSorting=!1,this._components=[],this._serializableComponents=[],this._transientComponents=[],this._beforeCameraUpdateStage=Xe.Create(),this._beforeClearStage=Xe.Create(),this._beforeRenderTargetClearStage=Xe.Create(),this._gatherRenderTargetsStage=Xe.Create(),this._gatherActiveCameraRenderTargetsStage=Xe.Create(),this._isReadyForMeshStage=Xe.Create(),this._beforeEvaluateActiveMeshStage=Xe.Create(),this._evaluateSubMeshStage=Xe.Create(),this._preActiveMeshStage=Xe.Create(),this._cameraDrawRenderTargetStage=Xe.Create(),this._beforeCameraDrawStage=Xe.Create(),this._beforeRenderTargetDrawStage=Xe.Create(),this._beforeRenderingGroupDrawStage=Xe.Create(),this._beforeRenderingMeshStage=Xe.Create(),this._afterRenderingMeshStage=Xe.Create(),this._afterRenderingGroupDrawStage=Xe.Create(),this._afterCameraDrawStage=Xe.Create(),this._afterCameraPostProcessStage=Xe.Create(),this._afterRenderTargetDrawStage=Xe.Create(),this._afterRenderTargetPostProcessStage=Xe.Create(),this._afterRenderStage=Xe.Create(),this._pointerMoveStage=Xe.Create(),this._pointerDownStage=Xe.Create(),this._pointerUpStage=Xe.Create(),this._geometriesByUniqueId=null,this._uniqueId=0,this._defaultMeshCandidates={data:[],length:0},this._defaultSubMeshCandidates={data:[],length:0},this.onReadyTimeoutObservable=new O,this.onReadyTimeoutDuration=120*1e3,this._timeoutChecksStartTime=0,this._floatingOriginScene=void 0,this._preventFreeActiveMeshesAndRenderingGroups=!1,this._activeMeshesFrozen=!1,this._activeMeshesFrozenButKeepClipping=!1,this._skipEvaluateActiveMeshesCompletely=!1,this._freezeActiveMeshesCancel=null,this._useCurrentFrameBuffer=!1,this._allowPostProcessClearColor=!0,this.getDeterministicFrameTime=()=>this._engine.getTimeStep(),this._getFloatingOriginScene=()=>this._floatingOriginScene,this._registeredActions=0,this._blockMaterialDirtyMechanism=!1,this._perfCollector=null,this.activeCameras=[],this._uniqueId=this.getUniqueId();const i={useGeometryUniqueIdsMap:!0,useMaterialMeshMap:!0,useClonedMeshMap:!0,virtual:!1,...t};e=this._engine=e||Te.LastCreatedEngine,i.virtual?e._virtualScenes.push(this):(Te._LastCreatedScene=this,e.scenes.push(this)),(e.getCreationOptions().useLargeWorldRendering||t?.useFloatingOrigin)&&(Vc(),this._floatingOriginScene=this),this._uid=null,this._renderingManager=new ct(this),Rn&&(this.postProcessManager=new Rn(this)),_t()&&this.attachControl(),this._createUbo(),ue&&(this._imageProcessingConfiguration=new ue),this.setDefaultCandidateProviders(),i.useGeometryUniqueIdsMap&&(this._geometriesByUniqueId={}),this.useMaterialMeshMap=i.useMaterialMeshMap,this.useClonedMeshMap=i.useClonedMeshMap,(!t||!t.virtual)&&e.onNewSceneAddedObservable.notifyObservers(this)}getClassName(){return"Scene"}_getDefaultMeshCandidates(){return this._defaultMeshCandidates.data=this.meshes,this._defaultMeshCandidates.length=this.meshes.length,this._defaultMeshCandidates}_getDefaultSubMeshCandidates(e){return this._defaultSubMeshCandidates.data=e.subMeshes,this._defaultSubMeshCandidates.length=e.subMeshes.length,this._defaultSubMeshCandidates}setDefaultCandidateProviders(){this.getActiveMeshCandidates=()=>this._getDefaultMeshCandidates(),this.getActiveSubMeshCandidates=e=>this._getDefaultSubMeshCandidates(e),this.getIntersectingSubMeshCandidates=(e,t)=>this._getDefaultSubMeshCandidates(e),this.getCollidingSubMeshCandidates=(e,t)=>this._getDefaultSubMeshCandidates(e)}get meshUnderPointer(){return this._inputManager.meshUnderPointer}get pointerX(){return this._inputManager.pointerX}set pointerX(e){this._inputManager.pointerX=e}get pointerY(){return this._inputManager.pointerY}set pointerY(e){this._inputManager.pointerY=e}getCachedMaterial(){return this._cachedMaterial}getCachedEffect(){return this._cachedEffect}getCachedVisibility(){return this._cachedVisibility}isCachedMaterialInvalid(e,t,i=1){return this._cachedEffect!==t||this._cachedMaterial!==e||this._cachedVisibility!==i}getEngine(){return this._engine}getTotalVertices(){return this._totalVertices.current}get totalVerticesPerfCounter(){return this._totalVertices}getActiveIndices(){return this._activeIndices.current}get totalActiveIndicesPerfCounter(){return this._activeIndices}getActiveParticles(){return this._activeParticles.current}get activeParticlesPerfCounter(){return this._activeParticles}getActiveBones(){return this._activeBones.current}get activeBonesPerfCounter(){return this._activeBones}getActiveMeshes(){return this._activeMeshes}getAnimationRatio(){return this._animationRatio!==void 0?this._animationRatio:1}getRenderId(){return this._renderId}getFrameId(){return this._frameId}incrementRenderId(){this._renderId++}_createUbo(){this.setSceneUniformBuffer(this.createSceneUniformBuffer())}simulatePointerMove(e,t){return this._inputManager.simulatePointerMove(e,t),this}simulatePointerDown(e,t){return this._inputManager.simulatePointerDown(e,t),this}simulatePointerUp(e,t,i){return this._inputManager.simulatePointerUp(e,t,i),this}isPointerCaptured(e=0){return this._inputManager.isPointerCaptured(e)}attachControl(e=!0,t=!0,i=!0){this._inputManager.attachControl(e,t,i)}detachControl(){this._inputManager.detachControl()}isReady(e=!0){if(this._isDisposed)return!1;let t;const i=this.getEngine(),s=i.currentRenderPassId;i.currentRenderPassId=this.activeCamera?.renderPassId??s;let r=!0;
30for(this._pendingData.length>0&&(r=!1),this.prePassRenderer?.update(),this.useOrderIndependentTransparency&&this.depthPeelingRenderer&&r&&(r=this.depthPeelingRenderer.isReady()),e&&(this._processedMaterials.reset(),this._materialsRenderTargets.reset()),t=0;t<this.meshes.length;t++){const n=this.meshes[t];if(!n.subMeshes||n.subMeshes.length===0)continue;if(!n.isReady(!0)){r=!1;continue}const o=n.hasThinInstances||n.getClassName()==="InstancedMesh"||n.getClassName()==="InstancedLinesMesh"||i.getCaps().instancedArrays&&n.instances.length>0;for(const l of this._isReadyForMeshStage)l.action(n,o)||(r=!1);if(!e)continue;const h=n.material||this.defaultMaterial;if(h)if(h._storeEffectOnSubMeshes)for(const l of n.subMeshes){const c=l.getMaterial();c&&c.hasRenderTargetTextures&&c.getRenderTargetTextures!=null&&this._processedMaterials.indexOf(c)===-1&&(this._processedMaterials.push(c),this._materialsRenderTargets.concatWithNoDuplicate(c.getRenderTargetTextures()))}else h.hasRenderTargetTextures&&h.getRenderTargetTextures!=null&&this._processedMaterials.indexOf(h)===-1&&(this._processedMaterials.push(h),this._materialsRenderTargets.concatWithNoDuplicate(h.getRenderTargetTextures()))}if(e)for(t=0;t<this._materialsRenderTargets.length;++t)this._materialsRenderTargets.data[t].isReadyForRendering()||(r=!1);for(t=0;t<this.geometries.length;t++)this.geometries[t].delayLoadState===2&&(r=!1);if(this.activeCameras&&this.activeCameras.length>0)for(const n of this.activeCameras)n.isReady(!0)||(r=!1);else this.activeCamera&&(this.activeCamera.isReady(!0)||(r=!1));for(const n of this.particleSystems)n.isReady()||(r=!1);if(this.layers)for(const n of this.layers)n.isReady()||(r=!1);if(this.effectLayers)for(const n of this.effectLayers)n.isLayerReady()||(r=!1);return i.areAllEffectsReady()||(r=!1),i.currentRenderPassId=s,r}resetCachedMaterial(){this._cachedMaterial=null,this._cachedEffect=null,this._cachedVisibility=null}registerBeforeRender(e){this.onBeforeRenderObservable.add(e)}unregisterBeforeRender(e){this.onBeforeRenderObservable.removeCallback(e)}registerAfterRender(e){this.onAfterRenderObservable.add(e)}unregisterAfterRender(e){this.onAfterRenderObservable.removeCallback(e)}_executeOnceBeforeRender(e){const t=()=>{e(),setTimeout(()=>{this.unregisterBeforeRender(t)})};this.registerBeforeRender(t)}executeOnceBeforeRender(e,t){t!==void 0?setTimeout(()=>{this._executeOnceBeforeRender(e)},t):this._executeOnceBeforeRender(e)}addPendingData(e){this._pendingData.push(e)}removePendingData(e){const t=this.isLoading,i=this._pendingData.indexOf(e);i!==-1&&this._pendingData.splice(i,1),t&&!this.isLoading&&this.onDataLoadedObservable.notifyObservers(this)}getWaitingItemsCount(){return this._pendingData.length}get isLoading(){return this._pendingData.length>0}executeWhenReady(e,t=!1){this.onReadyObservable.addOnce(e),this._executeWhenReadyTimeoutId===null&&this._checkIsReady(t)}async whenReadyAsync(e=!1){return await new Promise(t=>{this.executeWhenReady(()=>{t()},e)})}_clearReadynessChecksData(){this._timeoutChecksStartTime=0,this.onReadyTimeoutObservable.clear(),this.onReadyObservable.clear(),this._executeWhenReadyTimeoutId=null}_checkIsReady(e=!1){if(this._registerTransientComponents(),this._timeoutChecksStartTime===0)this._timeoutChecksStartTime=vt.Now;else if(this.onReadyTimeoutDuration>0&&vt.Now-this._timeoutChecksStartTime>this.onReadyTimeoutDuration){this.onReadyTimeoutObservable.notifyObservers(this),this._clearReadynessChecksData();return}if(this.isReady(e)){this.onReadyObservable.notifyObservers(this),this._clearReadynessChecksData();return}if(this._isDisposed){this._clearReadynessChecksData();return}this._executeWhenReadyTimeoutId=setTimeout(()=>{this.incrementRenderId(),this._checkIsReady(e)},100)}get animatables(){return this._activeAnimatables}resetLastAnimationTimeFrame(){this._animationTimeLast=vt.Now}getViewMatrix(){return this._viewMatrix}getProjectionMatrix(){return this._projectionMatrix}getTransformMatrix(){return this._transformMatrix}setTransformMatrix(e,t,i,s){!i&&!s&&this._multiviewSceneUbo&&(this._multiviewSceneUbo.dispose(),this._multiviewSceneUbo=null),!(this._viewUpdateFlag===e.updateFlag&&this._projectionUpdateFlag===t.updateFlag)&&(this._viewUpdateFlag=e.updateFlag,this._projectionUpdateFlag=t.updateFlag,this._viewMatrix=e,this._projectionMatrix=t,this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?Gt.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=Gt.GetPlanes(this._transformMatrix),this._multiviewSceneUbo&&this._multiviewSceneUbo.useUbo?this._updateMultiviewUbo(i,s):this._sceneUbo.useUbo&&(this._sceneUbo.updateMatrix("viewProjection",this._transformMatrix),this._sceneUbo.updateMatrix("view",this._viewMatrix),this._sceneUbo.updateMatrix("projection",this._projectionMatrix)))}getSceneUniformBuffer(){return this._multiviewSceneUbo?this._multiviewSceneUbo:this._sceneUbo}createSceneUniformBuffer(e,t){const i=new K(this._engine,void 0,!1,e??"scene",void 0,t);return i.addUniform("viewProjection",16),i.addUniform("view",16),i.addUniform("projection",16),i.addUniform("vEyePosition",4),i}setSceneUniformBuffer(e){this._sceneUbo=e,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1}get floatingOriginMode(){return this._floatingOriginScene!==void 0}get floatingOriginOffset(){return this.floatingOriginMode?this._eyePosition:_.ZeroReadOnly}getUniqueId(){return xh.UniqueId}
vendor: 12,258 bytes, line 30
30addMesh(e,t=!1){if(!this._blockEntityCollection&&(this.meshes.push(e),e._resyncLightSources(),e.parent||e._addToSceneRootNodes(),se.SetImmediate(()=>{this.onNewMeshAddedObservable.notifyObservers(e)}),t)){const i=e.getChildMeshes();for(const s of i)this.addMesh(s)}}removeMesh(e,t=!1){const i=this.meshes.indexOf(e);if(i!==-1&&(this.meshes.splice(i,1),e.parent||e._removeFromSceneRootNodes()),this._inputManager._invalidateMesh(e),this.onMeshRemovedObservable.notifyObservers(e),t){const s=e.getChildMeshes();for(const r of s)this.removeMesh(r)}return i}addTransformNode(e){this._blockEntityCollection||e.getScene()===this&&e._indexInSceneTransformNodesArray!==-1||(e._indexInSceneTransformNodesArray=this.transformNodes.length,this.transformNodes.push(e),e.parent||e._addToSceneRootNodes(),this.onNewTransformNodeAddedObservable.notifyObservers(e))}removeTransformNode(e){const t=e._indexInSceneTransformNodesArray;if(t!==-1){if(t!==this.transformNodes.length-1){const i=this.transformNodes[this.transformNodes.length-1];this.transformNodes[t]=i,i._indexInSceneTransformNodesArray=t}e._indexInSceneTransformNodesArray=-1,this.transformNodes.pop(),e.parent||e._removeFromSceneRootNodes()}return this.onTransformNodeRemovedObservable.notifyObservers(e),t}removeSkeleton(e){const t=this.skeletons.indexOf(e);return t!==-1&&(this.skeletons.splice(t,1),this.onSkeletonRemovedObservable.notifyObservers(e),this._executeActiveContainerCleanup(this._activeSkeletons)),t}removeMorphTargetManager(e){const t=this.morphTargetManagers.indexOf(e);return t!==-1&&this.morphTargetManagers.splice(t,1),t}removeLight(e){const t=this.lights.indexOf(e);if(t!==-1){for(const i of this.meshes)i._removeLightSource(e,!1);this.lights.splice(t,1),this.sortLightsByPriority(),e.parent||e._removeFromSceneRootNodes(),this.onLightRemovedObservable.notifyObservers(e)}return t}removeCamera(e){const t=this.cameras.indexOf(e);if(t!==-1&&(this.cameras.splice(t,1),e.parent||e._removeFromSceneRootNodes()),this.activeCameras){const i=this.activeCameras.indexOf(e);i!==-1&&this.activeCameras.splice(i,1)}return this.activeCamera===e&&(this.cameras.length>0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t}removeParticleSystem(e){const t=this.particleSystems.indexOf(e);return t!==-1&&(this.particleSystems.splice(t,1),this._executeActiveContainerCleanup(this._activeParticleSystems)),this.onParticleSystemRemovedObservable.notifyObservers(e),t}removeAnimation(e){const t=this.animations.indexOf(e);return t!==-1&&this.animations.splice(t,1),t}stopAnimation(e,t,i){}removeAnimationGroup(e){const t=this.animationGroups.indexOf(e);return t!==-1&&this.animationGroups.splice(t,1),this.onAnimationGroupRemovedObservable.notifyObservers(e),t}removeMultiMaterial(e){const t=this.multiMaterials.indexOf(e);return t!==-1&&this.multiMaterials.splice(t,1),this.onMultiMaterialRemovedObservable.notifyObservers(e),t}removeMaterial(e){const t=e._indexInSceneMaterialArray;if(t!==-1&&t<this.materials.length){if(t!==this.materials.length-1){const i=this.materials[this.materials.length-1];this.materials[t]=i,i._indexInSceneMaterialArray=t}e._indexInSceneMaterialArray=-1,this.materials.pop()}return this.onMaterialRemovedObservable.notifyObservers(e),t}removeActionManager(e){const t=this.actionManagers.indexOf(e);return t!==-1&&this.actionManagers.splice(t,1),t}removeTexture(e){const t=this.textures.indexOf(e);return t!==-1&&this.textures.splice(t,1),this.onTextureRemovedObservable.notifyObservers(e),t}removeFrameGraph(e){const t=this.frameGraphs.indexOf(e);return t!==-1&&this.frameGraphs.splice(t,1),this.onFrameGraphRemovedObservable.notifyObservers(e),t}removeObjectRenderer(e){const t=this.objectRenderers.indexOf(e);return t!==-1&&this.objectRenderers.splice(t,1),this.onObjectRendererRemovedObservable.notifyObservers(e),t}removePostProcess(e){const t=this.postProcesses.indexOf(e);return t!==-1&&this.postProcesses.splice(t,1),this.onPostProcessRemovedObservable.notifyObservers(e),t}removeEffectLayer(e){const t=this.effectLayers.indexOf(e);return t!==-1&&this.effectLayers.splice(t,1),this.onEffectLayerRemovedObservable.notifyObservers(e),t}addLight(e){if(!this._blockEntityCollection){this.lights.push(e),this.sortLightsByPriority(),e.parent||e._addToSceneRootNodes();for(const t of this.meshes)t.lightSources.indexOf(e)===-1&&(t.lightSources.push(e),t._resyncLightSources());se.SetImmediate(()=>{this.onNewLightAddedObservable.notifyObservers(e)})}}sortLightsByPriority(){this.requireLightSorting&&this.lights.sort(Ee.CompareLightsPriority)}addCamera(e){this._blockEntityCollection||(this.cameras.push(e),se.SetImmediate(()=>{this.onNewCameraAddedObservable.notifyObservers(e)}),e.parent||e._addToSceneRootNodes())}addSkeleton(e){this._blockEntityCollection||(this.skeletons.push(e),se.SetImmediate(()=>{this.onNewSkeletonAddedObservable.notifyObservers(e)}))}addParticleSystem(e){this._blockEntityCollection||(this.particleSystems.push(e),se.SetImmediate(()=>{this.onNewParticleSystemAddedObservable.notifyObservers(e)}))}addAnimation(e){this._blockEntityCollection||this.animations.push(e)}addAnimationGroup(e){this._blockEntityCollection||(this.animationGroups.push(e),se.SetImmediate(()=>{this.onNewAnimationGroupAddedObservable.notifyObservers(e)}))}addMultiMaterial(e){this._blockEntityCollection||(this.multiMaterials.push(e),se.SetImmediate(()=>{this.onNewMultiMaterialAddedObservable.notifyObservers(e)}))}addMaterial(e){this._blockEntityCollection||e.getScene()===this&&e._indexInSceneMaterialArray!==-1||(e._indexInSceneMaterialArray=this.materials.length,this.materials.push(e),se.SetImmediate(()=>{this.onNewMaterialAddedObservable.notifyObservers(e)}))}addMorphTargetManager(e){this._blockEntityCollection||this.morphTargetManagers.push(e)}addGeometry(e){this._blockEntityCollection||(this._geometriesByUniqueId&&(this._geometriesByUniqueId[e.uniqueId]=this.geometries.length),this.geometries.push(e))}addActionManager(e){this.actionManagers.push(e)}addTexture(e){this._blockEntityCollection||(this.textures.push(e),this.onNewTextureAddedObservable.notifyObservers(e))}addFrameGraph(e){this.frameGraphs.push(e),se.SetImmediate(()=>{this.onNewFrameGraphAddedObservable.notifyObservers(e)})}addObjectRenderer(e){this.objectRenderers.push(e),se.SetImmediate(()=>{this.onNewObjectRendererAddedObservable.notifyObservers(e)})}addPostProcess(e){this._blockEntityCollection||(this.postProcesses.push(e),se.SetImmediate(()=>{this.onNewPostProcessAddedObservable.notifyObservers(e)}))}addEffectLayer(e){this._blockEntityCollection||(this.effectLayers.push(e),se.SetImmediate(()=>{this.onNewEffectLayerAddedObservable.notifyObservers(e)}))}switchActiveCamera(e,t=!0){this._engine.getInputElement()&&(this.activeCamera&&this.activeCamera.detachControl(),this.activeCamera=e,t&&e.attachControl())}setActiveCameraById(e){const t=this.getCameraById(e);return t?(this.activeCamera=t,t):null}setActiveCameraByName(e){const t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null}getAnimationGroupByName(e){for(let t=0;t<this.animationGroups.length;t++)if(this.animationGroups[t].name===e)return this.animationGroups[t];return null}_getMaterial(e,t){for(let i=0;i<this.materials.length;i++){const s=this.materials[i];if(t(s))return s}if(e)for(let i=0;i<this.multiMaterials.length;i++){const s=this.multiMaterials[i];if(t(s))return s}return null}getMaterialByUniqueID(e,t=!1){return this.getMaterialByUniqueId(e,t)}getMaterialByUniqueId(e,t=!1){return this._getMaterial(t,i=>i.uniqueId===e)}getMaterialById(e,t=!1){return this._getMaterial(t,i=>i.id===e)}getMaterialByName(e,t=!1){return this._getMaterial(t,i=>i.name===e)}getLastMaterialById(e,t=!1){for(let i=this.materials.length-1;i>=0;i--)if(this.materials[i].id===e)return this.materials[i];if(t){for(let i=this.multiMaterials.length-1;i>=0;i--)if(this.multiMaterials[i].id===e)return this.multiMaterials[i]}return null}getTextureByUniqueId(e){for(let t=0;t<this.textures.length;t++)if(this.textures[t].uniqueId===e)return this.textures[t];return null}getTextureByName(e){for(let t=0;t<this.textures.length;t++)if(this.textures[t].name===e)return this.textures[t];return null}getCameraById(e){for(let t=0;t<this.cameras.length;t++)if(this.cameras[t].id===e)return this.cameras[t];return null}getCameraByUniqueId(e){for(let t=0;t<this.cameras.length;t++)if(this.cameras[t].uniqueId===e)return this.cameras[t];return null}getCameraByName(e){for(let t=0;t<this.cameras.length;t++)if(this.cameras[t].name===e)return this.cameras[t];return null}getBoneById(e){for(let t=0;t<this.skeletons.length;t++){const i=this.skeletons[t];for(let s=0;s<i.bones.length;s++)if(i.bones[s].id===e)return i.bones[s]}return null}getBoneByName(e){for(let t=0;t<this.skeletons.length;t++){const i=this.skeletons[t];for(let s=0;s<i.bones.length;s++)if(i.bones[s].name===e)return i.bones[s]}return null}getLightByName(e){for(let t=0;t<this.lights.length;t++)if(this.lights[t].name===e)return this.lights[t];return null}getLightById(e){for(let t=0;t<this.lights.length;t++)if(this.lights[t].id===e)return this.lights[t];return null}getLightByUniqueId(e){for(let t=0;t<this.lights.length;t++)if(this.lights[t].uniqueId===e)return this.lights[t];return null}getParticleSystemById(e){for(let t=0;t<this.particleSystems.length;t++)if(this.particleSystems[t].id===e)return this.particleSystems[t];return null}getGeometryById(e){for(let t=0;t<this.geometries.length;t++)if(this.geometries[t].id===e)return this.geometries[t];return null}_getGeometryByUniqueId(e){if(this._geometriesByUniqueId){const t=this._geometriesByUniqueId[e];if(t!==void 0)return this.geometries[t]}else for(let t=0;t<this.geometries.length;t++)if(this.geometries[t].uniqueId===e)return this.geometries[t];return null}getFrameGraphByName(e){for(let t=0;t<this.frameGraphs.length;t++)if(this.frameGraphs[t].name===e)return this.frameGraphs[t];return null}pushGeometry(e,t){return!t&&this._getGeometryByUniqueId(e.uniqueId)?!1:(this.addGeometry(e),se.SetImmediate(()=>{this.onNewGeometryAddedObservable.notifyObservers(e)}),!0)}removeGeometry(e){let t;if(this._geometriesByUniqueId){if(t=this._geometriesByUniqueId[e.uniqueId],t===void 0)return!1}else if(t=this.geometries.indexOf(e),t<0)return!1;if(t!==this.geometries.length-1){const i=this.geometries[this.geometries.length-1];i&&(this.geometries[t]=i,this._geometriesByUniqueId&&(this._geometriesByUniqueId[i.uniqueId]=t))}return this._geometriesByUniqueId&&(this._geometriesByUniqueId[e.uniqueId]=void 0),this.geometries.pop(),this.onGeometryRemovedObservable.notifyObservers(e),!0}getGeometries(){return this.geometries}getMeshById(e){for(let t=0;t<this.meshes.length;t++)if(this.meshes[t].id===e)return this.meshes[t];return null}getMeshesById(e){return this.meshes.filter(function(t){return t.id===e})}getTransformNodeById(e){for(let t=0;t<this.transformNodes.length;t++)if(this.transformNodes[t].id===e)return this.transformNodes[t];return null}getTransformNodeByUniqueId(e){for(let t=0;t<this.transformNodes.length;t++)if(this.transformNodes[t].uniqueId===e)return this.transformNodes[t];return null}getTransformNodesById(e){return this.transformNodes.filter(function(t){return t.id===e})}getMeshByUniqueId(e){for(let t=0;t<this.meshes.length;t++)if(this.meshes[t].uniqueId===e)return this.meshes[t];return null}getLastMeshById(e){for(let t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];return null}getLastTransformNodeById(e){for(let t=this.transformNodes.length-1;t>=0;t--)if(this.transformNodes[t].id===e)return this.transformNodes[t];return null}getLastEntryById(e){let t;for(t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.transformNodes.length-1;t>=0;t--)if(this.transformNodes[t].id===e)return this.transformNodes[t];for(t=this.cameras.length-1;t>=0;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;t>=0;t--)if(this.lights[t].id===e)return this.lights[t];return null}getNodeById(e){const t=this.getMeshById(e);if(t)return t;const i=this.getTransformNodeById(e);if(i)return i;const s=this.getLightById(e);if(s)return s;const r=this.getCameraById(e);if(r)return r;const n=this.getBoneById(e);return n||null}getNodeByName(e){const t=this.getMeshByName(e);
30if(t)return t;const i=this.getTransformNodeByName(e);if(i)return i;const s=this.getLightByName(e);if(s)return s;const r=this.getCameraByName(e);if(r)return r;const n=this.getBoneByName(e);return n||null}getMeshByName(e){for(let t=0;t<this.meshes.length;t++)if(this.meshes[t].name===e)return this.meshes[t];return null}getTransformNodeByName(e){for(let t=0;t<this.transformNodes.length;t++)if(this.transformNodes[t].name===e)return this.transformNodes[t];return null}getLastSkeletonById(e){for(let t=this.skeletons.length-1;t>=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null}getSkeletonByUniqueId(e){for(let t=0;t<this.skeletons.length;t++)if(this.skeletons[t].uniqueId===e)return this.skeletons[t];return null}getSkeletonById(e){for(let t=0;t<this.skeletons.length;t++)if(this.skeletons[t].id===e)return this.skeletons[t];return null}getSkeletonByName(e){for(let t=0;t<this.skeletons.length;t++)if(this.skeletons[t].name===e)return this.skeletons[t];return null}getMorphTargetManagerById(e){for(let t=0;t<this.morphTargetManagers.length;t++)if(this.morphTargetManagers[t].uniqueId===e)return this.morphTargetManagers[t];return null}getMorphTargetById(e){for(let t=0;t<this.morphTargetManagers.length;++t){const i=this.morphTargetManagers[t];for(let s=0;s<i.numTargets;++s){const r=i.getTarget(s);if(r.id===e)return r}}return null}getMorphTargetByName(e){for(let t=0;t<this.morphTargetManagers.length;++t){const i=this.morphTargetManagers[t];for(let s=0;s<i.numTargets;++s){const r=i.getTarget(s);if(r.name===e)return r}}return null}getPostProcessByName(e){for(let t=0;t<this.postProcesses.length;++t){const i=this.postProcesses[t];if(i.name===e)return i}return null}isActiveMesh(e){return this._activeMeshes.indexOf(e)!==-1}get uid(){return this._uid||(this._uid=se.RandomId()),this._uid}addExternalData(e,t){return this._externalData||(this._externalData=new ya),this._externalData.add(e,t)}getExternalData(e){return this._externalData?this._externalData.get(e):null}getOrAddExternalDataWithFactory(e,t){return this._externalData||(this._externalData=new ya),this._externalData.getOrAddWithFactory(e,t)}removeExternalData(e){return this._externalData.remove(e)}_evaluateSubMesh(e,t,i,s){if(s||e.isInFrustum(this._frustumPlanes)){for(const n of this._evaluateSubMeshStage)n.action(t,e);const r=e.getMaterial();r!=null&&(r.hasRenderTargetTextures&&r.getRenderTargetTextures!=null&&this._processedMaterials.indexOf(r)===-1&&(this._processedMaterials.push(r),this._materialsRenderTargets.concatWithNoDuplicate(r.getRenderTargetTextures())),this._renderingManager.dispatch(e,t,r))}}freeProcessedMaterials(){this._processedMaterials.dispose()}get blockfreeActiveMeshesAndRenderingGroups(){return this._preventFreeActiveMeshesAndRenderingGroups}set blockfreeActiveMeshesAndRenderingGroups(e){this._preventFreeActiveMeshesAndRenderingGroups!==e&&(e&&(this.freeActiveMeshes(),this.freeRenderingGroups()),this._preventFreeActiveMeshesAndRenderingGroups=e)}freeActiveMeshes(){if(!this.blockfreeActiveMeshesAndRenderingGroups&&(this._activeMeshes.dispose(),this.activeCamera&&this.activeCamera._activeMeshes&&this.activeCamera._activeMeshes.dispose(),this.activeCameras))for(let e=0;e<this.activeCameras.length;e++){const t=this.activeCameras[e];t&&t._activeMeshes&&t._activeMeshes.dispose()}}freeRenderingGroups(){if(!this.blockfreeActiveMeshesAndRenderingGroups&&(this._renderingManager&&this._renderingManager.freeRenderingGroups(),this.textures))for(let e=0;e<this.textures.length;e++){const t=this.textures[e];t&&t.renderList&&t.freeRenderingGroups()}}_isInIntermediateRendering(){return this._intermediateRendering}freezeActiveMeshes(e=!1,t,i,s=!0,r=!1){if(this.frameGraph){this._renderWithFrameGraph(!0,!1,!0);const n=this.frameGraph.getTasksByClassName(["FrameGraphObjectRendererTask","FrameGraphGeometryRendererTask"]);for(const o of n)o.objectRenderer._freezeActiveMeshes(s);return this._freezeActiveMeshesCancel=tr(()=>{let o=!0,h=!0;for(const l of n)o&&(o=l.objectRenderer._isFrozen),h&&(h=l.objectRenderer._freezeActiveMeshesCancel!==null);if(o)return!0;if(!h)throw new Error("Freezing active meshes was cancelled");return!1},()=>{this._freezeActiveMeshesCancel=null,this._activeMeshesFrozen=!0,this._activeMeshesFrozenButKeepClipping=r,this._skipEvaluateActiveMeshesCompletely=e,t?.()},(o,h)=>{if(this._freezeActiveMeshesCancel=null,this.unfreezeActiveMeshes(),h){const l="Scene: Timeout while waiting for meshes to be frozen.";i?i(l):(w.Error(l),o&&w.Error(o))}else{const l="Scene: An unexpected error occurred while trying to freeze active meshes.";i?i(l):(w.Error(l),o&&(w.Error(o),o.stack&&w.Error(o.stack)))}}),this}return this.executeWhenReady(()=>
vendor: 13,328 bytes, line 30
30{if(!this.activeCamera){i&&i("No active camera found");return}if(this._frustumPlanes||this.updateTransformMatrix(),this._evaluateActiveMeshes(),this._activeMeshesFrozen=!0,this._activeMeshesFrozenButKeepClipping=r,this._skipEvaluateActiveMeshesCompletely=e,s)for(let n=0;n<this._activeMeshes.length;n++)this._activeMeshes.data[n]._freeze();t&&t()}),this}unfreezeActiveMeshes(){for(let e=0;e<this.meshes.length;e++){const t=this.meshes[e];t._internalAbstractMeshDataInfo&&(t._internalAbstractMeshDataInfo._isActive=!1)}if(this._freezeActiveMeshesCancel?.(),this._freezeActiveMeshesCancel=null,this.frameGraph){const e=this.frameGraph.getTasksByClassName(["FrameGraphObjectRendererTask","FrameGraphGeometryRendererTask"]);for(const t of e)t.objectRenderer._unfreezeActiveMeshes()}else for(let e=0;e<this._activeMeshes.length;e++)this._activeMeshes.data[e]._unFreeze();return this._activeMeshesFrozen=!1,this}_executeActiveContainerCleanup(e){!(this._engine.snapshotRendering&&this._engine.snapshotRenderingMode===1)&&this._activeMeshesFrozen&&this._activeMeshes.length||this.onBeforeRenderObservable.addOnce(()=>e.dispose())}_evaluateActiveMeshes(){if(this._engine.snapshotRendering&&this._engine.snapshotRenderingMode===1){this._activeMeshes.length>0&&(this.activeCamera?._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset());return}if(this._activeMeshesFrozen&&this._activeMeshes.length){if(!this._skipEvaluateActiveMeshesCompletely){const i=this._activeMeshes.length;for(let s=0;s<i;s++)this._activeMeshes.data[s].computeWorldMatrix()}if(this._activeParticleSystems){const i=this._activeParticleSystems.length;for(let s=0;s<i;s++)this._activeParticleSystems.data[s].animate()}this._renderingManager.resetSprites();return}if(!this.activeCamera)return;this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this),this.activeCamera._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset(),this._materialsRenderTargets.reset();for(const i of this._beforeEvaluateActiveMeshStage)i.action();const e=this.getActiveMeshCandidates(),t=e.length;for(let i=0;i<t;i++){const s=e.data[i];let r=s._internalAbstractMeshDataInfo._currentLOD.get(this.activeCamera);if(r?r[1]=-1:(r=[s,-1],s._internalAbstractMeshDataInfo._currentLOD.set(this.activeCamera,r)),s.isBlocked||(this._totalVertices.addCount(s.getTotalVertices(),!1),!s.isReady()||!s.isEnabled()||s.scaling.hasAZeroComponent))continue;s.computeWorldMatrix(),s.actionManager&&s.actionManager.hasSpecificTriggers2(12,13)&&this._meshesForIntersections.pushNoDuplicate(s);let n=this.customLODSelector?this.customLODSelector(s,this.activeCamera):s.getLOD(this.activeCamera);if(r[0]=n,r[1]=this._frameId,n!=null&&(n!==s&&n.billboardMode!==0&&n.computeWorldMatrix(),s._preActivate(),s.isVisible&&s.visibility>0&&(s.layerMask&this.activeCamera.layerMask)!==0&&(this._skipFrustumClipping||s.alwaysSelectAsActiveMesh||s.isInFrustum(this._frustumPlanes)))){this._activeMeshes.push(s),this.activeCamera._activeMeshes.push(s),n!==s&&n._activate(this._renderId,!1);for(const o of this._preActiveMeshStage)o.action(s);s._activate(this._renderId,!1)&&(s.isAnInstance?s._internalAbstractMeshDataInfo._actAsRegularMesh&&(n=s):n._internalAbstractMeshDataInfo._onlyForInstances=!1,n._internalAbstractMeshDataInfo._isActive=!0,this._activeMesh(s,n)),s._postActivate()}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(let i=0;i<this.particleSystems.length;i++){const s=this.particleSystems[i];if(!s.isStarted()||!s.emitter)continue;const r=s.emitter;(!r.position||r.isEnabled())&&(this._activeParticleSystems.push(s),s.animate(),this._renderingManager.dispatchParticles(s))}this.onAfterParticlesRenderingObservable.notifyObservers(this)}}_prepareSkeleton(e){!this._skeletonsEnabled||!e.skeleton||(this._activeSkeletons.pushNoDuplicate(e.skeleton)&&(e.skeleton.prepare(),this._activeBones.addCount(e.skeleton.bones.length,!1)),e.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(e)&&this.frameGraph&&e.applySkeleton(e.skeleton))}_activeMesh(e,t){this._prepareSkeleton(t);let i=e.hasInstances||e.isAnInstance||this.dispatchAllSubMeshesOfActiveMeshes||this._skipFrustumClipping||t.alwaysSelectAsActiveMesh;if(t&&t.subMeshes&&t.subMeshes.length>0){const s=this.getActiveSubMeshCandidates(t),r=s.length;i=i||r===1;for(let n=0;n<r;n++){const o=s.data[n];this._evaluateSubMesh(o,t,e,i)}}}updateTransformMatrix(e){const t=this.activeCamera;if(t)if(t._renderingMultiview){const i=t._rigCameras[0],s=t._rigCameras[1];this.setTransformMatrix(i.getViewMatrix(),i.getProjectionMatrix(e),s.getViewMatrix(),s.getProjectionMatrix(e))}else this.setTransformMatrix(t.getViewMatrix(),t.getProjectionMatrix(e))}_bindFrameBuffer(e,t=!0){this._useCurrentFrameBuffer||(e&&e._multiviewTexture?e._multiviewTexture._bindFrameBuffer():e&&e.outputRenderTarget?e.outputRenderTarget._bindFrameBuffer():this._engine._currentFrameBufferIsDefaultFrameBuffer()||this._engine.restoreDefaultFramebuffer()),t&&this._clearFrameBuffer(e)}_clearFrameBuffer(e){if(!(e&&e._multiviewTexture))if(e&&e.outputRenderTarget&&!e._renderingMultiview){const t=e.outputRenderTarget;t.onClearObservable.hasObservers()?t.onClearObservable.notifyObservers(this._engine):!t.skipInitialClear&&!e.isRightCamera&&(this.autoClear&&this._engine.clear(t.clearColor||this._clearColor,!t._cleared,!0,!0),t._cleared=!0)}else this._defaultFrameBufferCleared?this._engine.clear(null,!1,!0,!0):(this._defaultFrameBufferCleared=!0,this._clear())}_renderForCamera(e,t,i=!0){if(e&&e._skipRendering)return;const s=this._engine;if(this._activeCamera=e,!this.activeCamera)throw new Error("Active camera not set");if(s.setViewport(this.activeCamera.viewport),this.resetCachedMaterial(),this._renderId++,!this.prePass&&i){let o=!0;e._renderingMultiview&&e.outputRenderTarget&&(o=e.outputRenderTarget.skipInitialClear,this.autoClear&&(this._defaultFrameBufferCleared=!1,e.outputRenderTarget.skipInitialClear=!1)),this._bindFrameBuffer(this._activeCamera),e._renderingMultiview&&e.outputRenderTarget&&(e.outputRenderTarget.skipInitialClear=o)}this.updateTransformMatrix(),this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),this._evaluateActiveMeshes();for(let o=0;o<this._softwareSkinnedMeshes.length;o++){const h=this._softwareSkinnedMeshes.data[o];h.applySkeleton(h.skeleton)}this.onBeforeRenderTargetsRenderObservable.notifyObservers(this),this._renderTargets.concatWithNoDuplicate(this._materialsRenderTargets),e.customRenderTargets&&e.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(e.customRenderTargets),t&&t.customRenderTargets&&t.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets),this.environmentTexture&&this.environmentTexture.isRenderTarget&&this._renderTargets.pushNoDuplicate(this.environmentTexture);for(const o of this._gatherActiveCameraRenderTargetsStage)o.action(this._renderTargets);let r=!1;if(this.renderTargetsEnabled){if(this._intermediateRendering=!0,this._renderTargets.length>0){se.StartPerformanceCounter("Render targets",this._renderTargets.length>0);const o=this.getBoundingBoxRenderer?.();let h;for(let l=0;l<this._renderTargets.length;l++){const c=this._renderTargets.data[l];if(c._shouldRender()){this._renderId++;const u=c.activeCamera&&c.activeCamera!==this.activeCamera;o&&!h&&(h=o.renderList.length>0?o.renderList.data.slice():[],h.length=o.renderList.length),c.render(u,this.dumpNextRenderTargets),r=!0}}o&&h&&(o.renderList.data=h,o.renderList.length=h.length),se.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._renderId++}for(const o of this._cameraDrawRenderTargetStage)r=o.action(this.activeCamera)||r;this._intermediateRendering=!1}this._engine.currentRenderPassId=e.outputRenderTarget?.renderPassId??e.renderPassId??0,r&&!this.prePass&&(this._bindFrameBuffer(this._activeCamera,!1),this.updateTransformMatrix()),this.onAfterRenderTargetsRenderObservable.notifyObservers(this),this.postProcessManager&&!e._multiviewTexture&&!this.prePass&&this.postProcessManager._prepareFrame();for(const o of this._beforeCameraDrawStage)o.action(this.activeCamera);this.onBeforeDrawPhaseObservable.notifyObservers(this);const n=s.snapshotRendering&&s.snapshotRenderingMode===1;n&&this.finalizeSceneUbo(),this._renderingManager.render(null,null,!0,!n),this.onAfterDrawPhaseObservable.notifyObservers(this);for(const o of this._afterCameraDrawStage)o.action(this.activeCamera);if(this.postProcessManager&&!e._multiviewTexture){const o=e.outputRenderTarget?e.outputRenderTarget.renderTarget:void 0;this.postProcessManager._finalizeFrame(e.isIntermediate,o)}for(const o of this._afterCameraPostProcessStage)o.action(this.activeCamera);this._renderTargets.reset(),this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera)}_processSubCameras(e,t=!0){if(e.cameraRigMode===0||e._renderingMultiview){e._renderingMultiview&&!this._multiviewSceneUbo&&this._createMultiviewUbo(),this._renderForCamera(e,void 0,t),this.onAfterRenderCameraObservable.notifyObservers(e);return}if(e._useMultiviewToSingleView)this._renderMultiviewToSingleView(e);else{this.onBeforeCameraRenderObservable.notifyObservers(e);for(let i=0;i<e._rigCameras.length;i++)this._renderForCamera(e._rigCameras[i],e)}this._activeCamera=e,this.updateTransformMatrix(),this.onAfterRenderCameraObservable.notifyObservers(e)}_checkIntersections(){for(let e=0;e<this._meshesForIntersections.length;e++){const t=this._meshesForIntersections.data[e];if(t.actionManager)for(let i=0;t.actionManager&&i<t.actionManager.actions.length;i++){const s=t.actionManager.actions[i];if(s.trigger===12||s.trigger===13){const r=s.getTriggerParameter(),n=r.mesh?r.mesh:r,o=n.intersectsMesh(t,r.usePreciseIntersection),h=t._intersectionsInProgress.indexOf(n);o&&h===-1?s.trigger===12?(s._executeCurrent(lt.CreateNew(t,void 0,n)),t._intersectionsInProgress.push(n)):s.trigger===13&&t._intersectionsInProgress.push(n):!o&&h>-1&&(s.trigger===13&&s._executeCurrent(lt.CreateNew(t,void 0,n)),(!t.actionManager.hasSpecificTrigger(13,l=>{const c=l.mesh?l.mesh:l;return n===c})||s.trigger===13)&&t._intersectionsInProgress.splice(h,1))}}}}_advancePhysicsEngineStep(e){}_animate(e){}animate(){if(this._engine.isDeterministicLockStep()){let e=Math.max(tt.MinDeltaTime,Math.min(this._engine.getDeltaTime(),tt.MaxDeltaTime))+this._timeAccumulator;const t=this._engine.getTimeStep(),i=1e3/t/1e3;let s=0;const r=this._engine.getLockstepMaxSteps();let n=Math.floor(e/t);for(n=Math.min(n,r);e>0&&s<n;)this.onBeforeStepObservable.notifyObservers(this),this._animationRatio=t*i,this._animate(t),this.onAfterAnimationsObservable.notifyObservers(this),this.physicsEnabled&&this._advancePhysicsEngineStep(t),this.onAfterStepObservable.notifyObservers(this),this._currentStepId++,s++,e-=t;this._timeAccumulator=e<0?0:e}else{const e=this.useConstantAnimationDeltaTime?16:Math.max(tt.MinDeltaTime,Math.min(this._engine.getDeltaTime(),tt.MaxDeltaTime));this._animationRatio=e*(60/1e3),this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this.physicsEnabled&&this._advancePhysicsEngineStep(e)}}_clear(){(this.autoClearDepthAndStencil||this.autoClear)&&this._engine.clear(this._clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,this.autoClearDepthAndStencil,this.autoClearDepthAndStencil)}_checkCameraRenderTarget(e){if(e?.outputRenderTarget&&!e?.isRigCamera&&(e.outputRenderTarget._cleared=!1),e?.rigCameras?.length)for(let t=0;t<e.rigCameras.length;++t){const i=e.rigCameras[t].outputRenderTarget;i&&(i._cleared=!1)}}resetDrawCache(e){if(this.meshes)for(const t of this.meshes)t.resetDrawCache(e)}_renderWithFrameGraph(e=!0,t=!1,i=!1){if(this.activeCamera=null,this.activeCameras=null,e){for(const s of this.cameras)if(s.update(),s.cameraRigMode!==0)for(let r=0;r<s._rigCameras.length;r++)s._rigCameras[r].update()}this.onBeforeRenderObservable.notifyObservers(this);for(const s of this._beforeClearStage)s.action();if(this._engine.snapshotRendering&&this._engine.snapshotRenderingMode===1)this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset();else{const s=this.getActiveMeshCandidates(),r=s.length;if(this._activeMeshesFrozen){if(!this._skipEvaluateActiveMeshesCompletely)for(let n=0;n<r;n++){const o=s.data[n];o._internalAbstractMeshDataInfo._wasActiveLastFrame&&o.computeWorldMatrix()}if(this.particlesEnabled){const n=this._activeParticleSystems.length;for(let o=0;o<n;o++)this._activeParticleSystems.data[o].animate()}}else{this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset();for(let n=0;n<r;n++){const o=s.data[n];o._internalAbstractMeshDataInfo._wasActiveLastFrame=!1,!o.isBlocked&&(this._totalVertices.addCount(o.getTotalVertices(),!1),!(!o.isReady()||!o.isEnabled()||o.scaling.hasAZeroComponent)&&(o.computeWorldMatrix(i),o.actionManager&&o.actionManager.hasSpecificTriggers2(12,13)&&this._meshesForIntersections.pushNo
30Duplicate(o)))}if(this.particlesEnabled)for(let n=0;n<this.particleSystems.length;n++){const o=this.particleSystems[n];if(!o.isStarted()||!o.emitter)continue;const h=o.emitter;(!h.position||h.isEnabled())&&(this._activeParticleSystems.push(o),o.animate())}}}this.frameGraph?.execute()}_renderRenderTarget(e,t,i=!1,s=!1){if(this._intermediateRendering=!0,e._shouldRender()){if(this._renderId++,this.activeCamera=t,!this.activeCamera)throw new Error("Active camera not set");this._engine.setViewport(this.activeCamera.viewport),this.updateTransformMatrix(),e.render(i,s)}this._intermediateRendering=!1}render(e=!0,t=!1){if(!this.isDisposed){if(this.onReadyObservable.hasObservers()&&this._executeWhenReadyTimeoutId===null&&this._checkIsReady(),Gr.getScene=this._getFloatingOriginScene,this._frameId++,this._defaultFrameBufferCleared=!1,this._checkCameraRenderTarget(this.activeCamera),this.activeCameras?.length)for(const i of this.activeCameras)this._checkCameraRenderTarget(i);this._registerTransientComponents(),this._activeParticles.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this._meshesForIntersections.reset(),this.resetCachedMaterial(),this.onBeforeAnimationsObservable.notifyObservers(this),this.actionManager&&this.actionManager.processTrigger(11),t||this.animate();for(const i of this._beforeCameraUpdateStage)i.action();if(e){if(this.activeCameras&&this.activeCameras.length>0)for(let i=0;i<this.activeCameras.length;i++){const s=this.activeCameras[i];if(s.update(),s.cameraRigMode!==0)for(let r=0;r<s._rigCameras.length;r++)s._rigCameras[r].update()}else if(this.activeCamera&&(this.activeCamera.update(),this.activeCamera.cameraRigMode!==0))for(let i=0;i<this.activeCamera._rigCameras.length;i++)this.activeCamera._rigCameras[i].update()}if(this.customRenderFunction)this._renderId++,this._engine.currentRenderPassId=0,this.customRenderFunction(e,t);else{this.onBeforeRenderObservable.notifyObservers(this),this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);const i=this.activeCameras?.length?this.activeCameras[0]:this.activeCamera;if(this.renderTargetsEnabled){se.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0);for(let s=0;s<this.customRenderTargets.length;s++){const r=this.customRenderTargets[s],n=r.activeCamera||this.activeCamera;this._renderRenderTarget(r,n,i!==n,this.dumpNextRenderTargets)}se.EndPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._renderId++}this._engine.currentRenderPassId=i?.renderPassId??0,this.activeCamera=i,this._activeCamera&&this._activeCamera.cameraRigMode!==22&&!this.prePass&&this._bindFrameBuffer(this._activeCamera,!1),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(const s of this._beforeClearStage)s.action();this._clearFrameBuffer(this.activeCamera);for(const s of this._gatherRenderTargetsStage)s.action(this._renderTargets);if(this.activeCameras&&this.activeCameras.length>0)for(let s=0;s<this.activeCameras.length;s++)this._processSubCameras(this.activeCameras[s],s>0);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera,!!this.activeCamera.outputRenderTarget)}}this._checkIntersections();for(const i of this._afterRenderStage)i.action();if(this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this),this._toBeDisposed.length){for(let i=0;i<this._toBeDisposed.length;i++){const s=this._toBeDisposed[i];s&&s.dispose()}this._toBeDisposed.length=0}this.dumpNextRenderTargets&&(this.dumpNextRenderTargets=!1),this._activeBones.addCount(0,!0),this._activeIndices.addCount(0,!0),this._activeParticles.addCount(0,!0),this._engine.restoreDefaultFramebuffer()}}freezeMaterials(){for(let e=0;e<this.materials.length;e++)this.materials[e].freeze()}unfreezeMaterials(){for(let e=0;e<this.materials.length;e++)this.materials[e].unfreeze()}dispose(){if(this.isDisposed)return;if(this.beforeRender=null,this.afterRender=null,this.metadata=null,this.skeletons.length=0,this.morphTargetManagers.length=0,this._transientComponents.length=0,this._isReadyForMeshStage.clear(),this._beforeEvaluateActiveMeshStage.clear(),this._evaluateSubMeshStage.clear(),this._preActiveMeshStage.clear(),this._cameraDrawRenderTargetStage.clear(),this._beforeCameraDrawStage.clear(),this._beforeRenderTargetDrawStage.clear(),this._beforeRenderingGroupDrawStage.clear(),this._beforeRenderingMeshStage.clear(),this._afterRenderingMeshStage.clear(),this._afterRenderingGroupDrawStage.clear(),this._afterCameraDrawStage.clear(),this._afterRenderTargetDrawStage.clear(),this._afterRenderStage.clear(),this._beforeCameraUpdateStage.clear(),this._beforeClearStage.clear(),this._gatherRenderTargetsStage.clear(),this._gatherActiveCameraRenderTargetsStage.clear(),this._pointerMoveStage.clear(),this._pointerDownStage.clear(),this._pointerUpStage.clear(),this.importedMeshesFiles=[],this._activeAnimatables&&this.stopAllAnimations){for(const r of this._activeAnimatables)r.onAnimationEndObservable.clear(),r.onAnimationEnd=null;this.stopAllAnimations()}this.resetCachedMaterial(),this.activeCamera&&(this.activeCamera._activeMeshes.dispose(),this.activeCamera=null),this.activeCameras=null,this._activeMeshes.dispose(),this._renderingManager.dispose(),this._processedMaterials.dispose(),this._activeParticleSystems.dispose(),this._activeSkeletons.dispose(),this._softwareSkinnedMeshes.dispose(),this._renderTargets.dispose(),this._materialsRenderTargets.dispose(),this._registeredForLateAnimationBindings.dispose(),this._meshesForIntersections.dispose(),this._toBeDisposed.length=0;const e=this._activeRequests.slice();for(const r of e)r.abort();this._activeRequests.length=0;try{this.onDisposeObservable.notifyObservers(this)}catch(r){w.Error("An error occurred while calling onDisposeObservable!",r)}if(this.detachControl(),this._engine.getInputElement())for(let r=0;r<this.cameras.length;r++)this.cameras[r].detachControl();this._disposeList(this.animationGroups),this._disposeList(this.lights),this._defaultMaterial&&this._defaultMaterial.dispose(),this._disposeList(this.multiMaterials),this._disposeList(this.materials),this._disposeList(this.meshes,r=>r.dispose(!0)),this._disposeList(this.transformNodes,r=>r.dispose(!0));const i=this.cameras;this._disposeList(i),this._disposeList(this.particleSystems),this._disposeList(this.postProcesses),this._disposeList(this.textures),this._disposeList(this.morphTargetManagers),this._disposeList(this.frameGraphs),this._sceneUbo.dispose(),this._multiviewSceneUbo&&this._multiviewSceneUbo.dispose(),this.postProcessManager.dispose(),this._disposeList(this._components);let s=this._engine.scenes.indexOf(this);if(s>-1&&this._engine.scenes.splice(s,1),this._floatingOriginScene=void 0,this._engine.scenes.length===0&&Hc(),Te._LastCreatedScene===this){Te._LastCreatedScene=null;let r=Te.Instances.length-1;for(;r>=0;){const n=Te.Instances[r];if(n.scenes.length>0){Te._LastCreatedScene=n.scenes[this._engine.scenes.length-1];break}r--}}s=this._engine._virtualScenes.indexOf(this),s>-1&&this._engine._virtualScenes.splice(s,1),this._engine.wipeCaches(!0),this.onDisposeObservable.clear(),this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderTargetsRenderObservable.clear(),this.onAfterRenderTargetsRenderObservable.clear(),this.onAfterStepObservable.clear(),this.onBeforeStepObservable.clear(),this.onBeforeActiveMeshesEvaluationObservable.clear(),this.onAfterActiveMeshesEvaluationObservable.clear(),this.onBeforeParticlesRenderingObservable.clear(),this.onAfterParticlesRenderingObservable.clear(),this.onBeforeDrawPhaseObservable.clear(),this.onAfterDrawPhaseObservable.clear(),this.onBeforeAnimationsObservable.clear(),this.onAfterAnimationsObservable.clear(),this.onDataLoadedObservable.clear(),this.onBeforeRenderingGroupObservable.clear(),this.onAfterRenderingGroupObservable.clear(),this.onMeshImportedObservable.clear(),this.onBeforeCameraRenderObservable.clear(),this.onAfterCameraRenderObservable.clear(),this.onAfterRenderCameraObservable.clear(),this.onReadyObservable.clear(),this.onNewCameraAddedObservable.clear(),this.onCameraRemovedObservable.clear(),this.onNewLightAddedObservable.clear(),this.onLightRemovedObservable.clear(),this.onNewGeometryAddedObservable.clear(),this.onGeometryRemovedObservable.clear(),this.onNewTransformNodeAddedObservable.clear(),this.onTransformNodeRemovedObservable.clear(),this.onNewMeshAddedObservable.clear(),this.onMeshRemovedObservable.clear(),this.onNewSkeletonAddedObservable.clear(),this.onSkeletonRemovedObservable.clear(),this.onNewMaterialAddedObservable.clear(),this.onNewMultiMaterialAddedObservable.clear(),this.onMaterialRemovedObservable.clear(),this.onMultiMaterialRemovedObservable.clear(),this.onNewTextureAddedObservable.clear(),this.onTextureRemovedObservable.clear(),this.onNewFrameGraphAddedObservable.clear(),this.onFrameGraphRemovedObservable.clear(),this.onNewObjectRendererAddedObservable.clear(),this.onObjectRendererRemovedObservable.clear(),this.onPrePointerObservable.clear(),this.onPointerObservable.clear(),this.onPreKeyboardObservable.clear(),this.onKeyboardObservable.clear(),this.onActiveCameraChanged.clear(),this.onScenePerformancePriorityChangedObservable.clear(),this.onClearColorChangedObservable.clear(),this.onEnvironmentTextureChangedObservable.clear(),this.onMeshUnderPointerUpdatedObservable.clear(),this._isDisposed=!0}
vendor: 7,723 bytes, line 30
30_disposeList(e,t){const i=e.slice(0);t=t??(s=>s.dispose());for(const s of i)t(s);e.length=0}get isDisposed(){return this._isDisposed}clearCachedVertexData(){for(let e=0;e<this.meshes.length;e++){const i=this.meshes[e].geometry;i&&i.clearCachedData()}}cleanCachedTextureBuffer(){for(const e of this.textures)e._buffer&&(e._buffer=null)}getWorldExtends(e){const t=new _(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),i=new _(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);e=e||(()=>!0);const s=this.meshes.filter(e);for(const r of s){if(r.computeWorldMatrix(!0),!r.subMeshes||r.subMeshes.length===0||r.infiniteDistance)continue;const n=r.getBoundingInfo(),o=n.boundingBox.minimumWorld,h=n.boundingBox.maximumWorld;_.CheckExtends(o,t,i),_.CheckExtends(h,t,i)}return t.x===Number.MAX_VALUE?{min:_.Zero(),max:_.Zero()}:{min:t,max:i}}createPickingRay(e,t,i,s,r=!1){throw ie("Ray")}createPickingRayToRef(e,t,i,s,r,n=!1,o=!1){throw ie("Ray")}createPickingRayInCameraSpace(e,t,i){throw ie("Ray")}createPickingRayInCameraSpaceToRef(e,t,i,s){throw ie("Ray")}pick(e,t,i,s,r,n){const o=ie("Ray",!0);return o&&w.Warn(o),new ms}pickWithBoundingInfo(e,t,i,s,r){const n=ie("Ray",!0);return n&&w.Warn(n),new ms}pickWithRay(e,t,i,s){throw ie("Ray")}multiPick(e,t,i,s,r){throw ie("Ray")}multiPickWithRay(e,t,i){throw ie("Ray")}setPointerOverMesh(e,t,i){this._inputManager.setPointerOverMesh(e,t,i)}getPointerOverMesh(){return this._inputManager.getPointerOverMesh()}_rebuildGeometries(){for(const e of this.geometries)e._rebuild();for(const e of this.meshes)e._rebuild();this.postProcessManager&&this.postProcessManager._rebuild();for(const e of this._components)e.rebuild();for(const e of this.particleSystems)e.rebuild();if(this.spriteManagers)for(const e of this.spriteManagers)e.rebuild()}_rebuildTextures(){for(const e of this.textures)e._rebuild(!0);this.markAllMaterialsAsDirty(1)}_getByTags(e,t,i){if(t===void 0)return e;const s=[];for(const r in e){const n=e[r];Ae&&Ae.MatchesQuery(n,t)&&(!i||i(n))&&s.push(n)}return s}getMeshesByTags(e,t){return this._getByTags(this.meshes,e,t)}getCamerasByTags(e,t){return this._getByTags(this.cameras,e,t)}getLightsByTags(e,t){return this._getByTags(this.lights,e,t)}getMaterialByTags(e,t){return this._getByTags(this.materials,e,t).concat(this._getByTags(this.multiMaterials,e,t))}getTransformNodesByTags(e,t){return this._getByTags(this.transformNodes,e,t)}setRenderingOrder(e,t=null,i=null,s=null){this._renderingManager.setRenderingOrder(e,t,i,s)}setRenderingAutoClearDepthStencil(e,t,i=!0,s=!0){this._renderingManager.setRenderingAutoClearDepthStencil(e,t,i,s)}getAutoClearDepthStencilSetup(e){return this._renderingManager.getAutoClearDepthStencilSetup(e)}_forceBlockMaterialDirtyMechanism(e){this._blockMaterialDirtyMechanism=e}get blockMaterialDirtyMechanism(){return this._blockMaterialDirtyMechanism}set blockMaterialDirtyMechanism(e){this._blockMaterialDirtyMechanism!==e&&(this._blockMaterialDirtyMechanism=e,e||this.markAllMaterialsAsDirty(127))}markAllMaterialsAsDirty(e,t){if(!this._blockMaterialDirtyMechanism)for(const i of this.materials)t&&!t(i)||i.markAsDirty(e)}_loadFile(e,t,i,s,r,n,o){const h=wi(e,t,i,s?this.offlineProvider:void 0,r,n,o);return this._activeRequests.push(h),h.onCompleteObservable.add(l=>{this._activeRequests.splice(this._activeRequests.indexOf(l),1)}),h}async _loadFileAsync(e,t,i,s,r){return await new Promise((n,o)=>{this._loadFile(e,h=>{n(h)},t,i,s,(h,l)=>{o(l)},r)})}_requestFile(e,t,i,s,r,n,o){const h=Fn(e,t,i,s?this.offlineProvider:void 0,r,n,o);return this._activeRequests.push(h),h.onCompleteObservable.add(l=>{this._activeRequests.splice(this._activeRequests.indexOf(l),1)}),h}async _requestFileAsync(e,t,i,s,r){return await new Promise((n,o)=>{this._requestFile(e,h=>{n(h)},t,i,s,h=>{o(h)},r)})}_readFile(e,t,i,s,r){const n=Gs(e,t,i,s,r);return this._activeRequests.push(n),n.onCompleteObservable.add(o=>{this._activeRequests.splice(this._activeRequests.indexOf(o),1)}),n}async _readFileAsync(e,t,i){return await new Promise((s,r)=>{this._readFile(e,n=>{s(n)},t,i,n=>{r(n)})})}getPerfCollector(){throw ie("performanceViewerSceneExtension")}setActiveCameraByID(e){return this.setActiveCameraById(e)}getMaterialByID(e){return this.getMaterialById(e)}getLastMaterialByID(e){return this.getLastMaterialById(e)}getTextureByUniqueID(e){return this.getTextureByUniqueId(e)}getCameraByID(e){return this.getCameraById(e)}getCameraByUniqueID(e){return this.getCameraByUniqueId(e)}getBoneByID(e){return this.getBoneById(e)}getLightByID(e){return this.getLightById(e)}getLightByUniqueID(e){return this.getLightByUniqueId(e)}getParticleSystemByID(e){return this.getParticleSystemById(e)}getGeometryByID(e){return this.getGeometryById(e)}getMeshByID(e){return this.getMeshById(e)}getMeshByUniqueID(e){return this.getMeshByUniqueId(e)}getLastMeshByID(e){return this.getLastMeshById(e)}getMeshesByID(e){return this.getMeshesById(e)}getTransformNodeByID(e){return this.getTransformNodeById(e)}getTransformNodeByUniqueID(e){return this.getTransformNodeByUniqueId(e)}getTransformNodesByID(e){return this.getTransformNodesById(e)}getNodeByID(e){return this.getNodeById(e)}getLastEntryByID(e){return this.getLastEntryById(e)}getLastSkeletonByID(e){return this.getLastSkeletonById(e)}}tt.FOGMODE_NONE=0;tt.FOGMODE_EXP=1;tt.FOGMODE_EXP2=2;tt.FOGMODE_LINEAR=3;tt.MinDeltaTime=1;tt.MaxDeltaTime=1e3;tt._OriginalDefaultMaterialFactory=tt.DefaultMaterialFactory;nt("BABYLON.Scene",tt);async function Lu(a,e){const t=e.method||"GET";return await new Promise((i,s)=>{const r=new gt;r.addEventListener("readystatechange",()=>{if(r.readyState==4)if(r.status==200){const n={};if(e.responseHeaders)for(const o of e.responseHeaders)n[o]=r.getResponseHeader(o)||"";i({response:r.response,headerValues:n})}else s(`Unable to fetch data from ${a}. Error code: ${r.status}`)}),r.open(t,a),r.send()})}var wa;(function(a){a[a.Clean=0]="Clean",a[a.Stop=1]="Stop",a[a.Sync=2]="Sync",a[a.NoSync=3]="NoSync"})(wa||(wa={}));function Bu(a){return!!a.createPlugin}function Nu(a){return!!a.name}const Uu=new O,Ri={};function Gn(){return Ri[".babylon"]}function ku(a){for(const e in Ri){const t=Ri[e];if(t.mimeType===a)return t}}function La(a,e){const t=Ri[a];return t||(w.Warn("Unable to find a plugin to load "+a+" files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/features/featuresDeepDive/importers/loadingFileTypes"),e?Gn():void 0)}function Gu(a){for(const e in Ri){const t=Ri[e].plugin;if(t.canDirectLoad&&t.canDirectLoad(a))return Ri[e]}return Gn()}function Hu(a){const e=a.indexOf("?");e!==-1&&(a=a.substring(0,e));const t=a.lastIndexOf(".");return a.substring(t,a.length).toLowerCase()}function Vu(a){return a.substring(0,5)==="data:"?a.substring(5):null}function Sh(a,e,t){let s="Unable to load from "+(a.rawData?"binary data":a.url);return e?s+=`: ${e}`:t&&(s+=`: ${t}`),s}async function Mh(a,e,t,i,s,r,n,o,h){const l=Vu(a.url);if(a.rawData&&!n)throw"When using ArrayBufferView to load data the file extension must be provided.";const c=!l&&!n?Hu(a.url):"";let u=n?La(n,!0):l?Gu(a.url):La(c,!1);if(!u&&c){if(a.url&&!a.url.startsWith("blob:")){const d=await Lu(a.url,{method:"HEAD",responseHeaders:["Content-Type"]}),g=d.headerValues?d.headerValues["Content-Type"]:"";g&&(u=ku(g))}u||(u=Gn())}if(!u)throw new Error(`No plugin or fallback for ${n??a.url}`);if(h?.[u.plugin.name]?.enabled===!1)throw new Error(`The '${u.plugin.name}' plugin is disabled via the loader options passed to the loading operation.`);if(a.rawData&&!u.isBinary)throw"Loading from ArrayBufferView can not be used with plugins that don't support binary loading.";return(d=>{if(Bu(u.plugin)){const p=u.plugin.createPlugin(h??{});
30return p instanceof Promise?(p.then(d).catch(m=>{s("Error instantiating plugin.",m)}),null):(d(p),p)}else return d(u.plugin),u.plugin})(d=>{if(!d)throw`The loader plugin corresponding to the '${n}' file type has not been found. If using es6, please import the plugin you wish to use before.`;if(Uu.notifyObservers(d),l&&(d.canDirectLoad&&d.canDirectLoad(a.url)||!wn(a.url))){if(d.directLoad){const C=d.directLoad(e,l);C instanceof Promise?C.then(x=>{t(d,x)}).catch(x=>{s("Error in directLoad of _loadData: "+x,x)}):t(d,C)}else t(d,l);return}const g=u.isBinary,p=(C,x)=>{if(e.isDisposed){s("Scene has been disposed");return}t(d,C,x)};let m=null,A=!1;d.onDisposeObservable?.add(()=>{A=!0,m&&(m.abort(),m=null),r()});const E=()=>{if(A)return;const C=(x,S)=>{s(x?.statusText,S)};if(!d.loadFile&&a.rawData)throw"Plugin does not support loading ArrayBufferView.";m=d.loadFile?d.loadFile(e,a.rawData||a.file||a.url,a.rootUrl,p,i,g,C,o):e._loadFile(a.file||a.url,p,i,!0,g,C)},I=e.getEngine();let M=I.enableOfflineSupport;if(M){let C=!1;for(const x of e.disableOfflineSupportExceptionRules)if(x.test(a.url)){C=!0;break}M=!C}M&&H.OfflineProviderFactory?e.offlineProvider=H.OfflineProviderFactory(a.url,E,I.disableManifestCheck):E()})}function Ch(a,e){let t,i,s=null,r=null;if(!e)t=a,i=se.GetFilename(a),a=se.GetFolderPath(a);else if(Nu(e))t=`file:${e.name}`,i=e.name,s=e;else if(ArrayBuffer.isView(e))t="",i=Bn(),r=e;else if(e.startsWith("data:"))t=e,i="";else if(a){const n=e;if(n.substring(0,1)==="/")return se.Error("Wrong sceneFilename parameter"),null;t=a+n,i=n}else t=e,i=se.GetFilename(e),a=se.GetFolderPath(e);return{url:t,rootUrl:a,name:i,file:s,rawData:r}}function Ps(a){if(typeof a.extensions=="string"){const e=a.extensions;Ri[e.toLowerCase()]={plugin:a,isBinary:!1}}else{const e=a.extensions,t=Object.keys(e);for(const i of t)Ri[i.toLowerCase()]={plugin:a,isBinary:e[i].isBinary,mimeType:e[i].mimeType}}}async function y_(a,e,t){const{meshNames:i,rootUrl:s="",onProgress:r,pluginExtension:n,name:o,pluginOptions:h}=t??{};return await Wu(i,s,a,e,r,n,o,h)}async function zu(a,e,t="",i=Te.LastCreatedScene,s=null,r=null,n=null,o=null,h="",l={}){if(!i)return w.Error("No scene available to import mesh to"),null;const c=Ch(e,t);if(!c)return null;const u={};i.addPendingData(u);const f=()=>{i.removePendingData(u)},d=(m,A)=>{const E=Sh(c,m,A);n?n(i,E,new Li(E,xs.SceneLoaderError,A)):w.Error(E),f()},g=r?m=>{try{r(m)}catch(A){d("Error in onProgress callback: "+A,A)}}:void 0,p=(m,A,E,I,M,C,x,S)=>{if(i.importedMeshesFiles.push(c.url),s)try{s(m,A,E,I,M,C,x,S)}catch(L){d("Error in onSuccess callback: "+L,L)}i.removePendingData(u)};return await Mh(c,i,(m,A,E)=>{if(m.rewriteRootURL&&(c.rootUrl=m.rewriteRootURL(c.rootUrl,E)),m.importMesh){const I=m,M=[],C=[],x=[];if(!I.importMesh(a,i,A,c.rootUrl,M,C,x,d))return;i.loadingPluginName=m.name,p(M,C,x,[],[],[],[],[])}else m.importMeshAsync(a,i,A,c.rootUrl,g,c.name).then(M=>{i.loadingPluginName=m.name,p(M.meshes,M.particleSystems,M.skeletons,M.animationGroups,M.transformNodes,M.geometries,M.lights,M.spriteManagers)}).catch(M=>{d(M.message,M)})},g,d,f,o,h,l)}async function Wu(a,e,t,i,s,r,n,o){return await new Promise((h,l)=>{try{zu(a,e,t,i,(c,u,f,d,g,p,m,A)=>{h({meshes:c,particleSystems:u,skeletons:f,animationGroups:d,transformNodes:g,geometries:p,lights:m,spriteManagers:A})},s,(c,u,f)=>{l(f||new Error(u))},r,n,o).catch(l)}catch(c){l(c)}})}async function Xu(a,e="",t=Te.LastCreatedScene,i=null,s=null,r=null,n=null,o="",h={}){if(!t)return w.Error("No scene available to load asset container to"),null;const l=Ch(a,e);if(!l)return null;const c={};t.addPendingData(c);const u=()=>{t.removePendingData(c)},f=(p,m)=>{const A=Sh(l,p,m);r?r(t,A,new Li(A,xs.SceneLoaderError,m)):w.Error(A),u()},d=s?p=>{try{s(p)}catch(m){f("Error in onProgress callback",m)}}:void 0,g=p=>{if(i)try{i(p)}catch(m){f("Error in onSuccess callback",m)}t.removePendingData(c)};return await Mh(l,t,(p,m)=>{if(p.loadAssetContainer){const E=p.loadAssetContainer(t,m,l.rootUrl,f);if(!E)return;E.populateRootNodes(),t.loadingPluginName=p.name,g(E)}else p.loadAssetContainerAsync?p.loadAssetContainerAsync(t,m,l.rootUrl,d,l.name).then(E=>{E.populateRootNodes(),t.loadingPluginName=p.name,g(E)}).catch(E=>{f(E.message,E)}):f("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.")},d,f,u,n,o,h)}async function Ku(a,e,t){const{rootUrl:i="",onProgress:s,pluginExtension:r,name:n,pluginOptions:o}=t??{};return await Yu(i,a,e,s,r,n,o)}async function Yu(a,e,t,i,s,r,n){return await new Promise((o,h)=>{try{Xu(a,e,t,l=>{o(l)},i,(l,c,u)=>{h(u||new Error(c))},s,r,n).catch(h)}catch(l){h(l)}})}class Si{constructor(e){if(this.VERTEXOUTPUT_INVARIANT=!1,this._keys=[],this._isDirty=!0,this._areLightsDirt
vendor: 5,807 bytes, lines 30-32
30y=!0,this._areLightsDisposed=!1,this._areAttributesDirty=!0,this._areTexturesDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._arePrePassDirty=!0,this._areImageProcessingDirty=!0,this._normals=!1,this._uvs=!1,this._needNormals=!1,this._needUVs=!1,this._externalProperties=e,e)for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&this._setDefaultValue(t)}get isDirty(){return this._isDirty}markAsProcessed(){this._isDirty=!1,this._areAttributesDirty=!1,this._areTexturesDirty=!1,this._areFresnelDirty=!1,this._areLightsDirty=!1,this._areLightsDisposed=!1,this._areMiscDirty=!1,this._arePrePassDirty=!1,this._areImageProcessingDirty=!1}markAsUnprocessed(){this._isDirty=!0}markAllAsDirty(){this._areTexturesDirty=!0,this._areAttributesDirty=!0,this._areLightsDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._arePrePassDirty=!0,this._areImageProcessingDirty=!0,this._isDirty=!0}markAsImageProcessingDirty(){this._areImageProcessingDirty=!0,this._isDirty=!0}markAsLightDirty(e=!1){this._areLightsDirty=!0,this._areLightsDisposed=this._areLightsDisposed||e,this._isDirty=!0}markAsAttributesDirty(){this._areAttributesDirty=!0,this._isDirty=!0}markAsTexturesDirty(){this._areTexturesDirty=!0,this._isDirty=!0}markAsFresnelDirty(){this._areFresnelDirty=!0,this._isDirty=!0}markAsMiscDirty(){this._areMiscDirty=!0,this._isDirty=!0}markAsPrePassDirty(){this._arePrePassDirty=!0,this._isDirty=!0}rebuild(){this._keys.length=0;for(const e of Object.keys(this))e[0]!=="_"&&this._keys.push(e);if(this._externalProperties)for(const e in this._externalProperties)this._keys.indexOf(e)===-1&&this._keys.push(e)}isEqual(e){if(this._keys.length!==e._keys.length)return!1;for(let t=0;t<this._keys.length;t++){const i=this._keys[t];if(this[i]!==e[i])return!1}return!0}cloneTo(e){this._keys.length!==e._keys.length&&(e._keys=this._keys.slice(0));for(let t=0;t<this._keys.length;t++){const i=this._keys[t];e[i]=this[i]}}reset(){for(const e of this._keys)this._setDefaultValue(e)}_setDefaultValue(e){const t=this._externalProperties?.[e]?.type??typeof this[e],i=this._externalProperties?.[e]?.default;switch(t){case"number":this[e]=i??0;break;case"string":this[e]=i??"";break;default:this[e]=i??!1;break}}toString(){let e="";for(let t=0;t<this._keys.length;t++){const i=this._keys[t],s=this[i];switch(typeof s){case"number":case"string":e+="#define "+i+" "+s+`
31`;break;default:s&&(e+="#define "+i+`
32`);break}}return e}}class Ih extends F{constructor(e,t,i=!0,s=!1){super(e,t,void 0,s),this._normalMatrix=new P,this._storeEffectOnSubMeshes=i}getEffect(){return this._storeEffectOnSubMeshes?this._activeEffect:super.getEffect()}isReady(e,t){return e?!this._storeEffectOnSubMeshes||!e.subMeshes||e.subMeshes.length===0?!0:this.isReadyForSubMesh(e,e.subMeshes[0],t):!1}_isReadyForSubMesh(e){const t=e.materialDefines;return!!(!this.checkReadyOnEveryCall&&e.effect&&t&&t._renderId===this.getScene().getRenderId())}bindOnlyWorldMatrix(e){this._activeEffect.setMatrix("world",e)}bindOnlyNormalMatrix(e){this._activeEffect.setMatrix("normalMatrix",e)}bind(e,t){t&&this.bindForSubMesh(e,t,t.subMeshes[0])}_afterBind(e,t=null,i){super._afterBind(e,t,i),this.getScene()._cachedEffect=t,i?i._drawWrapper._forceRebindOnNextCall=!1:this._drawWrapper._forceRebindOnNextCall=!1}_mustRebind(e,t,i,s=1){return i._drawWrapper._forceRebindOnNextCall||e.isCachedMaterialInvalid(this,t,s)}dispose(e,t,i){this._activeEffect=void 0,super.dispose(e,t,i)}}function Ph(a){return class extends a{constructor(){super(...arguments),this.IMAGEPROCESSING=!1,this.VIGNETTE=!1,this.VIGNETTEBLENDMODEMULTIPLY=!1,this.VIGNETTEBLENDMODEOPAQUE=!1,this.TONEMAPPING=0,this.CONTRAST=!1,this.COLORCURVES=!1,this.COLORGRADING=!1,this.COLORGRADING3D=!1,this.SAMPLER3DGREENDEPTH=!1,this.SAMPLER3DBGRMAP=!1,this.DITHER=!1,this.IMAGEPROCESSINGPOSTPROCESS=!1,this.SKIPFINALCOLORCLAMP=!1,this.EXPOSURE=!1}}}class vh{constructor(){this._defines={},this._currentRank=32,this._maxRank=-1,this._mesh=null}unBindMesh(){this._mesh=null}addFallback(e,t){this._defines[e]||(e<this._currentRank&&(this._currentRank=e),e>this._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)}addCPUSkinningFallback(e,t){this._mesh=t,e<this._currentRank&&(this._currentRank=e),e>this._maxRank&&(this._maxRank=e)}get hasMoreFallbacks(){return this._currentRank<=this._maxRank}reduce(e,t){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),t._bonesComputationForcedToCPU=!0;const i=this._mesh.getScene();for(let s=0;s<i.meshes.length;s++){const r=i.meshes[s];if(!r.material){!this._mesh.material&&r.computeBonesUsingShaders&&r.numBoneInfluencers>0&&(r.computeBonesUsingShaders=!1);continue}if(!(!r.computeBonesUsingShaders||r.numBoneInfluencers===0)){if(r.material.getEffect()===t)r.computeBonesUsingShaders=!1;else if(r.subMeshes){for(const n of r.subMeshes)if(n.effect===t){r.computeBonesUsingShaders=!1;break}}}}}else{const i=this._defines[this._currentRank];if(i)for(let s=0;s<i.length;s++)e=e.replace("#define "+i[s],"");this._currentRank++}return e}}function Dh(a){return class extends a{constructor(...e){super(...e),ml.call(this,this,"_imageProcessingConfiguration")}get imageProcessingConfiguration(){return this._imageProcessingConfiguration}set imageProcessingConfiguration(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsImageProcessingDirty&&this._markAllSubMeshesAsImageProcessingDirty()}_attachImageProcessingConfiguration(e){e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
32!e&&this.getScene?this._imageProcessingConfiguration=this.getScene().imageProcessingConfiguration:e&&(this._imageProcessingConfiguration=e),this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(()=>{this._markAllSubMeshesAsImageProcessingDirty&&this._markAllSubMeshesAsImageProcessingDirty()})))}get cameraColorCurvesEnabled(){return this.imageProcessingConfiguration.colorCurvesEnabled}set cameraColorCurvesEnabled(e){this.imageProcessingConfiguration.colorCurvesEnabled=e}get cameraColorGradingEnabled(){return this.imageProcessingConfiguration.colorGradingEnabled}set cameraColorGradingEnabled(e){this.imageProcessingConfiguration.colorGradingEnabled=e}get cameraToneMappingEnabled(){return this._imageProcessingConfiguration.toneMappingEnabled}set cameraToneMappingEnabled(e){this._imageProcessingConfiguration.toneMappingEnabled=e}get cameraExposure(){return this._imageProcessingConfiguration.exposure}set cameraExposure(e){this._imageProcessingConfiguration.exposure=e}get cameraContrast(){return this._imageProcessingConfiguration.contrast}set cameraContrast(e){this._imageProcessingConfiguration.contrast=e}get cameraColorGradingTexture(){return this._imageProcessingConfiguration.colorGradingTexture}set cameraColorGradingTexture(e){this._imageProcessingConfiguration.colorGradingTexture=e}get cameraColorCurves(){return this._imageProcessingConfiguration.colorCurves}set cameraColorCurves(e){this._imageProcessingConfiguration.colorCurves=e}}}class qu extends Si{}class ju extends Ph(qu){constructor(){super(),this.DIFFUSE=!1,this.DIFFUSEDIRECTUV=0,this.GAMMADIFFUSE=!1,this.DIFFUSEHASALPHA=!1,this.OPACITYFRESNEL=!1,this.REFLECTIONBLUR=!1,this.REFLECTIONFRESNEL=!1,this.REFLECTIONFALLOFF=!1,this.TEXTURELODSUPPORT=!1,this.PREMULTIPLYALPHA=!1,this.USERGBCOLOR=!1,this.USEHIGHLIGHTANDSHADOWCOLORS=!1,this.BACKMAT_SHADOWONLY=!1,this.NOISE=!1,this.REFLECTIONBGR=!1,this.PROJECTED_GROUND=!1,this.REFLECTION=!1,this.REFLECTIONMAP_3D=!1,this.REFLECTIONMAP_SPHERICAL=!1,this.REFLECTIONMAP_PLANAR=!1,this.REFLECTIONMAP_CUBIC=!1,this.REFLECTIONMAP_PROJECTION=!1,this.REFLECTIONMAP_SKYBOX=!1,this.REFLECTIONMAP_EXPLICIT=!1,this.REFLECTIONMAP_EQUIRECTANGULAR=!1,this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,this.INVERTCUBICMAP=!1,this.REFLECTIONMAP_OPPOSITEZ=!1,this.LODINREFLECTIONALPHA=!1,this.GAMMAREFLECTION=!1,this.RGBDREFLECTION=!1,this.EQUIRECTANGULAR_RELFECTION_FOV=!1,this.MAINUV1=!1,this.MAINUV2=!1,this.UV1=!1,this.UV2=!1,this.CLIPPLANE=!1,this.CLIPPLANE2=!1,this.CLIPPLANE3=!1,this.CLIPPLANE4=!1,this.CLIPPLANE5=!1,this.CLIPPLANE6=!1,this.POINTSIZE=!1,this.FOG=!1,this.NORMAL=!1,this.NUM_BONE_INFLUENCERS=0,this.BonesPerMesh=0,this.INSTANCES=!1,this.SHADOWFLOAT=!1,this.LOGARITHMICDEPTH=!1,this.NONUNIFORMSCALING=!1,this.ALPHATEST=!1,this.rebuild()}}class Qu extends Dh(Ih){}class _e extends Qu{get _perceptualColor(){return this.__perceptualColor}set _perceptualColor(e){this.__perceptualColor=e,this._computePrimaryColorFromPerceptualColor(),this._markAllSubMeshesAsLightsDirty()}get primaryColorShadowLevel(){return this._primaryColorShadowLevel}set primaryColorShadowLevel(e){this._primaryColorShadowLevel=e,this._computePrimaryColors(),this._markAllSubMeshesAsLightsDirty()}get primaryColorHighlightLevel(){return this._primaryColorHighlightLevel}set primaryColorHighlightLevel(e){this._primaryColorHighlightLevel=e,this._computePrimaryColors(),this._markAllSubMeshesAsLightsDirty()}set reflectionStandardFresnelWeight(e){let t=e;t<.5?(t=t*2,this.reflectionReflectance0=_e.StandardReflectance0*t,this.reflectionReflectance90=_e.StandardReflectance90*t):(t=t*2-1,this.reflectionReflectance0=_e.StandardReflectance0+(1-_e.StandardReflectance0)*t,this.reflectionReflectance90=_e.StandardReflectance90+(1-_e.StandardReflectance90)*t)}get fovMultiplier(){return this._fovMultiplier}set fovMultiplier(e){isNaN(e)&&(e=1),this._fovMultiplier=Math.max(0,Math.min(2,e))}constructor(e,t,i=!1){super(e,t,void 0,i),this.primaryColor=q.White(),this._primaryColorShadowLevel=0,this._primaryColorHighlightLevel=0,this.reflectionTexture=null,this.reflectionBlur=0,this.diffuseTexture=null,this._shadowLights=null,this.shadowLights=null,this.shadowLevel=0,this.sceneCenter=_.Zero(),this.opacityFresnel=!0,this.reflectionFresnel=!1,this.reflectionFalloffDistance=0,this.reflectionAmount=1,this.reflectionReflectance0=.05,this.reflectionReflectance90=.5,this.useRGBColor=!0,this.enableNoise=!1,this._fovMultiplier=1,this.useEquirectangularFOV=!1,this._maxSimultaneousLights=4,this.maxSimultaneousLights=4,this._shadowOnly=!1,this.shadowOnly=!1,this.switchToBGR=!1,this._enableGroundProjection=!1,this.enableGroundProjection=!1,this.projectedGroundRadius=1e3,this.projectedGroundHeight=10,this._renderTargets=new it(16),this._reflectionControls=ge.Zero(),this._white=q.White(),this._primaryShadowColor=q.Black(),this._primaryHighlightColor=q.Black(),this._shadersLoaded=!1,this._attachImageProcessingConfiguration(null),this.getRenderTargetTextures=()=>(this._renderTargets.reset(),this._diffuseTexture&&this._diffuseTexture.isRenderTarget&&this._renderTargets.push(this._diffuseTexture),this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._renderTargets.push(this._reflectionTexture),this._renderTargets)}get hasRenderTargetTextures(){return!!(this._diffuseTexture&&this._diffuseTexture.isRenderTarget||this._reflectionTexture&&this._reflectionTexture.isRenderTarget)}needAlphaTesting(){return!0}needAlphaBlending(){return this.alpha<1||this._diffuseTexture!=null&&this._diffuseTexture.hasAlpha||this._shadowOnly}isReadyForSubMesh(e,t,i=!1){const s=t._drawWrapper;if(s.effect&&this.isFrozen&&s._wasPreviouslyReady&&s._wasPreviouslyUsingInstances===i)return!0;t.materialDefines||(t.materialDefines=new ju);const r=this.getScene(),n=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;const o=r.getEngine();if(lh(r,e,n,!1,this._maxSimultaneousLights),n._needNormals=!0,fh(r,n),n._areTexturesDirty){if(n._needUVs=!1,r.texturesEnabled){if(r.getEngine().getCaps().textureLOD&&(n.TEXTURELODSUPPORT=!0),this._diffuseTexture&&U.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;Ne(this._diffuseTexture,n,"DIFFUSE"),n.DIFFUSEHASALPHA=this._diffuseTexture.hasAlpha,n.GAMMADIFFUSE=this._diffuseTexture.gammaSpace,n.OPACITYFRESNEL=this._opacityFresnel}
32else n.DIFFUSE=!1,n.DIFFUSEDIRECTUV=0,n.DIFFUSEHASALPHA=!1,n.GAMMADIFFUSE=!1,n.OPACITYFRESNEL=!1;const h=this._reflectionTexture;if(ch(r,h,n),h&&U.ReflectionTextureEnabled){if(!h.isReadyOrNotBlocking())return!1;n.EQUIRECTANGULAR_RELFECTION_FOV=this.useEquirectangularFOV,n.REFLECTIONBGR=this.switchToBGR,n.REFLECTIONBLUR=this._reflectionBlur>0,this.reflectionFresnel?(n.REFLECTIONFRESNEL=!0,n.REFLECTIONFALLOFF=this.reflectionFalloffDistance>0,this._reflectionControls.x=this.reflectionAmount,this._reflectionControls.y=this.reflectionReflectance0,this._reflectionControls.z=this.reflectionReflectance90,this._reflectionControls.w=1/this.reflectionFalloffDistance):(n.REFLECTIONFRESNEL=!1,n.REFLECTIONFALLOFF=!1)}else n.REFLECTIONFRESNEL=!1,n.REFLECTIONFALLOFF=!1,n.REFLECTIONBLUR=!1}n.PREMULTIPLYALPHA=this.alphaMode===7||this.alphaMode===8,n.USERGBCOLOR=this._useRGBColor,n.NOISE=this._enableNoise}if(n._areLightsDirty&&(n.USEHIGHLIGHTANDSHADOWCOLORS=!this._useRGBColor&&(this._primaryColorShadowLevel!==0||this._primaryColorHighlightLevel!==0),n.BACKMAT_SHADOWONLY=this._shadowOnly),n._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(n)}if(n._areMiscDirty&&(n.REFLECTIONMAP_3D&&this._enableGroundProjection?(n.PROJECTED_GROUND=!0,n.REFLECTIONMAP_SKYBOX=!0):n.PROJECTED_GROUND=!1),hh(e,r,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this.needAlphaTestingForMesh(e),n,void 0,void 0,void 0,this._isVertexOutputInvariant),uh(r,o,this,n,i,null,t.getRenderingMesh().hasThinInstances),dh(e,n,!1,!0,!1)&&e&&!r.getEngine().getCaps().standardDerivatives&&!e.isVerticesDataPresent(b.NormalKind)&&(e.createNormals(!0),w.Warn("BackgroundMaterial: Normals have been created for the mesh: "+e.name)),n.isDirty){n.markAsProcessed(),r.resetCachedMaterial();const h=new vh;n.FOG&&h.addFallback(0,"FOG"),n.POINTSIZE&&h.addFallback(1,"POINTSIZE"),n.MULTIVIEW&&h.addFallback(0,"MULTIVIEW"),oh(n,h,this._maxSimultaneousLights);const l=[b.PositionKind];n.NORMAL&&l.push(b.NormalKind),n.UV1&&l.push(b.UVKind),n.UV2&&l.push(b.UV2Kind),nh(l,e,n,h),ah(l,n);const c=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","mBones","vPrimaryColor","vPrimaryColorShadow","fFovMultiplier","shadowLevel","alpha","vBackgroundCenter","vReflectionControl","vDiffuseInfos","diffuseMatrix","projectedGroundInfos","logarithmicDepthConstant"];qo(c);const u=["diffuseSampler"];_h(c,u,!1);const f=["Material","Scene"];ue&&(ue.PrepareUniforms(c,n),ue.PrepareSamplers(u,n)),gh({uniformsNames:c,uniformBuffersNames:f,samplers:u,defines:n,maxSimultaneousLights:this._maxSimultaneousLights});const d=n.toString(),g=r.getEngine().createEffect("background",{attributes:l,uniformsNames:c,uniformBuffersNames:f,samplers:u,defines:d,fallbacks:h,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights},shaderLanguage:this._shaderLanguage,extraInitializationsAsync:this._shadersLoaded?void 0:async()=>{this.shaderLanguage===1?await Promise.all([G(()=>import("./background.vertex-SWsJCPxj.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]),import.meta.url),G(()=>import("./background.fragment-BG3FvZXK.js"),__vite__mapDeps([15,1,2,3,16,17,18,10,19,20,21,13,14]),import.meta.url)]):await Promise.all([G(()=>import("./background.vertex-ZS3q0fNA.js"),__vite__mapDeps([22,23,24,25,26,27,28,29,30,31,13,14]),import.meta.url),G(()=>import("./background.fragment-BzZWuUI3.js"),__vite__mapDeps([32,23,24,25,33,34,35,36,31,37,38,13,14]),import.meta.url)]),this._shadersLoaded=!0}},o);t.setEffect(g,n,this._materialContext),this.buildUniformLayout()}return!t.effect||!t.effect.isReady()?!1:(n._renderId=r.getRenderId(),s._wasPreviouslyReady=!0,s._wasPreviouslyUsingInstances=i,this._checkScenePerformancePriority(),!0)}_computePrimaryColorFromPerceptualColor(){this.__perceptualColor&&(this._primaryColor.copyFrom(this.__perceptualColor),this._primaryColor.toLinearSpaceToRef(this._primaryColor,this.getScene().getEngine().useExactSrgbConversions),this._imageProcessingConfiguration&&this._primaryColor.scaleToRef(1/this._imageProcessingConfiguration.exposure,this._primaryColor),this._computePrimaryColors())}_computePrimaryColors(){this._primaryColorShadowLevel===0&&this._primaryColorHighlightLevel===0||(this._primaryColor.scaleToRef(this._primaryColorShadowLevel,this._primaryShadowColor),this._primaryColor.subtractToRef(this._primaryShadowColor,this._primaryShadowColor),this._white.subtractToRef(this._primaryColor,this._primaryHighlightColor),this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel,this._primaryHighlightColor),this._primaryColor.addToRef(this._primaryHighlightColor,this._primaryHighlightColor))}buildUniformLayout(){this._uniformBuffer.addUniform("vPrimaryColor",4),this._uniformBuffer.addUniform("vPrimaryColorShadow",4),this._uniformBuffer.addUniform("vDiffuseInfos",2),this._uniformBuffer.addUniform("diffuseMatrix",16),this._uniformBuffer.addUniform("fFovMultiplier",1),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.addUniform("shadowLevel",1),this._uniformBuffer.addUniform("alpha",1),this._uniformBuffer.addUniform("vBackgroun
32dCenter",3),this._uniformBuffer.addUniform("vReflectionControl",4),this._uniformBuffer.addUniform("projectedGroundInfos",2),ph(this._uniformBuffer,!0,!1,!1),this._uniformBuffer.create()}unbind(){this._diffuseTexture&&this._diffuseTexture.isRenderTarget&&this._uniformBuffer.setTexture("diffuseSampler",null),this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),super.unbind()}bindOnlyWorldMatrix(e){this._activeEffect.setMatrix("world",e)}bindForSubMesh(e,t,i){const s=this.getScene(),r=i.materialDefines;if(!r)return;const n=i.effect;if(!n)return;this._activeEffect=n,this.bindOnlyWorldMatrix(e),sh(t,this._activeEffect);const o=this._mustRebind(s,n,i,t.visibility);if(o){this._uniformBuffer.bindToEffect(n,"Material"),this.bindViewProjection(n);const h=this._reflectionTexture;if((!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync||i._drawWrapper._forceRebindOnNextCall)&&(s.texturesEnabled&&(this._diffuseTexture&&U.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),Ue(this._diffuseTexture,this._uniformBuffer,"diffuse")),th(s,r,this._uniformBuffer,q.White(),h,!1,!0,!1,!1,!1,!1,this._reflectionBlur)),this.shadowLevel>0&&this._uniformBuffer.updateFloat("shadowLevel",this.shadowLevel),this._uniformBuffer.updateFloat("alpha",this.alpha),this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),r.USEHIGHLIGHTANDSHADOWCOLORS?(this._uniformBuffer.updateColor4("vPrimaryColor",this._primaryHighlightColor,1),this._uniformBuffer.updateColor4("vPrimaryColorShadow",this._primaryShadowColor,1)):this._uniformBuffer.updateColor4("vPrimaryColor",this._primaryColor,1)),this._uniformBuffer.updateFloat("fFovMultiplier",this._fovMultiplier),r.REFLECTIONFRESNEL&&this._uniformBuffer.updateFloat4("vReflectionControl",this._reflectionControls.x,this._reflectionControls.y,this._reflectionControls.z,this._reflectionControls.w),r.REFLECTIONFRESNEL&&r.REFLECTIONFALLOFF||r.OPACITYFRESNEL){const l=v.Vector3[0].copyFrom(this.sceneCenter).subtractInPlace(s.floatingOriginOffset);
32this._uniformBuffer.updateFloat3("vBackgroundCenter",l.x,l.y,l.z)}s.texturesEnabled&&(this._diffuseTexture&&U.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("diffuseSampler",this._diffuseTexture),h&&U.ReflectionTextureEnabled&&ih(s,r,this._uniformBuffer,h),r.PROJECTED_GROUND&&this._uniformBuffer.updateFloat2("projectedGroundInfos",this.projectedGroundRadius,this.projectedGroundHeight)),jo(this._activeEffect,this,s),s.bindEyePosition(n)}else s.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._uniformBuffer.bindToEffect(n,"Material"),this._needToBindSceneUbo=!0);(o||!this.isFrozen)&&(s.lightsEnabled&&rh(s,t,this._activeEffect,r,this._maxSimultaneousLights),this.bindView(n),$o(s,t,this._activeEffect,!0),this._useLogarithmicDepth&&Zo(r,n,s),this._imageProcessingConfiguration&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._afterBind(t,this._activeEffect,i),this._uniformBuffer.update()}hasTexture(e){return!!(super.hasTexture(e)||this._reflectionTexture===e||this._diffuseTexture===e)}dispose(e=!1,t=!1){t&&(this.diffuseTexture&&this.diffuseTexture.dispose(),this.reflectionTexture&&this.reflectionTexture.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),super.dispose(e)}clone(e){return le.Clone(()=>new _e(e,this.getScene()),this)}serialize(){const e=super.serialize();
32return e.customType="BABYLON.BackgroundMaterial",e}getClassName(){return"BackgroundMaterial"}static Parse(e,t,i){return le.Parse(()=>new _e(e.name,t),e,t,i)}}_e.StandardReflectance0=.05;_e.StandardReflectance90=.5;T([At()],_e.prototype,"_primaryColor",void 0);T([B("_markAllSubMeshesAsLightsDirty")],_e.prototype,"primaryColor",void 0);T([At()],_e.prototype,"__perceptualColor",void 0);T([R()],_e.prototype,"_primaryColorShadowLevel",void 0);T([R()],_e.prototype,"_primaryColorHighlightLevel",void 0);T([B("_markAllSubMeshesAsLightsDirty")],_e.prototype,"primaryColorHighlightLevel",null);T([Oe()],_e.prototype,"_reflectionTexture",void 0);T([B("_markAllSubMeshesAsTexturesDirty")],_e.prototype,"reflectionTexture",void 0);T([R()],_e.prototype,"_reflectionBlur",void 0);T([B("_markAllSubMeshesAsTexturesDirty")],_e.prototype,"reflectionBlur",void 0);T([Oe()],_e.prototype,"_diffuseTexture",void 0);T([B("_markAllSubMeshesAsTexturesDirty")],_e.prototype,"diffuseTexture",void 0);T([B("_markAllSubMeshesAsTexturesDirty")],_e.prototype,"shadowLights",void 0);T([R()],_e.prototype,"_shadowLevel",void 0);T([B("_markAllSubMeshesAsTexturesDirty")],_e.prototype,"shadowLevel",void 0);T([qt()],_e.prototype,"_sceneCenter",void 0);T([B("_markAllSubMeshesAsTexturesDirty")],_e.prototype,"sceneCenter",void 0);T([R()],_e.prototype,"_opacityFresnel",void 0);T([B("_markAllSubMeshesAsTexturesDirty")],_e.prototype,"opacityFresnel",void 0);T([R()],_e.prototype,"_reflectionFresnel",void 0);T([B("_markAllSubMeshesAsTexturesDirty")],_e.prototype,"reflectionFresnel",void 0);T([R()],_e.prototype,"_reflectionFalloffDistance",void 0);T([B("_markAllSubMeshesAsTexturesDirty")],_e.prototype,"reflectionFalloffDistance",void 0);T([R()],_e.prototype,"_reflectionAmount",void 0);T([B("_markAllSubMeshesAsTexturesDirty")],_e.prototype,"reflectionAmount",void 0);T([R()],_e.prototype,"_reflectionReflectance0",void 0);T([B("_markAllSubMeshesAsTexturesDirty")],_e.prototype,"reflectionReflectance0",void 0);T([R()],_e.prototype,"_reflectionReflectance90",void 0);T([B("_markAllSubMeshesAsTexturesDirty")],_e.prototype,"reflectionReflectance90",void 0);T([R()],_e.prototype,"_useRGBColor",void 0);T([B("_markAllSubMeshesAsTexturesDirty")],_e.prototype,"useRGBColor",void 0);T([R()],_e.prototype,"_enableNoise",void 0);T([B("_markAllSubMeshesAsTexturesDirty")],_e.prototype,"enableNoise",void 0);T([R()],_e.prototype,"_maxSimultaneousLights",void 0);T([B("_markAllSubMeshesAsTexturesDirty")],_e.prototype,"maxSimultaneousLights",void 0);T([R()],_e.prototype,"_shadowOnly",void 0);T([B("_markAllSubMeshesAsLightsDirty")],_e.prototype,"shadowOnly",void 0);T([R(),B("_markAllSubMeshesAsMiscDirty")],_e.prototype,"enableGroundProjection",void 0);T([R()],_e.prototype,"projectedGroundRadius",void 0);T([R()],_e.prototype,"projectedGroundHeight",void 0);
vendor: 23,972 bytes, lines 32-41
32nt("BABYLON.BackgroundMaterial",_e);const yn="postprocessVertexShader",Oh=`attribute vec2 position;uniform vec2 scale;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);
33#define CUSTOM_VERTEX_DEFINITIONS
34void main(void) {
35#define CUSTOM_VERTEX_MAIN_BEGIN
36vUV=(position*madd+madd)*scale;gl_Position=vec4(position,0.0,1.0);
37#define CUSTOM_VERTEX_MAIN_END
38}`;We.ShadersStore[yn]||(We.ShadersStore[yn]=Oh);const Zu={name:yn,shader:Oh},Fh=Object.freeze(Object.defineProperty({__proto__:null,postprocessVertexShader:Zu},Symbol.toStringTag,{value:"Module"})),rn={positions:[1,1,-1,1,-1,-1,1,-1],indices:[0,1,2,0,2,3]};class $u{constructor(e,t=rn){this._fullscreenViewport=new ps(0,0,1,1);const i=t.positions??rn.positions,s=t.indices??rn.indices;this.engine=e,this._vertexBuffers={[b.PositionKind]:new b(e,i,b.PositionKind,!1,!1,2)},this._indexBuffer=e.createIndexBuffer(s),this._indexBufferLength=s.length,this._onContextRestoredObserver=e.onContextRestoredObservable.add(()=>{this._indexBuffer=e.createIndexBuffer(s);for(const r in this._vertexBuffers)this._vertexBuffers[r]._rebuild()})}setViewport(e=this._fullscreenViewport){this.engine.setViewport(e)}bindBuffers(e){this.engine.bindBuffers(this._vertexBuffers,this._indexBuffer,e)}applyEffectWrapper(e,t=!1,i=!1){this.engine.setState(!0),this.engine.depthCullingState.depthTest=t,this.engine.stencilState.stencilTest=i,this.engine.enableEffect(e.drawWrapper),this.bindBuffers(e.effect),e.onApplyObservable.notifyObservers({})}saveStates(){this._savedStateDepthTest=this.engine.depthCullingState.depthTest,this._savedStateStencilTest=this.engine.stencilState.stencilTest}restoreStates(){this.engine.depthCullingState.depthTest=this._savedStateDepthTest,this.engine.stencilState.stencilTest=this._savedStateStencilTest}draw(){this.engine.drawElementsType(0,0,this._indexBufferLength)}_isRenderTargetTexture(e){return e.renderTarget!==void 0}render(e,t=null){if(!e.effect.isReady())return;this.saveStates(),this.setViewport();const i=t===null?null:this._isRenderTargetTexture(t)?t.renderTarget:t;i&&this.engine.bindFramebuffer(i),this.applyEffectWrapper(e),this.draw(),i&&this.engine.unBindFramebuffer(i),this.restoreStates()}dispose(){const e=this._vertexBuffers[b.PositionKind];e&&(e.dispose(),delete this._vertexBuffers[b.PositionKind]),this._indexBuffer&&this.engine._releaseBuffer(this._indexBuffer),this._onContextRestoredObserver&&(this.engine.onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)}}class rt{static RegisterShaderCodeProcessing(e,t){if(!t){delete rt._CustomShaderCodeProcessing[e??""];return}rt._CustomShaderCodeProcessing[e??""]=t}static _GetShaderCodeProcessing(e){return rt._CustomShaderCodeProcessing[e]??rt._CustomShaderCodeProcessing[""]}get name(){return this.options.name}set name(e){this.options.name=e}isReady(){return this._drawWrapper.effect?.isReady()??!1}get drawWrapper(){return this._drawWrapper}get effect(){return this._drawWrapper.effect}set effect(e){this._drawWrapper.effect=e}constructor(e){this.alphaMode=0,this.onEffectCreatedObservable=new O(void 0,!0),this.onApplyObservable=new O,this._shadersLoaded=!1,this._webGPUReady=!1,this._importPromises=[],this.options={...e,name:e.name||"effectWrapper",engine:e.engine,uniforms:e.uniforms||e.uniformNames||[],uniformNames:void 0,samplers:e.samplers||e.samplerNames||[],samplerNames:void 0,attributeNames:e.attributeNames||["position"],uniformBuffers:e.uniformBuffers||[],defines:e.defines||"",useShaderStore:e.useShaderStore||!1,vertexUrl:e.vertexUrl||e.vertexShader||"postprocess",vertexShader:void 0,fragmentShader:e.fragmentShader||"pass",indexParameters:e.indexParameters,blockCompilation:e.blockCompilation||!1,shaderLanguage:e.shaderLanguage||0,onCompiled:e.onCompiled||void 0,extraInitializations:e.extraInitializations||void 0,extraInitializationsAsync:e.extraInitializationsAsync||void 0,useAsPostProcess:e.useAsPostProcess??!1,allowEmptySourceTexture:e.allowEmptySourceTexture??!1},this.options.uniformNames=this.options.uniforms,this.options.samplerNames=this.options.samplers,this.options.vertexShader=this.options.vertexUrl,this.options.useAsPostProcess&&(!this.options.allowEmptySourceTexture&&this.options.samplers.indexOf("textureSampler")===-1&&this.options.samplers.push("textureSampler"),this.options.uniforms.indexOf("scale")===-1&&this.options.uniforms.push("scale")),e.vertexUrl||e.vertexShader?this._shaderPath={vertexSource:this.options.vertexShader}:(this.options.useAsPostProcess||(this.options.uniforms.push("scale"),this.onApplyObservable.add(()=>{this.effect.setFloat2("scale",1,1)})),this._shaderPath={vertex:this.options.vertexShader}),this._shaderPath.fragmentSource=this.options.fragmentShader,this._shaderPath.spectorName=this.options.name,this.options.useShaderStore&&(this._shaderPath.fragment=this._shaderPath.fragmentSource,this._shaderPath.vertex||(this._shaderPath.vertex=this._shaderPath.vertexSource),delete this._shaderPath.fragmentSource,delete this._shaderPath.vertexSource),this.onApplyObservable.add(()=>{this.bind()}),this.options.useShaderStore||(this._onContextRestoredObserver=this.options.engine.onContextRestoredObservable.add(()=>{this.effect._pipelineContext=null,this.effect._prepareEffect()})),this._drawWrapper=new kn(this.options.engine),this._webGPUReady=this.options.shaderLanguage===1;const t=Array.isArray(this.options.defines)?this.options.defines.join(`
39`):this.options.defines;this._postConstructor(this.options.blockCompilation,t,this.options.extraInitializations)}_gatherImports(e=!1,t){this.options.useAsPostProcess&&(e&&this._webGPUReady?t.push(Promise.all([G(()=>import("./postprocess.vertex-CSEam0SV.js"),__vite__mapDeps([39,13,14]),import.meta.url)])):t.push(Promise.all([G(()=>Promise.resolve().then(()=>Fh),void 0,import.meta.url)])))}_postConstructor(e,t=null,i,s){this._importPromises.length=0,s&&this._importPromises.push(...s);const r=this.options.engine.isWebGPU&&!rt.ForceGLSL;this._gatherImports(r,this._importPromises),i!==void 0&&i(r,this._importPromises),r&&this._webGPUReady&&(this.options.shaderLanguage=1),e||this.updateEffect(t)}updateEffect(e=null,t=null,i=null,s,r,n,o,h){const l=rt._GetShaderCodeProcessing(this.name);if(l?.defineCustomBindings){const f=t?.slice()??[];f.push(...this.options.uniforms);const d=i?.slice()??[];d.push(...this.options.samplers),e=l.defineCustomBindings(this.name,e,f,d),t=f,i=d}this.options.defines=e||"";const c=this._shadersLoaded||this._importPromises.length===0?void 0:async()=>{await Promise.all(this._importPromises),this._shadersLoaded=!0};let u;this.options.extraInitializationsAsync?u=async()=>{c?.(),await this.options.extraInitializationsAsync()}:u=c,this.options.useShaderStore?this._drawWrapper.effect=this.options.engine.createEffect({vertex:o??this._shaderPath.vertex,fragment:h??this._shaderPath.fragment},{attributes:this.options.attributeNames,uniformsNames:t||this.options.uniforms,uniformBuffersNames:this.options.uniformBuffers,samplers:i||this.options.samplers,defines:e!==null?e:"",fallbacks:null,onCompiled:r??this.options.onCompiled,onError:n??null,indexParameters:s||this.options.indexParameters,processCodeAfterIncludes:l?.processCodeAfterIncludes?(f,d)=>l.processCodeAfterIncludes(this.name,f,d):null,processFinalCode:l?.processFinalCode?(f,d)=>l.processFinalCode(this.name,f,d):null,shaderLanguage:this.options.shaderLanguage,extraInitializationsAsync:u},this.options.engine):this._drawWrapper.effect=new ze(this._shaderPath,this.options.attributeNames,t||this.options.uniforms,i||this.options.samplerNames,this.options.engine,e,void 0,r||this.options.onCompiled,void 0,void 0,void 0,this.options.shaderLanguage,u),this.onEffectCreatedObservable.notifyObservers(this._drawWrapper.effect)}bind(e=!1){this.options.useAsPostProcess&&!e&&(this.options.engine.setAlphaMode(this.alphaMode),this.drawWrapper.effect.setFloat2("scale",1,1)),rt._GetShaderCodeProcessing(this.name)?.bindCustomBindings?.(this.name,this._drawWrapper.effect)}dispose(e=!1){this._onContextRestoredObserver&&(this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null),this.onEffectCreatedObservable.clear(),this._drawWrapper.dispose(!0)}}rt.ForceGLSL=!1;rt._CustomShaderCodeProcessing={};H.prototype.setTextureFromPostProcess=function(a,e,t){let i=null;e&&(e._forcedOutputTexture?i=e._forcedOutputTexture:e._textures.data[e._currentRenderTextureInd]&&(i=e._textures.data[e._currentRenderTextureInd])),this._bindTexture(a,i?.texture??null,t)};H.prototype.setTextureFromPostProcessOutput=function(a,e,t){this._bindTexture(a,e?._outputTexture?.texture??null,t)};ze.prototype.setTextureFromPostProcess=function(a,e){this._engine.setTextureFromPostProcess(this._samplers[a],e,a)};ze.prototype.setTextureFromPostProcessOutput=function(a,e){this._engine.setTextureFromPostProcessOutput(this._samplers[a],e,a)};class je{static get ForceGLSL(){return rt.ForceGLSL}static set ForceGLSL(e){rt.ForceGLSL=e}static RegisterShaderCodeProcessing(e,t){rt.RegisterShaderCodeProcessing(e,t)}get name(){return this._effectWrapper.name}set name(e){this._effectWrapper.name=e}get alphaMode(){return this._effectWrapper.alphaMode}set alphaMode(e){this._effectWrapper.alphaMode=e}get samples(){return this._samples}set samples(e){this._samples=Math.min(e,this._engine.getCaps().maxMSAASamples),this._textures.forEach(t=>{t.setSamples(this._samples)})}get shaderLanguage(){return this._shaderLanguage}getEffectName(){return this._fragmentUrl}set onActivate(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),e&&(this._onActivateObserver=this.onActivateObservable.add(e))}set onSizeChanged(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)}set onApply(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)}set onBeforeRender(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)}set onAfterRender(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)}get inputTexture(){return this._textures.data[this._currentRenderTextureInd]}set inputTexture(e){this._forcedOutputTexture=e}restoreDefaultInputTexture(){this._forcedOutputTexture&&(this._forcedOutputTexture=null,this.markTextureDirty())}getCamera(){return this._camera}get texelSize(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.texelSize:(this._forcedOutputTexture&&this._texelSize.copyFromFloats(1/this._forcedOutputTexture.width,1/this._forcedOutputTexture.height),this._texelSize)}constructor(e,t,i,s,r,n,o=1,h,l,c=null,u=0,f="postprocess",d,g=!1,p=5,m,A){this._parentContainer=null,this.width=-1,this.height=-1,this.nodeMaterialSource=null,this._outputTexture=null,this.autoClear=!0,this.forceAutoClearInAlphaMode=!1,this.animations=[],this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=1,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this.doNotSerialize=!1,this._webGPUReady=!1,this._reusable=!1,this._renderId=0,this.externalTextureSamplerBinding=!1,this._textures=new it(2),this._textureCache=[],this._currentRenderTextureInd=0,this._scaleRatio=new Q(1,1),this._texelSize=Q.Zero(),this.onActivateObservable=new O,this.onSizeChangedObservable=new O,this.onApplyObservable=new O,this.onBeforeRenderObservable=new O,this.onAfterRenderObservable=new O,this.onDisposeObservable=new O;let E=1,I=null,M;if(i&&!Array.isArray(i)){const C=i;i=C.uniforms??null,s=C.samplers??null,E=C.size??1,n=C.camera??null,o=C.samplingMode??1,h=C.engine,l=C.reusable,c=Array.isArray(C.defines)?C.defines.join(`
40`):C.defines??null,u=C.textureType??0,f=C.vertexUrl??"postprocess",d=C.indexParameters,g=C.blockCompilation??!1,p=C.textureFormat??5,m=C.shaderLanguage??0,I=C.uniformBuffers??null,A=C.extraInitializations,M=C.effectWrapper}else r&&(typeof r=="number"?E=r:E={width:r.width,height:r.height});if(this._useExistingThinPostProcess=!!M,this._effectWrapper=M??new rt({name:e,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:t,engine:h||n?.getScene().getEngine(),uniforms:i,samplers:s,uniformBuffers:I,defines:c,vertexUrl:f,indexParameters:d,blockCompilation:!0,shaderLanguage:m,extraInitializations:void 0}),this.name=e,this.onEffectCreatedObservable=this._effectWrapper.onEffectCreatedObservable,n!=null?(this._camera=n,this._scene=n.getScene(),n.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.addPostProcess(this),this.uniqueId=this._scene.getUniqueId()):h&&(this._engine=h,this._engine.postProcesses.push(this)),this._options=E,this.renderTargetSamplingMode=o||1,this._reusable=l||!1,this._textureType=u,this._textureFormat=p,this._shaderLanguage=m||0,this._samplers=s||[],this._samplers.indexOf("textureSampler")===-1&&this._samplers.push("textureSampler"),this._fragmentUrl=t,this._vertexUrl=f,this._parameters=i||[],this._parameters.indexOf("scale")===-1&&this._parameters.push("scale"),this._uniformBuffers=I||[],this._indexParameters=d,!this._useExistingThinPostProcess){this._webGPUReady=this._shaderLanguage===1;const C=[];this._gatherImports(this._engine.isWebGPU&&!je.ForceGLSL,C),this._effectWrapper._webGPUReady=this._webGPUReady,this._effectWrapper._postConstructor(g,c,A,C)}}_gatherImports(e=!1,t){e&&this._webGPUReady?t.push(Promise.all([G(()=>import("./postprocess.vertex-CSEam0SV.js"),__vite__mapDeps([39,13,14]),import.meta.url)])):t.push(Promise.all([G(()=>Promise.resolve().then(()=>Fh),void 0,import.meta.url)]))}getClassName(){return"PostProcess"}getEngine(){return this._engine}getEffect(){return this._effectWrapper.drawWrapper.effect}shareOutputWith(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this}useOwnOutput(){this._textures.length==0&&(this._textures=new it(2)),this._shareOutputWithPostProcess=null}updateEffect(e=null,t=null,i=null,s,r,n,o,h){this._effectWrapper.updateEffect(e,t,i,s,r,n,o,h),this._postProcessDefines=Array.isArray(this._effectWrapper.options.defines)?this._effectWrapper.options.defines.join(`
41`):this._effectWrapper.options.defines}isReusable(){return this._reusable}markTextureDirty(){this.width=-1}_createRenderTargetTexture(e,t,i=0){for(let r=0;r<this._textureCache.length;r++)if(this._textureCache[r].texture.width===e.width&&this._textureCache[r].texture.height===e.height&&this._textureCache[r].postProcessChannel===i&&this._textureCache[r].texture._generateDepthBuffer===t.generateDepthBuffer&&this._textureCache[r].texture.samples===t.samples)return this._textureCache[r].texture;const s=this._engine.createRenderTargetTexture(e,t);return this._textureCache.push({texture:s,postProcessChannel:i,lastUsedRenderId:-1}),s}_flushTextureCache(){const e=this._renderId;for(let t=this._textureCache.length-1;t>=0;t--)if(e-this._textureCache[t].lastUsedRenderId>100){let i=!1;for(let s=0;s<this._textures.length;s++)if(this._textures.data[s]===this._textureCache[t].texture){i=!0;break}i||(this._textureCache[t].texture.dispose(),this._textureCache.splice(t,1))}}resize(e,t,i=null,s=!1,r=!1){this._textures.length>0&&this._textures.reset(),this.width=e,this.height=t;let n=null;if(i){for(let l=0;l<i._postProcesses.length;l++)if(i._postProcesses[l]!==null){n=i._postProcesses[l];break}}const o={width:this.width,height:this.height},h={generateMipMaps:s,generateDepthBuffer:r||n===this,generateStencilBuffer:(r||n===this)&&this._engine.isStencilEnable,samplingMode:this.renderTargetSamplingMode,type:this._textureType,format:this._textureFormat,samples:this._samples,label:"PostProcessRTT-"+this.name};this._textures.push(this._createRenderTargetTexture(o,h,0)),this._reusable&&this._textures.push(this._createRenderTargetTexture(o,h,1)),this._texelSize.copyFromFloats(1/this.width,1/this.height),this.onSizeChangedObservable.notifyObservers(this)}_getTarget(){let e;if(this._shareOutputWithPostProcess)e=this._shareOutputWithPostProcess.inputTexture;else if(this._forcedOutputTexture)e=this._forcedOutputTexture,this.width=this._forcedOutputTexture.width,this.height=this._forcedOutputTexture.height;else{e=this.inputTexture;let t;for(let i=0;i<this._textureCache.length;i++)if(this._textureCache[i].texture===e){t=this._textureCache[i];break}t&&(t.lastUsedRenderId=this._renderId)}return e}activate(e,t=null,i){const s=e===null||e.cameraRigMode!==void 0?e||this._camera:null,r=s?.getScene()??e,n=r.getEngine(),o=n.getCaps().maxTextureSize,h=(t?t.width:this._engine.getRenderWidth(!0))*this._options|0,l=(t?t.height:this._engine.getRenderHeight(!0))*this._options|0;let c=this._options.width||h,u=this._options.height||l;const f=this.renderTargetSamplingMode!==7&&this.renderTargetSamplingMode!==1&&this.renderTargetSamplingMode!==2;let d=null;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this.adaptScaleToCurrentViewport){const g=n.currentViewport;g&&(c*=g.width,u*=g.height)}(f||this.alwaysForcePOT)&&(this._options.width||(c=n.needPOTTextures?Vs(c,o,this.scaleMode):c),this._options.height||(u=n.needPOTTextures?Vs(u,o,this.scaleMode):u)),(this.width!==c||this.height!==u||!(d=this._getTarget()))&&this.resize(c,u,s,f,i),this._textures.forEach(g=>{g.samples!==this.samples&&this._engine.updateRenderTargetTextureSampleCount(g,this.samples)}),this._flushTextureCache(),this._renderId++}return d||(d=this._getTarget()),this.enablePixelPerfectMode?(this._scaleRatio.copyFromFloats(h/c,l/u),this._engine.bindFramebuffer(d,0,h,l,this.forceFullscreenViewport)):(this._scaleRatio.copyFromFloats(1,1),this._engine.bindFramebuffer(d,0,void 0,void 0,this.forceFullscreenViewport)),this._engine._debugInsertMarker?.(`post process ${this.name} input`),this.onActivateObservable.notifyObservers(s),this.autoClear&&(this.alphaMode===0||this.forceAutoClearInAlphaMode)&&this._engine.clear(this.clearColor?this.clearColor:r.clearColor,r._allowPostProcessClearColor,!0,!0),this._reusable&&(this._currentRenderTextureInd=(this._currentRenderTextureInd+1)%2),d}get isSupported(){return this._effectWrapper.drawWrapper.effect.isSupported}get aspectRatio(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.aspectRatio:this._forcedOutputTexture?this._forcedOutputTexture.width/this._forcedOutputTexture.height:this.width/this.height}isReady(){return this._effectWrapper.isReady()}apply(){if(!this._effectWrapper.isReady())return null;this._engine.enableEffect(this._effectWrapper.drawWrapper),this._engine.setState(!1),this._engine.setDepthBuffer(!1),this._engine.setDepthWrite(!1),this.alphaConstants&&this.getEngine().setAlphaConstants(this.alphaConstants.r,this.alphaConstants.g,this.alphaConstants.b,this.alphaConstants.a),this._engine.setAlphaMode(this.alphaMode);let e;return this._shareOutputWithPostProcess?e=this._shareOutputWithPostProcess.inputTexture:this._forcedOutputTexture?e=this._forcedOutputTexture:e=this.inputTexture,this.externalTextureSamplerBinding||this._effectWrapper.drawWrapper.effect._bindTexture("textureSampler",e?.texture),this._effectWrapper.drawWrapper.effect.setVector2("scale",this._scaleRatio),this.onApplyObservable.notifyObservers(this._effectWrapper.drawWrapper.effect),this._effectWrapper.bind(!0),this._effectWrapper.drawWrapper.effect}_disposeTextures(){if(this._shareOutputWithPostProcess||this._forcedOutputTexture){this._disposeTextureCache();return}this._disposeTextureCache(),this._textures.dispose()}_disposeTextureCache(){for(let e=this._textureCache.length-1;e>=0;e--)this._textureCache[e].texture.dispose();this._textureCache.length=0}setPrePassRenderer(e){return this._prePassEffectConfiguration?(this._prePassEffectConfiguration=e.addEffectConfiguration(this._prePassEffectConfiguration),this._prePassEffectConfiguration.enabled=!0,!0):!1}dispose(e){e=e||this._camera,this._useExistingThinPostProcess||this._effectWrapper.dispose(),this._disposeTextures();let t;if(this._scene&&(t=this._scene.removePostProcess(this)),this._parentContainer){const i=this._parentContainer.postProcesses.indexOf(this);i>-1&&this._parentContainer.postProcesses.splice(i,1),this._parentContainer=null}if(t=this._engine.postProcesses.indexOf(this),t!==-1&&this._engine.postProcesses.splice(t,1),this.onDisposeObservable.notifyObservers(),!!e){if(e.detachPostProcess(this),t=e._postProcesses.indexOf(this),t===0&&e._postProcesses.length>0){const i=this._camera._getFirstPostProcess();i&&i.markTextureDirty()}this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear(),this.onEffectCreatedObservable.clear()}}serialize(){const e=le.Serialize(this),t=this.getCamera()||this._scene&&this._scene.activeCamera;return e.customType="BABYLON."+this.getClassName(),e.cameraId=t?t.id:null,e.reusable=this._reusable,e.textureType=this._textureType,e.fragmentUrl=this._fragmentUrl,e.parameters=this._parameters,e.samplers=this._samplers,e.uniformBuffers=this._uniformBuffers,e.options=this._options,e.defines=this._postProcessDefines,e.textureFormat=this._textureFormat,e.vertexUrl=this._vertexUrl,e.indexParameters=this._indexParameters,e}clone(){const e=this.serialize();e._engine=this._engine,e.cameraId=null;const t=je.Parse(e,this._scene,"");return t?(t.onActivateObservable=this.onActivateObservable.clone(),t.onSizeChangedObservable=this.onSizeChangedObservable.clone(),t.onApplyObservable=this.onApplyObservable.clone(),t.onBeforeRenderObservable=this.onBeforeRenderObservable.clone(),t.onAfterRenderObservable=this.onAfterRenderObservable.clone(),t._prePassEffectConfiguration=this._prePassEffectConfiguration,t):null}static Parse(e,t,i){const s=Oi(e.customType);if(!s||!s._Parse)return null;const r=t?t.getCameraById(e.cameraId):null;return s._Parse(e,r,t,i)}static _Parse(e,t,i,s){return le.Parse(()=>new je(e.name,e.fragmentUrl,e.parameters,e.samplers,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable,e.defines,e.textureType,e.vertexUrl,e.indexParameters,!1,e.textureFormat),e,i,s)}}T([R()],je.prototype,"uniqueId",void 0);T([R()],je.prototype,"name",null);T([R()],je.prototype,"width",void 0);T([R()],je.prototype,"height",void 0);T([R()],je.prototype,"renderTargetSamplingMode",void 0);T([fo()],je.prototype,"clearColor",void 0);T([R()],je.prototype,"autoClear",void 0);T([R()],je.prototype,"forceAutoClearInAlphaMode",void 0);T([R()],je.prototype,"alphaMode",null);T([R()],je.prototype,"alphaConstants",void 0);T([R()],je.prototype,"enablePixelPerfectMode",void 0);T([R()],je.prototype,"forceFullscreenViewport",void 0);T([R()],je.prototype,"scaleMode",void 0);T([R()],je.prototype,"alwaysForcePOT",void 0);T([R("samples")],je.prototype,"_samples",void 0);T([R()],je.prototype,"adaptScaleToCurrentViewport",void 0);nt("BABYLON.PostProcess",je);class Kt{get renderList(){return this._renderList}set renderList(e){this._renderList!==e&&(this._unObserveRenderList&&(this._unObserveRenderList(),this._unObserveRenderList=null),e&&(this._unObserveRenderList=_o(e,this._renderListHasChanged)),this._renderList=e)}get disableImageProcessing(){return this._disableImageProcessing}set disableImageProcessing(e){e!==this._disableImageProcessing&&(this._disableImageProcessing=e,this._scene.markAllMaterialsAsDirty(64))}get disableDepthPrePass(){return this._disableDepthPrePass}set disableDepthPrePass(e){this._disableDepthPrePass=e,this._renderingManager.disableDepthPrePass=e}get name(){return this._name}set name(e){if(this._name!==e){if(this._name=e,this._sceneUBOs)for(let t=0;t<this._sceneUBOs.length;++t)this._sceneUBOs[t].name=`Scene ubo #${t} for ${this.name}`;if(this._scene)for(let t=0;t<this._renderPassIds.length;++t){const i=this._renderPassIds[t];this._engine._renderPassNames[i]=`${this._name}#${t}`}}}get renderPassIds(){return this._renderPassIds}
41get currentRefreshId(){return this._currentRefreshId}getActiveMeshes(){return this._activeMeshes}setMaterialForRendering(e,t){let i;Array.isArray(e)?i=e:i=[e];for(let s=0;s<i.length;++s)for(let r=0;r<this.options.numPasses;++r){let n=i[s];i[s].isAnInstance&&(n=i[s].sourceMesh),n.setMaterialForRenderPass(this._renderPassIds[r],t!==void 0?Array.isArray(t)?t[r]:t:void 0)}}_freezeActiveMeshes(e){this._freezeActiveMeshesCancel=tr(()=>this._checkReadiness(),()=>{if(this._freezeActiveMeshesCancel=null,e)for(let t=0;t<this._activeMeshes.length;t++)this._activeMeshes.data[t]._freeze();this._prepareRenderingManager(0,!0),this._isFrozen=!0},(t,i)=>{this._freezeActiveMeshesCancel=null,i?(w.Error("ObjectRenderer: Timeout while waiting for the renderer to be ready."),t&&w.Error(t)):(w.Error("ObjectRenderer: An unexpected error occurred while waiting for the renderer to be ready."),t&&(w.Error(t),t.stack&&w.Error(t.stack)))})}_unfreezeActiveMeshes(){this._freezeActiveMeshesCancel?.(),this._freezeActiveMeshesCancel=null;for(let e=0;e<this._activeMeshes.length;e++)this._activeMeshes.data[e]._unFreeze();this._isFrozen=!1}constructor(e,t,i){this._unObserveRenderList=null,this._renderListHasChanged=(s,r)=>{const n=this._renderList?this._renderList.length:0;if(r===0&&n>0||n===0)for(const o of this._scene.meshes)o._markSubMeshesAsLightDirty()},this.particleSystemList=null,this.getCustomRenderList=null,this.renderMeshes=!0,this.renderDepthOnlyMeshes=!0,this.renderOpaqueMeshes=!0,this.renderAlphaTestMeshes=!0,this.renderTransparentMeshes=!0,this.renderParticles=!0,this.renderSprites=!1,this.forceLayerMaskCheck=!1,this.enableBoundingBoxRendering=!1,this.enableOutlineRendering=!0,this._disableImageProcessing=!1,this.dontSetTransformationMatrix=!1,this._disableDepthPrePass=!1,this.onBeforeRenderObservable=new O,this.onAfterRenderObservable=new O,this.onBeforeRenderingManagerRenderObservable=new O,this.onAfterRenderingManagerRenderObservable=new O,this.onInitRenderingObservable=new O,this.onFinishRenderingObservable=new O,this.onFastPathRenderObservable=new O,this._currentRefreshId=-1,this._refreshRate=1,this._currentApplyByPostProcessSetting=!1,this._activeMeshes=new it(256),this._activeBoundingBoxes=new it(32),this._currentFrameId=-1,this._currentSceneUBOIndex=0,this._isFrozen=!1,this._freezeActiveMeshesCancel=null,this._currentSceneCamera=null,this.name=e,this._scene=t,this._engine=this._scene.getEngine(),this._useUBO=this._engine.supportsUniformBuffers,this._useUBO&&(this._sceneUBOs=[],this._createSceneUBO()),this.renderList=[],this._renderPassIds=[],this.options={numPasses:1,doNotChangeAspectRatio:!0,enableClusteredLights:!1,...i},this._createRenderPassId(),this.renderPassId=this._renderPassIds[0],this._renderingManager=new ct(t),this._renderingManager._useSceneAutoClearSetup=!0,this.options.enableClusteredLights&&this.onInitRenderingObservable.add(()=>{for(const s of this._scene.lights)s.getTypeID()===Ee.LIGHTTYPEID_CLUSTERED_CONTAINER&&s.isSupported&&s._updateBatches(this.activeCamera).render()}),this._scene.addObjectRenderer(this)}_releaseRenderPassId(){for(let e=0;e<this.options.numPasses;++e)this._engine.releaseRenderPassId(this._renderPassIds[e]);this._renderPassIds.length=0}_createRenderPassId(){this._releaseRenderPassId();for(let e=0;e<this.options.numPasses;++e)this._renderPassIds[e]=this._engine.createRenderPassId(`${this.name}#${e}`)}_createSceneUBO(){const e=this._sceneUBOs.length;this._sceneUBOs.push(this._scene.createSceneUniformBuffer(`Scene ubo #${e} for ${this.name}`,!1))}_getSceneUBO(){this._currentFrameId!==this._engine.frameId&&(this._currentSceneUBOIndex=0,this._currentFrameId=this._engine.frameId),this._currentSceneUBOIndex>=this._sceneUBOs.length&&this._createSceneUBO();const e=this._sceneUBOs[this._currentSceneUBOIndex++];return e.unbindEffect(),e}resetRefreshCounter(){this._currentRefreshId=-1}get refreshRate(){return this._refreshRate}set refreshRate(e){this._refreshRate=e,this.resetRefreshCounter()}shouldRender(){return this._currentRefreshId===-1?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefresh
41Id=1,!0):(this._currentRefreshId++,!1)}isReadyForRendering(e,t){this.prepareRenderList(),this.initRender(e,t);const i=this._checkReadiness();return this.finishRender(),i}prepareRenderList(){const e=this._scene;if(this._waitingRenderList){if(!this.renderListPredicate){this.renderList=[];for(let t=0;t<this._waitingRenderList.length;t++){const i=this._waitingRenderList[t],s=e.getMeshById(i);s&&this.renderList.push(s)}}this._waitingRenderList=void 0}if(this.renderListPredicate){this.renderList?this.renderList.length=0:this.renderList=[];const t=this._scene.meshes;for(let i=0;i<t.length;i++){const s=t[i];this.renderListPredicate(s)&&this.renderList.push(s)}}this._currentApplyByPostProcessSetting=this._scene.imageProcessingConfiguration.applyByPostProcess,this._disableImageProcessing&&(this._scene.imageProcessingConfiguration._applyByPostProcess=this._disableImageProcessing)}initRender(e,t){const i=this.activeCamera??this._scene.activeCamera;this._currentSceneCamera=this._scene.activeCamera,this._useUBO&&(this._currentSceneUBO=this._scene.getSceneUniformBuffer(),this._currentSceneUBO.unbindEffect(),this._scene.setSceneUniformBuffer(this._getSceneUBO())),this.onInitRenderingObservable.notifyObservers(this),i&&(this.dontSetTransformationMatrix||this._scene.setTransformMatrix(i.getViewMatrix(),i.getProjectionMatrix(!0)),this._scene.activeCamera=i,this._engine.setViewport(i.rigParent?i.rigParent.viewport:i.viewport,e,t)),this._useUBO&&this._scene.finalizeSceneUbo(),this._defaultRenderListPrepared=!1}finishRender(){const e=this._scene;this._useUBO&&this._scene.setSceneUniformBuffer(this._currentSceneUBO),this._disableImageProcessing&&(e.imageProcessingConfiguration._applyByPostProcess=this._currentApplyByPostProcessSetting),e.activeCamera=this._currentSceneCamera,this._currentSceneCamera&&(this.activeCamera&&this.activeCamera!==e.activeCamera&&e.setTransformMatrix(this._currentSceneCamera.getViewMatrix(),this._currentSceneCamera.getProjectionMatrix(!0)),this._engine.setViewport(this._currentSceneCamera.viewport)),e.resetCachedMaterial(),this.onFinishRenderingObservable.notifyObservers(this)}render(e=0,t=!1){const i=this._engine.currentRenderPassId;if(this._engine.currentRenderPassId=this._renderPassIds[e],this.onBeforeRenderObservable.notifyObservers(e),this._engine.snapshotRendering&&this._engine.snapshotRenderingMode===1)this.onFastPathRenderObservable.notifyObservers(e);else{const r=this._prepareRenderingManager(e),n=this._scene.getOutlineRenderer?.(),o=n?.enabled;n&&(n.enabled=this.enableOutlineRendering),this.onBeforeRenderingManagerRenderObservable.notifyObservers(e),this._renderingManager.render(this.customRenderFunction,r,this.renderParticles,this.renderSprites,this.renderDepthOnlyMeshes,this.renderOpaqueMeshes,this.renderAlphaTestMeshes,this.renderTransparentMeshes,this.customRenderTransparentSubMeshes),this.onAfterRenderingManagerRenderObservable.notifyObservers(e),n&&(n.enabled=o)}t||this.onAfterRenderObservable.notifyObservers(e),this._engine.currentRenderPassId=i}_checkReadiness(){const e=this._scene,t=this._engine.currentRenderPassId;let i=!0;e.getViewMatrix()||e.updateTransformMatrix();const s=this.options.numPasses;for(let n=0;n<s&&i;n++){let o=null;const h=this.renderList?this.renderList:e.frameGraph?e.meshes:e.getActiveMeshes().data,l=this.renderList?this.renderList.length:e.frameGraph?e.meshes.length:e.getActiveMeshes().length;this._engine.currentRenderPassId=this._renderPassIds[n],this.onBeforeRenderObservable.notifyObservers(n),this.getCustomRenderList&&(o=this.getCustomRenderList(n,h,l)),o||(o=h),this.options.doNotChangeAspectRatio||e.updateTransformMatrix(!0);for(let c=0;c<o.length&&i;++c){const u=o[c];if(!(!u.isEnabled()||u.isBlocked||!u.isVisible||!u.subMeshes)){if(this.customIsReadyFunction){if(!this.customIsReadyFunction(u,this.refreshRate,!0)){i=!1;continue}}else if(!u.isReady(!0)){i=!1;continue}}}this.onAfterRenderObservable.notifyObservers(n),s>1&&(e.incrementRenderId(),e.resetCachedMaterial())}const r=this.particleSystemList||e.particleSystems;for(const n of r)n.isReady()||(i=!1);return this._engine.currentRenderPassId=t,i}_prepareRenderingManager(e=0,t=!1){const i=this._scene;let s=null,r=0,n=!1;const o=this.renderList?this.renderList:i.frameGraph?i.meshes:i.getActiveMeshes().data,h=this.renderList?this.renderList.length:i.frameGraph?i.meshes.length:i.getActiveMeshes().length;if(this.getCustomRenderList&&(s=this.getCustomRenderList(e,o,h)),s)r=s.length,n=this.forceLayerMaskCheck;else{if(this._defaultRenderListPrepared&&!t)return o;this._defaultRenderListPrepared=!0,s=o,r=h,n=!this.renderList||this.forceLayerMaskCheck}const l=i.activeCamera,c=this.cameraForLOD??l,u=i.getBoundingBoxRenderer?.();if(i._activeMeshesFrozen&&this._isFrozen){if(this._renderingManager.resetSprites(),this.enableBoundingBoxRendering&&u){u.reset();for(let f=0;f<this._activeBoundingBoxes.length;f++){const d=this._activeBoundingBoxes.data[f];u.renderList.push(d)}}return s}if(this._renderingManager.reset(),this._activeMeshes.reset(),this._activeBoundingBoxes.reset(),u&&u.reset(),this.renderMeshes){const f=i.getRenderId(),d=i.getFrameId();for(let g=0;g<r;g++){const p=s[g];if(p&&!p.isBlocked){if(this.customIsReadyFunction){if(!this.customIsReadyFunction(p,this.refreshRate,!1)){this.resetRefreshCounter();continue}}else if(!p.isReady(this.refreshRate===0)){this.resetRefreshCounter();continue}let m=null;if(c){const E=p._internalAbstractMeshDataInfo._currentLOD.get(c);!E||E[1]!==d?(m=i.customLODSelector?i.customLODSelector(p,c):p.getLOD(c),E?(E[0]=m,E[1]=d):p._internalAbstractMeshDataInfo._currentLOD.set(c,[m,d])):m=E[0]}else m=p;if(!m)continue;m!==p&&m.billboardMode!==0&&m.computeWorldMatrix(),m._preActivateForIntermediateRendering(f);let A;if(n&&l?A=(p.layerMask&l.layerMask)===0:A=!1,p.isEnabled()&&p.isVisible&&p.subMeshes&&!A){if(this._activeMeshes.push(p),m._internalAbstractMeshDataInfo._wasActiveLastFrame=!0,m!==p&&m._activate(f,!0),this.enableBoundingBoxRendering&&u&&u._preActiveMesh(p),p._activate(f,!0)&&p.subMeshes.length){p.isAnInstance?p._internalAbstractMeshDataInfo._actAsRegularMesh&&(m=p):m._internalAbstractMeshDataInfo._onlyForInstancesIntermediate=!1,m._internalAbstractMeshDataInfo._isActiveIntermediate=!0,i._prepareSkeleton(m);for(let E=0;E<m.subMeshes.length;E++){const I=m.subMeshes[E];this.enableBoundingBoxRendering&&u&&u._evaluateSubMesh(p,I),this._renderingManager.dispatch(I,m)}}p._postActivate()}}}}if(this.enableBoundingBoxRendering&&u&&t)for(let f=0;f<u.renderList.length;f++){const d=u.renderList.data[f];this._activeBoundingBoxes.push(d)}if(this._scene.particlesEnabled&&this.renderParticles){this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);const f=this.particleSystemList||i.particleSystems;for(let d=0;d<f.length;d++){const g=f[d],p=g.emitter;!g.isStarted()||!p||p.position&&!p.isEnabled()||this._renderingManager.dispatchParticles(g)}this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene)}return s}get renderingManager(){return this._renderingManager}
41setRenderingOrder(e,t=null,i=null,s=null){this._renderingManager.setRenderingOrder(e,t,i,s)}setRenderingAutoClearDepthStencil(e,t,i=!0,s=!0){this._renderingManager.setRenderingAutoClearDepthStencil(e,t,i,s),this._renderingManager._useSceneAutoClearSetup=!1}clone(){const e=new Kt(this.name,this._scene,this.options);return this.renderList&&(e.renderList=this.renderList.slice(0)),e}dispose(){const e=this.renderList?this.renderList:this._scene.getActiveMeshes().data,t=this.renderList?this.renderList.length:this._scene.getActiveMeshes().length;for(let i=0;i<t;i++){const s=e[i];s&&s.getMaterialForRenderPass(this.renderPassId)!==void 0&&s.setMaterialForRenderPass(this.renderPassId,void 0)}if(this.onInitRenderingObservable.clear(),this.onFinishRenderingObservable.clear(),this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderingManagerRenderObservable.clear(),this.onAfterRenderingManagerRenderObservable.clear(),this.onFastPathRenderObservable.clear(),this._releaseRenderPassId(),this.renderList=null,this._sceneUBOs)for(const i of this._sceneUBOs)i.dispose();this._sceneUBOs=void 0,this._scene.removeObjectRenderer(this)}_rebuild(){this.refreshRate===Kt.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=Kt.REFRESHRATE_RENDER_ONCE)}freeRenderingGroups(){this._renderingManager&&this._renderingManager.freeRenderingGroups()}}Kt.REFRESHRATE_RENDER_ONCE=0;Kt.REFRESHRATE_RENDER_ONEVERYFRAME=1;Kt.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2;ze.prototype.setDepthStencilTexture=function(a,e){this._engine.setDepthStencilTexture(this._samplers[a],this._uniforms[a],e,a)};class Bi extends z{get renderListPredicate(){return this._objectRenderer.renderListPredicate}set renderListPredicate(e){this._objectRenderer.renderListPredicate=e}get renderList(){return this._objectRenderer.renderList}set renderList(e){this._objectRenderer.renderList=e}get particleSystemList(){return this._objectRenderer.particleSystemList}set particleSystemList(e){this._objectRenderer.particleSystemList=e}get getCustomRenderList(){return this._objectRenderer.getCustomRenderList}set getCustomRenderList(e){this._objectRenderer.getCustomRenderList=e}get renderParticles(){return this._objectRenderer.renderParticles}set renderParticles(e){this._objectRenderer.renderParticles=e}get renderSprites(){return this._objectRenderer.renderSprites}set renderSprites(e){this._objectRenderer.renderSprites=e}get enableBoundingBoxRendering(){return this._objectRenderer.enableBoundingBoxRendering}set enableBoundingBoxRendering(e){this._objectRenderer.enableBoundingBoxRendering=e}get enableOutlineRendering(){return this._objectRenderer.enableOutlineRendering}set enableOutlineRendering(e){this._objectRenderer.enableOutlineRendering=e}get forceLayerMaskCheck(){return this._objectRenderer.forceLayerMaskCheck}set forceLayerMaskCheck(e){this._objectRenderer.forceLayerMaskCheck=e}get activeCamera(){return this._objectRenderer.activeCamera}set activeCamera(e){this._objectRenderer.activeCamera=e}get cameraForLOD(){return this._objectRenderer.cameraForLOD}set cameraForLOD(e){this._objectRenderer.cameraForLOD=e}get disableImageProcessing(){return this._objectRenderer.disableImageProcessing}set disableImageProcessing(e){this._objectRenderer.disableImageProcessing=e}get customIsReadyFunction(){return this._objectRenderer.customIsReadyFunction}set customIsReadyFunction(e){this._objectRenderer.customIsReadyFunction=e}get customRenderFunction(){return this._objectRenderer.customRenderFunction}set customRenderFunction(e){this._objectRenderer.customRenderFunction=e}get postProcesses(){return this._postProcesses}get _prePassEnabled(){return!!this._prePassRenderTarget&&this._prePassRenderTarget.enabled}set onAfterUnbind(e){this._onAfterUnbindObserver&&this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=this.onAfterUnbindObservable.add(e)}get onBeforeRenderObservable(){return this._objectRenderer.onBeforeRenderObservable}set onBeforeRender(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)}get onAfterRenderObservable(){return this._objectRenderer.onAfterRenderObservable}set onAfterRender(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)}set onClear(e){this._onClearObserver&&this.onClearObservable.remove(this._onClearObserver),this._onClearObserver=this.onClearObservable.add(e)}get _waitingRenderList(){return this._objectRenderer._waitingRenderList}set _waitingRenderList(e){this._objectRenderer._waitingRenderList=e}get renderPassId(){return this._objectRenderer.renderPassId}get renderPassIds(){return this._objectRenderer.renderPassIds}
vendor: 8,705 bytes, line 41
41get currentRefreshId(){return this._objectRenderer.currentRefreshId}setMaterialForRendering(e,t){this._objectRenderer.setMaterialForRendering(e,t)}get isMulti(){return this._renderTarget?.isMulti??!1}get renderTargetOptions(){return this._renderTargetOptions}get renderTarget(){return this._renderTarget}_onRatioRescale(){this._sizeRatio&&this.resize(this._initialSizeParameter)}set boundingBoxSize(e){if(this._boundingBoxSize&&this._boundingBoxSize.equals(e))return;this._boundingBoxSize=e;const t=this.getScene();t&&t.markAllMaterialsAsDirty(1)}get boundingBoxSize(){return this._boundingBoxSize}get depthStencilTexture(){return this._renderTarget?._depthStencilTexture??null}constructor(e,t,i,s=!1,r=!0,n=0,o=!1,h=z.TRILINEAR_SAMPLINGMODE,l=!0,c=!1,u=!1,f=5,d=!1,g,p,m=!1,A=!1){let E,I=!0,M,C=!1;if(typeof s=="object"){const S=s;s=!!S.generateMipMaps,r=S.doNotChangeAspectRatio??!0,n=S.type??0,o=!!S.isCube,h=S.samplingMode??z.TRILINEAR_SAMPLINGMODE,l=S.generateDepthBuffer??!0,c=!!S.generateStencilBuffer,u=!!S.isMulti,f=S.format??5,d=!!S.delayAllocation,g=S.samples,p=S.creationFlags,m=!!S.noColorAttachment,A=!!S.useSRGBBuffer,E=S.colorAttachment,I=S.gammaSpace??I,M=S.existingObjectRenderer,C=!!S.enableClusteredLights}if(super(null,i,!s,void 0,h,void 0,void 0,void 0,void 0,f),this.ignoreCameraViewport=!1,this.onBeforeBindObservable=new O,this.onAfterUnbindObservable=new O,this.onClearObservable=new O,this.onResizeObservable=new O,this._cleared=!1,this.skipInitialClear=!1,this._samples=1,this._canRescale=!0,this._renderTarget=null,this._dontDisposeObjectRenderer=!1,this.boundingBoxPosition=_.Zero(),this._disableEngineStages=!1,this._dumpToolsLoading=!1,i=this.getScene(),!i)return;const x=this.getScene().getEngine();this._gammaSpace=I,this._coordinatesMode=z.PROJECTION_MODE,this.name=e,this.isRenderTarget=!0,this._initialSizeParameter=t,this._dontDisposeObjectRenderer=!!M,this._processSizeParameter(t),this._objectRenderer=M??new Kt(e,i,{numPasses:o?6:this.getRenderLayers()||1,doNotChangeAspectRatio:r,enableClusteredLights:C}),this._onBeforeRenderingManagerRenderObserver=this._objectRenderer.onBeforeRenderingManagerRenderObservable.add(()=>{if(!this._disableEngineStages)for(const S of this._scene._beforeRenderTargetClearStage)S.action(this,this._currentFaceIndex,this._currentLayer);if(this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(x):this.skipInitialClear||x.clear(this.clearColor||this._scene.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||this._scene.updateTransformMatrix(!0),!this._disableEngineStages)for(const S of this._scene._beforeRenderTargetDrawStage)S.action(this,this._currentFaceIndex,this._currentLayer);x._debugPushGroup?.(`Render to ${this.name} (face #${this._currentFaceIndex} layer #${this._currentLayer})`)}),this._onAfterRenderingManagerRenderObserver=this._objectRenderer.onAfterRenderingManagerRenderObservable.add(()=>{if(x._debugPopGroup?.(),!this._disableEngineStages)for(const L of this._scene._afterRenderTargetDrawStage)L.action(this,this._currentFaceIndex,this._currentLayer);const S=this._texture?.generateMipMaps??!1;if(this._texture&&(this._texture.generateMipMaps=!1),this._postProcessManager?this._postProcessManager._finalizeFrame(!1,this._renderTarget??void 0,this._currentFaceIndex,this._postProcesses,this.ignoreCameraViewport):this._currentUseCameraPostProcess&&this._scene.postProcessManager._finalizeFrame(!1,this._renderTarget??void 0,this._currentFaceIndex),!this._disableEngineStages)for(const L of this._scene._afterRenderTargetPostProcessStage)L.action(this,this._currentFaceIndex,this._currentLayer);this._texture&&(this._texture.generateMipMaps=S),this._doNotChangeAspectRatio||this._scene.updateTransformMatrix(!0),this._currentDumpForDebug&&(this._dumpTools?this._dumpTools.DumpFramebuffer(this.getRenderWidth(),this.getRenderHeight(),x):w.Error("dumpTools module is still being loaded. To speed up the process import dump tools directly in your project"))}),this._onFastPathRenderObserver=this._objectRenderer.onFastPathRenderObservable.add(()=>{this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(x):this.skipInitialClear||x.clear(this.clearColor||this._scene.clearColor,!0,!0,!0)}),this._resizeObserver=x.onResizeObservable.add(()=>{}),this._generateMipMaps=!!s,this._doNotChangeAspectRatio=r,!u&&(this._renderTargetOptions={generateMipMaps:s,type:n,format:this._format??void 0,samplingMode:this.samplingMode,generateDepthBuffer:l,generateStencilBuffer:c,samples:g,creationFlags:p,noColorAttachment:m,useSRGBBuffer:A,colorAttachment:E,label:this.name},this.samplingMode===z.NEAREST_SAMPLINGMODE&&(this.wrapU=z.CLAMP_ADDRESSMODE,this.wrapV=z.CLAMP_ADDRESSMODE),d||(o?(this._renderTarget=i.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions),this.coordinatesMode=z.INVCUBIC_MODE,this._textureMatrix=P.Identity()):this._renderTarget=i.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this._texture=this._renderTarget.texture,g!==void 0&&(this.samples=g)))}createDepthStencilTexture(e=0,t=!0,i=!1,s=1,r=14,n){this._renderTarget?.createDepthStencilTexture(e,t,i,s,r,n)}_processSizeParameter(e){if(e.ratio){this._sizeRatio=e.ratio;const t=this._getEngine();this._size={width:this._bestReflectionRenderTargetDimension(t.getRenderWidth(),this._sizeRatio),height:this._bestReflectionRenderTargetDimension(t.getRenderHeight(),this._sizeRatio)}}else this._size=e}get samples(){return this._renderTarget?.samples??this._samples}set samples(e){this._renderTarget&&(this._samples=this._renderTarget.setSamples(e))}addPostProcess(e){if(!this._postProcessManager){const t=this.getScene();if(!t)return;this._postProcessManager=new Rn(t),this._postProcesses=new Array}this._postProcesses.push(e),this._postProcesses[0].autoClear=!1}clearPostProcesses(e=!1){if(this._postProcesses){if(e)for(const t of this._postProcesses)t.dispose();this._postProcesses=[]}}removePostProcess(e){if(!this._postProcesses)return;const t=this._postProcesses.indexOf(e);t!==-1&&(this._postProcesses.splice(t,1),this._postProcesses.length>0&&(this._postProcesses[0].autoClear=!1))}resetRefreshCounter(){this._objectRenderer.resetRefreshCounter()}get refreshRate(){return this._objectRenderer.refreshRate}set refreshRate(e){this._objectRenderer.refreshRate=e}_shouldRender(){return this._objectRenderer.shouldRender()}getRenderSize(){return this.getRenderWidth()}getRenderWidth(){return this._size.width?this._size.width:this._size}getRenderHeight(){return this._size.width?this._size.height:this._size}getRenderLayers(){const e=this._size.layers;if(e)return e;const t=this._size.depth;return t||0}disableRescaling(){this._canRescale=!1}get canRescale(){return this._canRescale}scale(e){const t=Math.max(1,this.getRenderSize()*e);this.resize(t)}getReflectionTextureMatrix(){return this.isCube?this._textureMatrix:super.getReflectionTextureMatrix()}resize(e){const t=this.isCube;this._renderTarget?.dispose(),this._renderTarget=null;const i=this.getScene();i&&(this._processSizeParameter(e),t?this._renderTarget=i.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):this._renderTarget=i.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this._texture=this._renderTarget.texture,this._renderTargetOptions.samples!==void 0&&(this.samples=this._renderTargetOptions.samples),this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this))}render(e=!1,t=!1){this._render(e,t)}isReadyForRendering(){this._dumpToolsLoading||(this._dumpToolsLoading=!0,G(()=>import("./dumpTools--9pbiuIS.js"),__vite__mapDeps([40,13,14]),import.meta.url).then(t=>this._dumpTools=t)),this._objectRenderer.prepareRenderList(),this.onBeforeBindObservable.notifyObservers(this),this._objectRenderer.initRender(this.getRenderWidth(),this.getRenderHeight());const e=this._objectRenderer._checkReadiness();return this.onAfterUnbindObservable.notifyObservers(this),this._objectRenderer.finishRender(),e}_render(e=!1,t=!1){const i=this.getScene();if(i){if(this.useCameraPostProcesses!==void 0&&(e=this.useCameraPostProcesses),this._objectRenderer.prepareRenderList(),this.onBeforeBindObservable.notifyObservers(this),this._objectRenderer.initRender(this.getRenderWidth(),this.getRenderHeight()),(this.is2DArray||this.is3D)&&!this.isMulti)for(let s=0;s<this.getRenderLayers();s++)this._renderToTarget(0,e,t,s),i.incrementRenderId(),i.resetCachedMaterial();else if(this.isCube&&!this.isMulti)for(let s=0;s<6;s++)this._renderToTarget(s,e,t),i.incrementRenderId(),i.resetCachedMaterial();else this._renderToTarget(0,e,t);this.onAfterUnbindObservable.notifyObservers(this),this._objectRenderer.f
41inishRender()}}_bestReflectionRenderTargetDimension(e,t){const s=e*t,r=Ho(s+16384/(128+s));return Math.min(Nn(e),r)}_bindFrameBuffer(e=0,t=0){const i=this.getScene();if(!i)return;const s=i.getEngine();this._renderTarget&&s.bindFramebuffer(this._renderTarget,this.isCube?e:void 0,void 0,void 0,this.ignoreCameraViewport,0,t)}_unbindFrameBuffer(e,t){this._renderTarget&&e.unBindFramebuffer(this._renderTarget,this.isCube,()=>{this.onAfterRenderObservable.notifyObservers(t)})}_prepareFrame(e,t,i,s){this._postProcessManager?this._prePassEnabled||this._postProcessManager._prepareFrame(this._texture,this._postProcesses)||this._bindFrameBuffer(t,i):(!s||!e.postProcessManager._prepareFrame(this._texture))&&this._bindFrameBuffer(t,i)}_renderToTarget(e,t,i,s=0){const r=this.getScene();if(!r)return;const n=r.getEngine();this._currentFaceIndex=e,this._currentLayer=s,this._currentUseCameraPostProcess=t,this._currentDumpForDebug=i,this._prepareFrame(r,e,s,t),this._objectRenderer.render(e+s,!0),this._unbindFrameBuffer(n,e),this._texture&&this.isCube&&e===5&&n.generateMipMapsForCubemap(this._texture,!0)}setRenderingOrder(e,t=null,i=null,s=null){this._objectRenderer.setRenderingOrder(e,t,i,s)}setRenderingAutoClearDepthStencil(e,t){this._objectRenderer.setRenderingAutoClearDepthStencil(e,t)}clone(){const e=this.getSize(),t=new Bi(this.name,e,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer,void 0,this._renderTargetOptions.format,void 0,this._renderTargetOptions.samples);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,this.renderList&&(t.renderList=this.renderList.slice(0)),t}serialize(){if(!this.name)return null;const e=super.serialize();if(e.renderTargetSize=this.getRenderSize(),e.renderList=[],this.renderList)for(let t=0;t<this.renderList.length;t++)e.renderList.push(this.renderList[t].id);return e}disposeFramebufferObjects(){this._renderTarget?.dispose(!0)}releaseInternalTexture(){this._renderTarget?.releaseTextures(),this._texture=null}dispose(){this.onResizeObservable.clear(),this.onClearObservable.clear(),this.onAfterUnbindObservable.clear(),this.onBeforeBindObservable.clear(),this._postProcessManager&&(this._postProcessManager.dispose(),this._postProcessManager=null),this._prePassRenderTarget&&this._prePassRenderTarget.dispose(),this._objectRenderer.onBeforeRenderingManagerRenderObservable.remove(this._onBeforeRenderingManagerRenderObserver),this._objectRenderer.onAfterRenderingManagerRenderObservable.remove(this._onAfterRenderingManagerRenderObserver),this._objectRenderer.onFastPathRenderObservable.remove(this._onFastPathRenderObserver),this._dontDisposeObjectRenderer||this._objectRenderer.dispose(),this.clearPostProcesses(!0),this._resizeObserver&&(this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null);const e=this.getScene();if(!e)return;let t=e.customRenderTargets.indexOf(this);t>=0&&e.customRenderTargets.splice(t,1);for(const i of e.cameras)t=i.customRenderTargets.indexOf(this),t>=0&&i.customRenderTargets.splice(t,1);this._renderTarget?.dispose(),this._renderTarget=null,this._texture=null,super.dispose()}_rebuild(){this._objectRenderer._rebuild(),this._postProcessManager&&this._postProcessManager._rebuild()}freeRenderingGroups(){this._objectRenderer.freeRenderingGroups()}getViewCount(){return 1}}Bi.REFRESHRATE_RENDER_ONCE=Kt.REFRESHRATE_RENDER_ONCE;Bi.REFRESHRATE_RENDER_ONEVERYFRAME=Kt.REFRESHRATE_RENDER_ONEVERYFRAME;Bi.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=Kt.REFRESHRATE_RENDER_ONEVERYTWOFRAMES;z._CreateRenderTargetTexture=(a,e,t,i,s)=>new Bi(a,e,t,i);const Ju=Object.freeze(Object.defineProperty({__proto__:null,RenderTargetTexture:Bi},Symbol.toStringTag,{value:"Module"}));class ed{constructor(){this.shaderLanguage=0}postProcessor(e,t,i,s,r){if(r.drawBuffersExtensionDisabled){const n=/#extension.+GL_EXT_draw_buffers.+(enable|require)/g;e=e.replace(n,"")}return e}}const td=/(flat\s)?\s*varying\s*.*/;class id{constructor(){this.shaderLanguage=0}attributeProcessor(e){return e.replace("attribute","in")}varyingCheck(e,t){return td.test(e)}varyingProcessor(e,t){return e.replace("varying",t?"in":"out")}postProcessor(e,t,i){const s=e.search(/#extension.+GL_EXT_draw_buffers.+require/)!==-1,r=/#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;if(e=e.replace(r,""),e=e.replace(/texture2D\s*\(/g,"texture("),i){const n=e.search(/layout *\(location *= *0\) *out/g)!==-1,o=t.indexOf("#define DUAL_SOURCE_BLENDING")!==-1,h=o?`layout(location = 0, index = 0) out vec4 glFragColor;
42layout(location = 0, index = 1) out vec4 glFragColor2;
43`:`layout(location = 0) out vec4 glFragColor;
44`;o&&(e=`#extension GL_EXT_blend_func_extended : require
45`+e),e=e.replace(/texture2DLodEXT\s*\(/g,"textureLod("),e=e.replace(/textureCubeLodEXT\s*\(/g,"textureLod("),e=e.replace(/textureCube\s*\(/g,"texture("),e=e.replace(/gl_FragDepthEXT/g,"gl_FragDepth"),e=e.replace(/gl_FragColor/g,"glFragColor"),e=e.replace(/gl_FragData/g,"glFragData"),e=e.replace(/void\s+?main\s*\(/g,(s||n?"":h)+"void main(")}else if(t.indexOf("#define VERTEXOUTPUT_INVARIANT")>=0&&(e=`invariant gl_Position;
46`+e),t.indexOf("#define MULTIVIEW")!==-1)return`#extension GL_OVR_multiview2 : require
47layout (num_views = 2) in;
48`+e;return e}}class Ys extends ir{constructor(e){super(),this._buffer=e}get underlyingResource(){return this._buffer}}class wh{get underlyingResource(){return this._webGLTexture}constructor(e=null,t){if(this._MSAARenderBuffers=null,this._context=t,!e&&(e=t.createTexture(),!e))throw new Error("Unable to create webGL texture");this.set(e)}setUsage(){}set(e){this._webGLTexture=e}reset(){this._webGLTexture=null,this._MSAARenderBuffers=null}addMSAARenderBuffer(e){this._MSAARenderBuffers||(this._MSAARenderBuffers=[]),this._MSAARenderBuffers.push(e)}releaseMSAARenderBuffers(){if(this._MSAARenderBuffers){for(const e of this._MSAARenderBuffers)this._context.deleteRenderbuffer(e);this._MSAARenderBuffers=null}}getMSAARenderBuffer(e=0){return this._MSAARenderBuffers?.[e]??null}release(){this.releaseMSAARenderBuffers(),this._webGLTexture&&this._context.deleteTexture(this._webGLTexture),this.reset()}}function xn(a){return a===13||a===14||a===15||a===16||a===17||a===18||a===19}function sd(a){switch(a){case 13:case 17:case 18:case 14:case 16:return 1;case 15:return 5;case 19:return 0}return 0}function bs(a){return a===13||a===17||a===18||a===19}class rd{}class he extends H{get name(){return this._name}set name(e){this._name=e}get version(){return this._webGLVersion}static get ShadersRepository(){return ze.ShadersRepository}static set ShadersRepository(e){ze.ShadersRepository=e}get supportsUniformBuffers(){return this.webGLVersion>1&&!this.disableUniformBuffers}get needPOTTextures(){return this._webGLVersion<2||this.forcePOTTextures}get _supportsHardwareTextureRescaling(){return!1}set framebufferDimensionsObject(e){this._framebufferDimensionsObject=e}snapshotRenderingReset(){this.snapshotRendering=!1}constructor(e,t,i,s){if(i=i||{},super(t??i.antialias,i,s),this._name="WebGL",this.forcePOTTextures=!1,this.validateShaderPrograms=!1,this.disableUniformBuffers=!1,this._webGLVersion=1,this._vertexAttribArraysEnabled=[],this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentFramebuffer=null,this._dummyFramebuffer=null,this._currentBufferPointers=new Array,this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._vaoRecordInProgress=!1,this._mustWipeVertexAttributes=!1,this._nextFreeTextureSlots=new Array,this._maxSimultaneousTextures=0,this._maxMSAASamplesOverride=null,this._unpackFlipYCached=null,this.enableUnpackFlipYCached=!0,this._boundUniforms={},!e)return;let r=null;if(e.getContext){if(r=e,i.preserveDrawingBuffer===void 0&&(i.preserveDrawingBuffer=!1),i.xrCompatible===void 0&&(i.xrCompatible=!1),navigator&&navigator.userAgent){this._setupMobileChecks();const h=navigator.userAgent;for(const l of he.ExceptionList){const c=l.key,u=l.targets;if(new RegExp(c).test(h)){if(l.capture&&l.captureConstraint){const d=l.capture,g=l.captureConstraint,m=new RegExp(d).exec(h);if(m&&m.length>0&&parseInt(m[m.length-1])>=g)continue}for(const d of u)switch(d){case"uniformBuffer":this.disableUniformBuffers=!0;break;case"vao":this.disableVertexArrayObjects=!0;break;case"antialias":i.antialias=!1;break;case"maxMSAASamples":this._maxMSAASamplesOverride=1;break}}}}if(this._doNotHandleContextLost?this._onContextLost=()=>{$r(this._gl)}:(this._onContextLost=h=>{h.preventDefault(),this._contextWasLost=!0,$r(this._gl),w.Warn("WebGL context lost."),this.onContextLostObservable.notifyObservers(this)},this._onContextRestored=()=>{this._restoreEngineAfterContextLost(()=>this._initGLContext())},r.addEventListener("webglcontextrestored",this._onContextRestored,!1),i.powerPreference=i.powerPreference||"high-performance"),r.addEventListener("webglcontextlost",this._onContextLost,!1),this._badDesktopOS&&(i.xrCompatible=!1),!i.disableWebGL2Support)try{this._gl=r.getContext("webgl2",i)||r.getContext("experimental-webgl2",i),this._gl&&(this._webGLVersion=2,this._shaderPlatformName="WEBGL2",this._gl.deleteQuery||(this._webGLVersion=1,this._shaderPlatformName="WEBGL1"))}catch{}if(!this._gl){if(!r)throw new Error("The provided canvas is null or undefined.");try{this._gl=r.getContext("webgl",i)||r.getContext("experimental-webgl",i)}catch{throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported")}else{this._gl=e,r=this._gl.canvas,this._gl.renderbufferStorageMultisample?(this._webGLVersion=2,this._shaderPlatformName="WEBGL2"):this._shaderPlatformName="WEBGL1";const h=this._gl.getContextAttributes();h&&(i.stencil=h.stencil)}this._sharedInit(r),this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,this._gl.NONE),i.useHighPrecisionFloats!==void 0&&(this._highPrecisionShadersAllowed=i.useHighPrecisionFloats),this.resize(),this._initGLContext(),this._initFeatures();for(let h=0;h<this._caps.maxVertexAttribs;h++)this._currentBufferPointers[h]=new rd;this._shaderProcessor=this.webGLVersion>1?new id:new ed;const n=`Babylon.js v${he.Version}`;w.Log(n+` - ${this.description}`),this._renderingCanvas&&this._renderingCanvas.setAttribute&&this._renderingCanvas.setAttribute("data-engine",n
vendor: 4,541 bytes, line 48
48);const o=Pt(this._gl);o.validateShaderPrograms=this.validateShaderPrograms,o.parallelShaderCompile=this._caps.parallelShaderCompile}_clearEmptyResources(){this._dummyFramebuffer=null,super._clearEmptyResources()}_getShaderProcessingContext(e){return null}areAllEffectsReady(){for(const e in this._compiledEffects)if(!this._compiledEffects[e].isReady())return!1;return!0}_initGLContext(){this._caps={maxTexturesImageUnits:this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),maxCombinedTexturesImageUnits:this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),maxVertexTextureImageUnits:this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),maxSamples:this._webGLVersion>1?this._gl.getParameter(this._gl.MAX_SAMPLES):1,maxCubemapTextureSize:this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),maxRenderTextureSize:this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),maxVertexAttribs:this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),maxVaryingVectors:this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),maxFragmentUniformVectors:this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),maxVertexUniformVectors:this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),shaderFloatPrecision:0,parallelShaderCompile:this._gl.getExtension("KHR_parallel_shader_compile")||void 0,standardDerivatives:this._webGLVersion>1||this._gl.getExtension("OES_standard_derivatives")!==null,maxAnisotropy:1,astc:this._gl.getExtension("WEBGL_compressed_texture_astc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),bptc:this._gl.getExtension("EXT_texture_compression_bptc")||this._gl.getExtension("WEBKIT_EXT_texture_compression_bptc"),s3tc:this._gl.getExtension("WEBGL_compressed_texture_s3tc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),s3tc_srgb:this._gl.getExtension("WEBGL_compressed_texture_s3tc_srgb")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc_srgb"),pvrtc:this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:this._gl.getExtension("WEBGL_compressed_texture_etc1")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),etc2:this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),textureAnisotropicFilterExtension:this._gl.getExtension("EXT_texture_filter_anisotropic")||this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),uintIndices:this._webGLVersion>1||this._gl.getExtension("OES_element_index_uint")!==null,fragmentDepthSupported:this._webGLVersion>1||this._gl.getExtension("EXT_frag_depth")!==null,highPrecisionShaderSupported:!1,timerQuery:this._gl.getExtension("EXT_disjoint_timer_query_webgl2")||this._gl.getExtension("EXT_disjoint_timer_query"),supportOcclusionQuery:this._webGLVersion>1,canUseTimestampForTimerQuery:!1,drawBuffersExtension:!1,maxMSAASamples:1,colorBufferFloat:!!(this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_float")),blendFloat:this._gl.getExtension("EXT_float_blend")!==null,supportFloatTexturesResolve:!1,rg11b10ufColorRenderable:!1,colorBufferHalfFloat:!!(this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_half_float")),textureFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_float")),textureHalfFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_half_float")),textureHalfFloatRender:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloatLinearFiltering:!1,vertexArrayObject:!1,instancedArrays:!1,textureLOD:!!(this._webGLVersion>1||this._gl.getExtension("EXT_shader_texture_lod")),texelFetch:this._webGLVersion!==1,blendMinMax:!1,multiview:this._gl.getExtension("OVR_multiview2"),oculusMultiview:this._gl.getExtension("OCULUS_multiview"),depthTextureExtension:!1,canUseGLInstanceID:this._webGLVersion>1,canUseGLVertexID:this._webGLVersion>1,supportComputeShaders:!1,supportSRGBBuffers:!1,supportTransformFeedbacks:this._webGLVersion>1,textureMaxLevel:this._webGLVersion>1,texture2DArrayMaxLayerCount:this._webGLVersion>1?this._gl.getParameter(this._gl.MAX_ARRAY_TEXTURE_LAYERS):128,disableMorphTargetTexture:!1,textureNorm16:!!this._gl.getExtension("EXT_texture_norm16"),blendParametersPerTarget:!1,dualSourceBlending:!1},this._caps.supportFloatTexturesResolve=this._caps.colorBufferFloat,this._caps.rg11b10ufColorRen
48derable=this._caps.colorBufferFloat,this._glVersion=this._gl.getParameter(this._gl.VERSION);const e=this._gl.getExtension("WEBGL_debug_renderer_info");e!=null&&(this._glRenderer=this._gl.getParameter(e.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(e.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor=this._gl.getParameter(this._gl.VENDOR)||"Unknown vendor"),this._glRenderer||(this._glRenderer=this._gl.getParameter(this._gl.RENDERER)||"Unknown renderer"),this._gl.HALF_FLOAT_OES!==36193&&(this._gl.HALF_FLOAT_OES=36193),this._gl.RGBA16F!==34842&&(this._gl.RGBA16F=34842),this._gl.RGBA32F!==34836&&(this._gl.RGBA32F=34836),this._gl.DEPTH24_STENCIL8!==35056&&(this._gl.DEPTH24_STENCIL8=35056),this._caps.timerQuery&&(this._webGLVersion===1&&(this._gl.getQuery=this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery)),this._caps.canUseTimestampForTimerQuery=(this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT,this._caps.timerQuery.QUERY_COUNTER_BITS_EXT)??0)>0),this._caps.maxAnisotropy=this._caps.textureAnisotropicFilterExtension?this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,this._caps.textureFloatLinearFiltering=!!(this._caps.textureFloat&&this._gl.getExtension("OES_texture_float_linear")),this._caps.textureFloatRender=!!(this._caps.textureFloat&&this._canRenderToFloatFramebuffer()),this._caps.textureHalfFloatLinearFiltering=!!(this._webGLVersion>1||this._caps.textureHalfFloat&&this._gl.getExtension("OES_texture_half_float_linear")),this._caps.textureNorm16&&(this._gl.R16_EXT=33322,this._gl.RG16_EXT=33324,this._gl.RGB16_EXT=32852,this._gl.RGBA16_EXT=32859,this._gl.R16_SNORM_EXT=36760,this._gl.RG16_SNORM_EXT=36761,this._gl.RGB16_SNORM_EXT=36762,this._gl.RGBA16_SNORM_EXT=36763);const t=this._gl.getExtension("OES_draw_buffers_indexed");if(this._caps.blendParametersPerTarget=!!t,this._alphaState=new Lo(this._caps.blendParametersPerTarget),t&&(this._gl.blendEquationSeparateIndexed=t.blendEquationSeparateiOES.bind(t),this._gl.blendEquationIndexed=t.blendEquationiOES.bind(t),this._gl.blendFuncSeparateIndexed=t.blendFuncSeparateiOES.bind(t),this._gl.blendFuncIndexed=t.blendFunciOES.bind(t),this._gl.colorMaskIndexed=t.colorMaskiOES.bind(t),this._gl.disableIndexed=t.disableiOES.bind(t),this._gl.enableIndexed=t.enableiOES.bind(t)),this._caps.dualSourceBlending=!!this._gl.getExtension("WEBGL_blend_func_extended"),this._caps.astc&&(this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR),this._caps.bptc&&(this._gl.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=this._caps.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT),this._caps.s3tc_srgb&&(this._gl.COMPRESSED_SRGB_S3TC_DXT1_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_S3TC_DXT1_EXT,this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT),this._caps.etc2&&(this._gl.COMPRESSED_SRGB8_ETC2=this._caps.etc2.COMPRESSED_SRGB8_ETC2,this._gl.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=this._caps.etc2.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC),this._webGLVersion>1&&this._gl.HALF_FLOAT_OES!==5131&&(this._gl.HALF_FLOAT_OES=5131),this._caps.textureHalfFloatRender=this._caps.textureHalfFloat&&this._canRenderToHalfFloatFramebuffer(),this._webGLVersion>1)this._caps.drawBuffersExtension=!0,this._caps.maxMSAASamples=this._maxMSAASamplesOverride!==null?this._maxMSAASamplesOverride:this._gl.getParameter(this._gl.MAX_SAMPLES),this._caps.maxDrawBuffers=this._gl.getParameter(this._gl.MAX_DRAW_BUFFERS);else{const i=this._gl.getExtension("WEBGL_draw_buffers");if(i!==null){this._caps.drawBuffersExtension=!0,this._gl.drawBuffers=i.drawBuffersWEBGL.bind(i),this._caps.maxDrawBuffers=this._gl.getParameter(i.MAX_DRAW_BUFFERS_WEBGL),this._gl.DRAW_FRAMEBUFFER=this._gl.FRAMEBUFFER;for(let s=0;s<16;s++)this._gl["COLOR_ATTACHMENT"+s+"_WEBGL"]=i["COLOR_ATTACHMENT"+s+"_WEBGL"]}}if(this._webGLVersion>1)this._caps.depthTextureExtension=!0;else{const i=this._gl.getExtension("WEBGL_depth_texture");i!=null&&(this._caps.depthTextureExtension=!0,this._gl.UNSIGNED_INT_24_8=i.UNSIGNED_INT_24_8_WEBGL)}if(this.disableVertexArrayObjects)this._caps.vertexArrayObject=!1;else if(this._webGLVersion>1)this._caps.vertexArrayObject=!0;else{const i=this._gl.getExtension("OES_vertex_array_object");i!=null&&(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=i.createVertexArrayOES.bind(i),this._gl.bindVertexArray=i.bindVertexArrayOES.bind(i),this._gl.deleteVertexArray=i.deleteVertexArrayOES.bind(i))}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{const i=this._gl.getExtension("ANGLE_instanced_arrays");i!=null?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=i.drawArraysInstancedANGLE.bind(i),this._gl.drawElementsInstanced=i.drawElementsInstancedANGLE.bind(i),this._gl.vertexAttribDivisor=i.vertexAttribDivisorANGLE.bind(i)):this._caps.instancedArrays=!1}if(this._gl.getShaderPrecisionFormat){const i=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.HIGH_FLOAT),s=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);if(i&&s&&(this._caps.highPrecisionShaderSupported=i.precision!==0&&s.precision!==0,this._caps.shaderFloatPrecision=Math.min(i.precision,s.precision)),!this._shouldUseHighPrecisionShader){const r=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.MEDIUM_FLOAT),n=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.MEDIUM_FLOAT);r&&n&&(this._caps.shaderFloatPrecision=Math.min(r.precision,n.precision))}this._caps.shaderFloatPrecision<10&&(this._caps.shaderFloatPrecision=10)}if(this._webGLVersion>1)this._caps.blendMinMax=!0;else{const i=this._gl.getExtension("EXT_blend_minmax");i!=null&&(this._caps.blendMinMax=!0,this._gl.MAX=i.MAX_EXT,this._gl.MIN=i.MIN_EXT)}if(!this._caps.supportSRGBBuffers){if(this._webGLVersion>1)this._caps.supportSRGBBuffers=!0,this._glSRGBExtensionValues={SRGB:WebGL2RenderingContext.SRGB,SRGB8:WebGL2RenderingContext.SRGB8,SRGB8_ALPHA8:WebGL2RenderingContext.SRGB8_ALPHA8};else{const i=this._gl.getExtension("EXT_sRGB");i!=null&&(this._caps.supportSRGBBuffers=!0,this._glSRGBExtensionValues={SRGB:i.SRGB_EXT,SRGB8:i.SRGB_ALPHA_EXT,SRGB8_ALPHA8:i.SRGB_ALPHA_EXT})}if(this._creationOptions){const i=this._creationOptions.forceSRGBBufferSupportState;i!==void 0&&(this._caps.supportSRGBBuffers=this._caps.supportSRGBBuffers&&i)}}this._depthCullingState.depthTest=!0,this._depthCullingState.depthFunc=this._gl.LEQUAL,this._depthCullingState.depthMask=!0,this._maxSimultaneousTextures=this._caps.maxCombinedTexturesImageUnits;for(let i=0;i<this._maxSimultaneousTextures;i++)this._nextFreeTextureSlots.push(i);this._glRenderer==="Mali-G72"&&(this._caps.disableMorphTargetTexture=!0)}_initFeatures(){this._features={forceBitmapOverHTMLImageElement:typeof HTMLImageElement>"u",supportRenderAndCopyToLodForFloatTextures:this._webGLVersion!==1,supportDepthStencilTexture:this._webGLVersion!==1,supportShadowSamplers:this._webGLVersion!==1,uniformBufferHardCheckMatrix:!1,allowTexturePrefiltering:this._webGLVersion!==1,trackUbosInFrame:!1,checkUbosContentBeforeUpload:!1,supportCSM:this._webGLVersion!==1,basisNeedsPOT:this._webGLVersion===1,support3DTextures:this._webGLVersion!==1,needTypeSuffixInShaderConstants:this._webGLVersion!==1,supportMSAA:this._webGLVersion!==1,supportSSAO2:this._webGLVersion!==1,supportIBLShadows:this._webGLVersion!==1,supportExtendedTextureFormats:this._webGLVersion!==1,supportSwitchCaseInSha
vendor: 7,402 bytes, line 48
48der:this._webGLVersion!==1,supportSyncTextureRead:!0,needsInvertingBitmap:!0,useUBOBindingCache:!0,needShaderCodeInlining:!1,needToAlwaysBindUniformBuffers:!1,supportRenderPasses:!1,supportSpriteInstancing:!0,forceVertexBufferStrideAndOffsetMultiple4Bytes:!1,_checkNonFloatVertexBuffersDontRecreatePipelineContext:!1,_collectUbosUpdatedInFrame:!1}}get webGLVersion(){return this._webGLVersion}getClassName(){return"ThinEngine"}_prepareWorkingCanvas(){if(this._workingCanvas)return;this._workingCanvas=this.createCanvas(1,1);const e=this._workingCanvas.getContext("2d");e&&(this._workingContext=e)}getInfo(){return this.getGlInfo()}getGlInfo(){return{vendor:this._glVendor,renderer:this._glRenderer,version:this._glVersion}}extractDriverInfo(){const e=this.getGlInfo();return e&&e.renderer?e.renderer:""}getRenderWidth(e=!1){return!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._framebufferDimensionsObject?this._framebufferDimensionsObject.framebufferWidth:this._gl.drawingBufferWidth}getRenderHeight(e=!1){return!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._framebufferDimensionsObject?this._framebufferDimensionsObject.framebufferHeight:this._gl.drawingBufferHeight}clear(e,t,i,s=!1,r=0){const n=this.stencilStateComposer.useStencilGlobalOnly;this.stencilStateComposer.useStencilGlobalOnly=!0,this.applyStates(),this.stencilStateComposer.useStencilGlobalOnly=n;let o=0;if(t&&e){let h=!0;if(this._currentRenderTarget){const l=this._currentRenderTarget.texture?.format;if(l===8||l===9||l===10||l===11){const c=this._currentRenderTarget.texture?.type;c===7||c===5?(he._TempClearColorUint32[0]=e.r*255,he._TempClearColorUint32[1]=e.g*255,he._TempClearColorUint32[2]=e.b*255,he._TempClearColorUint32[3]=e.a*255,this._gl.clearBufferuiv(this._gl.COLOR,0,he._TempClearColorUint32),h=!1):(he._TempClearColorInt32[0]=e.r*255,he._TempClearColorInt32[1]=e.g*255,he._TempClearColorInt32[2]=e.b*255,he._TempClearColorInt32[3]=e.a*255,this._gl.clearBufferiv(this._gl.COLOR,0,he._TempClearColorInt32),h=!1)}}h&&(this._gl.clearColor(e.r,e.g,e.b,e.a!==void 0?e.a:1),o|=this._gl.COLOR_BUFFER_BIT)}i&&(this.useReverseDepthBuffer?(this._depthCullingState.depthFunc=this._gl.GEQUAL,this._gl.clearDepth(0)):this._gl.clearDepth(1),o|=this._gl.DEPTH_BUFFER_BIT),s&&(this._gl.clearStencil(r),o|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(o)}_viewport(e,t,i,s){(e!==this._viewportCached.x||t!==this._viewportCached.y||i!==this._viewportCached.z||s!==this._viewportCached.w)&&(this._viewportCached.x=e,this._viewportCached.y=t,this._viewportCached.z=i,this._viewportCached.w=s,this._gl.viewport(e,t,i,s))}endFrame(){super.endFrame(),this._badOS&&this.flushFramebuffer()}get performanceMonitor(){throw new Error("Not Supported by ThinEngine")}bindFramebuffer(e,t=0,i,s,r,n=0,o=0){const h=e;this._currentRenderTarget&&this._resolveAndGenerateMipMapsFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this._bindUnboundFramebuffer(h._framebuffer);const l=this._gl;e.isMulti||(e.is2DArray||e.is3D?(l.framebufferTextureLayer(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,e.texture._hardwareTexture?.underlyingResource,n,o),h._currentLOD=n):e.isCube?l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_CUBE_MAP_POSITIVE_X+t,e.texture._hardwareTexture?.underlyingResource,n):h._currentLOD!==n&&(l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,e.texture._hardwareTexture?.underlyingResource,n),h._currentLOD=n));const c=e._depthStencilTexture;if(c){e.is3D&&(e.texture.width!==c.width||e.texture.height!==c.height||e.texture.depth!==c.depth)&&w.Warn("Depth/Stencil attachment for 3D target must have same dimensions as color attachment");const u=e._depthStencilTextureWithStencil?l.DEPTH_STENCIL_ATTACHMENT:l.DEPTH_ATTACHMENT;e.is2DArray||e.is3D?l.framebufferTextureLayer(l.FRAMEBUFFER,u,c._hardwareTexture?.underlyingResource,n,o):e.isCube?l.framebufferTexture2D(l.FRAMEBUFFER,u,l.TEXTURE_CUBE_MAP_POSITIVE_X+t,c._hardwareTexture?.underlyingResource,n):l.framebufferTexture2D(l.FRAMEBUFFER,u,l.TEXTURE_2D,c._hardwareTexture?.underlyingResource,n)}h._MSAAFramebuffer&&this._bindUnboundFramebuffer(h._MSAAFramebuffer),this._cachedViewport&&!r?this.setViewport(this._cachedViewport,i,s):(i||(i=e.width,n&&(i=i/Math.pow(2,n))),s||(s=e.height,n&&(s=s/Math.pow(2,n))),this._viewport(0,0,i,s)),this.wipeCaches()}setStateCullFaceType(e,t){const i=this.cullBackFaces??e??!0?this._gl.BACK:this._gl.FRONT;(this._depthCullingState.cullFace!==i||t)&&(this._depthCullingState.cullFace=i)}setState(e,t=0,i,s=!1,r,n,o=0){(this._depthCullingState.cull!==e||i)&&(this._depthCullingState.cull=e),this.setStateCullFaceType(r,i),this.setZOffset(t),this.setZOffsetUnits(o);const h=s?this._gl.CW:this._gl.CCW;(this._depthCullingState.frontFace!==h||i)&&(this._depthCullingState.frontFace=h),this._stencilStateComposer.stencilMaterial=n}_resolveAndGenerateMipMapsFramebuffer(e,t=!1){e.disableAutomaticMSAAResolve||(e.isMulti?this.resolveMultiFramebuffer(e):this.resolveFramebuffer(e)),t||(e.isMulti?this.generateMipMapsMultiFramebuffer(e):this.generateMipMapsFramebuffer(e))}_bindUnboundFramebuffer(e){this._currentFramebuffer!==e&&(this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,e),this._currentFramebuffer=e)}_currentFrameBufferIsDefaultFrameBuffer(){return this._currentFramebuffer===null}generateMipmaps(e){const t=this._getTextureTarget(e);this._bindTextureDirectly(t,e,!0),this._gl.generateMipmap(t),this._bindTextureDirectly(t,null)}unBindFramebuffer(e,t,i){const s=e;this._currentRenderTarget=null,this._resolveAndGenerateMipMapsFramebuffer(e,t),i&&(s._MSAAFramebuffer&&this._bindUnboundFramebuffer(s._framebuffer),i()),this._bindUnboundFramebuffer(null)}generateMipMapsFramebuffer(e){!e.isMulti&&e.texture?.generateMipMaps&&!e.isCube&&this.generateMipmaps(e.texture)}resolveFramebuffer(e){const t=e,i=this._gl;if(!t._MSAAFramebuffer||t.isMulti)return;let s=t.resolveMSAAColors?i.COLOR_BUFFER_BIT:0;s|=t._generateDepthBuffer&&t.resolveMSAADepth?i.DEPTH_BUFFER_BIT:0,s|=t._generateStencilBuffer&&t.resolveMSAAStencil?i.STENCIL_BUFFER_BIT:0,i.bindFramebuffer(i.READ_FRAMEBUFFER,t._MSAAFramebuffer),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,t._framebuffer),i.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,s,i.NEAREST)}flushFramebuffer(){this._gl.flush()}restoreDefaultFramebuffer(){this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this._bindUnboundFramebuffer(null),this._cachedViewport&&this.setViewport(this._cachedViewport),this.wipeCaches()}_resetVertexBufferBinding(){this.bindArrayBuffer(null),this._cachedVertexBuffers=null}createVertexBuffer(e,t,i){return this._createVertexBuffer(e,this._gl.STATIC_DRAW)}_createVertexBuffer(e,t){const i=this._gl.createBuffer();if(!i)throw new Error("Unable to create vertex buffer");const s=new Ys(i);return this.bindArrayBuffer(s),typeof e!="number"?e instanceof Array?(this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(e),t),s.capacity=e.length*4):(this._gl.bufferData(this._gl.ARRAY_BUFFER,e,t),s.capacity=e.byteLength):(this._gl.bufferData(this._gl.ARRAY_BUFFER,new Uint8Array(e),t),s.capacity=e),this._resetVertexBufferBinding(),s.references=1,s}createDynamicVertexBuffer(e,t){return this._createVertexBuffer(e,this._gl.DYNAMIC_DRAW)}_resetIndexBufferBinding(){this.bindIndexBuffer(null),this._cachedIndexBuffer=null}createIndexBuffer(e,t,i){const s=this._gl.createBuffer(),r=new Y
vendor: 7,572 bytes, line 48
48s(s);if(!s)throw new Error("Unable to create index buffer");this.bindIndexBuffer(r);const n=this._normalizeIndexData(e);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,n,t?this._gl.DYNAMIC_DRAW:this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),r.references=1,r.is32Bits=n.BYTES_PER_ELEMENT===4,r}_normalizeIndexData(e){if(e.BYTES_PER_ELEMENT===2)return e;if(this._caps.uintIndices){if(e instanceof Uint32Array)return e;for(let i=0;i<e.length;i++)if(e[i]>=65535)return new Uint32Array(e);return new Uint16Array(e)}return new Uint16Array(e)}bindArrayBuffer(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this._bindBuffer(e,this._gl.ARRAY_BUFFER)}bindUniformBlock(e,t,i){const s=e.program,r=this._gl.getUniformBlockIndex(s,t);this._gl.uniformBlockBinding(s,r,i)}bindIndexBuffer(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this._bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)}_bindBuffer(e,t){(this._vaoRecordInProgress||this._currentBoundBuffer[t]!==e)&&(this._gl.bindBuffer(t,e?e.underlyingResource:null),this._currentBoundBuffer[t]=e)}updateArrayBuffer(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)}_vertexAttribPointer(e,t,i,s,r,n,o){const h=this._currentBufferPointers[t];if(!h)return;let l=!1;h.active?(h.buffer!==e&&(h.buffer=e,l=!0),h.size!==i&&(h.size=i,l=!0),h.type!==s&&(h.type=s,l=!0),h.normalized!==r&&(h.normalized=r,l=!0),h.stride!==n&&(h.stride=n,l=!0),h.offset!==o&&(h.offset=o,l=!0)):(l=!0,h.active=!0,h.index=t,h.size=i,h.type=s,h.normalized=r,h.stride=n,h.offset=o,h.buffer=e),(l||this._vaoRecordInProgress)&&(this.bindArrayBuffer(e),s===this._gl.UNSIGNED_INT||s===this._gl.INT?this._gl.vertexAttribIPointer(t,i,s,n,o):this._gl.vertexAttribPointer(t,i,s,r,n,o))}_bindIndexBufferWithCache(e){e!=null&&this._cachedIndexBuffer!==e&&(this._cachedIndexBuffer=e,this.bindIndexBuffer(e),this._uintIndicesCurrentlySet=e.is32Bits)}_bindVertexBuffersAttributes(e,t,i){const s=t.getAttributesNames();this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.unbindAllAttributes();for(let r=0;r<s.length;r++){const n=t.getAttributeLocation(r);if(n>=0){const o=s[r];let h=null;if(i&&(h=i[o]),h||(h=e[o]),!h)continue;this._gl.enableVertexAttribArray(n),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[n]=!0);const l=h.getBuffer();l&&(this._vertexAttribPointer(l,n,h.getSize(),h.type,h.normalized,h.byteStride,h.byteOffset),h.getIsInstanced()&&(this._gl.vertexAttribDivisor(n,h.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(n),this._currentInstanceBuffers.push(l))))}}}recordVertexArrayObject(e,t,i,s){const r=this._gl.createVertexArray();if(!r)throw new Error("Unable to create VAO");return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(r),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(e,i,s),this.bindIndexBuffer(t),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),r}bindVertexArrayObject(e,t){this._cachedVertexArrayObject!==e&&(this._cachedVertexArrayObject=e,this._gl.bindVertexArray(e),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._uintIndicesCurrentlySet=t!=null&&t.is32Bits,this._mustWipeVertexAttributes=!0)}bindBuffersDirectly(e,t,i,s,r){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==r){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=r;const n=r.getAttributesCount();this._unbindVertexArrayObject(),this.unbindAllAttributes();let o=0;for(let h=0;h<n;h++)if(h<i.length){const l=r.getAttributeLocation(h);l>=0&&(this._gl.enableVertexAttribArray(l),this._vertexAttribArraysEnabled[l]=!0,this._vertexAttribPointer(e,l,i[h],this._gl.FLOAT,!1,s,o)),o+=i[h]*4}}this._bindIndexBufferWithCache(t)}_unbindVertexArrayObject(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))}bindBuffers(e,t,i,s){(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==i)&&(this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i,this._bindVertexBuffersAttributes(e,i,s)),this._bindIndexBufferWithCache(t)}unbindInstanceAttributes(){let e;for(let t=0,i=this._currentInstanceLocations.length;t<i;t++){const s=this._currentInstanceBuffers[t];e!=s&&s.references&&(e=s,this.bindArrayBuffer(s));const r=this._currentInstanceLocations[t];this._gl.vertexAttribDivisor(r,0)}this._currentInstanceBuffers.length=0,this._currentInstanceLocations.length=0}releaseVertexArrayObject(e){this._gl.deleteVertexArray(e)}_releaseBuffer(e){return e.references--,e.references===0?(this._deleteBuffer(e),!0):!1}_deleteBuffer(e){this._gl.deleteBuffer(e.underlyingResource)}updateAndBindInstancesBuffer(e,t,i){if(this.bindArrayBuffer(e),t&&this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t),i[0].index!==void 0)this.bindInstancesBuffer(e,i,!0);else for(let s=0;s<4;s++){const r=i[s];this._vertexAttribArraysEnabled[r]||(this._gl.enableVertexAttribArray(r),this._vertexAttribArraysEnabled[r]=!0),this._vertexAttribPointer(e,r,4,this._gl.FLOAT,!1,64,s*16),this._gl.vertexAttribDivisor(r,1),this._currentInstanceLocations.push(r),this._currentInstanceBuffers.push(e)}}bindInstancesBuffer(e,t,i=!0){this.bindArrayBuffer(e);let s=0;if(i)for(let r=0;r<t.length;r++){const n=t[r];s+=n.attributeSize*4}for(let r=0;r<t.length;r++){const n=t[r];n.index===void 0&&(n.index=this._currentEffect.getAttributeLocationByName(n.attributeName)),!(n.index<0)&&(this._vertexAttribArraysEnabled[n.index]||(this._gl.enableVertexAttribArray(n.index),this._vertexAttribArraysEnabled[n.index]=!0),this._vertexAttribPointer(e,n.index,n.attributeSize,n.attributeType||this._gl.FLOAT,n.normalized||!1,s,n.offset),this._gl.vertexAttribDivisor(n.index,n.divisor===void 0?1:n.divisor),this._currentInstanceLocations.push(n.index),this._currentInstanceBuffers.push(e))}}disableInstanceAttributeByName(e){if(!this._currentEffect)return;const t=this._currentEffect.getAttributeLocationByName(e);this.disableInstanceAttribute(t)}disableInstanceAttribute(e){let t=!1,i;for(;(i=this._currentInstanceLocations.indexOf(e))!==-1;)this._currentInstanceLocations.splice(i,1),this._currentInstanceBuffers.splice(i,1),t=!0,i=this._currentInstanceLocations.indexOf(e);t&&(this._gl.vertexAttribDivisor(e,0),this.disableAttributeByIndex(e))}disableAttributeByIndex(e){this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1,this._currentBufferPointers[e].active=!1}draw(e,t,i,s){this.drawElementsType(e?0:1,t,i,s)}drawPointClouds(e,t,i){this.drawArraysType(2,e,t,i)}drawUnIndexed(e,t,i,s){this.drawArraysType(e?0:1,t,i,s)}drawElementsType(e,t,i,s){this.applyStates(),this._reportDrawCall();const r=this._drawMode(e),n=this._uintIndicesCurrentlySet?this._gl.UNSIGNED_INT:this._gl.UNSIGNED_SHORT,o=this._uintIndicesCurrentlySet?4:2;s?this._gl.drawElementsInstanced(r,i,n,t*o,s):this._gl.drawElements(r,i,n,t*o)}drawArraysType(e,t,i,s){this.applyStates(),this._reportDrawCall();const r=this._drawMode(e);s?this._gl.drawArraysInstanced(r,t,i,s):this._gl.drawArrays(r,t,i)}_drawMode(e){switch(e){case 0:return this._gl.TRIANGLES;case 2:return this._gl.POINTS;case 1:return this._gl.LINES;case 3:return this._gl.POINTS;case 4:return this._gl.LINES;case 5:return this._gl.LINE_LOOP;case 6:return this._gl.LINE_STRIP;case 7:return this._gl.TRIANGLE_STRIP;case 8:return this._gl.TRIANGLE_FAN;default:return this._gl.TRIANGLES}}_releaseEffect(e){this._compiledEffects[e._key]&&delete this._compiledEffects[e._key];const t=e.getPipelineContext();t&&this._deletePipelineContext(t)}_deletePipelineContext(e){const t=e;t&&t.program&&(t.program.__SPECTOR_rebuildProgram=null,
vendor: 35,427 bytes, line 48
48wo(t),this._gl&&(this._currentProgram===t.program&&this._setProgram(null),this._gl.deleteProgram(t.program)))}_getGlobalDefines(e){return vo(e,this.isNDCHalfZRange,this.useReverseDepthBuffer,this.useExactSrgbConversions)}createEffect(e,t,i,s,r,n,o,h,l,c=0,u){const f=typeof e=="string"?e:e.vertexToken||e.vertexSource||e.vertexElement||e.vertex,d=typeof e=="string"?e:e.fragmentToken||e.fragmentSource||e.fragmentElement||e.fragment,g=this._getGlobalDefines(),p=t.attributes!==void 0;let m=r??t.defines??"";g&&(m+=g);const A=f+"+"+d+"@"+m;if(this._compiledEffects[A]){const I=this._compiledEffects[A];return o&&I.isReady()&&o(I),I._refCount++,I}this._gl&&Pt(this._gl);const E=new ze(e,t,p?this:i,s,this,r,n,o,h,l,A,t.shaderLanguage??c,t.extraInitializationsAsync??u);return this._compiledEffects[A]=E,E}_getShaderSource(e){return this._gl.getShaderSource(e)}createRawShaderProgram(e,t,i,s,r=null){const n=Pt(this._gl);return n._contextWasLost=this._contextWasLost,n.validateShaderPrograms=this.validateShaderPrograms,Oo(e,t,i,s||this._gl,r)}createShaderProgram(e,t,i,s,r,n=null){const o=Pt(this._gl);return o._contextWasLost=this._contextWasLost,o.validateShaderPrograms=this.validateShaderPrograms,Fo(e,t,i,s,r||this._gl,n)}inlineShaderCode(e){return e}createPipelineContext(e){if(this._gl){const i=Pt(this._gl);i.parallelShaderCompile=this._caps.parallelShaderCompile}const t=uc(this._gl);return t.engine=this,t}createMaterialContext(){}createDrawContext(){}_finalizePipelineContext(e){return Pn(e,this._gl,this.validateShaderPrograms)}_preparePipelineContextAsync(e,t,i,s,r,n,o,h,l,c,u){const f=Pt(this._gl);return f._contextWasLost=this._contextWasLost,f.validateShaderPrograms=this.validateShaderPrograms,f._createShaderProgramInjection=this._createShaderProgram.bind(this),f.createRawShaderProgramInjection=this.createRawShaderProgram.bind(this),f.createShaderProgramInjection=this.createShaderProgram.bind(this),f.loadFileInjection=this._loadFile.bind(this),fc(e,t,i,s,r,n,o,h,l,c,u)}_createShaderProgram(e,t,i,s,r=null){return In(e,t,i,s,r)}_isRenderingStateCompiled(e){return this._isDisposed?!1:dc(e,this._gl,this.validateShaderPrograms)}_executeWhenRenderingStateIsCompiled(e,t){gc(e,t)}getUniforms(e,t){const i=new Array,s=e;for(let r=0;r<t.length;r++)i.push(this._gl.getUniformLocation(s.program,t[r]));return i}getAttributes(e,t){const i=[],s=e;for(let r=0;r<t.length;r++)try{i.push(this._gl.getAttribLocation(s.program,t[r]))}catch{i.push(-1)}return i}enableEffect(e){e=e!==null&&mh(e)?e.effect:e,!(!e||e===this._currentEffect)&&(this._stencilStateComposer.stencilMaterial=void 0,this.bindSamplers(e),this._currentEffect=e,e.onBind&&e.onBind(e),e._onBindObservable&&e._onBindObservable.notifyObservers(e))}setInt(e,t){return e?(this._gl.uniform1i(e,t),!0):!1}setInt2(e,t,i){return e?(this._gl.uniform2i(e,t,i),!0):!1}setInt3(e,t,i,s){return e?(this._gl.uniform3i(e,t,i,s),!0):!1}setInt4(e,t,i,s,r){return e?(this._gl.uniform4i(e,t,i,s,r),!0):!1}setIntArray(e,t){return e?(this._gl.uniform1iv(e,t),!0):!1}setIntArray2(e,t){return!e||t.length%2!==0?!1:(this._gl.uniform2iv(e,t),!0)}setIntArray3(e,t){return!e||t.length%3!==0?!1:(this._gl.uniform3iv(e,t),!0)}setIntArray4(e,t){return!e||t.length%4!==0?!1:(this._gl.uniform4iv(e,t),!0)}setUInt(e,t){return e?(this._gl.uniform1ui(e,t),!0):!1}setUInt2(e,t,i){return e?(this._gl.uniform2ui(e,t,i),!0):!1}setUInt3(e,t,i,s){return e?(this._gl.uniform3ui(e,t,i,s),!0):!1}setUInt4(e,t,i,s,r){return e?(this._gl.uniform4ui(e,t,i,s,r),!0):!1}setUIntArray(e,t){return e?(this._gl.uniform1uiv(e,t),!0):!1}setUIntArray2(e,t){return!e||t.length%2!==0?!1:(this._gl.uniform2uiv(e,t),!0)}setUIntArray3(e,t){return!e||t.length%3!==0?!1:(this._gl.uniform3uiv(e,t),!0)}setUIntArray4(e,t){return!e||t.length%4!==0?!1:(this._gl.uniform4uiv(e,t),!0)}setArray(e,t){return!e||t.length<1?!1:(this._gl.uniform1fv(e,t),!0)}setArray2(e,t){return!e||t.length%2!==0?!1:(this._gl.uniform2fv(e,t),!0)}setArray3(e,t){return!e||t.length%3!==0?!1:(this._gl.uniform3fv(e,t),!0)}setArray4(e,t){return!e||t.length%4!==0?!1:(this._gl.uniform4fv(e,t),!0)}setMatrices(e,t){return e?(this._gl.uniformMatrix4fv(e,!1,t),!0):!1}setMatrix3x3(e,t){return e?(this._gl.uniformMatrix3fv(e,!1,t),!0):!1}setMatrix2x2(e,t){return e?(this._gl.uniformMatrix2fv(e,!1,t),!0):!1}setFloat(e,t){return e?(this._gl.uniform1f(e,t),!0):!1}setFloat2(e,t,i){return e?(this._gl.uniform2f(e,t,i),!0):!1}setFloat3(e,t,i,s){return e?(this._gl.uniform3f(e,t,i,s),!0):!1}setFloat4(e,t,i,s,r){return e?(this._gl.uniform4f(e,t,i,s,r),!0):!1}applyStates(){if(this._depthCullingState.apply(this._gl),this._stencilStateComposer.apply(this._gl),this._alphaState.apply(this._gl,this._currentRenderTarget&&this._currentRenderTarget.textures?this._currentRenderTarget.textures.length:1),this._colorWriteChanged){this._colorWriteChanged=!1;const e=this._colorWrite;this._gl.colorMask(e,e,e,e)}}wipeCaches(e){this.preventCacheWipeBetweenFrames&&!e||(this._currentEffect=null,this._viewportCached.x=0,this._viewportCached.y=0,this._viewportCached.z=0,this._viewportCached.w=0,this._unbindVertexArrayObject(),e&&(this._currentProgram=null,this.resetTextureCache(),this._stencilStateComposer.reset(),this._depthCullingState.reset(),this._depthCullingState.depthFunc=this._gl.LEQUAL,this._alphaState.reset(),this._resetAlphaMode(),this._colorWrite=!0,this._colorWriteChanged=!0,this._unpackFlipYCached=null,this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,this._gl.NONE),this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),this._mustWipeVertexAttributes=!0,this.unbindAllAttributes()),this._resetVertexBufferBinding(),this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null,this.bindIndexBuffer(null))}_getSamplingParameters(e,t){const i=this._gl;let s=i.NEAREST,r=i.NEAREST,n=!1;switch(e){case 11:s=i.LINEAR,t?r=i.LINEAR_MIPMAP_NEAREST:r=i.LINEAR;break;case 3:s=i.LINEAR,n=!0,t?r=i.LINEAR_MIPMAP_LINEAR:r=i.LINEAR;break;case 8:n=!0,s=i.NEAREST,t?r=i.NEAREST_MIPMAP_LINEAR:r=i.NEAREST;break;case 4:s=i.NEAREST,t?r=i.NEAREST_MIPMAP_NEAREST:r=i.NEAREST;break;case 5:s=i.NEAREST,t?r=i.LINEAR_MIPMAP_NEAREST:r=i.LINEAR;break;case 6:n=!0,s=i.NEAREST,t?r=i.LINEAR_MIPMAP_LINEAR:r=i.LINEAR;break;case 7:s=i.NEAREST,r=i.LINEAR;break;case 1:s=i.NEAREST,r=i.NEAREST;break;case 9:s=i.LINEAR,t?r=i.NEAREST_MIPMAP_NEAREST:r=i.NEAREST;break;case 10:n=!0,s=i.LINEAR,t?r=i.NEAREST_MIPMAP_LINEAR:r=i.NEAREST;break;case 2:s=i.LINEAR,r=i.LINEAR;break;case 12:s=i.LINEAR,r=i.NEAREST;break}return{min:r,mag:s,hasMipMaps:n}}_createTexture(){const e=this._gl.createTexture();if(!e)throw new Error("Unable to create texture");return e}_createHardwareTexture(){return new wh(this._createTexture(),this._gl)}_createInternalTexture(e,t,i=!0,s=0){let r=!1,n=!1,o=0,h=3,l=5,c=!1,u=1,f,d=!1,g=0,p=!1;t!==void 0&&typeof t=="object"?(r=!!t.generateMipMaps,n=!!t.createMipMaps,o=t.type===void 0?0:t.type,h=t.samplingMode===void 0?3:t.samplingMode,l=t.format===void 0?5:t.format,c=t.useSRGBBuffer===void 0?!1:t.useSRGBBuffer,u=t.samples??1,f=t.label,d=!!t.createMSAATexture,g=t.comparisonFunction||0,p=!!t.isCube):r=!!t,c&&(c=this._caps.supportSRGBBuffers&&(this.webGLVersion>1||this.isWebGPU)),(o===1&&!this._caps.textureFloatLinearFiltering||o===2&&!this._caps.textureHalfFloatLinearFiltering)&&(h=1),o===1&&!this._caps.textureFloat&&(o=0,w.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));const m=xn(l),A=bs(l),E=this._gl,I=new Et(this,s),M=e.width||e,C=e.height||e,x=e.depth||0,S=e.layers||0,L=this._getSamplingParameters(h,(r||n)&&!m),N=S!==0?E.TEXTURE_2D_ARRAY:x!==0?E.TEXTURE_3D:p?E.TEXTURE_CUBE_MAP:E.TEXTURE_2D,D=m?this._getInternalFormatFromDepthTextureFormat(l,!0,A):this._getRGBABufferInternalSizedFormat(o,l,c),Re=m?A?E.DEPTH_STENCIL:E.DEPTH_COMPONENT:this._getInternalFormat(l),pe=m?this._getWebGLTextureTypeFromDepthTextureFormat(l):this._getWebGLTextureType(o);if(this._bindTextureDirectly(N,I),S!==0)I.is2DArray=!0,E.texImage3D(N,0,D,M,C,S,0,Re,pe,null);else if(x!==0)I.is3D=!0,E.texImage3D(N,0,D,M,C,x,0,Re,pe,null);else if(p){I.isCube=!0;for(let ce=0;ce<6;ce++)E.texImage2D(E.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,D,M,C,0,Re,pe,null)}else E.texImage2D(N,0,D,M,C,0,Re,pe,null);if(E.texParameteri(N,E.TEXTURE_MAG_FILTER,L.mag),E.texParameteri(N,E.TEXTURE_MIN_FILTER,L.min),E.texParameteri(N,E.TEXTURE_WRAP_S,E.CLAMP_TO_EDGE),E.texParameteri(N,E.TEXTURE_WRAP_T,E.CLAMP_TO_EDGE),m&&this.webGLVersion>1&&(g===0?(E.texParameteri(N,E.TEXTURE_COMPARE_FUNC,515),E.texParameteri(N,E.TEXTURE_COMPARE_MODE,E.NONE)):(E.texParameteri(N,E.TEXTURE_COMPARE_FUNC,g),E.texParameteri(N,E.TEXTURE_COMPARE_MODE,E.COMPARE_REF_TO_TEXTURE))),(r||n)&&this._gl.generateMipmap(N),this._bindTextureDirectly(N,null),I._useSRGBBuffer=c,I.baseWidth=M,I.baseHeight=C,I.width=M,I.height=C,I.depth=S||x,I.isReady=!0,I.samples=u,I.generateMipMaps=r,I.samplingMode=h,I.type=o,I.format=l,I.label=f,I.comparisonFunction=g,this._internalTexturesCache.push(I),d){let ce=null;if(xn(I.format)?ce=this._setupFramebufferDepthAttachments(bs(I.format),I.format!==19,I.width,I.height,u,I.format,!0):ce=this._createRenderBuffer(I.width,I.height,u,-1,this._getRGBABufferInternalSizedFormat(I.type,I.format,I._useSRGBBuffer),-1),!ce)throw new Error("Unable to create render buffer");I._autoMSAAManagement=!0;let oe=I._hardwareTexture;oe||(oe=I._hardwareTexture=this._createHardwareTexture()),oe.addMSAARenderBuffer(ce)}return I}_getUseSRGBBuffer(e,t){return e&&this._caps.supportSRGBBuffers&&(this.webGLVersion>1||t)}createTexture(e,t,i,s,r=3,n=null,o=null,h=null,l=null,c=null,u=null,f,d,g,p){return this._createTextureBase(e,t,i,s,r,n,o,(...m)=>this._prepareWebGLTexture(...m,c),(m,A,E,I,M,C)=>{const x=this._gl,S=E.width===m&&E.height===A;M._creationFlags=g??0;const L=this._getTexImageParametersForCreateTexture(M.format,M._useSRGBBuffer);if(S)return x.texImage2D(x.TEXTURE_2D,0,L.internalFormat,L.format,L.type,E),!1;const N=this._caps.maxTextureSize;if(E.width>N||E.height>N||!this._supportsHardwareTextureRescaling)return this._prepareWorkingCanvas(),!this._workingCanvas||!this._workingContext||(this._workingCanvas.width=m,this._workingCanvas.height=A,this._workingContext.drawImage(E,0,0,E.width,E.height,0,0,m,A),x.texImage2D(x.TEXTURE_2D,0,L.internalFormat,L.format,L.type,this._workingCanvas),M.width=m,M.height=A),!1;{const D=new Et(this,2);this._bindTextureDirectly(x.TEXTURE_2D,D,!0),x.texImage2D(x.TEXTURE_2D,0,L.internalFormat,L.format,L.type,E),this._rescaleTexture(D,M,s,L.format,()=>{this._releaseTexture(D),this._bindTextureDirectly(x.TEXTURE_2D,M,!0),C()})}return!0},h,l,c,u,f,d,p)}_getTexImageParametersForCreateTexture(e,t){let i,s;return this.webGLVersion===1?(i=this._getInternalFormat(e,t),s=i):(i=this._getInternalFormat(e,!1),s=this._getRGBABufferInternalSizedFormat(0,e,t)),{internalFormat:s,format:i,type:this._gl.UNSIGNED_BYTE}}_rescaleTexture(e,t,i,s,r){}_unpackFlipY(e){this._unpackFlipYCached!==e&&(this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,e?1:0),this.enableUnpackFlipYCached&&(this._unpackFlipYCached=e))}_getUnpackAlignement(){return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)}_getTextureTarget(e){return e.isCube?this._gl.TEXTURE_CUBE_MAP:e.is3D?this._gl.TEXTURE_3D:e.is2DArray||e.isMultiview?this._gl.TEXTURE_2D_ARRAY:this._gl.TEXTURE_2D}updateTextureSamplingMode(e,t,i=!1){const s=this._getTextureTarget(t),r=this._getSamplingParameters(e,t.useMipMaps||i);this._setTextureParameterInteger(s,this._gl.TEXTURE_MAG_FILTER,r.mag,t),this._setTextureParameterInteger(s,this._gl.TEXTURE_MIN_FILTER,r.min),i&&r.hasMipMaps&&(t.generateMipMaps=!0,this._gl.generateMipmap(s)),this._bindTextureDirectly(s,null),t.samplingMode=e}updateTextureDimensions(e,t,i,s=1){}updateTextureWrappingMode(e,t,i=null,s=null){const r=this._getTextureTarget(e);t!==null&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t),e),e._cachedWrapU=t),i!==null&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(i),e),e._cachedWrapV=i),(e.is2DArray||e.is3D)&&s!==null&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(s),e),e._cachedWrapR=s),this._bindTextureDirectly(r,null)}_uploadCompressedDataToTextureDirectly(e,t,i,s,r,n=0,o=0){const h=this._gl;let l=h.TEXTURE_2D;if(e.isCube&&(l=h.TEXTURE_CUBE_MAP_POSITIVE_X+n),e._useSRGBBuffer)switch(t){case 37492:case 36196:this._caps.etc2?t=h.COMPRESSED_SRGB8_ETC2:e._useSRGBBuffer=!1;break;case 37496:this._caps.etc2?t=h.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:e._useSRGBBuffer=!1;break;case 36492:t=h.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;break;case 37808:t=h.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;break;case 33776:this._caps.s3tc_srgb?t=h.COMPRESSED_SRGB_S3TC_DXT1_EXT:e._useSRGBBuffer=!1;break;case 33777:this._caps.s3tc_srgb?t=h.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:e._useSRGBBuffer=!1;break;case 33779:this._caps.s3tc_srgb?t=h.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:e._useSRGBBuffer=!1;break;default:e._useSRGBBuffer=!1;break}if(e.generateMipMaps){const c=e._hardwareTexture;c.memoryAllocated||(h.texStorage2D(e.isCube?h.TEXTURE_CUBE_MAP:h.TEXTURE_2D,Math.floor(Math.log2(Math.max(i,s)))+1,t,e.width,e.height),c.memoryAllocated=!0),this._gl.compressedTexSubImage2D(l,o,0,0,i,s,t,r)}else this._gl.compressedTexImage2D(l,o,t,i,s,0,r)}_uploadDataToTextureDirectly(e,t,i=0,s=0,r,n=!1){const o=this._gl,h=this._getWebGLTextureType(e.type),l=this._getInternalFormat(e.format),c=r===void 0?this._getRGBABufferInternalSizedFormat(e.type,e.format,e._useSRGBBuffer):this._getInternalFormat(r,e._useSRGBBuffer);this._unpackFlipY(e.invertY);let u=o.TEXTURE_2D;e.isCube&&(u=o.TEXTURE_CUBE_MAP_POSITIVE_X+i);const f=Math.round(Math.log(e.width)*Math.LOG2E),d=Math.round(Math.log(e.height)*Math.LOG2E),g=n?e.width:Math.pow(2,Math.max(f-s,0)),p=n?e.height:Math.pow(2,Math.max(d-s,0));o.texImage2D(u,s,c,g,p,0,l,h,t)}updateTextureData(e,t,i,s,r,n,o=0,h=0,l=!1){const c=this._gl,u=this._getWebGLTextureType(e.type),f=this._getInternalFormat(e.format);this._unpackFlipY(e.invertY);let d=c.TEXTURE_2D,g=c.TEXTURE_2D;e.isCube&&(g=c.TEXTURE_CUBE_MAP_POSITIVE_X+o,d=c.TEXTURE_CUBE_MAP),this._bindTextureDirectly(d,e,!0),c.texSubImage2D(g,h,i,s,r,n,f,u,t),l&&this._gl.generateMipmap(g),this._bindTextureDirectly(d,null)}_uploadArrayBufferViewToTexture(e,t,i=0,s=0){const r=this._gl,n=e.isCube?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D;this._bindTextureDirectly(n,e,!0),this._uploadDataToTextureDirectly(e,t,i,s),this._bindTextureDirectly(n,null,!0)}_prepareWebGLTextureContinuation(e,t,i,s,r){const n=this._gl;if(!n)return;const o=this._getSamplingParameters(r,!i);n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,o.mag),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,o.min),!i&&!s&&n.generateMipmap(n.TEXTURE_2D),this._bindTextureDirectly(n.TEXTURE_2D,null),t&&t.removePendingData(e),e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear()}_prepareWebGLTexture(e,t,i,s,r,n,o,h,l,c){const u=this.getCaps().maxTextureSize,f=Math.min(u,this.needPOTTextures?Vs(s.width,u):s.width),d=Math.min(u,this.needPOTTextures?Vs(s.height,u):s.height),g=this._gl;if(g){if(!e._hardwareTexture){i&&i.removePendingData(e);return}this._bindTextureDirectly(g.TEXTURE_2D,e,!0),this._unpackFlipY(r===void 0?!0:!!r),e.baseWidth=s.width,e.baseHeight=s.height,e.width=f,e.height=d,e.isReady=!0,e.type=e.type!==-1?e.type:0,e.format=e.format!==-1?e.format:c??(t===".jpg"&&!e._useSRGBBuffer?4:5),!h(f,d,s,t,e,()=>{this._prepareWebGLTextureContinuation(e,i,n,o,l)})&&this._prepareWebGLTextureContinuation(e,i,n,o,l)}}_getInternalFormatFromDepthTextureFormat(e,t,i){const s=this._gl;if(!t)return s.STENCIL_INDEX8;let n=i?s.DEPTH_STENCIL:s.DEPTH_COMPONENT;return this.webGLVersion>1?e===15?n=s.DEPTH_COMPONENT16:e===16?n=s.DEPTH_COMPONENT24:e===17||e===13?n=i?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24:e===14?n=s.DEPTH_COMPONENT32F:e===18&&(n=i?s.DEPTH32F_STENCIL8:s.DEPTH_COMPONENT32F):n=s.DEPTH_COMPONENT16,n}_getWebGLTextureTypeFromDepthTextureFormat(e){const t=this._gl;let i=t.UNSIGNED_INT;return e===15?i=t.UNSIGNED_SHORT:e===17||e===13?i=t.UNSIGNED_INT_24_8:e===14?i=t.FLOAT:e===18?i=t.FLOAT_32_UNSIGNED_INT_24_8_REV:e===19&&(i=t.UNSIGNED_BYTE),i}_setupFramebufferDepthAttachments(e,t,i,s,r=1,n,o=!1){const h=this._gl;n=n??(e?13:14);const l=this._getInternalFormatFromDepthTextureFormat(n,t,e);return e&&t?this._createRenderBuffer(i,s,r,h.DEPTH_STENCIL,l,o?-1:h.DEPTH_STENCIL_ATTACHMENT):t?this._createRenderBuffer(i,s,r,l,l,o?-1:h.DEPTH_ATTACHMENT):e?this._createRenderBuffer(i,s,r,l,l,o?-1:h.STENCIL_ATTACHMENT):null}_createRenderBuffer(e,t,i,s,r,n,o=!0){const l=this._gl.createRenderbuffer();return this._updateRenderBuffer(l,e,t,i,s,r,n,o)}_updateRenderBuffer(e,t,i,s,r,n,o,h=!0){const l=this._gl;return l.bindRenderbuffer(l.RENDERBUFFER,e),s>1&&l.renderbufferStorageMultisample?l.renderbufferStorageMultisample(l.RENDERBUFFER,s,n,t,i):l.renderbufferStorage(l.RENDERBUFFER,r,t,i),o!==-1&&l.framebufferRenderbuffer(l.FRAMEBUFFER,o,l.RENDERBUFFER,e),h&&l.bindRenderbuffer(l.RENDERBUFFER,null),e}_releaseTexture(e){this._deleteTexture(e._hardwareTexture),this.unbindAllTextures();const t=this._internalTexturesCache.indexOf(e);t!==-1&&this._internalTexturesCache.splice(t,1),e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureLow&&e._lodTextureLow.dispose(),e._irradianceTexture&&e._irradianceTexture.dispose()}_deleteTexture(e){e?.release()}_setProgram(e){this._currentProgram!==e&&(_c(e,this._gl),this._currentProgram=e)}bindSamplers(e){const t=e.getPipelineContext();this._setProgram(t.program);const i=e.getSamplers();for(let s=0;s<i.length;s++){const r=e.getUniform(i[s]);r&&(this._boundUniforms[s]=r)}this._currentEffect=null}_activateCurrentTexture(){this._currentTextureChannel!==this._activeChannel&&(this._gl.activeTexture(this._gl.TEXTURE0+this._activeChannel),this._currentTextureChannel=this._activeChannel)}_bindTextureDirectly(e,t,i=!1,s=!1){let r=!1;const n=t&&t._associatedChannel>-1;if(i&&n&&(this._activeChannel=t._associatedChannel),this._boundTexturesCache[this._activeChannel]!==t||s){if(this._activateCurrentTexture(),t&&t.isMultiview)throw w.Error(["_bindTextureDirectly called with a multiview texture!",e,t]),"_bindTextureDirectly called with a multiview texture!";this._gl.bindTexture(e,t?._hardwareTexture?.underlyingResource??null),this._boundTexturesCache[this._activeChannel]=t,t&&(t._associatedChannel=this._activeChannel)}else i&&(r=!0,this._activateCurrentTexture());return n&&!i&&this._bindSamplerUniformToChannel(t._associatedChannel,this._activeChannel),r}_bindTexture(e,t,i){if(e===void 0)return;t&&(t._associatedChannel=e),this._activeChannel=e;const s=t?this._getTextureTarget(t):this._gl.TEXTURE_2D;this._bindTextureDirectly(s,t)}unbindAllTextures(){for(let e=0;e<this._maxSimultaneousTextures;e++)this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.webGLVersion>1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))}setTexture(e,t,i,s){e!==void 0&&(t&&(this._boundUniforms[e]=t),this._setTexture(e,i))}_bindSamplerUniformToChannel(e,t){const i=this._boundUniforms[e];!i||i._currentState===t||(this._gl.uniform1i(i,t),i._currentState=t)}_getTextureWrapMode(e){switch(e){case 1:return this._gl.REPEAT;case 0:return this._gl.CLAMP_TO_EDGE;case 2:return this._gl.MIRRORED_REPEAT}return this._gl.REPEAT}_setTexture(e,t,i=!1,s=!1,r=""){if(!t)return this._boundTexturesCache[e]!=null&&(this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.webGLVersion>1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))),!1;if(t.video){this._activeChannel=e;const l=t.getInternalTexture();l&&(l._associatedChannel=e),t.update()}else if(t.delayLoadState===4)return t.delayLoad(),!1;let n;s?n=t.depthStencilTexture:t.isReady()?n=t.getInternalTexture():t.isCube?n=this.emptyCubeTexture:t.is3D?n=this.emptyTexture3D:t.is2DArray?n=this.emptyTexture2DArray:n=this.emptyTexture,!i&&n&&(n._associatedChannel=e);let o=!0;this._boundTexturesCache[e]===n&&(i||this._bindSamplerUniformToChannel(n._associatedChannel,e),o=!1),this._activeChannel=e;const h=this._getTextureTarget(n);if(o&&this._bindTextureDirectly(h,n,i),n&&!n.isMultiview){if(n.isCube&&n._cachedCoordinatesMode!==t.coordinatesMode){n._cachedCoordinatesMode=t.coordinatesMode;const l=t.coordinatesMode!==3&&t.coordinatesMode!==5?1:0;t.wrapU=l,t.wrapV=l}n._cachedWrapU!==t.wrapU&&(n._cachedWrapU=t.wrapU,this._setTextureParameterInteger(h,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t.wrapU),n)),n._cachedWrapV!==t.wrapV&&(n._cachedWrapV=t.wrapV,this._setTextureParameterInteger(h,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(t.wrapV),n)),n.is3D&&n._cachedWrapR!==t.wrapR&&(n._cachedWrapR=t.wrapR,this._setTextureParameterInteger(h,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(t.wrapR),n)),this._setAnisotropicLevel(h,n,t.anisotropicFilteringLevel)}return!0}setTextureArray(e,t,i,s){if(!(e===void 0||!t)){(!this._textureUnits||this._textureUnits.length!==i.length)&&(this._textureUnits=new Int32Array(i.length));for(let r=0;r<i.length;r++){const n=i[r].getInternalTexture();n?(this._textureUnits[r]=e+r,n._associatedChannel=e+r):this._textureUnits[r]=-1}this._gl.uniform1iv(t,this._textureUnits);for(let r=0;r<i.length;r++)this._setTexture(this._textureUnits[r],i[r],!0)}}_setAnisotropicLevel(e,t,i){const s=this._caps.textureAnisotropicFilterExtension;t.samplingMode!==11&&t.samplingMode!==3&&t.samplingMode!==2&&(i=1),s&&t._cachedAnisotropicFilteringLevel!==i&&(this._setTextureParameterFloat(e,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(i,this._caps.maxAnisotropy),t),t._cachedAnisotropicFilteringLevel=i)}_setTextureParameterFloat(e,t,i,s){this._bindTextureDirectly(e,s,!0,!0),this._gl.texParameterf(e,t,i)}_setTextureParameterInteger(e,t,i,s){s&&this._bindTextureDirectly(e,s,!0,!0),this._gl.texParameteri(e,t,i)}unbindAllAttributes(){if(this._mustWipeVertexAttributes){this._mustWipeVertexAttributes=!1;for(let e=0;e<this._caps.maxVertexAttribs;e++)this.disableAttributeByIndex(e);return}for(let e=0,t=this._vertexAttribArraysEnabled.length;e<t;e++)e>=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||this.disableAttributeByIndex(e)}releaseEffects(){this._compiledEffects={},this.onReleaseEffectsObservable.notifyObservers(this)}dispose(){_t()&&this._renderingCanvas&&(this._renderingCanvas.removeEventListener("webglcontextlost",this._onContextLost),this._onContextRestored&&this._renderingCanvas.removeEventListener("webglcontextrestored",this._onContextRestored)),super.dispose(),this._dummyFramebuffer&&this._gl.deleteFramebuffer(this._dummyFramebuffer),this.unbindAllAttributes(),this._boundUniforms={},this._workingCanvas=null,this._workingContext=null,this._currentBufferPointers.length=0,this._currentProgram=null,this._creationOptions.loseContextOnDispose&&this._gl.getExtension("WEBGL_lose_context")?.loseContext(),$r(this._gl)}attachContextLostEvent(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextlost",e,!1)}attachContextRestoredEvent(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)}getError(){return this._gl.getError()}_canRenderToFloatFramebuffer(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(1)}_canRenderToHalfFloatFramebuffer(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(2)}_canRenderToFramebuffer(e){const t=this._gl;for(;t.getError()!==t.NO_ERROR;);let i=!0;const s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s),t.texImage2D(t.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(e),1,1,0,t.RGBA,this._getWebGLTextureType(e),null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST);const r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0);const n=t.checkFramebufferStatus(t.FRAMEBUFFER);if(i=i&&n===t.FRAMEBUFFER_COMPLETE,i=i&&t.getError()===t.NO_ERROR,i&&(t.clear(t.COLOR_BUFFER_BIT),i=i&&t.getError()===t.NO_ERROR),i){t.bindFramebuffer(t.FRAMEBUFFER,null);const o=t.RGBA,h=t.UNSIGNED_BYTE,l=new Uint8Array(4);t.readPixels(0,0,1,1,o,h,l),i=i&&t.getError()===t.NO_ERROR}for(t.deleteTexture(s),t.deleteFramebuffer(r),t.bindFramebuffer(t.FRAMEBUFFER,null);!i&&t.getError()!==t.NO_ERROR;);return i}_getWebGLTextureType(e){if(this._webGLVersion===1){switch(e){case 1:return this._gl.FLOAT;case 2:return this._gl.HALF_FLOAT_OES;case 0:return this._gl.UNSIGNED_BYTE;case 8:return this._gl.UNSIGNED_SHORT_4_4_4_4;case 9:return this._gl.UNSIGNED_SHORT_5_5_5_1;case 10:return this._gl.UNSIGNED_SHORT_5_6_5}return this._gl.UNSIGNED_BYTE}switch(e){case 3:return this._gl.BYTE;case 0:return this._gl.UNSIGNED_BYTE;case 4:return this._gl.SHORT;case 5:return this._gl.UNSIGNED_SHORT;case 6:return this._gl.INT;case 7:return this._gl.UNSIGNED_INT;case 1:return this._gl.FLOAT;case 2:return this._gl.HALF_FLOAT;case 8:return this._gl.UNSIGNED_SHORT_4_4_4_4;case 9:return this._gl.UNSIGNED_SHORT_5_5_5_1;case 10:return this._gl.UNSIGNED_SHORT_5_6_5;case 11:return this._gl.UNSIGNED_INT_2_10_10_10_REV;case 12:return this._gl.UNSIGNED_INT_24_8;case 13:return this._gl.UNSIGNED_INT_10F_11F_11F_REV;case 14:return this._gl.UNSIGNED_INT_5_9_9_9_REV;case 15:return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV}return this._gl.UNSIGNED_BYTE}_getInternalFormat(e,t=!1){let i=t?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA;switch(e){case 0:i=this._gl.ALPHA;break;case 1:i=this._gl.LUMINANCE;break;case 2:i=this._gl.LUMINANCE_ALPHA;break;case 6:case 33322:case 36760:i=this._gl.RED;break;case 7:case 33324:case 36761:i=this._gl.RG;break;case 4:case 32852:case 36762:i=t?this._glSRGBExtensionValues.SRGB:this._gl.RGB;break;case 5:case 32859:case 36763:i=t?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA;break}if(this._webGLVersion>1)switch(e){case 8:i=this._gl.RED_INTEGER;break;case 9:i=this._gl.RG_INTEGER;break;case 10:i=this._gl.RGB_INTEGER;break;case 11:i=this._gl.RGBA_INTEGER;break}return i}_getRGBABufferInternalSizedFormat(e,t,i=!1){if(this._webGLVersion===1){if(t!==void 0)switch(t){case 0:return this._gl.ALPHA;case 1:return this._gl.LUMINANCE;case 2:return this._gl.LUMINANCE_ALPHA;case 4:return i?this._glSRGBExtensionValues.SRGB:this._gl.RGB}return this._gl.RGBA}switch(e){case 3:switch(t){case 6:return this._gl.R8_SNORM;case 7:return this._gl.RG8_SNORM;case 4:return this._gl.RGB8_SNORM;case 8:return this._gl.R8I;case 9:return this._gl.RG8I;case 10:return this._gl.RGB8I;case 11:return this._gl.RGBA8I;default:return this._gl.RGBA8_SNORM}case 0:switch(t){case 6:return this._gl.R8;case 7:return this._gl.RG8;case 4:return i?this._glSRGBExtensionValues.SRGB8:this._gl.RGB8;case 5:return i?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA8;case 8:return this._gl.R8UI;case 9:return this._gl.RG8UI;case 10:return this._gl.RGB8UI;case 11:return this._gl.RGBA8UI;case 0:return this._gl.ALPHA;case 1:return this._gl.LUMINANCE;case 2:return this._gl.LUMINANCE_ALPHA;default:return this._gl.RGBA8}case 4:switch(t){case 8:return this._gl.R16I;case 36760:return this._gl.R16_SNORM_EXT;case 36761:return this._gl.RG16_SNORM_EXT;case 36762:return this._gl.RGB16_SNORM_EXT;case 36763:return this._gl.RGBA16_SNORM_EXT;case 9:return this._gl.RG16I;case 10:return this._gl.RGB16I;case 11:return this._gl.RGBA16I;default:return this._gl.RGBA16I}case 5:switch(t){case 8:return this._gl.R16UI;case 33322:return this._gl.R16_EXT;case 33324:return this._gl.RG16_EXT;case 32852:return this._gl.RGB16_EXT;case 32859:return this._gl.RGBA16_EXT;case 9:return this._gl.RG16UI;case 10:return this._gl.RGB16UI;case 11:return this._gl.RGBA16UI;default:return this._gl.RGBA16UI}case 6:switch(t){case 8:return this._gl.R32I;case 9:return this._gl.RG32I;case 10:return this._gl.RGB32I;case 11:return this._gl.RGBA32I;default:return this._gl.RGBA32I}case 7:switch(t){case 8:return this._gl.R32UI;case 9:return this._gl.RG32UI;case 10:return this._gl.RGB32UI;case 11:return this._gl.RGBA32UI;default:return this._gl.RGBA32UI}case 1:switch(t){case 6:return this._gl.R32F;case 7:return this._gl.RG32F;case 4:return this._gl.RGB32F;case 5:return this._gl.RGBA32F;default:return this._gl.RGBA32F}case 2:switch(t){case 6:return this._gl.R16F;case 7:return this._gl.RG16F;case 4:return this._gl.RGB16F;case 5:return this._gl.RGBA16F;default:return this._gl.RGBA16F}case 10:return this._gl.RGB565;case 13:return this._gl.R11F_G11F_B10F;case 14:return this._gl.RGB9_E5;case 8:return this._gl.RGBA4;case 9:return this._gl.RGB5_A1;case 11:switch(t){case 5:return this._gl.RGB10_A2;case 11:return this._gl.RGB10_A2UI;default:return this._gl.RGB10_A2}}return i?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA8}readPixels(e,t,i,s,r=!0,n=!0,o=null){const h=r?4:3,l=r?this._gl.RGBA:this._gl.RGB,c=i*s*h;if(!o)o=new Uint8Array(c);else if(o.length<c)return w.Error(`Data buffer is too small to store the read pixels (${o.length} should be more than ${c})`),Promise.resolve(o);return n&&this.flushFramebuffer(),this._gl.readPixels(e,t,i,s,l,this._gl.UNSIGNED_BYTE,o),Promise.resolve(o)}static get IsSupportedAsync(){return Promise.resolve(this.isSupported())}static get IsSupported(){return this.isSupported()}static isSupported(){if(this._HasMajorPerformanceCaveat!==null)return!this._HasMajorPerformanceCaveat;if(this._IsSupported===null)try{const e=H._CreateCanvas(1,1),t=e.getContext("webgl")||e.getContext("experimental-webgl");this._IsSupported=t!=null&&!!globalThis.WebGLRenderingContext}catch{this._IsSupported=!1}return this._IsSupported}static get HasMajorPerformanceCaveat(){if(this._HasMajorPerformanceCaveat===null)try{const e=H._CreateCanvas(1,1),t=e.getContext("webgl",{failIfMajorPerformanceCaveat:!0})||e.getContext("experimental-webgl",{failIfMajorPerformanceCaveat:!0});this._HasMajorPerformanceCaveat=!t}catch{this._HasMajorPerformanceCaveat=!1}return this._HasMajorPerformanceCaveat}}he._TempClearColorUint32=new Uint32Array(4);he._TempClearColorInt32=new Int32Array(4);he.ExceptionList=[{key:"Chrome/63.0",capture:"63\\.0\\.3239\\.(\\d+)",captureConstraint:108,targets:["uniformBuffer"]},{key:"Firefox/58",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Firefox/59",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Chrome/72.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Chrome/73.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Chrome/74.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome/71",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome/72",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Chrome/12\\d\\..+?Mobile",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:".*AppleWebKit.*(15.4).*Safari",capture:null,captureConstraint:null,targets:["antialias","maxMSAASamples"]},{key:".*(15.4).*AppleWebKit.*Safari",capture:null,captureConstraint:null,targets:["antialias","maxMSAASamples"]}];he._ConcatenateShader=Io;he._IsSupported=null;he._HasMajorPerformanceCaveat=null;const x_=Object.freeze(Object.defineProperty({__proto__:null,ThinEngine:he},Symbol.toStringTag,{value:"Module"}));class nd{constructor(e=30){this._enabled=!0,this._rollingFrameTime=new ad(e)}sampleFrame(e=vt.Now){if(this._enabled){if(this._lastFrameTimeMs!=null){const t=e-this._lastFrameTimeMs;this._rollingFrameTime.add(t)}this._lastFrameTimeMs=e}}get averageFrameTime(){return this._rollingFrameTime.average}get averageFrameTimeVariance(){return this._rollingFrameTime.variance}get instantaneousFrameTime(){return this._rollingFrameTime.history(0)}get averageFPS(){return 1e3/this._rollingFrameTime.average}get instantaneousFPS(){const e=this._rollingFrameTime.history(0);return e===0?0:1e3/e}get isSaturated(){return this._rollingFrameTime.isSaturated()}enable(){this._enabled=!0}disable(){this._enabled=!1,this._lastFrameTimeMs=null}get isEnabled(){return this._enabled}reset(){this._lastFrameTimeMs=null,this._rollingFrameTime.reset()}}class ad{constructor(e){this._samples=new Array(e),this.reset()}add(e){let t;if(this.isSaturated()){const i=this._samples[this._pos];t=i-this.average,this.average-=t/(this._sampleCount-1),this._m2-=t*(i-this.average)}else this._sampleCount++;t=e-this.average,this.average+=t/this._sampleCount,this._m2+=t*(e-this.average),this.variance=this._m2/(this._sampleCount-1),this._samples[this._pos]=e,this._pos++,this._pos%=this._samples.length}history(e){if(e>=this._sampleCount||e>=this._samples.length)return 0;const t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]}isSaturated(){return this._sampleCount>=this._samples.length}reset(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0}_wrapPosition(e){const t=this._samples.length;return(e%t+t)%t}}he.prototype.setAlphaMode=function(a,e=!1,t=0){if(this._alphaMode[t]===a){if(!e){const s=a===0;this.depthCullingState.depthMask!==s&&(this.depthCullingState.depthMask=s)}return}const i=a===0;this._alphaState.setAlphaBlend(!i,t),this._alphaState.setAlphaMode(a,t),e||(this.depthCullingState.depthMask=i),this._alphaMode[t]=a};he.prototype.updateRawTexture=function(a,e,t,i,s=null,r=0,n=!1){if(!a)return;const o=this._getRGBABufferInternalSizedFormat(r,t,n),h=this._getInternalFormat(t),l=this._getWebGLTextureType(r);this._bindTextureDirectly(this._gl.TEXTURE_2D,a,!0),this._unpackFlipY(i===void 0?!0:!!i),this._doNotHandleContextLost||(a._bufferView=e,a.format=t,a.type=r,a.invertY=i,a._compression=s),a.width%4!==0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),s&&e?this._gl.compressedTexImage2D(this._gl.TEXTURE_2D,0,this.getCaps().s3tc[s],a.width,a.height,0,e):this._gl.texImage2D(this._gl.TEXTURE_2D,0,o,a.width,a.height,0,h,l,e),a.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),a.isReady=!0};he.prototype.createRawTexture=function(a,e,t,i,s,r,n,o=null,h=0,l=0,c=!1){const u=new Et(this,3);u.baseWidth=e,u.baseHeight=t,u.width=e,u.height=t,u.format=i,u.generateMipMaps=s,u.samplingMode=n,u.invertY=r,u._compression=o,u.type=h,u._useSRGBBuffer=this._getUseSRGBBuffer(c,!s),this._doNotHandleContextLost||(u._bufferView=a),this.updateRawTexture(u,a,i,r,o,h,u._useSRGBBuffer),this._bindTextureDirectly(this._gl.TEXTURE_2D,u,!0);const f=this._getSamplingParameters(n,s);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,f.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,f.min),s&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._internalTexturesCache.push(u),u};he.prototype.createRawCubeTexture=function(a,e,t,i,s,r,n,o=null){const h=this._gl,l=new Et(this,8);l.isCube=!0,l.format=t,l.type=i,this._doNotHandleContextLost||(l._bufferViewArray=a);const c=this._getWebGLTextureType(i);let u=this._getInternalFormat(t);u===h.RGB&&(u=h.RGBA),c===h.FLOAT&&!this._caps.textureFloatLinearFiltering?(s=!1,n=1,w.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to fal
48se and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):c===this._gl.HALF_FLOAT_OES&&!this._caps.textureHalfFloatLinearFiltering?(s=!1,n=1,w.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):c===h.FLOAT&&!this._caps.textureFloatRender?(s=!1,w.Warn("Render to float textures is not supported. Mipmap generation forced to false.")):c===h.HALF_FLOAT&&!this._caps.colorBufferFloat&&(s=!1,w.Warn("Render to half float textures is not supported. Mipmap generation forced to false."));const f=e,d=f;if(l.width=f,l.height=d,l.invertY=r,l._compression=o,!this.needPOTTextures||Hs(l.width)&&Hs(l.height)||(s=!1),a)this.updateRawCubeTexture(l,a,t,i,r,o);else{const m=this._getRGBABufferInternalSizedFormat(i),A=0;this._bindTextureDirectly(h.TEXTURE_CUBE_MAP,l,!0);for(let E=0;E<6;E++)o?h.compressedTexImage2D(h.TEXTURE_CUBE_MAP_POSITIVE_X+E,A,this.getCaps().s3tc[o],l.width,l.height,0,void 0):h.texImage2D(h.TEXTURE_CUBE_MAP_POSITIVE_X+E,A,m,l.width,l.height,0,u,c,null);this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)}this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,l,!0),a&&s&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);const p=this._getSamplingParameters(n,s);return h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MAG_FILTER,p.mag),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MIN_FILTER,p.min),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),this._bindTextureDirectly(h.TEXTURE_CUBE_MAP,null),l.generateMipMaps=s,l.samplingMode=n,l.isReady=!0,l};he.prototype.updateRawCubeTexture=function(a,e,t,i,s,r=null,n=0){a._bufferViewArray=e,a.format=t,a.type=i,a.invertY=s,a._compression=r;const o=this._gl,h=this._getWebGLTextureType(i);let l=this._getInternalFormat(t);const c=this._getRGBABufferInternalSizedFormat(i);let u=!1;l===o.RGB&&(l=o.RGBA,u=!0),this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,a,!0),this._unpackFlipY(s===void 0?!0:!!s),a.width%4!==0&&o.pixelStorei(o.UNPACK_ALIGNMENT,1);for(let d=0;d<6;d++){let g=e[d];r?o.compressedTexImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+d,n,this.getCaps().s3tc[r],a.width,a.height,0,g):(u&&(g=Lh(g,a.width,a.height,i)),o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+d,n,c,a.width,a.height,0,l,h,g))}(!this.needPOTTextures||Hs(a.width)&&Hs(a.height))&&a.generateMipMaps&&n===0&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),a.isReady=!0};he.prototype.createRawCubeTextureFromUrl=function(a,e,t,i,s,r,n,o,h=null,l=null,c=3,u=!1){const f=this._gl,d=this.createRawCubeTexture(null,t,i,s,!r,u,c,null);e?.addPendingData(d),d.url=a,d.isReady=!1,this._internalTexturesCache.push(d);const g=(m,A)=>{e?.removePendingData(d),l&&m&&l(m.status+" "+m.statusText,A)},p=async m=>{if(!d._hardwareTexture)return;const A=n(m);if(!A)return;const E=A instanceof Promise?await A:A,I=d.width;if(o){const M=this._getWebGLTextureType(s);let C=this._getInternalFormat(i);const x=this._getRGBABufferInternalSizedFormat(s);let S=!1;C===f.RGB&&(C=f.RGBA,S=!0),this._bindTextureDirectly(f.TEXTURE_CUBE_MAP,d,!0),this._unpackFlipY(!1);const L=o(E);for(let N=0;N<L.length;N++){const D=I>>N;for(let Re=0;Re<6;Re++){let pe=L[N][Re];S&&(pe=Lh(pe,D,D,s)),f.texImage2D(Re,N,x,D,D,0,C,M,pe)}}this._bindTextureDirectly(f.TEXTURE_CUBE_MAP,null)}else this.updateRawCubeTexture(d,E,i,s,u);d.isReady=!0,e?.removePendingData(d),d.onLoadedObservable.notifyObservers(d),d.onLoadedObservable.clear(),h&&h()};return this._loadFile(a,m=>{p(m).catch(A=>{g(void 0,A)})},void 0,e?.offlineProvider,!0,g),d};function Lh(a,e,t,i){let s,r=1;i===1?s=new Float32Array(e*t*4):i===2?(s=new Uint16Array(e*t*4),r=15360):i===7?s=new Uint32Array(e*t*4):s=new Uint8Array(e*t*4);for(let n=0;n<e;n++)for(let o=0;o<t;o++){const h=(o*e+n)*3,l=(o*e+n)*4;s[l+0]=a[h+0],s[l+1]=a[h+1],s[l+2]=a[h+2],s[l+3]=r}return s}function Bh(a){return function(e,t,i,s,r,n,o,h,l=null,c=0){const u=a?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D_ARRAY,f=a?10:11,d=new Et(this,f);d.baseWidth=t,d.baseHeight=i,d.baseDepth=s,d.width=t,d.height=i,d.depth=s,d.format=r,d.t
vendor: 35,018 bytes, line 48
48ype=c,d.generateMipMaps=n,d.samplingMode=h,a?d.is3D=!0:d.is2DArray=!0,this._doNotHandleContextLost||(d._bufferView=e),a?this.updateRawTexture3D(d,e,r,o,l,c):this.updateRawTexture2DArray(d,e,r,o,l,c),this._bindTextureDirectly(u,d,!0);const g=this._getSamplingParameters(h,n);return this._gl.texParameteri(u,this._gl.TEXTURE_MAG_FILTER,g.mag),this._gl.texParameteri(u,this._gl.TEXTURE_MIN_FILTER,g.min),n&&this._gl.generateMipmap(u),this._bindTextureDirectly(u,null),this._internalTexturesCache.push(d),d}}he.prototype.createRawTexture2DArray=Bh(!1);he.prototype.createRawTexture3D=Bh(!0);function Nh(a){return function(e,t,i,s,r=null,n=0){const o=a?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D_ARRAY,h=this._getWebGLTextureType(n),l=this._getInternalFormat(i),c=this._getRGBABufferInternalSizedFormat(n,i);this._bindTextureDirectly(o,e,!0),this._unpackFlipY(s===void 0?!0:!!s),this._doNotHandleContextLost||(e._bufferView=t,e.format=i,e.invertY=s,e._compression=r),e.width%4!==0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),r&&t?this._gl.compressedTexImage3D(o,0,this.getCaps().s3tc[r],e.width,e.height,e.depth,0,t):this._gl.texImage3D(o,0,c,e.width,e.height,e.depth,0,l,h,t),e.generateMipMaps&&this._gl.generateMipmap(o),this._bindTextureDirectly(o,null),e.isReady=!0}}he.prototype.updateRawTexture2DArray=Nh(!1);he.prototype.updateRawTexture3D=Nh(!0);he.prototype._readTexturePixelsSync=function(a,e,t,i=-1,s=0,r=null,n=!0,o=!1,h=0,l=0){const c=this._gl;if(!c)throw new Error("Engine does not have gl rendering context.");if(!this._dummyFramebuffer){const f=c.createFramebuffer();if(!f)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=f}c.bindFramebuffer(c.FRAMEBUFFER,this._dummyFramebuffer),i>-1?c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_CUBE_MAP_POSITIVE_X+i,a._hardwareTexture?.underlyingResource,s):c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,a._hardwareTexture?.underlyingResource,s);let u=a.type!==void 0?this._getWebGLTextureType(a.type):c.UNSIGNED_BYTE;return o?r||(r=Zl(a.type,4*e*t)):u===c.UNSIGNED_BYTE?(r||(r=new Uint8Array(4*e*t)),u=c.UNSIGNED_BYTE):(r||(r=new Float32Array(4*e*t)),u=c.FLOAT),n&&this.flushFramebuffer(),c.readPixels(h,l,e,t,c.RGBA,u,r),c.bindFramebuffer(c.FRAMEBUFFER,this._currentFramebuffer),r};he.prototype._readTexturePixels=function(a,e,t,i=-1,s=0,r=null,n=!0,o=!1,h=0,l=0){return Promise.resolve(this._readTexturePixelsSync(a,e,t,i,s,r,n,o,h,l))};he.prototype.updateDynamicIndexBuffer=function(a,e,t=0){this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER]=null,this.bindIndexBuffer(a);let i;a.is32Bits?i=e instanceof Uint32Array?e:new Uint32Array(e):i=e instanceof Uint16Array?e:new Uint16Array(e),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,i,this._gl.DYNAMIC_DRAW),this._resetIndexBufferBinding()};he.prototype.updateDynamicVertexBuffer=function(a,e,t,i){this.bindArrayBuffer(a),t===void 0&&(t=0);const s=e.byteLength||e.length;i===void 0||i>=s&&t===0?e instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,t,new Float32Array(e)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,t,e):e instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,t,new Float32Array(e).subarray(0,i/4)):(e instanceof ArrayBuffer?e=new Uint8Array(e,0,i):e=new Uint8Array(e.buffer,e.byteOffset,i),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,t,e)),this._resetVertexBufferBinding()};he.prototype._createDepthStencilCubeTexture=function(a,e){const t=new Et(this,12);if(t.isCube=!0,this.webGLVersion===1)return w.Error("Depth cube texture is not supported by WebGL 1."),t;const i={bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,...e},s=this._gl;this._bindTextureDirectly(s.TEXTURE_CUBE_MAP,t,!0),this._setupDepthStencilTexture(t,a,i.bilinearFiltering,i.comparisonFunction);for(let r=0;r<6;r++)i.generateStencil?s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,s.DEPTH24_STENCIL8,a,a,0,s.DEPTH_STENCIL,s.UNSIGNED_INT_24_8,null):s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,s.DEPTH_COMPONENT24,a,a,0,s.DEPTH_COMPONENT,s.UNSIGNED_INT,null);return this._bindTextureDirectly(s.TEXTURE_CUBE_MAP,null),this._internalTexturesCache.push(t),t};he.prototype._setCubeMapTextureParams=function(a,e,t){const i=this._gl;i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MIN_FILTER,e?i.LINEAR_MIPMAP_LINEAR:i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),a.samplingMode=e?3:2,e&&this.getCaps().textureMaxLevel&&t!==void 0&&t>0&&(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_LEVEL,t),a._maxLodLevel=t),this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,null)};he.prototype.createCubeTexture=function(a,e,t,i,s=null,r=null,n,o=null,h=!1,l=0,c=0,u=null,f,d=!1,g=null){const p=this._gl;return this.createCubeTextureBase(a,e,t,!!i,s,r,n,o,h,l,c,u,m=>this._bindTextureDirectly(p.TEXTURE_CUBE_MAP,m,!0),(m,A)=>{const E=this.needPOTTextures?Vs(A[0].width,this._caps.maxCubemapTextureSize):A[0].width,I=E,M=[p.TEXTURE_CUBE_MAP_POSITIVE_X,p.TEXTURE_CUBE_MAP_POSITIVE_Y,p.TEXTURE_CUBE_MAP_POSITIVE_Z,p.TEXTURE_CUBE_MAP_NEGATIVE_X,p.TEXTURE_CUBE_MAP_NEGATIVE_Y,p.TEXTURE_CUBE_MAP_NEGATIVE_Z];this._bindTextureDirectly(p.TEXTURE_CUBE_MAP,m,!0),this._unpackFlipY(!1);const C=n?this._getInternalFormat(n,m._useSRGBBuffer):m._useSRGBBuffer?this._glSRGBExtensionValues.SRGB8_ALPHA8:p.RGBA;let x=n?this._getInternalFormat(n):p.RGBA;m._useSRGBBuffer&&this.webGLVersion===1&&(x=C);for(let S=0;S<M.length;S++)if(A[S].width!==E||A[S].height!==I){if(this._prepareWorkingCanvas(),!this._workingCanvas||!this._workingContext){w.Warn("Cannot create canvas to resize texture.");return}this._workingCanvas.width=E,this._workingCanvas.height=I,this._workingContext.drawImage(A[S],0,0,A[S].width,A[S].height,0,0,E,I),p.texImage2D(M[S],0,C,x,p.UNSIGNED_BYTE,this._workingCanvas)}else p.texImage2D(M[S],0,C,x,p.UNSIGNED_BYTE,A[S]);i||p.generateMipmap(p.TEXTURE_CUBE_MAP),this._setCubeMapTextureParams(m,!i),m.width=E,m.height=I,m.isReady=!0,n&&(m.format=n),m.onLoadedObservable.notifyObservers(m),m.onLoadedObservable.clear(),s&&s()},!!d,g)};he.prototype.generateMipMapsForCubemap=function(a,e=!0){if(a.generateMipMaps){const t=this._gl;this._bindTextureDirectly(t.TEXTURE_CUBE_MAP,a,!0),t.generateMipmap(t.TEXTURE_CUBE_MAP),e&&this._bindTextureDirectly(t.TEXTURE_CUBE_MAP,null)}};class od{get depthStencilTexture(){return this._depthStencilTexture}setDepthStencilTexture(e,t=!0){t&&this._depthStencilTexture&&this._depthStencilTexture.dispose(),this._depthStencilTexture=e,this._generateDepthBuffer=this._generateStencilBuffer=this._depthStencilTextureWithStencil=!1,e&&(this._generateDepthBuffer=!0,this._generateStencilBuffer=this._depthStencilTextureWithStencil=bs(e.format))}get depthStencilTextureWithStencil(){return this._depthStencilTextureWithStencil}get isCube(){return this._isCube}get isMulti(){return this._isMulti}get is2DArray(){return this.layers>0}get is3D(){return this.depth>0}get size(){return this.width}get width(){return this._size.width??this._size}get height(){return this._size.height??this._size}get layers(){return this._size.layers||0}get depth(){return this._size.depth||0}get texture(){return this._textures?.[0]??null}get textures(){return this._textures}get faceIndices(){return this._faceIndices}get layerIndices(){return this._layerIndices}getBaseArrayLayer(e){if(!this._textures)return-1;const t=this._textures[e],i=this._layerIndices?.[e]??0,s=this._faceIndices?.[e]??0;return t.isCube?i*6+s:t.is3D?0:i}get samples(){return this._samples}setSamples(e,t=!0,i=!1){if(this.samples===e&&!i)return e;const s=this._isMulti?this._engine.updateMultipleRenderTargetTextureSampleCount(this,e,t):this._engine.updateRenderTargetTextureSampleCount(this,e);return this._samples=e,s}resolveMSAATextures(){this.isMulti?this._engine.resolveMultiFramebuffer(this):this._engine.resolveFramebuffer(this)}generateMipMaps(){this._engine._currentRenderTarget===this&&(this.isMulti?this._engine.unBindMultiColorAttachmentFramebuffer(this,!0):this._engine.unBindFramebuffer(this,!0)),this.isMulti?this._engine.generateMipMapsMultiFramebuffer(this):this._engine.generateMipMapsFramebuffer(this)}constructor(e,t,i,s,r){this._textures=null,this._faceIndices=null,this._layerIndices=null,this._samples=1,this._attachments=null,this._generateStencilBuffer=!1,this._generateDepthBuffer=!1,this._depthStencilTextureWithStencil=!1,this.disableAutomaticMSAAResolve=!1,this.resolveMSAAColors=!0,this.resolveMSAADepth=!1,this.resolveMSAAStencil=!1,this.depthReadOnly=!1,this.stencilReadOnly=!1,this._isMulti=e,this._isCube=t,this._size=i,this._engine=s,this._depthStencilTexture=null,this.label=r}setTextures(e){Array.isArray(e)?this._textures=e:e?this._textures=[e]:this._textures=null}setTexture(e,t=0,i=!0){this._textures||(this._textures=[]),this._textures[t]!==e&&(this._textures[t]&&i&&this._textures[t].dispose(),this._textures[t]=e)}setLayerAndFaceIndices(e,t){this._layerIndices=e,this._faceIndices=t}setLayerAndFaceIndex(e=0,t,i){this._layerIndices||(this._layerIndices=[]),this._faceIndices||(this._faceIndices=[]),t!==void 0&&t>=0&&(this._layerIndices[e]=t),i!==void 0&&i>=0&&(this._faceIndices[e]=i)}createDepthStencilTexture(e=0,t=!0,i=!1,s=1,r=14,n){return this._depthStencilTexture?.dispose(),this._depthStencilTextureWithStencil=i,this._depthStencilTextureLabel=n,this._depthStencilTexture=this._engine.createDepthStencilTexture(this._size,{bilinearFiltering:t,comparisonFunction:e,generateStencil:i,isCube:this._isCube,samples:s,depthTextureFormat:r,label:n},this),this._depthStencilTexture}_shareDepth(e){this.shareDepth(e)}shareDepth(e){this._depthStencilTexture&&(e._depthStencilTexture&&e._depthStencilTexture.dispose(),e._depthStencilTexture=this._depthStencilTexture,e._depthStencilTextureWithStencil=this._depthStencilTextureWithStencil,this._depthStencilTexture.incrementReferences())}_swapAndDie(e){this.texture&&this.texture._swapAndDie(e),this._textures=null,this.dispose(!0)}_cloneRenderTargetWrapper(){let e=null;if(this._isMulti){const t=this.textures;if(t&&t.length>0){let i=!1,s=t.length,r=-1;const n=t[t.length-1]._source;(n===14||n===12)&&(i=!0,r=t[t.length-1].format,s--);const o=[],h=[],l=[],c=[],u=[],f=[],d=[],g={};for(let A=0;A<s;++A){const E=t[A];o.push(E.samplingMode),h.push(E.type),l.push(E.format),g[E.uniqueId]!==void 0?(c.push(-1),d.push(0)):(g[E.uniqueId]=A,E.is2DArray?(c.push(35866),d.push(E.depth)):E.isCube?(c.push(34067),d.push(0)):E.is3D?(c.push(32879),d.push(E.depth)):(c.push(3553),d.push(0))),this._faceIndices&&u.push(this._faceIndices[A]??0),this._layerIndices&&f.push(this._layerIndices[A]??0)}const p={samplingModes:o,generateMipMaps:t[0].generateMipMaps,generateDepthBuffer:this._generateDepthBuffer,generateStencilBuffer:this._generateStencilBuffer,generateDepthTexture:i,depthTextureFormat:r,types:h,formats:l,textureCount:s,targetTypes:c,faceIndex:u,layerIndex:f,layerCounts:d,label:this.label},m={width:this.width,height:this.height,depth:this.depth};e=this._engine.createMultipleRenderTarget(m,p);for(let A=0;A<s;++A){if(c[A]!==-1)continue;const E=g[t[A].uniqueId];e.setTexture(e.textures[E],A)}}}else{const t={};if(t.generateDepthBuffer=this._generateDepthBuffer,t.generateMipMaps=this.texture?.generateMipMaps??!1,t.generateStencilBuffer=this._generateStencilBuffer,t.samplingMode=this.texture?.samplingMode,t.type=this.texture?.type,t.format=this.texture?.format,t.noColorAttachment=!this._textures,t.label=this.label,this.isCube)e=this._engine.createRenderTargetCubeTexture(this.width,t);else{const i={width:this.width,height:this.height,layers:this.is2DArray||this.is3D?this.texture?.depth:void 0};e=this._engine.createRenderTargetTexture(i,t)}e.texture&&(e.texture.isReady=!0)}return e}_swapRenderTargetWrapper(e){if(this._textures&&e._textures)for(let t=0;t<this._textures.length;++t)this._textures[t]._swapAndDie(e._textures[t],!1),e._textures[t].isReady=!0;this._depthStencilTexture&&e._depthStencilTexture&&(this._depthStencilTexture._swapAndDie(e._depthStencilTexture),e._depthStencilTexture.isReady=!0),this._textures=null,this._depthStencilTexture=null}_rebuild(){const e=this._cloneRenderTargetWrapper();if(e){if(this._depthStencilTexture){const t=this._depthStencilTexture.samplingMode,i=this._depthStencilTexture.format,s=t===2||t===3||t===11;e.createDepthStencilTexture(this._depthStencilTexture._comparisonFunction,s,this._depthStencilTextureWithStencil,this._depthStencilTexture.samples,i,this._depthStencilTextureLabel)}this.samples>1&&e.setSamples(this.samples),e._swapRenderTargetWrapper(this),e.dispose()}}releaseTextures(){if(this._textures)for(let e=0;e<this._textures.length;++e)this._textures[e].dispose();this._textures=null}dispose(e=!1){e||(this._depthStencilTexture?.dispose(),this._depthStencilTexture=null,this.releaseTextures()),this._engine._releaseRenderTargetWrapper(this)}}class hd extends od{setDepthStencilTexture(e,t=!0){if(super.setDepthStencilTexture(e,t),!e)return;const i=this._engine,s=this._context,r=e._hardwareTexture;if(r&&e._autoMSAAManagement&&this._MSAAFramebuffer){const n=i._currentFramebuffer;i._bindUnboundFramebuffer(this._MSAAFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,bs(e.format)?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,s.RENDERBUFFER,r.getMSAARenderBuffer()),i._bindUnboundFramebuffer(n)}}constructor(e,t,i,s,r){super(e,t,i,s),this._framebuffer=null,this._depthStencilBuffer=null,this._MSAAFramebuffer=null,this._colorTextureArray=null,this._depthStencilTextureArray=null,this._disposeOnlyFramebuffers=!1,this._currentLOD=0,this._context=r}_cloneRenderTargetWrapper(){let e=null;return this._colorTextureArray&&this._depthStencilTextureArray?(e=this._engine.createMultiviewRenderTargetTexture(this.width,this.height),e.texture.isReady=!0):e=super._cloneRenderTargetWrapper(),e}_swapRenderTargetWrapper(e){super._swapRenderTargetWrapper(e),e._framebuffer=this._framebuffer,e._depthStencilBuffer=this._depthStencilBuffer,e._MSAAFramebuffer=this._MSAAFramebuffer,e._colorTextureArray=this._colorTextureArray,e._depthStencilTextureArray=this._depthStencilTextureArray,this._framebuffer=this._depthStencilBuffer=this._MSAAFramebuffer=this._colorTextureArray=this._depthStencilTextureArray=null}createDepthStencilTexture(e=0,t=!0,i=!1,s=1,r=14,n){if(this._depthStencilBuffer){const o=this._engine,h=o._currentFramebuffer,l=this._context;o._bindUnboundFramebuffer(this._framebuffer),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_STENCIL_ATTACHMENT,l.RENDERBUFFER,null),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_ATTACHMENT,l.RENDERBUFFER,null),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.STENCIL_ATTACHMENT,l.RENDERBUFFER,null),o._bindUnboundFramebuffer(h),l.deleteRenderbuffer(this._depthStencilBuffer),this._depthStencilBuffer=null}return super.createDepthStencilTexture(e,t,i,s,r,n)}shareDepth(e){super.shareDepth(e);const t=this._context,i=this._depthStencilBuffer,s=e._MSAAFramebuffer||e._framebuffer,r=this._engine;e._depthStencilBuffer&&e._depthStencilBuffer!==i&&t.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=i;const n=e._generateStencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;r._bindUnboundFramebuffer(s),t.framebufferRenderbuffer(t.FRAMEBUFFER,n,t.RENDERBUFFER,i),r._bindUnboundFramebuffer(null)}_bindTextureRenderTarget(e,t=0,i,s=0){const r=e._hardwareTexture;if(!r)return;const n=this._framebuffer,o=this._engine,h=o._currentFramebuffer;o._bindUnboundFramebuffer(n);let l;if(o.webGLVersion>1){const c=this._context;l=c["COLOR_ATTACHMENT"+t],e.is2DArray||e.is3D?(i=i??this.layerIndices?.[t]??0,c.framebufferTextureLayer(c.FRAMEBUFFER,l,r.underlyingResource,s,i)):e.isCube?(i=i??this.faceIndices?.[t]??0,c.framebufferTexture2D(c.FRAMEBUFFER,l,c.TEXTURE_CUBE_MAP_POSITIVE_X+i,r.underlyingResource,s)):c.framebufferTexture2D(c.FRAMEBUFFER,l,c.TEXTURE_2D,r.underlyingResource,s)}else{const c=this._context;l=c["COLOR_ATTACHMENT"+t+"_WEBGL"];const u=i!==void 0?c.TEXTURE_CUBE_MAP_POSITIVE_X+i:c.TEXTURE_2D;c.framebufferTexture2D(c.FRAMEBUFFER,l,u,r.underlyingResource,s)}if(e._autoMSAAManagement&&this._MSAAFramebuffer){const c=this._context;o._bindUnboundFramebuffer(this._MSAAFramebuffer),c.framebufferRenderbuffer(c.FRAMEBUFFER,l,c.RENDERBUFFER,r.getMSAARenderBuffer())}o._bindUnboundFramebuffer(h)}setTexture(e,t=0,i=!0){super.setTexture(e,t,i),this._bindTextureRenderTarget(e,t)}setLayerAndFaceIndices(e,t){if(super.setLayerAndFaceIndices(e,t),!this.textures||!this.layerIndices||!this.faceIndices)return;const i=this._attachments?.length??this.textures.length;for(let s=0;s<i;s++){const r=this.textures[s];r&&(r.is2DArray||r.is3D?this._bindTextureRenderTarget(r,s,this.layerIndices[s]):r.isCube?this._bindTextureRenderTarget(r,s,this.faceIndices[s]):this._bindTextureRenderTarget(r,s))}}setLayerAndFaceIndex(e=0,t,i){if(super.setLayerAndFaceIndex(e,t,i),!this.textures||!this.layerIndices||!this.faceIndices)return;const s=this.textures[e];s.is2DArray||s.is3D?this._bindTextureRenderTarget(this.textures[e],e,this.layerIndices[e]):s.isCube&&this._bindTextureRenderTarget(this.textures[e],e,this.faceIndices[e])}resolveMSAATextures(){const e=this._engine,t=e._currentFramebuffer;e._bindUnboundFramebuffer(this._MSAAFramebuffer),super.resolveMSAATextures(),e._bindUnboundFramebuffer(t)}dispose(e=this._disposeOnlyFramebuffers){const t=this._context;e||(this._colorTextureArray&&(this._context.deleteTexture(this._colorTextureArray),this._colorTextureArray=null),this._depthStencilTextureArray&&(this._context.deleteTexture(this._depthStencilTextureArray),this._depthStencilTextureArray=null)),this._framebuffer&&(t.deleteFramebuffer(this._framebuffer),this._framebuffer=null),this._depthStencilBuffer&&(t.deleteRenderbuffer(this._depthStencilBuffer),this._depthStencilBuffer=null),this._MSAAFramebuffer&&(t.deleteFramebuffer(this._MSAAFramebuffer),this._MSAAFramebuffer=null),super.dispose(e)}}H.prototype.createDepthStencilTexture=function(a,e,t){if(e.isCube){const i=a.width||a;return this._createDepthStencilCubeTexture(i,e)}else return this._createDepthStencilTexture(a,e,t)};he.prototype._createHardwareRenderTargetWrapper=function(a,e,t){const i=new hd(a,e,t,this,this._gl);return this._renderTargetWrapperCache.push(i),i};he.prototype.createRenderTargetTexture=function(a,e){const t=this._createHardwareRenderTargetWrapper(!1,!1,a);let i=!0,s=!1,r=!1,n,o=1,h;e!==void 0&&typeof e=="object"&&(i=e.generateDepthBuffer??!0,s=!!e.generateStencilBuffer,r=!!e.noColorAttachment,n=e.colorAttachment,o=e.samples??1,h=e.label);const l=n||(r?null:this._createInternalTexture(a,e,!0,5)),c=a.width||a,u=a.height||a,f=this._currentFramebuffer,d=this._gl,g=d.createFramebuffer();if(this._bindUnboundFramebuffer(g),t._depthStencilBuffer=this._setupFramebufferDepthAttachments(s,i,c,u),l&&!l.is2DArray&&!l.is3D&&d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,l._hardwareTexture.underlyingResource,0),this._bindUnboundFramebuffer(f),t.label=h??"RenderTargetWrapper",t._framebuffer=g,t._generateDepthBuffer=i,t._generateStencilBuffer=s,t.setTextures(l),!n)this.updateRenderTargetTextureSampleCount(t,o);else if(t._samples=n.samples,n.samples>1){const p=n._hardwareTexture.getMSAARenderBuffer(0);t._MSAAFramebuffer=d.createFramebuffer(),this._bindUnboundFramebuffer(t._MSAAFramebuffer),d.framebufferRenderbuffer(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.RENDERBUFFER,p),this._bindUnboundFramebuffer(null)}return t};he.prototype._createDepthStencilTexture=function(a,e,t){const i=this._gl,s=a.layers||0,r=a.depth||0;let n=i.TEXTURE_2D;s!==0?n=i.TEXTURE_2D_ARRAY:r!==0&&(n=i.TEXTURE_3D);const o=new Et(this,12);if(o.label=e.label,!this._caps.depthTextureExtension)return w.Error("Depth texture is not supported by your browser or hardware."),o;const h={bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,...e};if(this._bindTextureDirectly(n,o,!0),this._setupDepthStencilTexture(o,a,h.comparisonFunction===0?!1:h.bilinearFiltering,h.comparisonFunction,h.samples),h.depthTextureFormat!==void 0){if(h.depthTextureFormat!==15&&h.depthTextureFormat!==16&&h.depthTextureFormat!==17&&h.depthTextureFormat!==13&&h.depthTextureFormat!==14&&h.depthTextureFormat!==18)return w.Error(`Depth texture ${h.depthTextureFormat} format is not supported.`),o;o.format=h.depthTextureFormat}else o.format=h.generateStencil?13:16;const l=bs(o.format),c=this._getWebGLTextureTypeFromDepthTextureFormat(o.format),u=l?i.DEPTH_STENCIL:i.DEPTH_COMPONENT,f=this._getInternalFormatFromDepthTextureFormat(o.format,!0,l);return o.is2DArray?i.texImage3D(n,0,f,o.width,o.height,s,0,u,c,null):o.is3D?i.texImage3D(n,0,f,o.width,o.height,r,0,u,c,null):i.texImage2D(n,0,f,o.width,o.height,0,u,c,null),this._bindTextureDirectly(n,null),this._internalTexturesCache.push(o),t._depthStencilBuffer&&(i.deleteRenderbuffer(t._depthStencilBuffer),t._depthStencilBuffer=null),this._bindUnboundFramebuffer(t._MSAAFramebuffer??t._framebuffer),t._generateStencilBuffer=l,t._depthStencilTextureWithStencil=l,t._depthStencilBuffer=this._setupFramebufferDepthAttachments(t._generateStencilBuffer,t._generateDepthBuffer,t.width,t.height,t.samples,o.format),this._bindUnboundFramebuffer(null),o};he.prototype.updateRenderTargetTextureSampleCount=function(a,e){if(this.webGLVersion<2||!a)return 1;if(a.samples===e)return e;const t=this._gl;e=Math.min(e,this.getCaps().maxMSAASamples),a._depthStencilBuffer&&(t.deleteRenderbuffer(a._depthStencilBuffer),a._depthStencilBuffer=null),a._MSAAFramebuffer&&(t.deleteFramebuffer(a._MSAAFramebuffer),a._MSAAFramebuffer=null);const i=a.texture?._hardwareTexture;if(i?.releaseMSAARenderBuffers(),a.texture&&e>1&&typeof t.renderbufferStorageMultisample=="function"){const r=t.createFramebuffer();if(!r)throw new Error("Unable to create multi sampled framebuffer");a._MSAAFramebuffer=r,this._bindUnboundFramebuffer(a._MSAAFramebuffer);const n=this._createRenderBuffer(a.texture.width,a.texture.height,e,-1,this._getRGBABufferInternalSizedFormat(a.texture.type,a.texture.format,a.texture._useSRGBBuffer),t.COLOR_ATTACHMENT0,!1);if(!n)throw new Error("Unable to create multi sampled framebuffer");i?.addMSAARenderBuffer(n)}this._bindUnboundFramebuffer(a._MSAAFramebuffer??a._framebuffer),a.texture&&(a.texture.samples=e),a._samples=e;const s=a._depthStencilTexture?a._depthStencilTexture.format:void 0;return a._depthStencilBuffer=this._setupFramebufferDepthAttachments(a._generateStencilBuffer,a._generateDepthBuffer,a.width,a.height,e,s),this._bindUnboundFramebuffer(null),e};he.prototype._setupDepthStencilTexture=function(a,e,t,i,s=1){const r=e.width??e,n=e.height??e,o=e.layers||0,h=e.depth||0;a.baseWidth=r,a.baseHeight=n,a.width=r,a.height=n,a.is2DArray=o>0,a.depth=o||h,a.isReady=!0,a.samples=s,a.generateMipMaps=!1,a.samplingMode=t?2:1,a.type=0,a._comparisonFunction=i;const l=this._gl,c=this._getTextureTarget(a),u=this._getSamplingParameters(a.samplingMode,!1);l.texParameteri(c,l.TEXTURE_MAG_FILTER,u.mag),l.texParameteri(c,l.TEXTURE_MIN_FILTER,u.min),l.texParameteri(c,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(c,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),this.webGLVersion>1&&(i===0?(l.texParameteri(c,l.TEXTURE_COMPARE_FUNC,515),l.texParameteri(c,l.TEXTURE_COMPARE_MODE,l.NONE)):(l.texParameteri(c,l.TEXTURE_COMPARE_FUNC,i),l.texParameteri(c,l.TEXTURE_COMPARE_MODE,l.COMPARE_REF_TO_TEXTURE)))};he.prototype.setDepthStencilTexture=function(a,e,t,i){a!==void 0&&(e&&(this._boundUniforms[a]=e),!t||!t.depthStencilTexture?this._setTexture(a,null,void 0,void 0,i):this._setTexture(a,t,!1,!0,i))};he.prototype.createRenderTargetCubeTexture=function(a,e){const t=this._createHardwareRenderTargetWrapper(!1,!0,a),i={generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:0,samplingMode:3,format:5,...e};i.generateStencilBuffer=i.generateDepthBuffer&&i.generateStencilBuffer,(i.type===1&&!this._caps.textureFloatLinearFiltering||i.type===2&&!this._caps.textureHalfFloatLinearFiltering)&&(i.samplingMode=1);const s=this._gl,r=new Et(this,5);this._bindTextureDirectly(s.TEXTURE_CUBE_MAP,r,!0);const n=this._getSamplingParameters(i.samplingMode,i.generateMipMaps);i.type===1&&!this._caps.textureFloat&&(i.type=0,w.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,n.mag),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,n.min),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE);for(let h=0;h<6;h++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+h,0,this._getRGBABufferInternalSizedFormat(i.type,i.format),a,a,0,this._getInternalFormat(i.format),this._getWebGLTextureType(i.type),null);const o=s.createFramebuffer();return this._bindUnboundFramebuffer(o),t._depthStencilBuffer=this._setupFramebufferDepthAttachments(i.generateStencilBuffer,i.generateDepthBuffer,a,a),i.generateMipMaps&&s.generateMipmap(s.TEXTURE_CUBE_MAP),this._bindTextureDirectly(s.TEXTURE_CUBE_MAP,null),this._bindUnboundFramebuffer(null),t._framebuffer=o,t._generateDepthBuffer=i.generateDepthBuffer,t._generateStencilBuffer=i.generateStencilBuffer,r.width=a,r.height=a,r.isReady=!0,r.isCube=!0,r.samples=1,r.generateMipMaps=i.generateMipMaps,r.samplingMode=i.samplingMode,r.type=i.type,r.format=i.format,this._internalTexturesCache.push(r),t.setTextures(r),t};const ri=[Math.sqrt(1/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(3/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(15/(4*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(5/(16*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(15/(16*Math.PI))],ld=[()=>1,a=>a.y,a=>a.z,a=>a.x,a=>a.x*a.y,a=>a.y*a.z,a=>3*a.z*a.z-1,a=>a.x*a.z,a=>a.x*a.x-a.y*a.y],_i=(a,e)=>ri[a]*ld[a](e),gi=[Math.PI,2*Math.PI/3,2*Math.PI/3,2*Math.PI/3,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4];class qs{constructor(){this.preScaled=!1,this.l00=_.Zero(),this.l1_1=_.Zero(),this.l10=_.Zero(),this.l11=_.Zero(),this.l2_2=_.Zero(),this.l2_1=_.Zero(),this.l20=_.Zero(),this.l21=_.Zero(),this.l22=_.Zero()}addLight(e,t,i){v.Vector3[0].set(t.r,t.g,t.b);const s=v.Vector3[0],r=v.Vector3[1];s.scaleToRef(i,r),r.scaleToRef(_i(0,e),v.Vector3[2]),this.l00.addInPlace(v.Vector3[2]),r.scaleToRef(_i(1,e),v.Vector3[2]),this.l1_1.addInPlace(v.Vector3[2]),r.scaleToRef(_i(2,e),v.Vector3[2]),this.l10.addInPlace(v.Vector3[2]),r.scaleToRef(_i(3,e),v.Vector3[2]),this.l11.addInPlace(v.Vector3[2]),r.scaleToRef(_i(4,e),v.Vector3[2]),this.l2_2.addInPlace(v.Vector3[2]),r.scaleToRef(_i(5,e),v.Vector3[2]),this.l2_1.addInPlace(v.Vector3[2]),r.scaleToRef(_i(6,e),v.Vector3[2]),this.l20.addInPlace(v.Vector3[2]),r.scaleToRef(_i(7,e),v.Vector3[2]),this.l21.addInPlace(v.Vector3[2]),r.scaleToRef(_i(8,e),v.Vector3[2]),this.l22.addInPlace(v.Vector3[2])}scaleInPlace(e){this.l00.scaleInPlace(e),this.l1_1.scaleInPlace(e),this.l10.scaleInPlace(e),this.l11.scaleInPlace(e),this.l2_2.scaleInPlace(e),this.l2_1.scaleInPlace(e),this.l20.scaleInPlace(e),this.l21.scaleInPlace(e),this.l22.scaleInPlace(e)}convertIncidentRadianceToIrradiance(){this.l00.scaleInPlace(gi[0]),this.l1_1.scaleInPlace(gi[1]),this.l10.scaleInPlace(gi[2]),this.l11.scaleInPlace(gi[3]),this.l2_2.scaleInPlace(gi[4]),this.l2_1.scaleInPlace(gi[5]),this.l20.scaleInPlace(gi[6]),this.l21.scaleInPlace(gi[7]),this.l22.scaleInPlace(gi[8])}convertIrradianceToLambertianRadiance(){this.scaleInPlace(1/Math.PI)}preScaleForRendering(){this.preScaled=!0,this.l00.scaleInPlace(ri[0]),this.l1_1.scaleInPlace(ri[1]),this.l10.scaleInPlace(ri[2]),this.l11.scaleInPlace(ri[3]),this.l2_2.scaleInPlace(ri[4]),this.l2_1.scaleInPlace(ri[5]),this.l20.scaleInPlace(ri[6]),this.l21.scaleInPlace(ri[7]),this.l22.scaleInPlace(ri[8])}updateFromArray(e){return _.FromArrayToRef(e[0],0,this.l00),_.FromArrayToRef(e[1],0,this.l1_1),_.FromArrayToRef(e[2],0,this.l10),_.FromArrayToRef(e[3],0,this.l11),_.FromArrayToRef(e[4],0,this.l2_2),_.FromArrayToRef(e[5],0,this.l2_1),_.FromArrayToRef(e[6],0,this.l20),_.FromArrayToRef(e[7],0,this.l21),_.FromArrayToRef(e[8],0,this.l22),this}updateFromFloatsArray(e){return _.FromFloatsToRef(e[0],e[1],e[2],this.l00),_.FromFloatsToRef(e[3],e[4],e[5],this.l1_1),_.FromFloatsToRef(e[6],e[7],e[8],this.l10),_.FromFloatsToRef(e[9],e[10],e[11],this.l11),_.FromFloatsToRef(e[12],e[13],e[14],this.l2_2),_.FromFloatsToRef(e[15],e[16],e[17],this.l2_1),_.FromFloatsToRef(e[18],e[19],e[20],this.l20),_.FromFloatsToRef(e[21],e[22],e[23],this.l21),_.FromFloatsToRef(e[24],e[25],e[26],this.l22),this}static FromArray(e){return new qs().updateFromArray(e)}static FromPolynomial(e){const t=new qs;return t.l00=e.xx.scale(.376127).add(e.yy.scale(.376127)).add(e.zz.scale(.376126)),t.l1_1=e.y.scale(.977204),t.l10=e.z.scale(.977204),t.l11=e.x.scale(.977204),t.l2_2=e.xy.scale(1.16538),t.l2_1=e.yz.scale(1.16538),t.l20=e.zz.scale(1.34567).subtract(e.xx.scale(.672834)).subtract(e.yy.scale(.672834)),t.l21=e.zx.scale(1.16538),t.l22=e.xx.scale(1.16538).subtract(e.yy.scale(1.16538)),t.l1_1.scaleInPlace(-1),t.l11.scaleInPlace(-1),t.l2_1.scaleInPlace(-1),t.l21.scaleInPlace(-1),t.scaleInPlace(Math.PI),t}}class js{constructor(){this.x=_.Zero(),this.y=_.Zero(),this.z=_.Zero(),this.xx=_.Zero(),this.yy=_.Zero(),this.zz=_.Zero(),this.xy=_.Zero(),this.yz=_.Zero(),this.zx=_.Zero()}get preScaledHarmonics(){return this._harmonics||(this._harmonics=qs.FromPolynomial(this)),this._harmonics.preScaled||this._harmonics.preScaleForRendering(),this._harmonics}addAmbient(e){v.Vector3[0].copyFromFloats(e.r,e.g,e.b);const t=v.Vector3[0];this.xx.addInPlace(t),this.yy.addInPlace(t),this.zz.addInPlace(t)}scaleInPlace(e){this.x.scaleInPlace(e),this.y.scaleInPlace(e),this.z.scaleInPlace(e),this.xx.scaleInPlace(e),this.yy.scaleInPlace(e),this.zz.scaleInPlace(e),this.yz.scaleInPlace(e),this.zx.scaleInPlace(e),this.xy.scaleInPlace(e)}updateFromHarmonics(e){return this._harmonics=e,this.x.copyFrom(e.l11),this.x.scaleInPlace(1.02333).scaleInPlace(-1),this.y.copyFrom(e.l1_1),this.y.scaleInPlace(1.02333).scaleInPlace(-1),this.z.copyFrom(e.l10),this.z.scaleInPlace(1.02333),this.xx.copyFrom(e.l00),v.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),v.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),this.xx.scaleInPlace(.886277).subtractInPlace(v.Vector3[0]).addInPlace(v.Vector3[1]),this.yy.copyFrom(e.l00),this.yy.scaleInPlace(.886277).subtractInPlace(v.Vector3[0]).subtractInPlace(v.Vector3[1]),this.zz.copyFrom(e.l00),v.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),this.zz.scaleInPlace(.886277).addInPlace(v.Vector3[0]),this.yz.copyFrom(e.l2_1),this.yz.scaleInPlace(.858086).scaleInPlace(-1),this.zx.copyFrom(e.l21),this.zx.scaleInPlace(.858086).scaleInPlace(-1),this.xy.copyFrom(e.l2_2),this.xy.scaleInPlace(.858086),this.scaleInPlace(1/Math.PI),this}static FromHarmonics(e){return new js().updateFromHarmonics(e)}static FromArray(e){const t=new js;return _.FromArrayToRef(e[0],0,t.x),_.FromArrayToRef(e[1],0,t.y),_.FromArrayToRef(e[2],0,t.z),_.FromArrayToRef(e[3],0,t.xx),_.FromArrayToRef(e[4],0,t.yy),_.FromArrayToRef(e[5],0,t.zz),_.FromArrayToRef(e[6],0,t.yz),_.FromArrayToRef(e[7],0,t.zx),_.FromArrayToRef(e[8],0,t.xy),t}}he.prototype.createPrefilteredCubeTexture=function(a,e,t,i,s=null,r=null,n,o=null,h=!0){const l=async c=>{if(!c){s&&s(null);return}const u=c.texture;if(h?c.info.sphericalPolynomial&&(u._sphericalPolynomial=c.info.sphericalPolynomial):u._sphericalPolynomial=u._sphericalPolynomial??new js,u._source=9,this.getCaps().textureLOD){s&&s(u);return}const f=3,d=this._gl,g=c.width;if(!g)return;const{DDSTools:p}=await G(async()=>{const{DDSTools:A}=await import("./dds-DfG5GArM.js");return{DDSTools:A}},__vite__mapDeps([41,42,13,14]),import.meta.url),m=[];for(let A=0;A<f;A++){const I=1-A/(f-1),M=i,C=Math.log2(g)*t+i,x=M+(C-M)*I,S=Math.round(Math.min(Math.max(x,0),C)),L=new Et(this,2);if(L.type=u.type,L.format=u.format,L.width=Math.pow(2,Math.max(Math.log2(g)-S,0)),L.height=L.width,L.isCube=!0,L._cachedWrapU=0,L._cachedWrapV=0,this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,L,!0),L.samplingMode=2,d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MAG_FILTER,d.LINEAR),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MIN_FILTER,d.LINEAR),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),c.isDDS){const D=c.info,Re=c.data;this._unpackFlipY(D.isCompressed),p.UploadDDSLevels(this,L,Re,D,!0,6,S)}else w.Warn("DDS is the only prefiltered cube map supported so far.");this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,null);const N=new De(e);N._isCube=!0,N._texture=L,L.isReady=!0,m.push(N)}u._lodTextureHigh=m[2],u._lodTextureMid=m[1],u._lodTextureLow=m[0],s&&s(u)};return this.createCubeTexture(a,e,null,!1,l,r,n,o,h,t,i)};he.prototype.createUniformBuffer=function(a,e){const t=this._gl.createBuffer();if(!t)throw new Error("Unable to create uniform buffer");const i=new Ys(t);return this.bindUniformBuffer(i),a instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,a,this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(a),this._gl.STATIC_DRAW),this.bindUniformBuffer(null),i.references=1,i};he.prototype.createDynamicUniformBuffer=function(a,e){const t=this._gl.createBuffer();if(!t)throw new Error("Unable to create dynamic uniform buffer");const i=new Ys(t);return this.bindUniformBuffer(i),a instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,a,this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(a),this._gl.DYNAMIC_DRAW),this.bindUniformBuffer(null),i.references=1,i};he.prototype.updateUniformBuffer=function(a,e,t,i){this.bindUniformBuffer(a),t===void 0&&(t=0),i===void 0?e instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,t,e):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,t,new Float32Array(e)):e instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,e.subarray(t,t+i)):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,new Float32Array(e).subarray(t,t+i)),this.bindUniformBuffer(null)};he.prototype.bindUniformBuffer=function(a){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,a?a.underlyingResource:null)};he.prototype.bindUniformBufferBase=function(a,e,t){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,e,a?a.underlyingResource:null)};he.prototype.bindUniformBlock=function(a,e,t){const i=a.program,s=this._gl.getUniformBlockIndex(i,e);s!==4294967295&&this._gl.uniformBlockBinding(i,s,t)};H.prototype.displayLoadingUI=function(){if(!_t())return;const a=this.loadingScreen;a&&a.displayLoadingUI()};H.prototype.hideLoadingUI=function(){if(!_t())return;const a=this._loadingScreen;a&&a.hideLoadingUI()};Object.defineProperty(H.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&this._renderingCanvas&&(this._loadingScreen=H.DefaultLoadingScreenFactory(this._renderingCanvas)),this._loadingScreen},set:function(a){this._loadingScreen=a},enumerable:!0,configurable:!0});Object.defineProperty(H.prototype,"loadingUIText",{set:function(a){this.loadingScreen.loadingUIText=a},enumerable:!0,configurable:!0});
48Object.defineProperty(H.prototype,"loadingUIBackgroundColor",{set:function(a){this.loadingScreen.loadingUIBackgroundColor=a},enumerable:!0,configurable:!0});H.prototype.getInputElement=function(){return this._renderingCanvas};H.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null};H.prototype.getInputElementClientRect=function(){return this._renderingCanvas?this.getInputElement().getBoundingClientRect():null};H.prototype.getAspectRatio=function(a,e=!1){const t=a.viewport;return this.getRenderWidth(e)*t.width/(this.getRenderHeight(e)*t.height)};H.prototype.getScreenAspectRatio=function(){return this.getRenderWidth(!0)/this.getRenderHeight(!0)};H.prototype._verifyPointerLock=function(){this._onPointerLockChange?.()};H.prototype.setAlphaEquation=function(a,e=0){if(this._alphaEquation[e]!==a){switch(a){case 0:this._alphaState.setAlphaEquationParameters(32774,32774,e);break;case 1:this._alphaState.setAlphaEquationParameters(32778,32778,e);break;case 2:this._alphaState.setAlphaEquationParameters(32779,32779,e);break;case 3:this._alphaState.setAlphaEquationParameters(32776,32776,e);break;case 4:this._alphaState.setAlphaEquationParameters(32775,32775,e);break;case 5:this._alphaState.setAlphaEquationParameters(32775,32774,e);break}this._alphaEquation[e]=a}};H.prototype.getInputElement=function(){return this._renderingCanvas};H.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc};H.prototype.setDepthFunction=function(a){this._depthCullingState.depthFunc=a};H.prototype.setDepthFunctionToGreater=function(){this.setDepthFunction(516)};H.prototype.setDepthFunctionToGreaterOrEqual=function(){this.setDepthFunction(518)};H.prototype.setDepthFunctionToLess=function(){this.setDepthFunction(513)};H.prototype.setDepthFunctionToLessOrEqual=function(){this.setDepthFunction(515)};H.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask};H.prototype.setDepthWrite=function(a){this._depthCullingState.depthMask=a};H.prototype.setAlphaConstants=function(a,e,t,i){this._alphaState.setAlphaBlendConstants(a,e,t,i)};H.prototype.getAlphaMode=function(a=0){return this._alphaMode[a]};H.prototype.getAlphaEquation=function(a=0){return this._alphaEquation[a]};H.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest};H.prototype.setStencilBuffer=function(a){this._stencilState.stencilTest=a};H.prototype.getStencilMask=function(){return this._stencilState.stencilMask};H.prototype.setStencilMask=function(a){this._stencilState.stencilMask=a};H.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc};H.prototype.getStencilBackFunction=function(){return this._stencilState.stencilBackFunc};H.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef};H.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask};H.prototype.setStencilFunction=function(a){this._stencilState.stencilFunc=a};H.prototype.setStencilBackFunction=function(a){this._stencilState.stencilBackFunc=a};H.prototype.setStencilFunctionReference=function(a){this._stencilState.stencilFuncRef=a};H.prototype.setStencilFunctionMask=function(a){this._stencilState.stencilFuncMask=a};H.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail};H.prototype.getStencilBackOperationFail=function(){return this._stencilState.stencilBackOpStencilFail};H.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail};H.prototype.getStencilBackOperationDepthFail=function(){return this._stencilState.stencilBackOpDepthFail};H.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass};H.prototype.getStencilBackOperationPass=function(){return this._stencilState.stencilBackOpStencilDepthPass};H.prototype.setStencilOperationFail=function(a){this._stencilState.stencilOpStencilFail=a};H.prototype.setStencilBackOperationFail=function(a){this._stencilState.stencilBackOpStencilFail=a};H.prototype.setStencilOperationDepthFail=function(a){this._stencilState.stencilOpDepthFail=a};H.prototype.setStencilBackOperationDepthFail=function(a){this._stencilState.stencilBackOpDepthFail=a};H.prototype.setStencilOperationPass=function(a){this._stencilState.stencilOpStencilDepthPass=a};H.prototype.setStencilBackOperationPass=function(a){this._stencilState.stencilBackOpStencilDepthPass=a};H.prototype.cacheStencilState=function(){this._cachedStencilBuffer=this.getStencilBuffer(),this._cachedStencilFunction=this.getStencilFunction(),this._cachedStencilMask=this.getStencilMask(),this._cachedStencilOperationPass=this.getStencilOperationPass(),this._cachedStencilOperationFail=this.getStencilOperationFail(),this._cachedStencilOperationDepthFail=this.getStencilOperationDepthFail(),this._cachedStencilReference=this.getStencilFunctionReference()};H.prototype.restoreStencilState=function(){this.setStencilFunction(this._cachedStencilFunction),this.setStencilMask(this._cachedStencilMask),this.setStencilBuffer(this._cachedStencilBuffer),this.setStencilOperationPass(this._cachedStencilOperationPass),this.setStencilOperationFail(this._cachedStencilOperationFail),this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail),this.setStencilFunctionReference(this._cachedStencilReference)};H.prototype.getRenderPassNames=function(){return this._renderPassNames};H.prototype.getCurrentRenderPassName=function(){return this._renderPassNames[this.currentRenderPassId]};H.prototype.createRenderPassId=function(a){const e=++H._RenderPassIdCounter;return this._renderPassNames[e]=a??"NONAME",e};H.prototype.releaseRenderPassId=function(a){this._renderPassNames[a]=void 0;for(let e=0;e<this.scenes.length;++e){const t=this.scenes[e];for(let i=0;i<t.meshes.length;++i){const s=t.meshes[i];if(s.subMeshes)for(let r=0;r<s.subMeshes.length;++r)s.subMeshes[r]._removeDrawWrapper(a)}}};H.prototype._loadFileAsync=async function(a,e,t){return await new Promise((i,s)=>{this._loadFile(a,r=>{i(r)},void 0,e,t,(r,n)=>{s(n)})})};const Fr=new Map;function pi(a,e){cd(a)&&w.Warn(`Extension with the name '${a}' already exists`),Fr.set(a,e)}function cd(a){return Fr.delete(a)}function ud(a,e){(e==="image/ktx"||e==="image/ktx2")&&(a=".ktx"),Fr.has(a)||(a.endsWith(".ies")&&pi(".ies",async()=>await G(()=>import("./iesTextureLoader-D-wCA04Y.js"),__vite__mapDeps([43,13,14]),import.meta.url).then(i=>new i._IESTextureLoader)),a.endsWith(".dds")&&pi(".dds",async()=>await G(()=>import("./ddsTextureLoader-0uCmQMjR.js"),__vite__mapDeps([44,41,42,13,14]),import.meta.url).then(i=>new i._DDSTextureLoader)),a.endsWith(".basis")&&pi(".basis",async()=>await G(()=>import("./basisTextureLoader-CkZABKjy.js"),__vite__mapDeps([45,13,14]),import.meta.url).then(i=>new i._BasisTextureLoader)),a.endsWith(".env")&&pi(".env",async()=>await G(()=>import("./envTextureLoader-DlkAv4hf.js"),__vite__mapDeps([46,47,13,14,40]),import.meta.url).then(i=>new i._ENVTextureLoader)),a.endsWith(".hdr")&&pi(".hdr",async()=>await G(()=>
vendor: 22,275 bytes, line 48
48import("./hdrTextureLoader-Dmt8hv9p.js"),__vite__mapDeps([48,49,13,14]),import.meta.url).then(i=>new i._HDRTextureLoader)),(a.endsWith(".ktx")||a.endsWith(".ktx2"))&&(pi(".ktx",async()=>await G(()=>import("./ktxTextureLoader-BRJyxzG2.js"),__vite__mapDeps([50,51,13,14]),import.meta.url).then(i=>new i._KTXTextureLoader)),pi(".ktx2",async()=>await G(()=>import("./ktxTextureLoader-BRJyxzG2.js"),__vite__mapDeps([50,51,13,14]),import.meta.url).then(i=>new i._KTXTextureLoader))),a.endsWith(".tga")&&pi(".tga",async()=>await G(()=>import("./tgaTextureLoader-DEOT4PSv.js"),__vite__mapDeps([52,13,14]),import.meta.url).then(i=>new i._TGATextureLoader)),a.endsWith(".exr")&&pi(".exr",async()=>await G(()=>import("./exrTextureLoader-RVDXldv6.js"),__vite__mapDeps([53,13,14]),import.meta.url).then(i=>new i._ExrTextureLoader)));const t=Fr.get(a);return t?Promise.resolve(t(e)):null}H.GetCompatibleTextureLoader=ud;function dd(a){!a||!a.setAttribute||(a.setAttribute("touch-action","none"),a.style.touchAction="none",a.style.webkitTapHighlightColor="transparent")}function fd(a,e,t){a._onCanvasFocus=()=>{a.onCanvasFocusObservable.notifyObservers(a)},a._onCanvasBlur=()=>{a.onCanvasBlurObservable.notifyObservers(a)},a._onCanvasContextMenu=s=>{a.disableContextMenu&&s.preventDefault()},e.addEventListener("focus",a._onCanvasFocus),e.addEventListener("blur",a._onCanvasBlur),e.addEventListener("contextmenu",a._onCanvasContextMenu),a._onBlur=()=>{a.disablePerformanceMonitorInBackground&&a.performanceMonitor.disable(),a._windowIsBackground=!0},a._onFocus=()=>{a.disablePerformanceMonitorInBackground&&a.performanceMonitor.enable(),a._windowIsBackground=!1},a._onCanvasPointerOut=s=>{document.elementFromPoint(s.clientX,s.clientY)!==e&&a.onCanvasPointerOutObservable.notifyObservers(s)};const i=a.getHostWindow();i&&typeof i.addEventListener=="function"&&(i.addEventListener("blur",a._onBlur),i.addEventListener("focus",a._onFocus)),e.addEventListener("pointerout",a._onCanvasPointerOut),t.doNotHandleTouchAction||dd(e),!H.audioEngine&&t.audioEngine&&H.AudioEngineFactory&&(H.audioEngine=H.AudioEngineFactory(a.getRenderingCanvas(),a.getAudioContext(),a.getAudioDestination())),Fs()&&(a._onFullscreenChange=()=>{a.isFullscreen=!!document.fullscreenElement,a.isFullscreen&&a._pointerLockRequested&&e&&Uh(e)},document.addEventListener("fullscreenchange",a._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",a._onFullscreenChange,!1),a._onPointerLockChange=()=>{a.isPointerLock=document.pointerLockElement===e},document.addEventListener("pointerlockchange",a._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",a._onPointerLockChange,!1)),a.enableOfflineSupport=H.OfflineProviderFactory!==void 0,a._deterministicLockstep=!!t.deterministicLockstep,a._lockstepMaxSteps=t.lockstepMaxSteps||0,a._timeStep=t.timeStep||1/60}function _d(a,e){Te.Instances.length===1&&H.audioEngine&&(H.audioEngine.dispose(),H.audioEngine=null);const t=a.getHostWindow();t&&typeof t.removeEventListener=="function"&&(t.removeEventListener("blur",a._onBlur),t.removeEventListener("focus",a._onFocus)),e&&(e.removeEventListener("focus",a._onCanvasFocus),e.removeEventListener("blur",a._onCanvasBlur),e.removeEventListener("pointerout",a._onCanvasPointerOut),e.removeEventListener("contextmenu",a._onCanvasContextMenu)),Fs()&&(document.removeEventListener("fullscreenchange",a._onFullscreenChange),document.removeEventListener("mozfullscreenchange",a._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",a._onFullscreenChange),document.removeEventListener("msfullscreenchange",a._onFullscreenChange),document.removeEventListener("pointerlockchange",a._onPointerLockChange),document.removeEventListener("mspointerlockchange",a._onPointerLockChange),document.removeEventListener("mozpointerlockchange",a._onPointerLockChange),document.removeEventListener("webkitpointerlockchange",a._onPointerLockChange))}function gd(a){const e=document.createElement("span");e.textContent="Hg",e.style.font=a;const t=document.createElement("div");t.style.display="inline-block",t.style.width="1px",t.style.height="0px",t.style.verticalAlign="bottom";const i=document.createElement("div");i.style.whiteSpace="nowrap",i.appendChild(e),i.appendChild(t),document.body.appendChild(i);let s=0,r=0;try{r=t.getBoundingClientRect().top-e.getBoundingClientRect().top,t.style.verticalAlign="baseline",s=t.getBoundingClientRect().top-e.getBoundingClientRect().top}finally{document.body.removeChild(i)}return{ascent:s,height:r,descent:r-s}}async function pd(a,e,t){return await new Promise((i,s)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{a.createImageBitmap(r,t).then(n=>{i(n)})})},r.onerror=()=>{s(`Error loading image ${r.src}`)},r.src=e})}function md(a,e,t,i){const r=a.createCanvas(t,i).getContext("2d");if(!r)throw new Error("Unable to get 2d context for resizeImageBitmap");return r.drawImage(e,0,0),r.getImageData(0,0,t,i).data}function Td(a){const e=a.requestFullscreen||a.webkitRequestFullscreen;e&&e.call(a)}function bd(){const a=document;document.exitFullscreen?document.exitFullscreen():a.webkitCancelFullScreen&&a.webkitCancelFullScreen()}function Uh(a){if(a.requestPointerLock){const e=a.requestPointerLock();e instanceof Promise?e.then(()=>{a.focus()}).catch(()=>{}):a.focus()}}function Ed(){document.exitPointerLock&&document.exitPointerLock()}class V extends he{static get NpmPackage(){return H.NpmPackage}static get Version(){return H.Version}static get Instances(){return Te.Instances}static get LastCreatedEngine(){return Te.LastCreatedEngine}static get LastCreatedScene(){return Te.LastCreatedScene}static DefaultLoadingScreenFactory(e){return H.DefaultLoadingScreenFactory(e)}get _supportsHardwareTextureRescaling(){return!!V._RescalePostProcessFactory}_measureFps(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaTime=this._performanceMonitor.instantaneousFrameTime||0}get performanceMonitor(){return this._performanceMonitor}constructor(e,t,i,s=!1){super(e,t,i,s),this.customAnimationFrameRequester=null,this._performanceMonitor=new nd,this._drawCalls=new oi,e&&(this._features.supportRenderPasses=!0,i=this._creationOptions)}_initGLContext(){super._initGLContext(),this._rescalePostProcess=null}_sharedInit(e){super._sharedInit(e),fd(this,e,this._creationOptions)}resizeImageBitmap(e,t,i){return md(this,e,t,i)}async _createImageBitmapFromSource(e,t){return await pd(this,e,t)}switchFullscreen(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)}enterFullscreen(e){this.isFullscreen||(this._pointerLockRequested=e,this._renderingCanvas&&Td(this._renderingCanvas))}exitFullscreen(){this.isFullscreen&&bd()}setDitheringState(e){e?this._gl.enable(this._gl.DITHER):this._gl.disable(this._gl.DITHER)}setRasterizerState(e){e?this._gl.disable(this._gl.RASTERIZER_DISCARD):this._gl.enable(this._gl.RASTERIZER_DISCARD)}setDirectViewport(e,t,i,s){const r=this._cachedViewport;return this._cachedViewport=null,this._viewport(e,t,i,s),r}scissorClear(e,t,i,s,r){this.enableScissor(e,t,i,s),this.clear(r,!0,!0,!0),this.disableScissor()}enableScissor(e,t,i,s){const r=this._gl;r.enable(r.SCISSOR_TEST),r.scissor(e,t,i,s)}disableScissor(){const e=this._gl;e.disable(e.SCISSOR_TEST)}getVertexShaderSource(e){const t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[0]):null}getFragmentShaderSource(e){const t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[1]):null}set framebufferDimensionsObject(e){this._framebufferDimensionsObject=e,this._framebufferDimensionsObject&&this.onResizeObservable.notifyObservers(this)}_rebuildBuffers(){for(const e of this.scenes)e.resetCachedMaterial(),e._rebuildGeometries();for(const e of this._virtualScenes)e.resetCachedMaterial(),e._rebuildGeometries();super._rebuildBuffers()}getFontOffset(e){return gd(e)}_cancelFrame(){if(this.customAnimationFrameRequester){if(this._frameHandler!==0){this._frameHandler=0;const{cancelAnimationFrame:e}=this.customAnimationFrameRequester;e&&e(this.customAnimationFrameRequester.requestID)}}else super._cancelFrame()}_renderLoop(e){this._processFrame(e),this._activeRenderLoops.length>0&&this._frameHandler===0&&(this.customAnimationFrameRequester?(this.customAnimationFrameRequester.requestID=this._queueNewFrame(this.customAnimationFrameRequester.renderFunction||this._boundRenderFunction,this.customAnimationFrameRequester),this._frameHandler=this.customAnimationFrameRequester.requestID):this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()))}enterPointerlock(){this._renderingCanvas&&Uh(this._renderingCanvas)}exitPointerlock(){Ed()}beginFrame(){this._measureFps(),super.beginFrame()}_deletePipelineContext(e){const t=e;t&&t.program&&t.transformFeedback&&(this.deleteTransformFeedback(t.transformFeedback),t.transformFeedback=null),super._deletePipelineContext(e)}createShaderProgram(e,t,i,s,r,n=null){r=r||this._gl,this.onBeforeShaderCompilationObservable.notifyObservers(this);const o=super.createShaderProgram(e,t,i,s,r,n);return this.onAfterShaderCompilationObservable.notifyObservers(this),o}_createShaderProgram(e,t,i,s,r=null){const n=s.createProgram();if(e.program=n,!n)throw new Error("Unable to create program");if(s.attachShader(n,t),s.attachShader(n,i),this.webGLVersion>1&&r){const o=this.createTransformFeedback();this.bindTransformFeedback(o),this.setTranformFeedbackVaryings(n,r),e.transformFeedback=o}return s.linkProgram(n),this.webGLVersion>1&&r&&this.bindTransformFeedback(null),e.context=s,e.vertexShader=t,e.fragmentShader=i,e.isParallelCompiled||this._finalizePipelineContext(e),n}_releaseTexture(e){super._releaseTexture(e)}_releaseRenderTargetWrapper(e){super._releaseRenderTargetWrapper(e);for(const t of this.scenes){for(const i of t.postProcesses)i._outputTexture===e&&(i._outputTexture=null);for(const i of t.cameras)for(const s of i._postProcesses)s&&s._outputTexture===e&&(s._outputTexture=null)}}_rescaleTexture(e,t,i,s,r){this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);const n=this.createRenderTargetTexture({width:t.width,height:t.height},{generateMipMaps:!1,type:0,samplingMode:2,generateDepthBuffer:!1,generateStencilBuffer:!1});if(!this._rescalePostProcess&&V._RescalePostProcessFactory&&(this._rescalePostProcess=V._RescalePostProcessFactory(this)),this._rescalePostProcess){this._rescalePostProcess.externalTextureSamplerBinding=!0;const o=()=>{this._rescalePostProcess.onApply=function(c){c._bindTexture("textureSampler",e)};let l=i;l||(l=this.scenes[this.scenes.length-1]),l.postProcessManager.directRender([this._rescalePostProcess],n,!0),this._bindTextureDirectly(this._gl.TEXTURE_2D,t,!0),this._gl.copyTexImage2D(this._gl.TEXTURE_2D,0,s,0,0,t.width,t.height,0),this.unBindFramebuffer(n),n.dispose(),r&&r()},h=this._rescalePostProcess.getEffect();h?h.executeWhenCompiled(o):this._rescalePostProcess.onEffectCreatedObservable.addOnce(l=>{l.executeWhenCompiled(o)})}}wrapWebGLTexture(e,t=!1,i=3,s=0,r=0){const n=new wh(e,this._gl),o=new Et(this,0,!0);return o._hardwareTexture=n,o.baseWidth=s,o.baseHeight=r,o.width=s,o.height=r,o.isReady=!0,o.useMipMaps=t,this.updateTextureSamplingMode(i,o),o}_uploadImageToTexture(e,t,i=0,s=0){const r=this._gl,n=this._getWebGLTextureType(e.type),o=this._getInternalFormat(e.format),h=this._getRGBABufferInternalSizedFormat(e.type,o),l=e.isCube?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D;this._bindTextureDirectly(l,e,!0),this._unpackFlipY(e.invertY);let c=r.TEXTURE_2D;e.isCube&&(c=r.TEXTURE_CUBE_MAP_POSITIVE_X+i),r.texImage2D(c,s,h,o,n,t),this._bindTextureDirectly(l,null,!0)}updateTextureComparisonFunction(e,t){if(this.webGLVersion===1){w.Error("WebGL 1 does not support texture comparison.");return}const i=this._gl;e.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,e,!0),t===0?(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,515),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,t),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),t===0?(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,515),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),e._comparisonFunction=t}createInstancesBuffer(e){const t=this._gl.createBuffer();if(!t)throw new Error("Unable to create instance buffer");const i=new Ys(t);return i.capacity=e,this.bindArrayBuffer(i),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),i.references=1,i}deleteInstancesBuffer(e){this._gl.deleteBuffer(e)}async _clientWaitAsync(e,t=0,i=10){const s=this._gl;return await new Promise((r,n)=>{tr(()=>{const o=s.clientWaitSync(e,t,0);if(o==s.WAIT_FAILED)throw new Error("clientWaitSync failed");return o!=s.TIMEOUT_EXPIRED},r,n,i)})}_readPixelsAsync(e,t,i,s,r,n,o){if(this._webGLVersion<2)throw new Error("_readPixelsAsync only work on WebGL2+");const h=this._gl,l=h.createBuffer();h.bindBuffer(h.PIXEL_PACK_BUFFER,l),h.bufferData(h.PIXEL_PACK_BUFFER,o.byteLength,h.STREAM_READ),h.readPixels(e,t,i,s,r,n,0),h.bindBuffer(h.PIXEL_PACK_BUFFER,null);const c=h.fenceSync(h.SYNC_GPU_COMMANDS_COMPLETE,0);return c?(h.flush(),this._clientWaitAsync(c,0,10).then(()=>(h.deleteSync(c),h.bindBuffer(h.PIXEL_PACK_BUFFER,l),h.getBufferSubData(h.PIXEL_PACK_BUFFER,0,o),h.bindBuffer(h.PIXEL_PACK_BUFFER,null),h.deleteBuffer(l),o))):null}dispose(){this.hideLoadingUI(),this._rescalePostProcess&&this._rescalePostProcess.dispose(),_d(this,this._renderingCanvas),super.dispose()}}V.ALPHA_DISABLE=0;V.ALPHA_ADD=1;V.ALPHA_COMBINE=2;V.ALPHA_SUBTRACT=3;V.ALPHA_MULTIPLY=4;V.ALPHA_MAXIMIZED=5;V.ALPHA_ONEONE=6;V.ALPHA_PREMULTIPLIED=7;V.ALPHA_PREMULTIPLIED_PORTERDUFF=8;V.ALPHA_INTERPOLATE=9;V.ALPHA_SCREENMODE=10;V.DELAYLOADSTATE_NONE=0;V.DELAYLOADSTATE_LOADED=1;V.DELAYLOADSTATE_LOADING=2;V.DELAYLOADSTATE_NOTLOADED=4;V.NEVER=512;V.ALWAYS=519;V.LESS=513;V.EQUAL=514;V.LEQUAL=515;V.GREATER=516;V.GEQUAL=518;V.NOTEQUAL=517;V.KEEP=7680;V.REPLACE=7681;V.INCR=7682;V.DECR=7683;V.INVERT=5386;V.INCR_WRAP=34055;V.DECR_WRAP=34056;V.TEXTURE_CLAMP_ADDRESSMODE=0;V.TEXTURE_WRAP_ADDRESSMODE=1;V.TEXTURE_MIRROR_ADDRESSMODE=2;V.TEXTUREFORMAT_ALPHA=0;V.TEXTUREFORMAT_LUMINANCE=1;V.TEXTUREFORMAT_LUMINANCE_ALPHA=2;V.TEXTUREFORMAT_RGB=4;V.TEXTUREFORMAT_RGBA=5;V.TEXTUREFORMAT_RED=6;V.TEXTUREFORMAT_R=6;V.TEXTUREFORMAT_R16_UNORM=33322;V.TEXTUREFORMAT_RG16_UNORM=33324;V.TEXTUREFORMAT_RGB16_UNORM=32852;V.TEXTUREFORMAT_RGBA16_UNORM=32859;V.TEXTUREFORMAT_R16_SNORM=36760;V.TEXTUREFORMAT_RG16_SNORM=36761;V.TEXTUREFORMAT_RGB16_SNORM=36762;V.TEXTUREFORMAT_RGBA16_SNORM=36763;V.TEXTUREFORMAT_RG=7;V.TEXTUREFORMAT_RED_INTEGER=8;V.TEXTUREFORMAT_R_INTEGER=8;V.TEXTUREFORMAT_RG_INTEGER=9;V.TEXTUREFORMAT_RGB_INTEGER=10;V.TEXTUREFORMAT_RGBA_INTEGER=11;V.TEXTURETYPE_UNSIGNED_BYTE=0;V.TEXTURETYPE_UNSIGNED_INT=0;V.TEXTURETYPE_FLOAT=1;V.TEXTURETYPE_HALF_FLOAT=2;V.TEXTURETYPE_BYTE=3;V.TEXTURETYPE_SHORT=4;V.TEXTURETYPE_UNSIGNED_SHORT=5;V.TEXTURETYPE_INT=6;V.TEXTURETYPE_UNSIGNED_INTEGER=7;V.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8;V.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9;V.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10;V.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11;V.TEXTURETYPE_UNSIGNED_INT_24_8=12;V.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13;V.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14;V.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15;V.TEXTURE_NEAREST_SAMPLINGMODE=1;V.TEXTURE_BILINEAR_SAMPLINGMODE=2;V.TEXTURE_TRILINEAR_SAMPLINGMODE=3;V.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8;V.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11;V.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3;V.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4;V.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5;V.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6;V.TEXTURE_NEAREST_LINEAR=7;V.TEXTURE_NEAREST_NEAREST=1;V.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9;V.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10;V.TEXTURE_LINEAR_LINEAR=2;V.TEXTURE_LINEAR_NEAREST=12;V.TEXTURE_EXPLICIT_MODE=0;V.TEXTURE_SPHERICAL_MODE=1;V.TEXTURE_PLANAR_MODE=2;V.TEXTURE_CUBIC_MODE=3;V.TEXTURE_PROJECTION_MODE=4;V.TEXTURE_SKYBOX_MODE=5;V.TEXTURE_INVCUBIC_MODE=6;V.TEXTURE_EQUIRECTANGULAR_MODE=7;V.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8;V.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9;V.SCALEMODE_FLOOR=1;V.SCALEMODE_NEAREST=2;V.SCALEMODE_CEILING=3;const Ad=Object.freeze(Object.defineProperty({__proto__:null,Engine:V},Symbol.toStringTag,{value:"Module"}));class Es extends rt{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([G(()=>import("./pass.fragment-yO6VVndP.js"),__vite__mapDeps([54,13,14]),import.meta.url)]))):t.push(Promise.all([G(()=>import("./pass.fragment-Cp9OTwUi.js"),__vite__mapDeps([55,13,14]),import.meta.url)])),super._gatherImports(e,t)}constructor(e,t=null,i){const s={name:e,engine:t||V.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:Es.FragmentUrl,...i};s.engine||(s.engine=V.LastCreatedEngine),super(s)}}Es.FragmentUrl="pass";class zr extends rt{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([G(()=>import("./passCube.fragment-D6ZVCTUo.js"),__vite__mapDeps([56,13,14]),import.meta.url)]))):t.push(Promise.all([G(()=>import("./passCube.fragment-BcJo8wMb.js"),__vite__mapDeps([57,13,14]),import.meta.url)])),super._gatherImports(e,t)}constructor(e,t=null,i){super({...i,name:e,engine:t||V.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:zr.FragmentUrl,defines:"#define POSITIVEX"}),this._face=0}get face(){return this._face}set face(e){if(!(e<0||e>5))switch(this._face=e,this._face){case 0:this.updateEffect("#define POSITIVEX");break;case 1:this.updateEffect("#define NEGATIVEX");break;case 2:this.updateEffect("#define POSITIVEY");break;case 3:this.updateEffect("#define NEGATIVEY");break;case 4:this.updateEffect("#define POSITIVEZ");break;case 5:this.updateEffect("#define NEGATIVEZ");break}}}zr.FragmentUrl="passCube";class Wr extends je{getClassName(){return"PassPostProcess"}constructor(e,t,i=null,s,r,n,o=0,h=!1){const l={size:typeof t=="number"?t:void 0,camera:i,samplingMode:s,engine:r,reusable:n,textureType:o,blockCompilation:h,...t};super(e,Es.FragmentUrl,{effectWrapper:typeof t=="number"||!t.effectWrapper?new Es(e,r,l):void 0,...l})}static _Parse(e,t,i,s){return le.Parse(()=>new Wr(e.name,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable),e,i,s)}}nt("BABYLON.PassPostProcess",Wr);class Hn extends je{get face(){return this._effectWrapper.face}set face(e){this._effectWrapper.face=e}getClassName(){return"PassCubePostProcess"}constructor(e,t,i=null,s,r,n,o=0,h=!1){const l={size:typeof t=="number"?t:void 0,camera:i,samplingMode:s,engine:r,reusable:n,textureType:o,blockCompilation:h,...t};super(e,Es.FragmentUrl,{effectWrapper:typeof t=="number"||!t.effectWrapper?new zr(e,r,l):void 0,...l})}static _Parse(e,t,i,s){return le.Parse(()=>new Hn(e.name,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable),e,i,s)}}T([R()],Hn.prototype,"face",null);H._RescalePostProcessFactory=a=>new Wr("rescale",1,null,2,a,!1,0);function Rd(a,e,t,i,s,r,n,o){const h=e.getEngine();return e.isReady=!1,s=s??e.samplingMode,i=i??e.type,r=r??e.format,n=n??e.width,o=o??e.height,i===-1&&(i=0),new Promise(l=>{const c=new je("postprocess",a,null,null,1,null,s,h,!1,void 0,i,void 0,null,!1,r);c.externalTextureSamplerBinding=!0;const u=h.createRenderTargetTexture({width:n,height:o},{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:s,type:i,format:r});c.onEffectCreatedObservable.addOnce(f=>{f.executeWhenCompiled(()=>{c.onApply=d=>{d._bindTexture("textureSampler",e),d.setFloat2("scale",1,1)},t.postProcessManager.directRender([c],u,!0),h.restoreDefaultFramebuffer(),h._releaseTexture(e),c&&c.dispose(),u._swapAndDie(e),e.type=i,e.format=5,e.isReady=!0,l(e)})})})}let _r,Ba;function S_(a){_r||(_r=new Float32Array(1),Ba=new Int32Array(_r.buffer)),_r[0]=a;const e=Ba[0];let t=e>>16&32768,i=e>>12&2047;const s=e>>23&255;return s<103?t:s>142?(t|=31744,t|=(s==255?0:1)&&e&8388607,t):s<113?(i|=2048,t|=(i>>114-s)+(i>>113-s&1),t):(t|=s-112<<10|i>>1,t+=i&1,t)}function M_(a){const e=(a&32768)>>15,t=(a&31744)>>10,i=a&1023;return t===0?(e?-1:1)*Math.pow(2,-14)*(i/Math.pow(2,10)):t==31?i?NaN:(e?-1:1)*(1/0):(e?-1:1)*Math.pow(2,t-15)*(1+i/Math.pow(2,10))}class Na{static ExpandRGBDTexture(e){const t=e._texture;if(!t||!e.isRGBD)return;const i=t.getEngine(),s=i.getCaps(),r=t.isReady;let n=!1;s.textureHalfFloatRender&&s.textureHalfFloatLinearFiltering?(n=!0,t.type=2):s.textureFloatRender&&s.textureFloatLinearFiltering&&(n=!0,t.type=1),n&&(t.isReady=!1,t._isRGBD=!1,t.invertY=!1);const o=async()=>{const h=i.isWebGPU,l=h?1:0;t.isReady=!1,h?await G(()=>import("./rgbdDecode.fragment-CNs6GR2F.js"),__vite__mapDeps([58,3,13,14]),import.meta.url):await G(()=>import("./rgbdDecode.fragment-BSk9DCY7.js"),__vite__mapDeps([59,25,13,14]),import.meta.url);const c=new je("rgbdDecode","rgbdDecode",null,null,1,null,3,i,!1,void 0,t.type,void 0,null,!1,void 0,l);c.externalTextureSamplerBinding=!0;const u=i.createRenderTargetTexture(t.width,{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:t.samplingMode,type:t.type,format:5});c.onEffectCreatedObservable.addOnce(f=>{f.executeWhenCompiled(()=>{c.onApply=d=>{d._bindTexture("textureSampler",t),d.setFloat2("scale",1,1)},e.getScene().postProcessManager.directRender([c],u,!0),i.restoreDefaultFramebuffer(),i._releaseTexture(t),c&&c.dispose(),u._swapAndDie(t),t.isReady=!0})})};n&&(r?o():e.onLoadObservable.addOnce(o))}static async EncodeTextureToRGBD(e,t,i=0){return t.getEngine().isWebGPU?await G(()=>import("./rgbdEncode.fragment-Bwep2fH2.js"),__vite__mapDeps([60,3,13,14]),import.meta.url):await G(()=>import("./rgbdEncode.fragment-DeAhXJbd.js"),__vite__mapDeps([61,25,13,14]),import.meta.url),await Rd("rgbdEncode",e,t,i,1,5)}}const yd
vendor: 5,849 bytes, line 48
48="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR42u29yY5tWXIlZnbuiSaTbZFUkZRKrCKhElASQA0EoQABgn6hJvoXzfUP+gP9hWb6Bg00IgRoQJaKqUxmZmTEe8/v0uB2u7Fm2T7HIyIrnz88uPvt3f2a2WrMbOvf/u3PvvzP/sUf/N6//i8vf/lv/3v5H//d//Sb//Uq/5u8yf8hV/m/5Cp/L1f5hVzlG7nKJ7mKyJuIXN/hPwqXI/g++zq6rPI5u8z+WqfLre+zy7PrVv9L8brsMiGvk8XLmM/sdfHXal4e3ad6GXPdyu2ij8u/+uv/5cuf/OSLfdtEfvUr+dnf/d0X//t3H/7bf/hP//N/928h/0Yg/4VA/kogfyGQP5Wr/IFAvhbIlwK5CGQTPP+9z5uPeePJSW+yo2+s/GtN30Rnv1E+f5zxof9R/lSXv/nr//mrr3+i+5dfyX7ZZQP07Tffys//8R/l/9TtX7790T/7r/8G8pdy+/8XAvnnAvkzgfwzgfyxQP5AIL8vkJ8K5KsmMVzu1U7p5PA5AXxOAJ8TwPf7sX/51ZeXfcemqnp9w/W77/S7X/6T/vzf/7383RWCX3/z05/9i3/13/0PX//eX/2FyP8tIv+PiPy9iPy/IvIzEfm5iPxCRH4lIt/c/393//9BRD6KyKf7f488fP74/PH544dJAF9cLl98IZfLBZtuqterXr/7Dt9982v95S9+Lv+gF/3i7Spv/8lf/vnf/vGf/dF/JfKnIvLnIvLvReQ/NEngn0TklyLy6/v/34jIt00iGJOBlxAsdvv54/PH5493SQCXy9t2ueh2ueimKorrFbjq9eNH+fDtb+TXv/ol/vHyhX4Fxfbx7euPf/Lnf/PfiPyeiPyhiPxxkwB+fk8AvxzQgJcIrGTwFsiAEXH4/PH54/PHUgLY7whgu2C7bLqpQgHB2xvePn6SDx8+6G9+84384vKF/IPu8iVU9Y/+7C/+jWxffiHytYj8VER+X0T+oEEBvxqQwCMJeIngo5EI3goIwVMIPn98/vj8ESaAbbtu2ybbvl8u2ybbdtluSECA65u8ffqIDx8+6G++/VZ/efkV/sO261dQXP7wT/7kX8vl8qXIFyLylbySwe/dE0CLAr65B/9vGn0gQwRMMqgmhM/J4fPH548eAezbZd/lsm3YtssNAYiqiogAAkCvb5/k46cP8u2HD/rrb7+R/2/b9Wu9yJe//8d/9Ney6S5yEZFdRL68/38khG/uKOCnAwoYkcCoEXwkEgGDDq7CeQfyOTl8/vhd1QCum26ybZtu2yabbrKpQvXue1yvuF6v+vbpTT5+/CDffviAX1++1V9sO77WXb/66R/+4V/dgkbllQi+aBLBV/dE8LWRALwkYCWCNyMZXElkwLTMeMkga/P4/PH547ccAVwuctkvdxSw6bbdtYDbTfSZBN7e8PHTR/3u4wf55vKd/nL7DX6mu3791U9//5+/gkNFZGuSgZUQvnKowKgLWLTAQgRtEniTuEfwaELw0MJvf3LQzynud+53uG+X6y3gN9kul+2y6XVT1U27JCDAFVc8ksAn/e7jR/nN5YP+avtWfq6Xy9f7Vz/9w1dgRYngiyYhfNkkgzYBWHTg44AEMmqQUYQKOmDaiCIa8TmsfmzB+DnZDQjgcpGLbti2y3bZHjRAdRMVvb/dcYU8kcDbPQlsH/CrbddfbF98+RPZfvLFnAQeieCRDC5DMvju/vmD4JkEvjRQgKULeGggowdHkAHTYxihg89vu88I5UeGAPSOAFTlrgPopiqbKPSmCKreUoAAkCcSePukHz590m8vH+WbD9/JP335k6/+tA86KxFchv8jMvhiogE4JQm8XhfKqOAqx5qRPyeGzx8/cgSwbXcUoLJtim27C4Oi93+4v6VxQwKAvl2v+Hj9pB8+fZJvt4/yzfbF9lPdv/wJnsE2BogmyeCRED40tGFvksIXiSbgiYSRRpDNDZ6BDI6ghM+J4fPHeyKAO+zX7cb9t4tedMMNAQju5V+f1uAtBSiu1zsduMrHy5t8ePsk3376KN98sX/xE5FPAnm7/782o0DiUINXMkCXCB7/P94/e87AWUmARQWVvgMuKej9t1RLBp+Tw+ePgwngsutFFdu26WXbbl+rSvdfbnqAiuA23QcBgCugV1zl7e1NPm5v+LC96XfbJ/1W9y++fgXjA3bDYXV+MuhRwSPwL3JLMFYC+HS/LU8HYrGwIhwyNOF12SvgM4SgztdifP85MXz+KGsA2C6X7aJ6bXSAOwrY5OYIqGy3d5uq4P5GhABXuV6veLvRAf10fZMPb2/y3b7vX7+g+9v98/WOBq7GG7RNAlYy+Dgkhhb+Xxp0sE8IAC4SGAP/TbgVJK/PoJPBnAiwPKxsXfbbnRg+i3s/JAK4Q/4b9NfLtomBAqCickMBjy7BuywAUVyv8na94tMjCVzf9KNcLl/0SeA6oAEYb1i9g+FtSALb/bKL8/+t+wxXFMyswqiHoK4ToIgKqslgpg1qUC0QoYbvJZg/B/q5v4szHmPX7YEAsD0CX25OwEUVm9xag1+agKg+nxQArnKjAtDr9U0+Xd/k4/UqH7bL5YsewrcBBiMJZPRAp6TwQgWfjM9vgRbgUYGL8AvLWH2gqhesCokeUmCSwPsnhs8fP2YNYMO2XeSmAWxy2VQaXeDmDIhApf33rD4PTUCuV+DtCn27XuXT5ir8VmCJ2G5BpBM8/r/dEcJb8/0lEQMtJHA5TAlqNuLRhJChhEpSqFabH3di+G1AGj+W1/dyAR4IYJNNnuLf6+tWC9CHHiAtFhAIFLjK2/Uqn65X+SS67aK+3QeTDoy/IG2ogQ7fb/dAtz5vBgrYGqrwNtCHsVfgIvwK07OTQBURVNCBFpKCOjqCHn5L/67TgTN+fpySAC56nwSUi256kXsSuFGAVyLoUIDo8/Pz7fdoErr/v17lk162HbgHvFpIYDfoAJJfW4sGPjkU4VNAF8ZEcLmLhdc7kljdY1y1Dq9yLiI4IiRqcLujb138KIPn80ejATwRwIbtBvn1cqv+2J78/5EI5N4cJA8qIPcmwRsKAHDF9WYP6mV7VmrgLuTpxYTcMEW0LAmoQxFsuvAI8tv/a/C5fV2ZMMiKg++FCM7RDPRu8ebWY7VG6VJi+Bzk35MI2LsAckMAgwvQ0gC5DQjd3ABg2HQLAPpEAlZ1Bu7VV7MGHDFRAbo3VKsTbAY9sPWC/uvx86gBbDK3D1eEQS8pbAeSgSwmhepnJb6uBv/o/PzHLzxWA/X7TH77De5j6AGQi6o0CUGfCOD2X7cXAlCFQABtEsGLDtxuOyQB2UTQBKZe5GUPXgkUYCUAbZJRhBDeuq8xBf+bgwbehDm+BFQi2IJksOocvA8ysIMfxluVcRsY/eB3JzH8GFDAXQO48X/dcIf9jyDHptIigDsFkEe066tBSETQUYF7ElDdYEBytN4+rk9UcBPfrKaZqFHWcw3i4J8/X4ev2//bSXqAhwTay6OEIPLD2Ipt8OtAGzxkwLw9WVFRjTc/qC6H3+YK/b1oAA0KuOizHfieCLaHHiAb5NYTIC9EMEbZrVEQt1xwhVy1UfBh8PUOquMizwaap3tQXfY5B//tea/NZdfhsvbz+PURQTDSGWB87VX/7WSd4KxjUqrIgE0IUkoKGnhIvwvawpGf6eECXJ7tv4qbA7DJgwpsKthEmmYgfaAAffYF3HLxo0vwNjJ0SwRWMG4db4eh1gPNm18vQ+us/0eGmxDemu/fnM/X4evq/8342ksGHgLY5LyT/zg0wM8lcMjgGFXwqIOVFJBQw99eCvF9oZL9Mfl3QwAvIXDsBRC9R+fz8x0FPBLB0xJEpwUobrfAkARgIAF41h3wQgP6QAmX5E/7eI43IxGwwf/moIkRyWRJQIPgt9CA9b39nzt4bYUWjAlCjWDPgv8IEjgLJfzuaAsrv9VdVG4OwOXW/fdoA35qAdL0BDwvf6AAUVHd8LIEu94A3K+Q+2YxaB84MOH62P//qoo38fCRDERE2zf0JfmDa+MieElAjcDPKz+mRKCOtdgGtXaBjgNJ4H2owSpNeAW/rRH4CaHSpMwnBYYycjgSJwfie9CR6mPu20Uv8kABF206AvXlBMiIBPSlB9wjBW1fwEuSb94296VCqgMaGCt/G1BbExi3IG+r3a3J6P48Gv/J0YmEYoiGY7V/SxwFCwGoE/xa0AJ0CEiV9QPCJb1OJ5F1VTjEY2/MO9AEJvj1BJTQpqLfTlGwjABuzT962e4IoKnyrdh3+/6mzDVJ4PHOxj0JqGKoy20+wBMN6D1gLWi9NQHfVP5MEEPzjGYy8BMAOnTAJgEr8HUIejRo5xrA5xkR5AngmiSHs+zDDAmMgWzTg55GSJEmHE8IvWPAoYTfhWak/Wn/bQ0CGLSAjv83SUEfKp5q24LXuQICpzrjrgWoza8xVE00CQCORdhMJuTUT/rjuls0gO4Iby8BIEgK6gS7BsGuTtDrScH/fR68biUHNVGBnxjeNyHEvQe/ve3LZQqgG3rof6cEclsNflG9J4KtaQ8WHcVBHS1BtHE4QP9OBMS98mpbKTeDW7dJwRsnHpMBTFJpV4I+b0kY/NqInVFSyBLANbnMSgBM8F+Fqfxq/h657/Up+GaBnwV9hRqc9bZ/vA6vu+T9E8KPJWns94UfTeCj2QXwCHS9dNL8Xf3Ho/rfewSeFODGDV69AU0y6NFAE1DP3qK++rdB7/1HRxf86gT376zOr99T/h/ioBiXWQkgQgVeIrCC/WomhDmQK+hASI2ARQZKooHMLdCJwGEBBXC3+uERwg+VOHZ9ioAt9H80AI06wGgJ3nQA3BoCut6AhxYwgcPOFnxuFnrphk+NIKIGrWPQtgz3b0i7Y6D5rs1GKqTop0nQX52vmQC4BkjA+r4a7Kx9WLENGeegkhSETBCrNXIMdi/444Rw1n6E96ry7OPuj8UfLxtQ78NA2iSBbg7gIiIbdDLsb5agPhLC3RkYKv8NDbS2YGsatNRAG2oQwf9ZIOydgy1MAzBkAw8UwEEIDzSAqdPQ6za0PkeJAMH3Z0wXniUSZoHvBXU2mcjQgv56TedIKglCpIoQfgwCIjOytd8WgN0bfxoR8Fn9Gx0Aj5Zgq0lIZbsH/ibSJoFnS+C98g9ooHEELI3gliy25yONIiE6pb0NfBlyNEYyENoodkKwgl6I6s8kARgJ4ZoEfuYWHLEJa0LhSBXm7kImGeSfVdoJ1DO2G7WXsehAptupSOoyrCSF904k+6vt98X/ZcM98Hsd4JYIXhQAIg3/f9AAUYhsLQKAtkHVBnzjCKhOoYl2ym+iBtvzDzQ2DLXJ4PUmbJHAVnBQX4jkxfvHhNDqAdHXGQJgv0aSDGItgOseHIU+K9hXnIJzkoGlEKzNHagTdJ6VWEUH4iCKH4fd2AwDPaYBm4Wgng4gQ9V/CoGiuNmD04AQtNGMGzSAAQ2I2pzfogY9LRh7BrbOh4+D30sAencljFu2CUFrwY8UAWRfWwGvVOVfbx2uIILM0pwDv082dUTw8hYs8L+uIWiHGpWgClnAa1lMPJogovvvbePPs/q3Xr++kgCsfgB5oQF9WYKPJqEn6G+OE3i5AqouF59FQOmahQC8rlPLj38kg1c2f30vw+XaoIX24/pMGIgSBoZqoH3wo0sIIGlA9PWcCPrAtpPB8eBf6x1o6cHra+2+tpIFP4PgBfxZtZUJfo4qxELT948D9ucK8Mt9+ccjIQw6QJcEbrD/1g340ATuDgDkFfx6twSf1f9xvuBECYxq/7ythQQGm
vendor: 25,504 bytes, line 48
48+5JDx6Brw4CkMGT3wgscCUoQ4sU2t6DR2ciBjTgtcpenQoZVX9NuL4Owc+dVaDursYVkVALX+shjSBKBuvCYDUZjE5BdNkxdHAUBexyHwB6NP7Iyw7sxUDViwge1t+mz8B/LAvVx/c3PeBBCToB8IUGOgqA3iV4yUg6UAOxaUFHDx6CYS8SorMOue0CCJGAf5YfRhoAI+A1CvwxqNkAY5yAIx2EQmkFfeWOXi+nEdSQQA0ZHMEItiagJArQxDXIrj8nCfQi4HZPAttrIahso9oPQ/2/JwV5JQU8zw+7I4D7/sBn4EO6rjw0FR+i3Z9fHtahzsFvJgM0X+tmVH5vaYiNDGAigewAz+gyNLThnjCURQFR1b9d3lZvnVqmj9mEPDKIUIC4KCCjBXywS4N+otp/Hk3QVthOkwEKlV9PQwXjT7s/zwF4Qf9toAAzFdjuaEB6S7D1//U5FIQu2MevO0rQQH8ZmoXE6B/IkgE60XCjVoq8gt2iCG0S8L5GdxkM1cGsfsCMArSCAnrr7dzAZxCEEpepvB8tqHJ/q+bmJGGts/AcAXFOMMeTwC7Pw0B6CtCtA2vWgonqBQJFSwH0JQK29OB2kvgj2HHXAoyeAIsCQO0kMNECAhFMqCBf8mElAkyBbX1tJQP2RJ/ha0gpAfS9l+/5n00CkrQpq0MZbOdAuxmMvHswog62jZj7BnYQe19b14kxNq2D/ehX/p68HEcF+x3yP7z/V/A/q/5DA3i5A/dzA5pdgbKp3v3/wQF4Bb70WkCTHGRAA6+KL0bFl6FJaFw0ImZwm6igSwbbwPn9RMBWf3sN2JgA/BVh/Rg0kQBgePf6HglAHLFQwqQQOwDjbdVxNZjR4iM6Qa3WxwvNxh0JFb3g/WzFQQS8b/ttKcDWoABtUMAd8j9hf0MB2uDXhzX4CHj03L9DBU3Qjz0C0l4mLSLQPicOOwZoVCB6P6dA7nDbGkVuxcNr8PU2JQO4wX5trEqmccZaHU4q8oCDFOpzAnOwqyMIMktNNNAHouDGxO37DgArQZzlmp/14W1QlqHTMaIIx7SCx0+5yza7AKJ3IXBrNAHVDcMZAU/BT/vgv/ULPOA+XiLggAREDF2g0ci6xNDRglegd7P7TWWH5oJfayliEg7bScQRBVgI4Ookg/F6rvpLWP29swREqA3CaG8/FpKqS8DTAV4TiBqIqtxfzaQRLys5I0XEFIFrPbZRQb+16Fgi2LvJv8EFUPW1gGfQv1T/F/d/HBnccP7rAwnIIyHI4ArgWeGbU4eHy6Tx/EeTZIb5bo/BsMBjmjBE08f/RB0PHYBd9eVRAGY7cHRwiBf8WeCPHY1bgBTa9xKTELzEkQX9CPtl0gJiqsAmCT7I8xbjivh3JGFI+D2nBcSJQJ8agDX+O9iBL7UfG4bzAkcaICrbtYHz1ycSmGmAjJfL3CMgT3tQpmrfB7gxSzC1DnvdhQMieG47u75+kTouKNkM8c/+vq/Q7ZYjO/hhVvRq8F/9gGfhP8aqE9EIdR6LTwJ1h0BItyDqB8iFwuNqASscRnYioxOg9ApvnYA35f8e9Ohbfe8J4rknoFkO0lmA2gmAG0YK0DkB4ieEjiLoMD8wBzom27ANZkzIoU8EMHk/uo1mzeVoEoRWKn8L/62EYAX/lsB7D/LXg74uAMr9oGivJ0CNJCGD6i9DhZdQF+gtOp4S+NODRzsDVbhdgv4BqTMNyIL9SCKwL9/FGPp5oQKxIf8A/UX6r231H7YIqLML0Ae2GtrADOvRQH5b/MPE9dt9BGLNG8jVTAQvIaK5TtvvvWQgDvyXIClUA78S9Nfg7VtIBlO7cbsEYkQDMot+ygQ7QwmOawTHnAM2XUSnJvPIYRYMmYPS+sv3J+cfP3d04JYIXsF/EwMbBKB9Q9AY+BiSwFj9mzrSXmcJhFPVHySTbgHJCPvRQ/z7G/SVUETsg0ZF+i3CRoCjhf7y1A9mOiDD7TwdwEoEXjLwAv+avLE2B7Jnb+OqDpBoAchoQJskxKnss0vu7Q2YhcDv4ySeLOg9GsCKiUIihP7yfW7zbTsBh0TQfN0iAWn9f72Z56/Ax9P7j5OAH/Qvv3/QxKfk0DgDuP+R3USg3bzBC7bO/QT9Eeh9QvDPG7glBQzJwK740lAFFgFk8P88CqDGAa223YckWYhr+c0BPdwetl2ocnsfzePAWcVnnAIp6gDVhDLyfV4nqFEDPxHsbWD3k4BDkN+pARqKMLYBPzYEvxp9xmCHQQdgWH/9EtH2TIFpu3AH/cdGydv1j0TQbRrq+D/mLcX3ZACZ15bF378CG0My6Kq/zoGOQwhASDFwFbxyNGBuSxbCEhQ/uEPe/6gAERWQObCVVfjPpQX+rexxYhYFxIkgpgX7Y/vPs+Pvxf9vwt8kAs7i32t3QCP+3SPaTwIytQXP38u0PESm+YER+o9B3vr8mETAUfDrEkPI80ck0FZ0dXh9U+HRbhey0cAc2H7A4y4egoD6y8JfkBiigLdFP8v2W00E8deT2IeAKujZ/QAVKpAtKI20gLWksHedfgPcb+0+NEHefd9vB9rayi8h7J91gBbaw20MsnWAF5xHkyDUCOoXp+yrOwwxcKj0aL6fFppaaKDv6OpHR5sgx5BAlK/+fYhuP1D196o8e7lFBaKqv5YIMnFQpd0FGVR35RJCnCDaABaXBtgbiSwtICMtalKC+1JQ6bx/PLcDPQL91QFodQNKpwOgF/9eqcBxBBqRcKAAVk+ArQOMx1RYGgB6naDhlK+uQQwJYx4meQbxtNnYQwMjt/d4f3M9ZE4UOld1LAh99fbfzOxiEkKFCkTJIUIMUeVnJ/9sDt8/e1NEJOi9oVHDGYhgnSLss9DX2IAqw1zALUncKcDr0FB5NP+0cBQNrEezDiyiADPkt9qGpwoPdL0AGPx/NOKeyf3b9WJNdfcFv6bKd2cLMJVfJ6Y3B6wB9WFUfWWEwKMfGiQL+3bz9XGQz2EHKhF41GCtZyDi/gUCsNhYoAr3UNJ58YidHKqnMb/6AB5J4N73/4L+t7mAkeeP3P+1LNSB/l0SkMEd8DcEuUlguEw6t2AU/PCE/q++Akw6QFf1u6SBrj1ZnnhG50AfkoGIdf7gJv1KcSfgzWWkQ9U33Z3tHXYASKJ9e/YhU90rvD+q9Ej69/wxYJVs506Eg/r3DkMDzEdDBRGgcZay49XihLA30P+l8N+hf1f57/0AoxbQbwYaan/rBMirE9Dk+sBzTkC8JNDEUlv5McB8PP19Y01Gayep+hC/2zvQ/2HGLAurowsNGlA1cnqGGzeH5weiYLZm7h3QQC4O2tXdhvMMk1ZS5ebpgI8eMrPvPGkwaxayk8Yc6PMOBPEdC1XZ+2UfbfOPtxLMQQAG9BcZFoF0gp/RKjxe7+oAw9T7ZPWhgedodgz0gf5KBtrtIZhQAZpAV1Bi36w6t98qVfH7hqGI318lLCjLCUFlxRHwqYEH9a2qb4XjWvDT7kBwfbZA5P0+PNuRuW1yf4yNQH3zzwv6b70QOJ0G9OT/dhoYRUGT15uQH/71MjQLtQlxfDuiCXrtM+SkA+icQdH6sU/xz7Ze7FlubV4TpoTQ2osdpaEjtqADmEU7OkBEFoLeC3IWFFeswJXKXzkboNL+wzcFHU8hTGKIboO7CLi1/P+5F+gydQhuvRbwEgxvtACmANikhLTbj0gCYk8KdlYgmj+4Ymaod7TwahwadICuX0Cm2fE5iNHPK0x/CDV66Kyg1MnqjNFBnhBoLQCgUULfaVe5nq/6EQWY67bXCszUb+7232fVPz51iGB12owK9peyP1T4raMFF/OEYJP792mgXYfZ04GHMAhBkCSmSj+dKqRPgVFGHbpLEGMiGFeQWfSgrY52VxaeDUPSNJI0P7NoisG729HHl78z6hxfs9rV3m4JjgM/lsui2qmThjCfDFSb+I9vwUqG5wwL55U7C+6ot8B+7N2o6r3q37T9trfpjgmTvv7PSQATLLeRAOZhIJHBQfDQQJPBdUwEbVW3+L08EcEE/9G4ANrCeWcnPKRHDupbNynMx5AA9IRYLmrc/YLSiD5EaEBS/s/TgnU9ILcH19n+CpHwegLejx7Mn/d25fdN+e9U/1vgb7bqf08MOtf8EXxaoh+GY8L6gDfhvs4i6HQ7seYI2sv1GchdMsBIG3xlvxcCRzdgCPTn+6q/TW00VE8Q9FaFv+R2VlOM1vm/hhjhDCdgNflVKME5B47I9xT8z0YgPAJ8myb/LqHy36j/Mwqw9AALxuO1JVjiuQAYLcFzIhiEPe05fk8tRjGw7yWQbsfuLAT2VqOId1osnr0F49VM8INACPHDoBz4B5mqqSnUgyh3ArjXxfQH5BbgUS8gP7aU+w0zHD9GGD0CGHf+P1p/DeivlhU4BbxR9a2kYFR58YaDZCUR2P0DMmgED2eg77puegy6PgDphEB0CwlG/i9d+/Hs34pBEQrBn0W51mqGnJAk3ACCHeiqkQ1XFQA5AlKH7Lk8yJKWY3/nym14h2C3JvxeMwD9ZVMz0BPMi1n1RbKl1cYhIVblF3G0ATsRiCMUvoK9//OgcwYMoe+ZKOLlC6/Xk50br9NFz9fanqA8UIYSpCwlBO4kHc4WLLBfBHVaKwKgLQjmP4Un61Vq+3s7Bsyi0WztmLjJwJwFeE0I2vD/1Q6MVwefxfUf32skCPbCnxQqf+QMPEUDHZ7vGeyj020JgkPXXwsldA7SYR1RE3h94NvNtugswcgxXEkIcBPCGZ1rmrgDC0A4K88nm2fn/eTnpQtWyZfybRoK8Dro4zYDIMGsf7saTBzvX0SMbkAD6o9CYbsfMK38cJKD9l2FJt9/VGs0h5Gib33pxMKWNsigFUh3G2un+/N1WUglI/EEx8fq27vUNnwsiOoKecL7kQS8VnWAGCFUgn6dBtQhv40CmIYggwK0uwDHRGAuBXVdfwzHUjZzATLMAoyJ4FmBhzaWBlrHld9CCWpPHRqofBqMReMGTJ78q9rDes1Tv7/0m0v0AFHXNR6P6g30SHivin7V1BOhh3iWPwvps/yE836L2XiwnUT8x2iHgfqhnwn667QHEE8oLQjEvtEW7GYBZDrDVkwNIO4G5GiBDf9fGoFM6n+vbEtzXwP6u9AduaWnGYSLAlVdl/AU+ikrSeEIKgwdaZ4AACAASURBVKj4/wtgHcHtdO2nWKcBkPfxcvnNQvsj2Me9f02r76T8q0IBn9OLKfz1HX8yVXQYGoAB/2UeBQ5/5kCL6+H/OGGoRnLSwdd3oH8r7KkGTbgIxEwVWvnF8KOpHnyzfF9Jod5Px+IF1h8owyitDw/XEgRb5bPqbt1uvn7qBIQ16vtS/u+DP3cR7CH0WWJgd5mTJKYgNzoGjQrfvu99NDBC+bnyW1x/qhTatv2OaMKgJWPvv5kwnMgxHYGFRtJW8VMl3uP+MgoqSZyWFKr7+KIDw1d6+IiOgZI4+d5iYL3imzbgyO+tph9t2oSBxOM3ugHtPoFZ1LM0hF4kXNEBssvVgPdjdXZWK7uKvyS3q1Xb1WQwtVDqSUggq+Vw3t56JA2cz7PXOwGNW1ecwxPhfe3QEUsDsFaAz8jg0nf+iZMAHNg/XSazDuC18Iq1HBRrOsAQ8NLB+16g614jmuSgs3bROxE55D+WDDQNA4ivdMJ9M1b309UqknaDU8ObV9/PwmMPATvTMAxpABLBzugUtV9bLdhNDQA+7B9tQJ06/7QNDHGSwtgZOCIA47InIoDdROQGtt0U1HI3GaoUnCnC/rzBMQJteN17+VaAzYNA7e+PFqHQUyXPUYB7iQYa5ZFjq1Zqpx8Uqu/XT7+6BWC1Xaj0GlBIwMoHu7UzcI/6/Acb8KIq+hzmGWmAYnADrIpvKP7TZeLaf0LAeQkGgebbq9FToI44p654F47tekKkI0L5PQNZPsDwPBpy/ni+wKMN76Vav4+2cFZFf8+JwAraMt0DFB7beA/u4Zz/a+RXx0M/ct4/jwaNAS8G17eSwmta0Fhx0VRxJkHMivso+onMXr+YwdWKbgioy1jp4x4AzIKg5lEA7wvHEYCRmdx11TAuT6lDLVl4KvXkAET9P4RT8H2u+lg9EPQIpw+/NpJ7RwE8HaDv/Mu4f3OdNkq/EfAiEiOANjEALvcWL9gfFV4NZbgbQc6qPky4Pm35QZxtH1f4j+P/jXuaYPcWwIEH/fmEPBoAO4m4LGxV3txOQqDU+dXgey+UwSzuqP++uImO/u/6ogCb7wTc1n61sL+vZi87rxnrNas+giTg6QLzaUCjIp6JfhwtGI7AjBBB9JjDY4ePYVR6ZPgN4owVv6Q2N5hhVHwNeYrM+w6dN6K1sMHZm/Ce7bHe3dzKr1xw1w4JrSQMZtgnoQHlr18fzunAszD4qurNUg/TDqzx/lfCaO6t4tACMUQ6P6htWjDPC1hCoZ8kpODzJ70MUR9AODcgwyqyPhmE+wfHYB/hvSqt6qeXUShhXH+d9SR8DzrDaZZdpSp/HxqLMQuATgDU/qDPRgOIeT8cvz/h/XC6BtE7ACLOWPE0KIS4UUjmZaJ2grBphiWgT41BUVWZfP3AnEIT6OrfoF122l2rMycBoU5i/OXoUZ4/aglsXwLzHNU++FVF3qikOj5HXm2PBitT1WuvJRAB+6O//W0/PY8vQH5IrAsMs/WuVmAdHBrQgrbOxJShXwRSsu08h8JMBpo0+aDTALwV4tbswgzHrftG/dJKIAQb5h9KCssWIMeto+GYqG12/HWGjx8kzqNJaa0noMWOr2KwW01AMwJoNvhMQda2/RKQP/3ecABM3g9uD6BY68Ntz9+nDOMb5iV+hIE+dP/Zs/wwJhJ9mgBnohBuStABUXjugF3hkXF9ZZJAjefKdHZCc389LoStKvIl7QIEb1d9RyciQgFDI9Cjyccc/23Aam7/PZJBhgDgin5CtQvbCzX8ip9YgIFtOAt+w0owp/hOiCWgEGbVHuYjRigPGR/YOnEoqPDoV5z5YqB3mRq2ox5ICmSSgAP1Ne+XV2NE+/vuFbCTRADxtS70VRBCjgBk2OyDUQiUgfl77b7DwaHm2rAZ7osRSOOUoHgKfNBSLI767+oDYrfwZvqChSpGfj3pFwZFsCJg2jeIQQBUiyI4WgD68ww4qO8khuWkkIuDrxWv2nv+UTBpJYiPd0KemTA8qqFiuUF1jWS3BoG6pADJq751JqBI0wvAVPyMQvjcX1zbELltKK+zBiXRFiRxG+b7q3M9xuLdzR8g0gCGNzSM5gNYfqGO9CBT8OHct6oB3KsSDBisUnwsFuISQaRHxDSv0vptt2oeLHMERfRn/FG/Cx01EpgIQG8LP+/i37PKw53xn6sYCM4/JwSRrCnIeB1ZkLsawDhaPKv/njU3wnZ/dBdGE8+YTHSG8+ofGgIjsC19YnwdM/KAnTSsqj6ig7uGgIPw3nYFzhhIIvriAxFP9CQd4HSlnzgxONIdrE7A8ZDPx9fjib8ifgegNIliRgdx95+E1T7+3nQVNNhEzDgGA3T2rEDLduwtPpuuouPcs8swwXFjdTaMKt+jA5gUAQPcf95KJQxYU0cYxEDvsBSmYuukp7AwnqniC9Afa5z8vboI68ImT0t26CvwBzSggkj447r9IojvCn7U92J/Hw0QSdwZKNNjxPCfSxRqnATkdwpOwh88oc4J8KTSm/wdbZjrc+4iFP8YO0/5JJDCfaijK5xVXevqfg6zGRrQf83chvX4aRfAE//6vv5+6490U4ADdO7QgM/5bcHP/n4OtCQhBEFeDWSvos8DPq8/IwzLzjpa8/U6MMSkBklDm8e0mn3QIY7XG1Om8wzN48y7HwhOK3P0/ZwUQHHv4psbdoVeb9VlAjChBCdtDDpOKTh9ZfcagOYq31RFjN4/gwBYzp8lAwYNwBELhZoxECeZxMlAzWGdCRV0fQWGHo8+8Kx+AAxnCIzowAxy9KvNepWfsfp4RR9kUrD88CPVTuXRybhqqTHcnxEGndsgub1Gdug8yz9fHt3Hpl57x/mfCOC29FOSQ7/noAZR5W3Ob24UMpuPYAYiQrQgk1gnFoUIKr4vKFpV15pHUJO3Y5rfH3UFHU4bGkU+NKJ9f2hJyOMxDBDpjAgwiYqvk5TqNl9EH2Arb6fA3yaA4cBtPWewhkEcIQJBlGzYp6zRmr1v+e3Fv27xpzvyI44NGDkCIi7CGNV9Dw0M8NtHC2vUwHINumCGNG8erxOwtQINsW88Tlwdoc+F85nI559ngEDpt2F/Uu3hiXYrkN/pBFS26hYDAkFgErMK67y9mGBA3L5ore5izf8b3n805MOq/t7XU4WHv1DUF/5gugCSOAIW/59uMwl6CHWAib8bvfxWl9/rBGEMTTwDfG+ezEYG4yk6FvRPuPwE+wvc39IRjENWM+/cm5b0W4Pf4WuKUnw/vD6eDbB1ETs5vl77Dhnm/51g6wPWwQAqxnivgQaeS3gy/u/1H4hpTPrIgHAN0mSgXUX13YP5PMIuQAfBr/f70cdeE+QoCX3i8nFMLcAjInBoAIYqt1LhC1WdtvmSab28AYffaeivCB+ohdYQgfUa/WS4ToMsNLHLc9nnvPZLwn1/EefPVf+U/xvnCVSEQEkEQEnEQJO7S7RvYDxNeNYKrG7DKMhtsQ8cMmhgPKKKj+F7CiHYFR5KIIPxOmg5IVAtu3ACQSPh7CzUQOgAej5CWEkIe3vgxz0ROGO//qYfz/dnLT+ZxDr4QW0eNCJBorCFOVC312Ec2TiY5Bk0cAaQmiA1VH1MOwDHQ0kHdEDDf+2UTWhS4Z8diQMicLx8MLBfverLcP/jQzF0P8EJj5+NGK9RCz755S6F/f1+X/gxeP+Wsedv+vF8/54aSPJYFjIQd624MDz/UDLQnr8HU3ztKHRf8Qeno1vyAQJBaLcMtTV3cvgP56COCqd/QP9xLgBkH4BxO13n4hNUDtACC6G1S3zqooZ6Ba4lp/zcAFb7iERKQwQcF39IFJjdXECGADw0IE4gg674pYAnk4HoHPx54tD5daO5vxrugSkMjgiiqc7TVKAT6AT8R4ckbHEQCYR/IZBxJgA+XZjsR7vaoRpIxWqeqfXuGC2CxwudicwePEB1kNkaZCuwyF0DuKv/4sz9mzP/Qxdg3BDkBTMC8Q+loD6UGBzx0Kz6eAX/KArOQTlPHFoI4vVtf4rNuLrca9edRn4xBP7k8w+9AgZCgBfEUZWfEs8iFNZ3UO7TqmkjCO/rWdgco/yIqHcQWaC2EGTzgz5y/iXQAvyx3riyxxV/JeBriaGB9OrTA5g9/eokM+37GszqfA/UZk9iW5UnCtBqBl3XoNN6Ag/+zy6A5evPAp+TIFDn15gQw9rjrOzFX0s2JBVAxa/nP1a6AsNWYGjPNGPLTQgBsNUFvOA3Ht9o/rGDN0tWOCcxJGp+f7++kkP7PxcGv1+GjkaLt/fawpwwerQxBJNW4b+PJsYEgiAYYdEAGIlDNaAbRkIgK3ut0jKByp+8yz23X6GttmBmjwDvChgiYLP5V/zhH6/110sGcKo5CkggCngxnIPoPja0j2B+1BRkiYJiviaLJqghDI63G2nAgAxMCuDdnoD0wIQm+urMB3VuAwbBrFGgGgnhAFqg9+ujKsLxB3qGCQNEEtPinIQlAj4WgIw7/iXc9V/x/yUWFs2KH504bAh4aYWf4TrTLGTy9YbftyLeVOWNfYNyt/ji29mQnqMAltU3ioTtbX343yv/1u0YPUBz6zB702tQucnX0gWaFh6DgPdmhXaapGotw0SFz1qDiTMdd8h45HfcqCPRUhA3+NmKz1l9teCPaMd4urGaewRitNBDdahR5c3AfQmDCFT9vmtQEwqAYXX4XI2n23Z9B/Yb1FL+LWox6wHGbZSo6FR1LzyG+3hriSZvWT6jfXhl2cmQZJDrAbuYAqAHo1GA/EOgD8eGcU7A8eDvH4fQBuAhBL/Zp/vamPTrRENDGLTV/7E1WEPLDlP/PwzU4YhusIMUgfIPAr6Dhv5R4y2r8ldFwiFoYHnmr8TAHbhRQSZOctH598ZYhqt6wP7q/ouqe77RJxvzFYaji/z4vna4v5cUMDXqDAJ5ytktqtBDckyjvJg04hl16LB0xFfyMfD77PZjErGQRRjYIfSvoAXntks0ok8MsUC4KARWnYPlJBeIgLeFrUgDOHYCag0/XNAbWgRwQuLAsaQwIhC1g7+jCNKuT38JfnYSyTi+QQEwwHeT4/dWHYxJPxfOj5oAnRQqgU3YgGZSOaDyK3n/qkDYBKptzR3oD6B4fyRKjp2AzSl80YR/3P+/1vBjX18Jbu+YsrMRgbqPP8zrDLTAaupphfeZtyPs9BPztpLSBZjowF3woYRwBwOWaqbev15b7X4RWsiqYiY6ZkFEIoUwUA2OrkeEQE8HYNyD/rl3m88jCGgO/nPW3xy8x4Q/HBcM1dYg5q8N+B/SBSYhtD0EY1PRGLDoKIBHF3yLz4H/gSYQJRETgqeB2d4vC8L2NVnQn4PoVJJAcP0inahAfdXVI8CFszjRagCTtRdV7Sr895NBpRKXIT64RMFw/iw5eChhEvmmyUIH+k+Qu3cLzOAN6ILlFvgWnx3YWFDz0f38ze9GlfP6UQ3ojEY0gtqRIEbA5/WgQFhsEuIeL75uTzvqHktAWfj/OD6sQXssROcGiRgFn0QVkld7OznMDT7CJKzhMIqxW9B+LCOQdH4uyxIcE49VTSeLj0wKjzcp2oDXQA8YoDEGBLMW0BJw+eAxXejPV/IXd59/tp5rVyYXDw5BlRetSpQAcvgfOwVM8ObzBq/AQ2wX4lwkQV3vNhYFfn2LFgaoDU1ogqsfqGkJYmrj9Tr22KQwBLzbLuzDeA9yzyJjVRfwegWq0H+FThDPA6ZhZwX2M2Kh4waovCzAWJTzD/qY00c+6PM8coz08VNqglzx54LfHuTJK7z2rwX35ABLg1DzsZ7Qv7l/f2yXDlbf4C/irg0MJ0aCuD0wP74MrxfdFlX7tq+vtRdCpvt599EG9Yz3V+P+Oj/n4zLruZHcJ7oMt/MNp9eD6HEeFb6/TMfbWo85Pb79HJo8t3371/PuIAZqMvjPC34nVV6ZB4hEuA7AzA5cfU0y2n6ux89D/35/n2/vWY5Bf0qwf3tPLISO1Tap9qzFB6eap/beqI94NCCbGwgqOItY3CGl446CaQ8i2Q9g0AvmgJOnBoAA0gu17tsKtKS7D4udgCYERy2QIceCX/P7mBW+g/7D9S6Mn50CS0eAoQPDcBjopIA5+EcxEjLweRjXq0UbLIjcBxsGx2IZvlf0ATjz/6qypAmY7bhrk4ahsIis6ccXKHdueAfUgk+RWPCLh42c6zEeKyJpRTdRAOqBbl/Wq/uT+q+Fx3FoTIuCzc6+hN8j4veGjuAnhSE5gKnco3A3XwYlq2sq+lmP4yEOpqEoG0M+mGDYuYT0pKCFHgLHKt3T7T9p8GcWH+n1UwGa8X6kQt2x4CeqPexegT6o/Z4Cr313PHdgrsS2ZReLfpKIf+IMFnmVmwxQ9AhithYT73+p2s+JIVfrjwiHnpAZrSsr9CMstQXP1+1+510N/q8E/YoekMN9OMFvi5LvkRDsy9rgFCOoPdpgaQIWBZjf5KCSQszZJ1ivTvLokpen6tsJAVND0NFqb6GUGg2Im4Dyx9Pn7/0dm4pADAslJzTv+dKNrAPQ0wyySm7bj1RQgbAXsRa4R+mBJzpaQmHLmy0BLoL+Nh2ZRca8uUc6P37k97n451fvTieAE8BdZ2ItqFEK6oOJIYPsiU4woo140Oh+H/UC++gatHYcOFT+2y3AYvD1rM/fpxdUcsAi70c0OxAEP45X/hymE9XeoC0zfYhbcqfbhs09HpwnKMDR6g0mmYyKth/UcLl9ITGQ8N1S6s+gA1HvQCc2pluPvN2Br8SyZyfyxPP/VhCi1L1HWX2CQCuAE8TIq/sBYdANZmTIwqq0sb0HIzhhugBeUpBZLFyA8y+EErsBUYDZHYN9QAAooQwOws+uQlhdESSSqk5Qsh8LSYI6LDS1AbmOvLlRBqQIeITvM36+TP63VfE5hFClCTr9zEyVFwS3STQBy66DMHB+PJWIrfgGnYBx2dTboPa2X49GaBVlePA7CFx4iaGi4ns0aLVjMGvtPTDtmO4XEE8E5Kb/8qYai+NHl60LgAICcUCoJPVeiYG6Pxw/X9VFNVbFn9FNPzXoIRDTyzcpREYB5Fm1EQQn3KRi9wKApR8Tz48SwxnV3qM0q7ZhpdKvr0zfY+gO4oQf+EGPFYW/Xf5hwWsUgxiBbShGoGIx+D2eH1h2EeR3UQMH4zMaUKr4033nzkSkfQADelFbLOQCalxdxvN8mInhPas9bxtGJw29Fx3Y8429MAS0fL33Oeo7qFZeiToCC3B/VSNYuU0fgDnkhxGgMFdxiYEY7MYel+OHPH30IMeVFK1C79l+QdXVpFqHlMAXEf3EYDyfkkGdNvJ8f3RAXU0jpgM7jMNA5yCrtfzOicKG/M9bgEkEjqqPPDEcDfqVwGZv6zcO9avDfOhf4OmLFd9OLBHHdxp51HvOBlnAoQksYjASA1xnIhPsapTCPjbsGB2YevpPpgM73EYeSYIftgPgte6CWesVBB9QEgfnWYMgoeC8ql69bWoRIqYHvSIv/u26bj/jdqZ9KSGk74JRo6QS9PuTiSHm6Z62kLUGH0UO4rwWrhtRETkR4iKRdI8giJ2D2nUCMjsA0TXiVDb98NAf/rCMlajA9wesWHZrAe1dlwRyVI2jx4KkyUHSx7YDe6YD4tOC6XW01puEdAJwaEJzf1uATHi6ZlSCpBQscsh6C1xRcWEG4bCFeKcAVhVlDu54JQIkTT21hptIT/Afk0kMcS9BKfjBJozcDXCrtgbWXxbMAw3INQIxtQJPAGwXmYaBbYh4SCsuKwLOAQ5awKskCMmRg8P3xwlBfbosQaDqyZqBkyQe1CLQACoTgN4qbyHsPwkTiF2pYaj6MAXBmUosQHnUEYCsBL3MW39SNKMJ5PfoBsT33DVJCEbFnBCMOkHfvj6Xq8uw+dgRIhGgAiUqf5QgKDFyhe8nnYrlqn9sG1GoAfirubygX4H+8IM1CmQrMFAJ5ExzKIp54nPoVU2Auh6eBShDlTV4u5c4HE/fVvjFrsII0Ik6QX+Iq68jB19ziLoKC27FYe0gC+j1RSS+BgB7AvAM3m8HLdy5fV60C8RMVuhD1ieQB32MCCq0QPJuvuw5IHF/geMKwOPdpmsxBwVEfGEOgeincJqNmuSFIPhPq/xM81CWIIi+gCFBqDX3QPYd2OcCRo6GZBoA3AM+00aesAOQ7/2Pe/vBCXoguD4OBD1WfPwClzcui12AuH+gC0gEwW72KfjBCQRBr05D0IQc7N8PzOCMehPWK384MPVDJQim7yDdoiRTItzzFV/ZOX9sYFetP0fsQzb6O7wOoFjxk89YoQXv+BmSN+yYHYO+BsDRAXHhuJXsEFbdIEGZQWUkNVNzGA9NZUVBIQL7jASR0AclE4Pb7JN3BO72mG92+o8UG3nybj+mASh0FsLKn9GPxDrEcS2Au35BzHO1BksriIJdpqWjKR1wlpR4fN977rZqI+XbYjYDgVDpcYQalOYKMiuQbB3G6Pu/HlMbi9a0EMkksXtjvvXTfgMKAEZRN/i/O7yD8Da2S2Bdh3ICWfp8yuMkYl5a4df4vVWt4UF0yyqEnaT6swYyWB8/j111Y1ERS9oB0SLMtBGDEBD1PEHwtdjUEAHnqmoHU4wCDAoAS+lHwtu9eQLUAgmxVvAuMB9cELMV3m8EUtcBYYI9nkNIEEJYrQeUHfnzzRyC39j8CgSkir/E0P2odnAmAqDnDIhqrtV9BDNS2POjv/0pwKr6z1h/PMz3uf9ykFYq9TtoAXSwpz0HljdvBCVAPY6t7osv6gFhMpkX13rcfXQMIpuTsfTibkfOPRAC2meLRipI4mDPwMD5x+v3+Ey+qEfACwoUEkKQSMZxYJDz9R68PyP43yvo2aYf881rNQbZgRU/jp80QnW/hdXqJxMvCFxXQSNHpE8QiF4XI+wFfQcw7VL2Md7RRajsKgh2D+6SLAKPF356+/7yXYBTUgFy/38StUjFHweD+iiHh8/LV/i/TSvGk4L5x7F6AsIKbgb4C0YjgdGRIToGUx7cgS3JKP8pRcgak95BJGQbjaJdBYQ1qHYnYHL8F45QgHx2gLMQ2cDxBD/4SeR0LSDi5XzPQNjM4ySE/HGG6g+ugltLNSARn281BPtNO72eJLjdX4ITSEgpQvJYFEUg24f1qAYQNQdxx6Q/RcB85j9f+03zf2QV33IDPHegNgPABTfqFR8cZK9TA7/ll0EQbUUHW8Gr1d+MSadia+LRHwhunv87yWoJ3h/pRDwJAbDNQQFd2P2mH4kP/wDT/ZeN3CK3+ZjvgVpw4r20AMafb58j4N1UMknuj6iCx883PU9g2VHVH5JX2eEcPghSgRBCKPzK0Q3fknwPN0Hk0CyC0zBkz//7duEetgFjVtypASDI4CsknYJgYDhqsBxxy29+eyxrAZX75EEf8f+CkOcijMDDHx4ASYGGu8WHgPwpHJc0qOG8FgFTuVk0cRZVePFwHEIUEu8xSHoL5qWg4I7/HgOKXe2dcnu2SSdCGIDTA+AcxY1zYL6Q6AAFu+/1GvjKPSeEoJV3NiM4Dz9C6oWkEav+NWjPWXNOIkKgNTi2I8LeBgaZHJxqrC4oNXoB9pzzMws/OW3ghSyQJgjbygOVEDhoj4nHLld8HPD6UUMFVLIgKrTL7cFoBRLQgEdXIseZ2/HhFPKbk4d5tYWwwR0nIFQSD2P5gQhs6meVfB+Bkyz2fOIvX/zxqsSODuAGIOLtPNnmIPCrv6Kqvgz3q4tCwNl9lWYfnsdHj2HTgQw5IBHwULmfSu1jEV3gDFSxTBmqSEVqiYK2IkWcRiAkwV/cyW9YhqHXDw9dkNQAcO6HFNJT7oChfrPUYc3KY17zAd+evAwF2w5SCKLV4EuCEKsKfjBVWHu9Q9Arh4CoBqEMWYBsNX7YgKP/69uC3M7/mOOz232QT+ox4iCyJGEFP4oBHd+GVvXBwX35nqp7qeIbV6L6tdZub3ueJ+gBIKgC6S5gOQFxDoGr+Bv2nzqbknd7ph/EmXzO0o+kZdc/wqvQkAOUffVMzKtYgx5Vob1/+HAfCdzHSiXHenX35/2JTr3KZ9Ruj2lYiMhLIFoNyMq9hFroeYMTE0bSLbhb4l3YlFPa6hMd2jk8dmrDgdQCnC4/+ANFlYTB6ATlx2GDGXP1rvL+SnWHw+cJes5/rRWt4H2pw9GklD4uSMpwasIQiaYR92gIyFX5S8dtRZt/nCAH48VXW3hRE/HKOsGquj8EM85Q9cfeAV4XwNGAlmIFIwPYrfLKuxV476RRetzcdeAsRSZhiHizCKEIOHn3EMOWy5X4uIJnXX6sFiBFLaBm/THOQAkVJK9j6TKwiSDTBWpwHkSPQJX7U959uAkoaTUuug6oQCBz1Zlxm0OJSIoIw04M+7zCGuYiznCfHww9AN6Ir+HXA7lfn2oBSJ2FOOh8SzINfmcAyITq8JX/sOMPx6A9LeYtVfwgCBZhdu25OB9/XmWWNPUEPD5dUuJ68wd1AqD2+w1PI9KxE9BW5t3z/igdYGWiL7L+wPv9jgVY8f0ZcbCKCuLAHN+c5wa69Zpr0J9t2KnpAGzyiAIPiFalJ8/xXrrA6Y+/8NoDnWCPNwFJzf5DpVkHte8hx76P+HU1+HEytEeSEIzAsu5r6wPJGu6oLz8VrKofXLce+ywIHhNa/Dmw8LrptWXZ4NKZm4pr/QQ7Qk8ehMrPtAF7PQCD309QgRgRZMKgAbFREAfBBXNalbHA9cEHMo4IgIUuPjjBWEUFEQpYTkhVO43eRiynJw9Jjj8TOUIlJExK+0wA4gWgQvcFBHAc7P4/u78/Ff4CC5ATB3P3oUwFClYgcALcxzp/B9Ez4DUV8RjBbsCBrMH4dLNwIDaCGhA6o3pXksdBvYBsktrXDgNJKAFy1Z+ZGIy5NXgXoBT8a3ZgVSPIUAMV6DjLxhsV8wX4n4ibbONObHNyCr8Z4FinNFjg8ziiF5zSV8A99u7Zdf5OisvVaAAAG3VJREFU/kIPAJLWX3hUIFD6o7MD4WkHIMXBk4IftSrPNBJVk0OoC7ice8HGS8XBKDoz/YFBLaQi392lGpCMJfhD9xVkx5Xbj73P9V4m1j0v73x9FjDDPlYvATkgFAVWcdNvJBamliOjAwRV0EpeRymAe717kMYRyy/j5FwFBX0fP7Dyx8gq8wn2ZXi8GfGYR+lFcGJSxa3Y84WgzBHetlU4cvKY44Ps4iP9fsgsPGEhQTAcHqwwGCj61SoPexKwasXFqtxq8qhD9SixoBBYcJEDNzmIoi3J7QkoJActVHocTVpPBCDhElAvMDK1PT/Sq3DwB/ygmyB9GNhYDH4so4Foy48kkPtZfZEv1PQTxYpyX0EI3Bu+/5krcN8fgwVdwWu2JNVNWAk+PcOOPMNdGFyAZ5Aj6gicgzNfwuHZg0HrLxBWfjSRl88fVCo/apX/IBrIvf65ZxtEoK9Bec4KZIPLe76osQns46NwW0pUPCPAyMc4A/KXOwZzFLGbAqD5xhhbgBcWfoJBAlarcCSQgdQJ+Movnih4gjZQTw51rz588y/ZgxVUEAQ8soCfX8OR26JwujCLGFAMsOjnwGrlPuQw9D/PPv8BYVR7pG/eeFtQpsLzR2KFI8SwKj9KlX++HeLOPuSBKrKeHBi7L4b+Kx184+ptAp4Trcscv69oARVYzWgaK01H1X0K3zNSmARKtxXYHvwJuT+8gLGGWgpHcWOmBeljFB2Ckg6wiAYOqfxEK3GMCAj6kIiTWdCBCXhkjUKMgJcLk271N9uLSbtvvK0S69OXAvoA5z94VsFubbmZvx4QAnXgBnJxENyQjy38wef81uPhxMpPJIQzr5ckuUTKe0wZyN57iFTWga8GvCwlh5UqvYgmaNV9XSxEVWs40kkosFwA70RgNOu8mLZfR6wDiwRa35y7j08NksqPQhcfkRBK/J8R75Iz+9C8gJpqzwiIeZII3QnYOkJWbVEI5jNuA+o2BwK82ifwnpSgHwaC+GNAdmW2VXfC+vPu6wR6lBj84C9WfvivZyUhZMJlJhjSukDlFJ3g4AvGJfC1iEpQJ/CaEd7G9wds7p71+odruKrHip/C7RdsxeVjzIxhoNkFGOW/+sk/YVAGtltfzZAIfzix8gcHhZCXpcGN2u69qWqD9OlRFAy7x2fQBhHUiETB+DocqvArYt98f+AEAXApsEmEcNLC0t2uPHCqPQIXwHYDfI4/9+8LMpchqr5HK39MJSrBXwnutNqjovjHFdq+fcHLp7YLR4mGgduW5hFpAXUoL4cTTuW5HJSkB5PC0S7A+8c+837DyoM1J9iv/po/o3BunlDqPjOSO/YbLFd+FGy9sxKFeT8b+nLNPrkAyD53FtT27yUS32yqUaEGTMBiASGcZ0FmK8nWxbvjC1q6WQC4VdWdAcBY8eFoAzIrC0b7Wt8wlPcIdE1FhUWeKU1Igv8Q/0dl4k/NnYSxdlDon8diUDeuQB4c8XVzcahRgyyZmNC+LAgeCfSVALde8/t1DCYawNoePGT83wlOpFUdOZKwxn89OsMEf0X8CxJCBN/dwKbFwkSMgx0ACJJDJD4iC1JEYh6XcEqVHpx4+J4I4UiAl26r5x64sttvSlAn3LBuQCz6edU8C+J5epBrC4YP52EFDgHrCw1B0eU9bOaTgh3wmYvQV3Oqqcf53XnVNXUBELX1xtSgFrirlII5d3HFulxBCNEfZx0h7K2f34XwdHpuYQcguN189Ow/nPXclaUcqMH5leCXjKOjbv3F0a7i2ZaRHmBe5zwnhA9S736ZC8AH8LHkg/T5znYgmES1dtuzGo92qwHIquiWX+4KgVLd8utv9Ml1BQNhEJW/FOgweiTguCUoQHkEwYhjfQIgm8eAzPKzHqAG5xGiiPyxeGRRaYetUpDVpHVC1T9bHGyaknb/TQTnuG7rDYwYCUT7/cMjtILzA+Go/FPw581F/mWeTkDuBsBCAK8ki+A29nMzPn4Rzjv6QV7xWW4fzQFUxb9jQQ1qc28kMi4mDl1NBr4usIsz5ltZqNm7AeJXfuTHd7nioLEyPBISU+8/tP1AC4Il/n+YGmjg2NiBRdl6yCw//zG5ph7bqaBuz8B4VMU/TqSsNPbwCeZA1cdxyG9SgKzRZPL+GXFOiH1/SFZ9wX8M3zUgvH8a4rMBjZj/h1W9MrwTiN6MlsCKiI4gycBzgV/xUaQGjGDHwHiYi0VIzeEAasCpNuL76AC7BIEl7i4AIxnAfoMxk35eJbZ68wWEUChs8IPz/EEE9BkUoNA4RCWSLJkY1h0Y/dG9bVCtUVPe7QRhtStXG4nOECDfUxc4Uw/Ik8JkA9o9+a83IrfHH11EdFUWc4phNgVFWkPsIHBnCvCCYBSgqEN9qtoXuwHhByYoJJA7BxIkkRwpDGgAHo+vQ3ZGOwCFJCJKUAx4MBpFZWvReeLgtBBkDDQu2OJxXa7SE/P4ZiUPHABjY1DsFIhPAaygWewiXK72hHjow/k8gCL6gKES8qcDZ7A+EhYlWCPGCX1wXIwzkQEKt8cP6iqkC0FEhFj/ZYtvXCtwuBLcDT5wXN+9H6ZEIkTwV/x/s78fXFX3siWHEKrC3tw7EFZ31Ll7ttknQyEMGgAqCaVe1bGk8r8nFWCQQR0h7CY0dsU/mIeIuA1AGCo02Q0YVXxub36sG1Qgfo0CBBUXxap+ECFEycQVyViBEBFPt14TK9rZHB9EwMG7DPXOv0OVHkdtx7OSCXfb3av4CFZGTwQBwT7/hKPHE4PzpJ4L4+FM9r1n8B+B+9R9I4Fu9brYUZgCunZWNxdQgIs8mASBQ4F8hJpEiaf4GPihk8FdAxin/kybjZjTj+mAQy6ihZ9whDvHAWB6BKrBXQr+5SBfqPaINwiz12UIwoTmbPACZY/fshBBBKNlW8ZCHwH/cVKSOZMm4Mxk4OwE9JeB+EFkn1IzcPQoiSB4vGgNeJSoik1A7m0TCmE/HrggB+/1M12C1Z18ACGoIeH1pH2IhAqFWgBq+kDFEWAvA3X8tpW0cnSD5WAOriOHhnYraF1eLTkS8P/QsHUBdtMPnOrMaANJE9AZiaKWII5Ue/8PTHn/UcCSTgIF2xN4zdmAQYIAKeBFl6FiO0aKfq5jcImHfPwTxcEdRmD3LcFoAva1Hdjm9UgGggI9YOoPkOBYLsT8HlG3nucMDGkOOJ8CkNOELdSO7D5qqAeJYBb2GpABgRi2gxLITgrOQ9C937HgB+0i7MeRx3gfPWCXLtgbLJAu/gCFBPzRX8eADJqCvA3FViC/BlOQC4LZyrBq8BdQAOUKoKjqR7v7EFfVFMojPgEoSlJesNIePyLHwW9NRgq7E6HvUN8A0yj0wyWDHRZ3J2A1jHdMyu3hCGwSDwdRir7h9VP7AKLgPoMCgKziOFLtrUm8aIFHlgxYfz8WBYUU55iAXauo+evJaIK/NTgRJM9sUcZRzcCnMdNKMJc7usnAyrpxHYkTRHK+n1HxS01LheAHqRWwKIDqLvQC0+PupHZgBawfVGsiniTVHwZHRqbUI/D4Cd+ftgyLAR1ehkIiqaKFw7MJEwUIuK5zsu4svoFYCFKgBJZACBuppOId2RDkPZas8H9kULcA9a0KTCQDGtpnzT+RMJiOGseHl4BQ1C29AWUXIIf/OIwwqoNEK3SCuA7FRiBrE9B4/PcrGJ1OQNj83F4Xbol/TgVHfMiIZLAdcaVkgh8sLrd+liNQH/FqsNTfj15m1J0X+ffZuq/gTY7QnvIfJz6UzBJLs83ItQpt3RfZz5iuGfNPajpngUm0R8DoA5jDlzsOTAwZjzsC3Jjxg7H914PjlcskGdghgx9HG4OOQH34uwQyzz61/0qiYNQjXxECuWYbGM/DrjtPH/Mw/K+gBLLSA+cEfPr4MroArzcDuybbr8Zc72i2UnzeHnTgzD4Ug78SzIvCoARVOQxaFFR3TzWnkkHUVFShEuqKxZnKz4p4YYcf8ZhYhuu8wFgSHcuuwCJagI4bgchJQK/qe9c/RT6nGcg6KGREJpb+MI0EY/b0jcsni3AJBeCQNsBOFVYoApcM2Aom4VFgIRdHpeIG8D3YaxBD+qCiQ+rBOSVnci8hzkAG1t/pgHA4uwDzmu8xFKkkkIqCfkIRs204r/hiDgutoAAcowBMZ9+KS0CcXVBOHCvJw2jMQSJyeoeExF2DuTuRcuWAo9sefyUQ6/oBaIjPtiRH1KvQKvygAHb171d+vc4GRMDPoxN/kL5pwlVh1mBQ1quQJAJ5j0TgOAis+h8d3mnC8xTKE34+8sDNjyVXE6nFMN+H39TQDmocHScENvN74LoGScGU4f7g6IG3n3C3qnG6JBS+Z5tHOOzRYQx+u7MZmAl0OSsRLAS/VIKfRAWU92+12aaVPksGDBWQuCMvgNy2M2Mt8EwqbjosZAec5xLEAmXmcFTHiOWARWglpNpjdEtBQRxJJU5VL5/7F1X86XntXgUK4q+KggsUoIIK8oA+kgy4+zLaACqQGTVOX6MBWdehL6BxHn+tlyBMDGAqufd7WOX5WTJwKYDfXJJP2GXDPk7Tj5Ed7BOG7DMFaBRAJgI/+H2Ngeb2SKb0zkoGlQBHkefDr7xMA5HZeJPtKIzyApI9gmnPgf1c3mulfhe0gFekDCdNFnrOwi4Gs6eTACNjB+Uegcgojog4V25P8bctRYY6RL8AJklE9ACFAGZdBEahd4d4CmghFhbzcwaXYH5qTlS6DY+KfNH5Avzjo2JJ0poDkSCMxLn73H/eB+ifvgvyIFCWAji7BWC8hd0qj0FziMdrS70BlVbgamIgcmotGZDNPwm0L9l5iHv7WRoAFx57ScFS2r2iwot8oKu8l+TOCOg2mZ2nFdjTgOFQENzKkJ8OjEnsE8f6AzyXwT6MNF3RDRnuj0Lwo6wTlBMDIyqaz6G+RiLJMg/KUrQV/rh9uH0tWduwoxmky0kSMQ+rnXxZsGadgnxfgk1pCnsIsGYltvfdzTOBIclIsN8MLAGcz5gBwj94AE8DuC9Molip/JGwB57nRyJiyD3pyk6q5ij+3TzRLohcqyqCEQBTepF15+WVmW8SEr5jMUUkx3oMIsrH3ndwAQganKzyMpOJNxMQooGBYwcByw7axIhgPRGEr6GSGJhkAELoQ1YRg+dPeD5IIRDIqq5PA2Jh0Rq0YcS8XBi0ghGRFpCtWTdum5+yLOsQf2EuYY8AfnbQZDgCjHxBSKwTGpt8QCIDVH3/4H5OwEvldhliINwAFLsEyyIfGKV+vm3eEehVqKTdNxtDiPoLHCRiuwTJxCECxMDqDjTvZ63KaPKvRgV2i/F3ohm88V8LN8hgJcXD5pVGIPPNn9EBqSQC0I4AMxBUcQNCkarkFgSn/oCs9GCVep4eUG5BRAOcQOCWlGSc3If0IFqRfURQGRrKewPKEJ9sLnIowKCcw+f48N6UHjqYtgInaCCkBbPSj8VEkCr2g8U43wY1xX/BNkwreQrzg+oaJghOCGTU8RBxuIp6VFOGoEXgEsBLIgV6gBgxoLSI5CgiYNT+GBHsU01GthrceiMUtv9KgAYktgVNeGrBbtiOQVi9x8WjiAW7UNUnm4Vet7WtsFgDCDYEwQ/EVL1PnQf/xCDLTowTh4c4HPRDoQaiwhKIAae4B7xgCBydI/CDPOrevK0FR4p6w3VfoXgQiB3T1N8Y1PCD0X19JqcHGfzB5WkQE4p/kdeXBcEVUXEIFqSij82lMyrWq/7c+LFHA7z5/dwOHHg8s/Y8C2CmhbmALtare+4UWLfb25BmXABKABTniC8gRAP2yvDAiUAsElnrxFzITQa/sAFecAOY7zPV/8jMQHSbWAiUPGkQNABhw85xrSCv+mMSzFR8+7mjw01A8f4F8S/td4jnDHYxpT8/OEyV3gz2+GTfdAeAszswfJNGlQhEIjB0Bls0BKn4Iw7WKu9f1gmSagmvqleEwJwnZwjO7npz1HdCJ1hS/mlBcRXyF3i/M7NxqJFoeH27z7nnJaBmpUZKHsTbGUc1ALEoIGsGYl9ixS50gjAT/VhB8IzvGTrBVfWEz1MzAkRFTtecW731VdjNQPukVdhdn0Y8d/a7WYH6i/TBPBzUFwAlHwtGHOQISrgb1AMUgDETTA3+THAdeRJhg59V/Ektofa9I8wxVICkC7QQSAd2O3cftzPzdMK6aA4iZI4ILfYRbb9RgqICt2AxVnYZ4kkBvHOBxT/zN9ybHx/f5Ql2fkGCX6ANm6F8WCfqAS+Eq5AGcHJd2IFHagTMHAAj+mWBnDXuc81CjhsAi5dL2K8QCYI1aJ/PJtSSxEFXASv7C2I3ZB9/a0j/7nDn/j1pHsz9Jr8fNpxPBUAUUYD4wz5GBlmyAiORjtAIGDFwzSUwqiNZ1d1tPiB7/Q9VeI9KeJU16/knkEeQJEALjY4rkp74fCZiMDSA/PgvT/aT2gYgp5E/P29AKBQAo6TRth5T4VesQFb0i4K7RA2MZpgyFXCEQHCOixuYMPgy2L7+45ezSSKt2oUkURlpXkEMOLSiXPuDQZjk63N5bmzOSxQdLHX7AhwUEA0BAeQPJIQzkAuFlOK/GtyLdiGDKEBdllQ7YouxV2Xdwza9So4Kp5Z0yAgUhTlJgFzSFrznIHYIwKcCu2/L3LsCg6UI1b1/CA+ApIV5/32HqOIjdQusE4azip5Wc1b0q/QGIAlaWEJbXP3r/L+AEipw/+BtkQVY9fIM2i/ZhgVEgJO6DZ1ksVtlYdoQAPhVO0oKmYBmnAYco4DRCRB3TwCziptaE0auER9/VzRqKNOEYINOQg2m1l9GpGNQAhh1v6UmxNQh2M4+LmlUzll0OTjYQOaGlZAEMCrdhmBphaMBwBADrSQQc3//He8KgFETT7p6BHnjj2X9EXsDjrgBS6ihoAmcSQVYmE4JgYWFpp1waAQRoqDzxDhU+HxSnZHz/9JEY6Y5MJA+cwoWrt99+U3Mc/9g/NQTFaigAEtwB1yBzwzucZSX7RZEILhR1d5GDCsBLVUdIQvsldZfEJt5i/MHx2hGJZFkVVyK242iFeh58oBUFqIQbkfp2DV2X0CkAYgv1sU+P+I/HmBu8nErugdRnUWhfp+A/ddlbEH3uQlBsNobUEMHasK1HOYn8BEEvCUaiuigXRIKj+sGOPA4KAWz9/s7WxcgB4+a6/fI2osEwv4yOENAiPf+wQhbc/5f0gGisWuQaRFmGoIqguARWsBQgTTocDLMT5OJUQnhqdCEig+/EShKSEgTVV0MBMnz04BcshPnLk/+OaV0/dwKzB4QUt1NB6uTDfGOP+cNm9mEsBAFiM7AQh9AKVEU75vy68jeOxrUC4mDEuYO0oLqoSdHaEF2eXYYSm0V+oEOwpLmYFOF3Z4CmAeBTIGueiIw2xoKPzDBJVBXQ5g5O8/twwA+QguIjJt3+g0NQEcDfUXgO5gsqlTBLkQLdl86K3CWneitQ8sg/5oWAUJP2C3V3RoEyji5n4b9lB4t9pz2CA+cAFn1Z9I/uzYsU/ELtEBOCHYQQqGcFejV+yeuRJX31zsKV5IGjway9z6PLDxKwNEPsBuOEiqw57jGgOtZ1Y++T50AuMFl7hPIbhskiOwsATtRoc7rS7dXrpcgrMCGJca6ELJo+Y0be0BW5ZKGcFz4y8W9BduwcDnK9iO5fagsKpp9ANnvDPxeP8THNyIVFo1AMas8Qk5v2Ytm0LCCYAXqn+wQsPTBh/5Bcnne14Os3uCQt28vsK1WUESJFviBgAW//3u9PLxusXchcCR2WsNzv/ImvgZzzkUByDUAIrjTvmSHAowpJBQE4SUlxMxnARlQbIqkArVAJ6pBBvELCCKlkyCDAP45BYfEPfcUpfMch3Vn4bheYK4E66BxAxHSVd5INgEPgU/NBCDfNQ8Ho1CoINAPQAW/QT8OCIZlNFCB84XhoDChFByHGjx35v9BLgyhmojqHYb5QYXnuAecvua0hZe6BV9f7v4ibvgvamrmAc1TmaEir0LQ9h97eYAYVoM/nWA60i8Q3Ifezha9BqaaL3zvqd6IAuwwLSCCuCLuJWch4h30giPtyiAphKEBcCu9BV5wwzkMxID8rhMwdwMhcSFgrBT3RUTQboAUg3+p+Qe1IGarOioVnazmefV3lHpwA0AcLWCahUiXwePHWJsP+GH1gnp/we5KfOhJAbsj0H/BIEb04TbrTPsAyb2LLu93KwfCvn5PLAwrOXAa72eEQRo1CNdw5IprsAZ3hApy9zlcITG2vpCihsRSYxNS+J4vdBZ6B52eqRcQ/QXmSjAWSfa/5GA5qEg4iJFtm624AqXLrSA2gx8p1Mdqcghv41S0lSp/xAYs9gakQc4Ie2RTUYwYgt748mV+FU1Xgp14eW3XYZ6cdqGTNHwHICTwEeTPl0jEZwIgP9gDEaogeg5IHWCF+1eoAhvEKPB/EAeTRsM/pSAP5wjWEUMM1/NJRhwJbpJSgK7S7zF3EOsI5jBQBK9DV80Z8Y0COzvmWzJXgDl40KEC6cqvqgi4OB5cpgLFYK/1CvDiItXqC6/S87wfAUfPtxqfGNzlYaOjlf1IsHPPvffHgDAoEeEST4ZLZUd/RSo91/BjXY5ggWgQ4In3fyj4mUqPrInHOCLKO3wUwRsfyXpt1nEIRLrqcWeTuk7bigsbid1zD4iDRQtnIdQsyIXnFCn1I9D7ADgxEhOvR5AJosoUbu1FkJyYCi9OhQERoIx+4AX/YqUXQhtYEwKN4Cy1HntLMmtaAQpqfrT/UCoLSxeswjA5UWPPi0mjajUWxMTdVusNvt/ChMdmILK5IRMFu90BMEzFYHdg2GAgeYVHMMJIBTA7EFTx/5fpgTFXz9w/en0ZjD8kCDoKPNGwlB01BmoWQbh+AxR689mBponGJOr9OwmMu3dtJ/ylW1Tik4ElUPmR9RqII+pVhD9ychABMQ51gOIZg+/G+5mGIzLB1JJC5WhzYjhJ7IWmLDpA8jzsAafUPkB2WnFBF4iSxkq1ty7f25rv/+EQLOxs2oUdTSA9HIR9swdBlCcFe9owPC3XWDDC0ISVzsEVbSCF/sWdA5Fu4HJqankp2SeQCYYrImNalfmhpVxYrGkUS4LeSUjg8dD7+D7w/ybIfy7vlB9/HJ978zr7/45Qgajzj+4EjIK/ULHPRAOlKr/aG0AFcqCyu0GcW45Igh6JMJmhA49/U+cEssHNJhtXDC1MOya3j/sAiAGcrEtqtgjBD6wEzSDc7D8o6C8rIqAZyPk+NQoNLAZ1hR64Yl1FBY648smUYKnSg1Xwk/0DyRyArByMUobyByhCcPnOaPyoegREFS4jNfYAw+IHCjdC1J2WDZBke/OyN85J24WiXwDYPoJyYuCD238ulvuzwt6KgHf0shWKsqCFFGjB/w8HU8eeTED9wAAAAABJRU5ErkJggg=="
48,xd="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAF9UlEQVR4nGWVy64eVxGF16X27u7/HMcyuZGYAINwmTBigngBXoc34El4B0ZMGDJjFCExQUIKiRKZYBITHdvn/L1rF4P+c+yEUqmH9WmtrrWLkdB4C1/91h/9yn947D8+8CfdlBeGGAMtqwNd6K7VWAJrw9qwLtw2nDaernh6wKuHPD3S1Vs6vaPT97W9r/Wx1seKUWj7Uzz6vX79T//wF/Gbx/7rw/jsFB/39nlrX7q99LKrp5bJZXAtrqW1uJIncbNOXafBU+o0tZW28got0AJ3KACsE4OfYvmzfvDMb/+4//Td9snD9rfr9vHWnyz9361/1fpNLLde0mt5pTZ7a9pCm32SrqQTfZI3aqNXHAwvcAB4BPwnk/oMEcqX8eaz1t9cHjxs7133f5z6p2v/Ylme9eWmLbexjlhnrPBirz3WxWv30rw0L/Yi96PpDrcDcPMEfq+qvQCfsFF1blcv2js3vb2xLNd9O/XT1p8u/Vlfnvd+25bResXC6BFLj2WJpUdv7uEe0exGByPoOAC//BH+cgNqUjfkU4mOEetde+O2vf+y8br71Nva+9q/XpYXvZ97z9ardUXrra3RerQWrUU4myLk4AzYiADwJ+NRQ41i7MSNEBIcM5YR1+f21rnlXcPWtbVYW1/a7dL21mZvbK211lv01lpEtIi0MxTmFGzMAABAN6gF1CTPxI1gkXa5Z5xGPNrbfo6xB/bQubW9nXvkHtXDPfqIJd2bI+1mpZjmNK17QFuxDzhBJued8Fy0KLvcp7fpNzJuM3JE7daIWGKMqAylW0bLiHQ0e1ppTXEK8Qrwkzv8fUIua6oG553wQpRIme7lbfpBxm3GnoEMZ+wZlYGMlu6pNh1pT3nqALCEugCeAB2ohKqYk9hZd4JFS5ThDm/lB9N305nGtKfnNKZiqk23qZhySZOcYhHFewXfI54UMCBDOYlU3TMkSaYWaCtdwXu5yprOKUxrqk9FyUWXNKXiBfCNgucGboGAUBwUJzFYO3G+MCwFtdAn6K6UZZSyXCXBAUVdGCoS5IVxAcQNujAHKCiLLHJqDtWZh1GHV0Et8EYNqOABTUhglKJoyKBBgSwCBC6Ajz7Azz+GiJbwhFTkZCXnEM6EJcuHDmmlztCkBE2IkMGAAhQoSCBBvgYA0G6xN4DgLE5IU5iqZA1hJ8zDqCY2qktJHfEnZSpIk6bE++kEXwHUEBMCmBBBFzE5UzNZuyBRshlSSF0aEg6MaDHIgyFCPAqvA/YdIjTgQ3WBLNZkpWoQPnRIUljdGiIkHd9jumgeO0ESEI97cNTPJj6Z4ISOZh1JUSVLwiAs7pRp02aTypRUhwIzjvhfPCKF1wH/BTqwA5pQlnYyipgs6dDBQVncZatZaZUlsUxZYVq0jyfm8kNeBzz/Gu0ETrjABAURAoTJOVVJpDAoM3ZOc5olfmMK42CYMrRTAr6tIK6QiSA84VtIIEosslSTNYUkUxyS5aEDQ6tMmQ7YDMOmjziYx8E56oPEl8DdDgM2/BLeIJVw9CRSTClZg97ZrDl0BF6m49V0GTIZQL4CvNuxFj47w4ASmqUkAalYU+DBoIbK8hAG506aZTLonWFG0IMa1AAHXlegW9wFGuAJG97hhFkqiuCxUZyqSSWR5GCZHKxB7nSwDcZADHiACQ4eJ/Oot9+BvsaLQD2Hby9RUEEs1cUlcdKpmWKSQ2VyqAY56J0RiEEPOqHxXYv2W4yJuANWxBkBOKEGFcwyjlhMYdLJSjLJpA8FAxqMwXZRQA0wgdQ94Hcf4nqDFnQhBDcY5YJUIqSSpnxpRqone6ol+2Af7Il2MJJxnN/8lgIA8yWQUKItaBMRsGEdDIrQoYNTnGSyBqdZQSY16IEYaANOOKn/A+htXH+OdgLOiB1BBOEGCz5ejmO6JpGEeexVJTmohJNORqIlnVDyO4CvvsT2AGm0BVEHo0IMHeEooeQipzDFY5eSNcigLgwoGYlIKHF/ky9Z+xD/WrCfoQUuRCGAKBhlwIBRQvmSuykkMYHkqx7EAPK+/wdqEbWmfB0bfwAAAABJRU5ErkJggg==";let Sd=0;const kh=(a,e,t,i)=>{if(!a[t]){const s=a.useDelayedTextureLoading;a.useDelayedTextureLoading=!1;const r=a._blockEntityCollection;a._blockEntityCollection=!1;const n=z.CreateFromBase64String(e,i+Sd++,a,!0,!1,z.BILINEAR_SAMPLINGMODE);a._blockEntityCollection=r;const o=a.getEngine().getLoadedTexturesCache(),h=o.indexOf(n.getInternalTexture());h!==-1&&o.splice(h,1),n.isRGBD=!0,n.wrapU=z.CLAMP_ADDRESSMODE,n.wrapV=z.CLAMP_ADDRESSMODE,a[t]=n,a.useDelayedTextureLoading=s,Na.ExpandRGBDTexture(n);const l=a.getEngine().onContextRestoredObservable.add(()=>{n.isRGBD=!0;const c=a.onBeforeRenderObservable.add(()=>{n.isReady()&&(a.onBeforeRenderObservable.remove(c),Na.ExpandRGBDTexture(n))})});a.onDisposeObservable.add(()=>{a.getEngine().onContextRestoredObservable.remove(l)})}return a[t]},Gh=a=>kh(a,yd,"environmentBRDFTexture","EnvironmentBRDFTexture"),C_=a=>kh(a,xd,"environmentFuzzBRDFTexture","EnvironmentFuzzBRDFTexture"),Md=new RegExp("^([gimus]+)!");class vi{constructor(e){this._plugins=[],this._activePlugins=[],this._activePluginsForExtraEvents=[],this._material=e,this._scene=e.getScene(),this._engine=this._scene.getEngine()}_addPlugin(e){for(let s=0;s<this._plugins.length;++s)if(this._plugins[s].name===e.name)return!1;if(this._material._uniformBufferLayoutBuilt&&(this._material.resetDrawCache(),this._material._createUniformBuffer()),!e.isCompatible(this._material.shaderLanguage))throw`The plugin "${e.name}" can't be added to the material "${this._material.name}" because the plugin is not compatible with the shader language of the material.`;const t=e.getClassName();vi._MaterialPluginClassToMainDefine[t]||(vi._MaterialPluginClassToMainDefine[t]="MATERIALPLUGIN_"+ ++vi._MaterialPluginCounter),this._material._callbackPluginEventGeneric=(s,r)=>this._handlePluginEvent(s,r),this._plugins.push(e),this._plugins.sort((s,r)=>s.priority-r.priority),this._codeInjectionPoints={};const i={};i[vi._MaterialPluginClassToMainDefine[t]]={type:"boolean",default:!0};for(const s of this._plugins)s.collectDefines(i),this._collectPointNames("vertex",s.getCustomCode("vertex",this._material.shaderLanguage)),this._collectPointNames("fragment",s.getCustomCode("fragment",this._material.shaderLanguage));return this._defineNamesFromPlugins=i,!0}_activatePlugin(e){this._activePlugins.indexOf(e)===-1&&(this._activePlugins.push(e),this._activePlugins.sort((t,i)=>t.priority-i.priority),this._material._callbackPluginEventIsReadyForSubMesh=this._handlePluginEventIsReadyForSubMesh.bind(this),this._material._callbackPluginEventPrepareDefinesBeforeAttributes=this._handlePluginEventPrepareDefinesBeforeAttributes.bind(this),this._material._callbackPluginEventPrepareDefines=this._handlePluginEventPrepareDefines.bind(this),this._material._callbackPluginEventBindForSubMesh=this._handlePluginEventBindForSubMesh.bind(this),e.registerForExtraEvents&&(this._activePluginsForExtraEvents.push(e),this._activePluginsForExtraEvents.sort((t,i)=>t.priority-i.priority),this._material._callbackPluginEventHasRenderTargetTextures=this._handlePluginEventHasRenderTargetTextures.bind(this),this._material._callbackPluginEventFillRen
vendor: 25,113 bytes, lines 48-56
48derTargetTextures=this._handlePluginEventFillRenderTargetTextures.bind(this),this._material._callbackPluginEventHardBindForSubMesh=this._handlePluginEventHardBindForSubMesh.bind(this)))}getPlugin(e){for(let t=0;t<this._plugins.length;++t)if(this._plugins[t].name===e)return this._plugins[t];return null}_handlePluginEventIsReadyForSubMesh(e){let t=!0;for(const i of this._activePlugins)t=t&&i.isReadyForSubMesh(e.defines,this._scene,this._engine,e.subMesh);e.isReadyForSubMesh=t}_handlePluginEventPrepareDefinesBeforeAttributes(e){for(const t of this._activePlugins)t.prepareDefinesBeforeAttributes(e.defines,this._scene,e.mesh)}_handlePluginEventPrepareDefines(e){for(const t of this._activePlugins)t.prepareDefines(e.defines,this._scene,e.mesh)}_handlePluginEventHardBindForSubMesh(e){for(const t of this._activePluginsForExtraEvents)t.hardBindForSubMesh(this._material._uniformBuffer,this._scene,this._engine,e.subMesh)}_handlePluginEventBindForSubMesh(e){for(const t of this._activePlugins)t.bindForSubMesh(this._material._uniformBuffer,this._scene,this._engine,e.subMesh)}_handlePluginEventHasRenderTargetTextures(e){let t=!1;for(const i of this._activePluginsForExtraEvents)if(t=i.hasRenderTargetTextures(),t)break;e.hasRenderTargetTextures=t}_handlePluginEventFillRenderTargetTextures(e){for(const t of this._activePluginsForExtraEvents)t.fillRenderTargetTextures(e.renderTargets)}_handlePluginEvent(e,t){switch(e){case 512:{const i=t;for(const s of this._activePlugins)s.getActiveTextures(i.activeTextures);break}case 256:{const i=t;for(const s of this._activePlugins)s.getAnimatables(i.animatables);break}case 1024:{const i=t;let s=!1;for(const r of this._activePlugins)if(s=r.hasTexture(i.texture),s)break;i.hasTexture=s;break}case 2:{const i=t;for(const s of this._plugins)s.dispose(i.forceDisposeTextures);break}case 4:{const i=t;i.defineNames=this._defineNamesFromPlugins;break}case 128:{const i=t;for(const s of this._activePlugins)i.fallbackRank=s.addFallbacks(i.defines,i.fallbacks,i.fallbackRank),s.getAttributes(i.attributes,this._scene,i.mesh);this._uniformList.length>0&&i.uniforms.push(...this._uniformList),this._samplerList.length>0&&i.samplers.push(...this._samplerList),this._uboList.length>0&&i.uniformBuffersNames.push(...this._uboList),i.customCode=this._injectCustomCode(i,i.customCode);break}case 8:{const i=t;this._uboDeclaration="",this._vertexDeclaration="",this._fragmentDeclaration="",this._uniformList=[],this._samplerList=[],this._uboList=[];const s=this._material.shaderLanguage===1;for(const r of this._plugins){const n=r.getUniforms(this._material.shaderLanguage);if(n){if(n.ubo)for(const o of n.ubo){if(o.size&&o.type){const h=o.arraySize??0;if(i.ubo.addUniform(o.name,o.size,h),s){let l;switch(o.type){case"mat4":l="mat4x4f";break;case"float":l="f32";break;default:l=`${o.type}f`;break}h>0?this._uboDeclaration+=`uniform ${o.name}: array<${l}, ${h}>;
49`:this._uboDeclaration+=`uniform ${o.name}: ${l};
50`}else this._uboDeclaration+=`${o.type} ${o.name}${h>0?`[${h}]`:""};
51`}this._uniformList.push(o.name)}n.vertex&&(this._vertexDeclaration+=n.vertex+`
52`),n.fragment&&(this._fragmentDeclaration+=n.fragment+`
53`),n.externalUniforms&&this._uniformList.push(...n.externalUniforms)}r.getSamplers(this._samplerList),r.getUniformBuffersNames(this._uboList)}break}}}_collectPointNames(e,t){if(t)for(const i in t)this._codeInjectionPoints[e]||(this._codeInjectionPoints[e]={}),this._codeInjectionPoints[e][i]=!0}_injectCustomCode(e,t){return(i,s)=>{t&&(s=t(i,s)),this._uboDeclaration&&(s=s.replace("#define ADDITIONAL_UBO_DECLARATION",this._uboDeclaration)),this._vertexDeclaration&&(s=s.replace("#define ADDITIONAL_VERTEX_DECLARATION",this._vertexDeclaration)),this._fragmentDeclaration&&(s=s.replace("#define ADDITIONAL_FRAGMENT_DECLARATION",this._fragmentDeclaration));const r=this._codeInjectionPoints?.[i];if(!r)return s;let n=null;for(let o in r){let h="";for(const l of this._activePlugins){let c=l.getCustomCode(i,this._material.shaderLanguage)?.[o];c&&(l.resolveIncludes&&(n===null&&(n={defines:[],indexParameters:e.indexParameters,isFragment:!1,shouldUseHighPrecisionShader:this._engine._shouldUseHighPrecisionShader,processor:void 0,supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:We.GetShadersRepository(0),includesShadersStore:We.GetIncludesShadersStore(0),version:void 0,platformName:this._engine.shaderPlatformName,processingContext:void 0,isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer,processCodeAfterIncludes:void 0}),n.isFragment=i==="fragment",Cr(c,n,u=>c=u)),h+=c+`
54`)}if(h.length>0)if(o.charAt(0)==="!"){o=o.substring(1);let l="g";if(o.charAt(0)==="!")l="",o=o.substring(1);else{const d=Md.exec(o);d&&d.length>=2&&(l=d[1],o=o.substring(l.length+1))}l.indexOf("g")<0&&(l+="g");const c=s,u=new RegExp(o,l);let f=u.exec(c);for(;f!==null;){let d=h;for(let g=0;g<f.length;++g)d=d.replace("$"+g,f[g]);s=s.replace(f[0],d),f=u.exec(c)}}else{const l="#define "+o;s=s.replace(l,`
55`+h+`
56`+l)}}return s}}}vi._MaterialPluginClassToMainDefine={};vi._MaterialPluginCounter=0;Te.OnEnginesDisposedObservable.add(()=>{Id()});const Cd=[];let Ua=null;function Id(){Cd.length=0,F.OnEventObservable.remove(Ua),Ua=null}class Qt{isCompatible(e){return e===0}_enable(e){e&&this._pluginManager._activatePlugin(this)}constructor(e,t,i,s,r=!0,n=!1,o=!1){this.priority=500,this.resolveIncludes=!1,this.registerForExtraEvents=!1,this.doNotSerialize=!1,this._material=e,this.name=t,this.priority=i,this.resolveIncludes=o,e.pluginManager||(e.pluginManager=new vi(e),e.onDisposeObservable.add(()=>{e.pluginManager=void 0})),this._pluginDefineNames=s,this._pluginManager=e.pluginManager,r&&this._pluginManager._addPlugin(this),n&&this._enable(!0),this.markAllDefinesAsDirty=e._dirtyCallbacks[127]}getClassName(){return"MaterialPluginBase"}isReadyForSubMesh(e,t,i,s){return!0}hardBindForSubMesh(e,t,i,s){}bindForSubMesh(e,t,i,s){}dispose(e){}getCustomCode(e,t=0){return null}collectDefines(e){if(this._pluginDefineNames)for(const t of Object.keys(this._pluginDefineNames)){if(t[0]==="_")continue;const i=typeof this._pluginDefineNames[t];e[t]={type:i==="number"?"number":i==="string"?"string":i==="boolean"?"boolean":"object",default:this._pluginDefineNames[t]}}}prepareDefinesBeforeAttributes(e,t,i){}prepareDefines(e,t,i){}hasTexture(e){return!1}hasRenderTargetTextures(){return!1}fillRenderTargetTextures(e){}getActiveTextures(e){}getAnimatables(e){}addFallbacks(e,t,i){return i}getSamplers(e){}getAttributes(e,t,i){}getUniformBuffersNames(e){}getUniforms(e=0){return{}}copyTo(e){le.Clone(()=>e,this)}serialize(){return le.Serialize(this)}parse(e,t,i){le.Parse(()=>this,e,t,i)}}T([R()],Qt.prototype,"name",void 0);T([R()],Qt.prototype,"priority",void 0);T([R()],Qt.prototype,"resolveIncludes",void 0);T([R()],Qt.prototype,"registerForExtraEvents",void 0);nt("BABYLON.MaterialPluginBase",Qt);class Pd extends Si{constructor(){super(...arguments),this.BRDF_V_HEIGHT_CORRELATED=!1,this.MS_BRDF_ENERGY_CONSERVATION=!1,this.SPHERICAL_HARMONICS=!1,this.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=!1,this.MIX_IBL_RADIANCE_WITH_IRRADIANCE=!0,this.LEGACY_SPECULAR_ENERGY_CONSERVATION=!1,this.BASE_DIFFUSE_MODEL=0,this.DIELECTRIC_SPECULAR_MODEL=0,this.CONDUCTOR_SPECULAR_MODEL=0}}class xe extends Qt{_markAllSubMeshesAsMiscDirty(){this._internalMarkAllSubMeshesAsMiscDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRBRDF",90,new Pd,t),this._useEnergyConservation=xe.DEFAULT_USE_ENERGY_CONSERVATION,this.useEnergyConservation=xe.DEFAULT_USE_ENERGY_CONSERVATION,this._useSmithVisibilityHeightCorrelated=xe.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this.useSmithVisibilityHeightCorrelated=xe.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this._useSphericalHarmonics=xe.DEFAULT_USE_SPHERICAL_HARMONICS,this.useSphericalHarmonics=xe.DEFAULT_USE_SPHERICAL_HARMONICS,this._useSpecularGlossinessInputEnergyConservation=xe.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this.useSpecularGlossinessInputEnergyConservation=xe.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this._mixIblRadianceWithIrradiance=xe.DEFAULT_MIX_IBL_RADIANCE_WITH_IRRADIANCE,this.mixIblRadianceWithIrradiance=xe.DEFAULT_MIX_IBL_RADIANCE_WITH_IRRADIANCE,this._useLegacySpecularEnergyConservation=xe.DEFAULT_USE_LEGACY_SPECULAR_ENERGY_CONSERVATION,this.useLegacySpecularEnergyConservation=xe.DEFAULT_USE_LEGACY_SPECULAR_ENERGY_CONSERVATION,this._baseDiffuseModel=xe.DEFAULT_DIFFUSE_MODEL,this.baseDiffuseModel=xe.DEFAULT_DIFFUSE_MODEL,this._dielectricSpecularModel=xe.DEFAULT_DIELECTRIC_SPECULAR_MODEL,this.dielectricSpecularModel=xe.DEFAULT_DIELECTRIC_SPECULAR_MODEL,this._conductorSpecularModel=xe.DEFAULT_CONDUCTOR_SPECULAR_MODEL,this.conductorSpecularModel=xe.DEFAULT_CONDUCTOR_SPECULAR_MODEL,this._internalMarkAllSubMeshesAsMiscDirty=e._dirtyCallbacks[16],this._enable(!0)}prepareDefines(e){e.BRDF_V_HEIGHT_CORRELATED=this._useSmithVisibilityHeightCorrelated,e.MS_BRDF_ENERGY_CONSERVATION=this._useEnergyConservation&&this._useSmithVisibilityHeightCorrelated,e.SPHERICAL_HARMONICS=this._useSphericalHarmonics,e.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=this._useSpecularGlossinessInputEnergyConservation,e.MIX_IBL_RADIANCE_WITH_IRRADIANCE=this._mixIblRadianceWithIrradiance,e.LEGACY_SPECULAR_ENERGY_CONSERVATION=this._useLegacySpecularEnergyConservation,e.BASE_DIFFUSE_MODEL=this._baseDiffuseModel,e.DIELECTRIC_SPECULAR_MODEL=this._dielectricSpecularModel,e.CONDUCTOR_SPECULAR_MODEL=this._conductorSpecularModel}getClassName(){return"PBRBRDFConfiguration"}}xe.DEFAULT_USE_ENERGY_CONSERVATION=!0;xe.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED=!0;xe.DEFAULT_USE_SPHERICAL_HARMONICS=!0;xe.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION=!0;xe.DEFAULT_MIX_IBL_RADIANCE_WITH_IRRADIANCE=!0;xe.DEFAULT_USE_LEGACY_SPECULAR_ENERGY_CONSERVATION=!0;xe.DEFAULT_DIFFUSE_MODEL=0;xe.DEFAULT_DIELECTRIC_SPECULAR_MODEL=0;xe.DEFAULT_CONDUCTOR_SPECULAR_MODEL=0;T([R(),B("_markAllSubMeshesAsMiscDirty")],xe.prototype,"useEnergyConservation",void 0);T([R(),B("_markAllSubMeshesAsMiscDirty")],xe.prototype,"useSmithVisibilityHeightCorrelated",void 0);T([R(),B("_markAllSubMeshesAsMiscDirty")],xe.prototype,"useSphericalHarmonics",void 0);T([R(),B("_markAllSubMeshesAsMiscDirty")],xe.prototype,"useSpecularGlossinessInputEnergyConservation",void 0);T([R(),B("_markAllSubMeshesAsMiscDirty")],xe.prototype,"mixIblRadianceWithIrradiance",void 0);T([R(),B("_markAllSubMeshesAsMiscDirty")],xe.prototype,"useLegacySpecularEnergyConservation",void 0);T([R("baseDiffuseModel"),B("_markAllSubMeshesAsMiscDirty")],xe.prototype,"baseDiffuseModel",void 0);T([R("dielectricSpecularModel"),B("_markAllSubMeshesAsMiscDirty")],xe.prototype,"dielectricSpecularModel",void 0);T([R("conductorSpecularModel"),B("_markAllSubMeshesAsMiscDirty")],xe.prototype,"conductorSpecularModel",void 0);class ka{constructor(){this.previousWorldMatrices={},this.previousBones={}}static AddUniforms(e){e.push("previousWorld","previousViewProjection","mPreviousBones")}static AddSamplers(e){}bindForSubMesh(e,t,i,s,r){if(t.prePassRenderer&&t.prePassRenderer.enabled&&t.prePassRenderer.currentRTisSceneRT&&(t.prePassRenderer.getIndex(2)!==-1||t.prePassRenderer.getIndex(11)!==-1)){this.previousWorldMatrices[i.uniqueId]||(this.previousWorldMatrices[i.uniqueId]=s.clone()),this.previousViewProjection||(this.previousViewProjection=t.getTransformMatrix().clone(),this.currentViewProjection=t.getTransformMatrix().clone());const n=t.getEngine();this.currentViewProjection.updateFlag!==t.getTransformMatrix().updateFlag?(this._lastUpdateFrameId=n.frameId,this.previousViewProjection.copyFrom(this.currentViewProjection),this.currentViewProjection.copyFrom(t.getTransformMatrix())):this._lastUpdateFrameId!==n.frameId&&(this._lastUpdateFrameId=n.frameId,this.previousViewProjection.copyFrom(this.currentViewProjection)),e.setMatrix("previousWorld",this.previousWorldMatrices[i.uniqueId]),e.setMatrix("previousViewProjection",this.previousViewProjection),this.previousWorldMatrices[i.uniqueId]=s.clone()}}}class ns{constructor(e,t,i,s){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=i,this.worldAxisForFileY=s}}class Xr{static ConvertCubeMapTextureToSphericalPolynomial(e){if(!e.isCube)return null;e.getScene()?.getEngine().flushFramebuffer();const t=e.getSize().width,i=e.readPixels(0,void 0,void 0,!1),s=e.readPixels(1,void 0,void 0,!1);let r,n;e.isRenderTarget?(r=e.readPixels(3,void 0,void 0,!1),n=e.readPixels(2,void 0,void 0,!1)):(r=e.readPixels(2,void 0,void 0,!1),n=e.readPixels(3,void 0,void 0,!1));const o=e.readPixels(4,void 0,void 0,!1),h=e.readPixels(5,void 0,void 0,!1),l=e.gammaSpace,c=5;let u=0;return(e.textureType==1||e.textureType==2)&&(u=1),new Promise(f=>{Promise.all([s,i,r,n,o,h]).then(([d,g,p,m,A,E])=>{const I={size:t,right:g,left:d,up:p,down:m,front:A,back:E,format:c,type:u,gammaSpace:l};f(this.ConvertCubeMapToSphericalPolynomial(I))})})}static _AreaElement(e,t){return Math.atan2(e*t,Math.sqrt(e*e+t*t+1))}static ConvertCubeMapToSphericalPolynomial(e){const t=new qs;let i=0;const s=2/e.size,r=s,n=.5*s,o=n-1;for(let f=0;f<6;f++){const d=this._FileFaces[f],g=e[d.name];let p=o;const m=e.format===5?4:3;for(let A=0;A<e.size;A++){let E=o;for(let I=0;I<e.size;I++){const M=d.worldAxisForFileX.scale(E).add(d.worldAxisForFileY.scale(p)).add(d.worldAxisForNormal);M.normalize();const C=this._AreaElement(E-n,p-n)-this._AreaElement(E-n,p+n)-this._AreaElement(E+n,p-n)+this._AreaElement(E+n,p+n);let x=g[A*e.size*m+I*m+0],S=g[A*e.size*m+I*m+1],L=g[A*e.size*m+I*m+2];isNaN(x)&&(x=0),isNaN(S)&&(S=0),isNaN(L)&&(L=0),e.type===0&&(x/=255,S/=255,L/=255),e.gammaSpace&&(x=Math.pow(be(x),Er),S=Math.pow(be(S),Er),L=Math.pow(be(L),Er));const N=this.MAX_HDRI_VALUE;if(this.PRESERVE_CLAMPED_COLORS){const Re=Math.max(x,S,L);if(Re>N){const pe=N/Re;x*=pe,S*=pe,L*=pe}}else x=be(x,0,N),S=be(S,0,N),L=be(L,0,N);const D=new q(x,S,L);t.addLight(M,D,C),i+=C,E+=s}p+=r}}const u=4*Math.PI*6/6/i;return t.scaleInPlace(u),t.convertIncidentRadianceToIrradiance(),t.convertIrradianceToLambertianRadiance(),js.FromHarmonics(t)}}Xr._FileFaces=[new ns("right",new _(1,0,0),new _(0,0,-1),new _(0,-1,0)),new ns("left",new _(-1,0,0),new _(0,0,1),new _(0,-1,0)),new ns("up",new _(0,1,0),new _(1,0,0),new _(0,0,1)),new ns("down",new _(0,-1,0),new _(1,0,0),new _(0,0,-1)),new ns("front",new _(0,0,1),new _(1,0,0),new _(0,-1,0)),new ns("back",new _(0,0,-1),new _(-1,0,0),new _(0,-1,0))];Xr.MAX_HDRI_VALUE=4096;Xr.PRESERVE_CLAMPED_COLORS=!1;De.prototype.forceSphericalPolynomialsRecompute=function(){this._texture&&(this._texture._sphericalPolynomial=null,this._texture._sphericalPolynomialPromise=null,this._texture._sphericalPolynomialComputed=!1)};Object.defineProperty(De.prototype,"sphericalPolynomial",{get:function(){if(this._texture){if(this._texture._sphericalPolynomial||this._texture._sphericalPolynomialComputed)return this._texture._sphericalPolynomial;if(this._texture.isReady)return this._texture._sphericalPolynomialPromise||(this._texture._sphericalPolynomialPromise=Xr.ConvertCubeMapTextureToSphericalPolynomial(this),this._texture._sphericalPolynomialPromise===null?this._texture._sphericalPolynomialComputed=!0:this._texture._sphericalPolynomialPromise.then(a=>{this._texture._sphericalPolynomial=a,this._texture._sphericalPolynomialComputed=!0})),null}return null},set:function(a){this._texture&&(this._texture._sphericalPolynomial=a)},enumerable:!0,configurable:!0});class vd extends Si{constructor(){super(...arguments),this.CLEARCOAT=!1,this.CLEARCOAT_DEFAULTIOR=!1,this.CLEARCOAT_TEXTURE=!1,this.CLEARCOAT_TEXTURE_ROUGHNESS=!1,this.CLEARCOAT_TEXTUREDIRECTUV=0,this.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV=0,this.CLEARCOAT_BUMP=!1,this.CLEARCOAT_BUMPDIRECTUV=0,this.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,this.CLEARCOAT_REMAP_F0=!1,this.CLEARCOAT_TINT=!1,this.CLEARCOAT_TINT_TEXTURE=!1,this.CLEARCOAT_TINT_TEXTUREDIRECTUV=0,this.CLEARCOAT_TINT_GAMMATEXTURE=!1}}class dt extends Qt{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRClearCoat",100,new vd,t),this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.roughness=0,this._indexOfRefraction=dt._DefaultIndexOfRefraction,this.indexOfRefraction=dt._DefaultIndexOfRefraction,this._texture=null,this.texture=null,this._useRoughnessFromMainTexture=!0,this.useRoughnessFromMainTexture=!0,this._textureRoughness=null,this.textureRoughness=null,this._remapF0OnInterfaceChange=!0,this.remapF0OnInterfaceChange=!0,this._bumpTexture=null,this.bumpTexture=null,this._isTintEnabled=!1,this.isTintEnabled=!1,this.tintColor=q.White(),this.tintColorAtDistance=1,this.tintThickness=1,this._tintTexture=null,this.tintTexture=null,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[1]}isReadyForSubMesh(e,t,i){if(!this._isEnabled)return!0;const s=this._material._disableBumpMap;return!(e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&U.ClearCoatTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._textureRoughness&&U.ClearCoatTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking()||i.getCaps().standardDerivatives&&this._bumpTexture&&U.ClearCoatBumpTextureEnabled&&!s&&!this._bumpTexture.isReady()||this._isTintEnabled&&this._tintTexture&&U.ClearCoatTintTextureEnabled&&!this._tintTexture.isReadyOrNotBlocking()))}prepareDefinesBeforeAttributes(e,t){this._isEnabled?(e.CLEARCOAT=!0,e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=this._useRoughnessFromMainTexture,e.CLEARCOAT_REMAP_F0=this._remapF0OnInterfaceChange,e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&U.ClearCoatTextureEnabled?Ne(this._texture,e,"CLEARCOAT_TEXTURE"):e.CLEARCOAT_TEXTURE=!1,this._textureRoughness&&U.ClearCoatTextureEnabled?Ne(this._textureRoughness,e,"CLEARCOAT_TEXTURE_ROUGHNESS"):e.CLEARCOAT_TEXTURE_ROUGHNESS=!1,this._bumpTexture&&U.ClearCoatBumpTextureEnabled?Ne(this._bumpTexture,e,"CLEARCOAT_BUMP"):e.CLEARCOAT_BUMP=!1,e.CLEARCOAT_DEFAULTIOR=this._indexOfRefraction===dt._DefaultIndexOfRefraction,this._isTintEnabled?(e.CLEARCOAT_TINT=!0,this._tintTexture&&U.ClearCoatTintTextureEnabled?(Ne(this._tintTexture,e,"CLEARCOAT_TINT_TEXTURE"),e.CLEARCOAT_TINT_GAMMATEXTURE=this._tintTexture.gammaSpace):e.CLEARCOAT_TINT_TEXTURE=!1):(e.CLEARCOAT_TINT=!1,e.CLEARCOAT_TINT_TEXTURE=!1))):(e.CLEARCOAT=!1,e.CLEARCOAT_TEXTURE=!1,e.CLEARCOAT_TEXTURE_ROUGHNESS=!1,e.CLEARCOAT_BUMP=!1,e.CLEARCOAT_TINT=!1,e.CLEARCOAT_TINT_TEXTURE=!1,e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,e.CLEARCOAT_DEFAULTIOR=!1,e.CLEARCOAT_TEXTUREDIRECTUV=0,e.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV=0,e.CLEARCOAT_BUMPDIRECTUV=0,e.CLEARCOAT_REMAP_F0=!1,e.CLEARCOAT_TINT_TEXTUREDIRECTUV=0,e.CLEARCOAT_TINT_GAMMATEXTURE=!1)}bindForSubMesh(e,t,i,s){if(!this._isEnabled)return;const r=s.materialDefines,n=this._material.isFrozen,o=this._material._disableBumpMap,h=this._material._invertNormalMapX,l=this._material._invertNormalMapY;if(!e.useUbo||!n||!e.isSync){(this._texture||this._textureRoughness)&&U.ClearCoatTextureEnabled&&(e.updateFloat4("vClearCoatInfos",this._texture?.coordinatesIndex??0,this._texture?.level??0,this._textureRoughness?.coordinatesIndex??0,this._textureRoughness?.level??0),this._texture&&Ue(this._texture,e,"clearCoat"),this._textureRoughness&&!r.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE&&Ue(this._textureRoughness,e,"clearCoatRoughness")),this._bumpTexture&&i.getCaps().standardDerivatives&&U.ClearCoatTextureEnabled&&!o&&(e.updateFloat2("vClearCoatBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level),Ue(this._bumpTexture,e,"clearCoatBump"),t._mirroredCameraPosition?e.updateFloat2("vClearCoatTangentSpaceParams",h?1:-1,l?1:-1):e.updateFloat2("vClearCoatTangentSpaceParams",h?-1:1,l?-1:1)),this._tintTexture&&U.ClearCoatTintTextureEnabled&&(e.updateFloat2("vClearCoatTintInfos",this._tintTexture.coordinatesIndex,this._tintTexture.level),Ue(this._tintTexture,e,"clearCoatTint")),e.updateFloat2("vClearCoatParams",this.intensity,this.roughness);const c=1-this._indexOfRefraction,u=1+this._indexOfRefraction,f=Math.pow(-c/u,2),d=1/this._indexOfRefraction;e.updateFloat4("vClearCoatRefractionParams",f,d,c,u),this._isTintEnabled&&(e.updateFloat4("vClearCoatTintParams",this.tintColor.r,this.tintColor.g,this.tintColor.b,Math.max(1e-5,this.tintThickness)),e.updateFloat("clearCoatColorAtDistance",Math.max(1e-5,this.tintColorAtDistance)))}t.texturesEnabled&&(this._texture&&U.ClearCoatTextureEnabled&&e.setTexture("clearCoatSampler",this._texture),this._textureRoughness&&!r.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE&&U.ClearCoatTextureEnabled&&e.setTexture("clearCoatRoughnessSampler",this._textureRoughness),this._bumpTexture&&i.getCaps().standardDerivatives&&U.ClearCoatBumpTextureEnabled&&!o&&e.setTexture("clearCoatBumpSampler",this._bumpTexture),this._isTintEnabled&&this._tintTexture&&U.ClearCoatTintTextureEnabled&&e.setTexture("clearCoatTintSampler",this._tintTexture))}hasTexture(e){return this._texture===e||this._textureRoughness===e||this._bumpTexture===e||this._tintTexture===e}getActiveTextures(e){this._texture&&e.push(this._texture),this._textureRoughness&&e.push(this._textureRoughness),this._bumpTexture&&e.push(this._bumpTexture),this._tintTexture&&e.push(this._tintTexture)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&e.push(this._textureRoughness),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._tintTexture&&this._tintTexture.animations&&this._tintTexture.animations.length>0&&e.push(this._tintTexture)}dispose(e){e&&(this._texture?.dispose(),this._textureRoughness?.dispose(),this._bumpTexture?.dispose(),this._tintTexture?.dispose())}getClassName(){return"PBRClearCoatConfiguration"}addFallbacks(e,t,i){return e.CLEARCOAT_BUMP&&t.addFallback(i++,"CLEARCOAT_BUMP"),e.CLEARCOAT_TINT&&t.addFallback(i++,"CLEARCOAT_TINT"),e.CLEARCOAT&&t.addFallback(i++,"CLEARCOAT"),i}getSamplers(e){e.push("clearCoatSampler","clearCoatRoughnessSampler","clearCoatBumpSampler","clearCoatTintSampler")}getUniforms(){return{ubo:[{name:"vClearCoatParams",size:2,type:"vec2"},{name:"vClearCoatRefractionParams",size:4,type:"vec4"},{name:"vClearCoatInfos",size:4,type:"vec4"},{name:"clearCoatMatrix",size:16,type:"mat4"},{name:"clearCoatRoughnessMatrix",size:16,type:"mat4"},{name:"vClearCoatBumpInfos",size:2,type:"vec2"},{name:"vClearCoatTangentSpaceParams",size:2,type:"vec2"},{name:"clearCoatBumpMatrix",size:16,type:"mat4"},{name:"vClearCoatTintParams",size:4,type:"vec4"},{name:"clearCoatColorAtDistance",size:1,type:"float"},{name:"vClearCoatTintInfos",size:2,type:"vec2"},{name:"clearCoatTintMatrix",size:16,type:"mat4"}]}}}dt._DefaultIndexOfRefraction=1.5;T([R(),B("_markAllSubMeshesAsTexturesDirty")],dt.prototype,"isEnabled",void 0);T([R()],dt.prototype,"intensity",void 0);T([R()],dt.prototype,"roughness",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],dt.prototype,"indexOfRefraction",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],dt.prototype,"texture",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],dt.prototype,"useRoughnessFromMainTexture",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],dt.prototype,"textureRoughness",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],dt.prototype,"remapF0OnInterfaceChange",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],dt.prototype,"bumpTexture",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],dt.prototype,"isTintEnabled",void 0);T([At()],dt.prototype,"tintColor",void 0);T([R()],dt.prototype,"tintColorAtDistance",void 0);T([R()],dt.prototype,"tintThickness",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],dt.prototype,"tintTexture",void 0);class Dd extends Si{constructor(){super(...arguments),this.IRIDESCENCE=!1,this.IRIDESCENCE_TEXTURE=!1,this.IRIDESCENCE_TEXTUREDIRECTUV=0,this.IRIDESCENCE_THICKNESS_TEXTURE=!1,this.IRIDESCENCE_THICKNESS_TEXTUREDIRECTUV=0}}class Mt extends Qt{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRIridescence",110,new Dd,t),this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.minimumThickness=Mt._DefaultMinimumThickness,this.maximumThickness=Mt._DefaultMaximumThickness,this.indexOfRefraction=Mt._DefaultIndexOfRefraction,this._texture=null,this.texture=null,this._thicknessTexture=null,this.thicknessTexture=null,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[1]}isReadyForSubMesh(e,t){return this._isEnabled?!(e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&U.IridescenceTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._thicknessTexture&&U.IridescenceTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())):!0}prepareDefinesBeforeAttributes(e,t){this._isEnabled?(e.IRIDESCENCE=!0,e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&U.IridescenceTextureEnabled?Ne(this._texture,e,"IR
56IDESCENCE_TEXTURE"):e.IRIDESCENCE_TEXTURE=!1,this._thicknessTexture&&U.IridescenceTextureEnabled?Ne(this._thicknessTexture,e,"IRIDESCENCE_THICKNESS_TEXTURE"):e.IRIDESCENCE_THICKNESS_TEXTURE=!1)):(e.IRIDESCENCE=!1,e.IRIDESCENCE_TEXTURE=!1,e.IRIDESCENCE_THICKNESS_TEXTURE=!1,e.IRIDESCENCE_TEXTUREDIRECTUV=0,e.IRIDESCENCE_THICKNESS_TEXTUREDIRECTUV=0)}bindForSubMesh(e,t){if(!this._isEnabled)return;const i=this._material.isFrozen;(!e.useUbo||!i||!e.isSync)&&((this._texture||this._thicknessTexture)&&U.IridescenceTextureEnabled&&(e.updateFloat4("vIridescenceInfos",this._texture?.coordinatesIndex??0,this._texture?.level??0,this._thicknessTexture?.coordinatesIndex??0,this._thicknessTexture?.level??0),this._texture&&Ue(this._texture,e,"iridescence"),this._thicknessTexture&&Ue(this._thicknessTexture,e,"iridescenceThickness")),e.updateFloat4("vIridescenceParams",this.intensity,this.indexOfRefraction,this.minimumThickness,this.maximumThickness)),t.texturesEnabled&&(this._texture&&U.IridescenceTextureEnabled&&e.setTexture("iridescenceSampler",this._texture),this._thicknessTexture&&U.IridescenceTextureEnabled&&e.setTexture("iridescenceThicknessSampler",this._thicknessTexture))}hasTexture(e){return this._texture===e||this._thicknessTexture===e}getActiveTextures(e){this._texture&&e.push(this._texture),this._thicknessTexture&&e.push(this._thicknessTexture)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._thicknessTexture&&this._thicknessTexture.animations&&this._thicknessTexture.animations.length>0&&e.push(this._thicknessTexture)}dispose(e){e&&(this._texture?.dispose(),this._thicknessTexture?.dispose())}getClassName(){return"PBRIridescenceConfiguration"}addFallbacks(e,t,i){return e.IRIDESCENCE&&t.addFallback(i++,"IRIDESCENCE"),i}getSamplers(e){e.push("iridescenceSampler","iridescenceThicknessSampler")}getUniforms(){return{ubo:[{name:"vIridescenceParams",size:4,type:"vec4"},{name:"vIridescenceInfos",size:4,type:"vec4"},{name:"iridescenceMatrix",size:16,type:"mat4"},{name:"iridescenceThicknessMatrix",size:16,type:"mat4"}]}}}Mt._DefaultMinimumThickness=100;Mt._DefaultMaximumThickness=400;Mt._DefaultIndexOfRefraction=1.3;T([R(),B("_markAllSubMeshesAsTexturesDirty")],Mt.prototype,"isEnabled",void 0);T([R()],Mt.prototype,"intensity",void 0);T([R()],Mt.prototype,"minimumThickness",void 0);T([R()],Mt.prototype,"maximumThickness",void 0);T([R()],Mt.prototype,"indexOfRefraction",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],Mt.prototype,"texture",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],Mt.prototype,"thicknessTexture",void 0);class Od extends Si{constructor(){super(...arguments),this.ANISOTROPIC=!1,this.ANISOTROPIC_TEXTURE=!1,this.ANISOTROPIC_TEXTUREDIRECTUV=0,this.ANISOTROPIC_LEGACY=!1,this.MAINUV1=!1}}class Ms extends Qt{set angle(e){this.direction.x=Math.cos(e),this.direction.y=Math.sin(e)}get angle(){return Math.atan2(this.direction.y,this.direction.x)}_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}_markAllSubMeshesAsMiscDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsMiscDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRAnisotropic",110,new Od,t),this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.direction=new Q(1,0),this._texture=null,this.texture=null,this._legacy=!1,this.legacy=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[1],this._internalMarkAllSubMeshesAsMiscDirty=e._dirtyCallbacks[16]}isReadyForSubMesh(e,t){return this._isEnabled?!(e._areTexturesDirty&&t.texturesEnabled&&this._texture&&U.AnisotropicTextureEnabled&&!this._texture.isReadyOrNotBlocking()):!0}prepareDefinesBeforeAttributes(e,t,i){this._isEnabled?(e.ANISOTROPIC=this._isEnabled,this._isEnabled&&!i.isVerticesDataPresent(b.TangentKind)&&(e._needUVs=!0,e.MAINUV1=!0),e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&U.AnisotropicTextureEnabled?Ne(this._texture,e,"ANISOTROPIC_TEXTURE"):e.ANISOTROPIC_TEXTURE=!1),e._areMiscDirty&&(e.ANISOTROPIC_LEGACY=this._legacy)):(e.ANISOTROPIC=!1,e.ANISOTROPIC_TEXTURE=!1,e.ANISOTROPIC_TEXTUREDIRECTUV=0,e.ANISOTROPIC_LEGACY=!1)}bindForSubMesh(e,t){if(!this._isEnabled)return;const i=this._material.isFrozen;(!e.useUbo||!i||!e.isSync)&&(this._texture&&U.AnisotropicTextureEnabled&&(e.updateFloat2("vAnisotropyInfos",this._texture.coordinatesIndex,this._texture.level),Ue(this._texture,e,"anisotropy")),e.updateFloat3("vAnisotropy",this.direction.x,this.direction.y,this.intensity)),t.texturesEnabled&&this._texture&&U.AnisotropicTextureEnabled&&e.setTexture("anisotropySampler",this._texture)}hasTexture(e){return this._texture===e}getActiveTextures(e){this._texture&&e.push(this._texture)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)}dispose(e){e&&this._texture&&this._texture.dispose()}getClassName(){return"PBRAnisotropicConfiguration"}addFallbacks(e,t,i){return e.ANISOTROPIC&&t.addFallback(i++,"ANISOTROPIC"),i}getSamplers(e){e.push("anisotropySampler")}getUniforms(){return{ubo:[{name:"vAnisotropy",size:3,type:"vec3"},{name:"vAnisotropyInfos",size:2,type:"vec2"},{name:"anisotropyMatrix",size:16,type:"mat4"}]}}parse(e,t,i){super.parse(e,t,i),e.legacy===void 0&&(this.legacy=!0)}}T([R(),B("_markAllSubMeshesAsTexturesDirty")],Ms.prototype,"isEnabled",void 0);T([R()],Ms.prototype,"intensity",void 0);T([co()],Ms.prototype,"direction",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],Ms.prototype,"texture",void 0);T([R(),B("_markAllSubMeshesAsMiscDirty")],Ms.prototype,"legacy",void 0);class Fd extends Si{constructor(){super(...arguments),this.SHEEN=!1,this.SHEEN_TEXTURE=!1,this.SHEEN_GAMMATEXTURE=!1,this.SHEEN_TEXTURE_ROUGHNESS=!1,this.SHEEN_TEXTUREDIRECTUV=0,this.SHEEN_TEXTURE_ROUGHNESSDIRECTUV=0,this.SHEEN_LINKWITHALBEDO=!1,this.SHEEN_ROUGHNESS=!1,this.SHEEN_ALBEDOSCALING=!1,this.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=!1}}class li extends Qt{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"Sheen",120,new Fd,t),this._isEnabled=!1,this.isEnabled=!1,this._linkSheenWithAlbedo=!1,this.linkSheenWithAlbedo=!1,this.intensity=1,this.color=q.White(),this._texture=null,this.texture=null,this._useRoughnessFromMainTexture=!0,this.useRoughnessFromMainTexture=!0,this._roughness=null,this.roughness=null,this._textureRoughness=null,this.textureRoughness=null,this._albedoScaling=!1,this.albedoScaling=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[1]}isReadyForSubMesh(e,t){return this._isEnabled?!(e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&U.SheenTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._textureRoughness&&U.SheenTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking())):!0}prepareDefinesBeforeAttributes(e,t){this._isEnabled?(e.SHEEN=!0,e.SHEEN_LINKWITHALBEDO=this._linkSheenWithAlbedo,e.SHEEN_ROUGHNESS=this._roughness!==null,e.SHEEN_ALBEDOSCALING=this._albedoScaling,e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=this._useRoughnessFromMainTexture,e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&U.SheenTextureEnabled?(Ne(this._texture,e,"SHEEN_TEXTURE"),e.SHEEN_GAMMATEXTURE=this._texture.gammaSpace):e.SHEEN_TEXTURE=!1,this._textureRoughness&&U.SheenTextureEnabled?Ne(this._textureRoughness,e,"SHEEN_TEXTURE_ROUGHNESS"):e.SHEEN_TEXTURE_ROUGHNESS=!1)):(e.SHEEN=!1,e.SHEEN_TEXTURE=!1,e.SHEEN_TEXTURE_ROUGHNESS=!1,e.SHEEN_LINKWITHALBEDO=!1,e.SHEEN_ROUGHNESS=!1,e.SHEEN_ALBEDOSCALING=!1,e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,e.SHEEN_GAMMATEXTURE=!1,e.SHEEN_TEXTUREDIRECTUV=0,e.SHEEN_TEXTURE_ROUGHNESSDIRECTUV=0)}bindForSubMesh(e,t,i,s){if(!this._isEnabled)return;const r=s.materialDefines,n=this._material.isFrozen;(!e.useUbo||!n||!e.isSync)&&((this._texture||this._textureRoughness)&&U.SheenTextureEnabled&&(e.updateFloat4("vSheenInfos",this._texture?.coordinatesIndex??0,this._texture?.level??0,this._textureRoughness?.coordinatesIndex??0,this._textureRoughness?.level??0),this._texture&&Ue(this._texture,e,"sheen"),this._textureRoughness&&!r.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&Ue(this._textureRoughness,e,"sheenRoughness")),e.updateFloat4("vSheenColor",this.color.r,this.color.g,this.color.b,this.intensity),this._roughness!==null&&e.updateFloat("vSheenRoughness",this._roughness)),t.texturesEnabled&&(this._texture&&U.SheenTextureEnabled&&e.setTexture("sheenSampler",this._texture),this._textureRoughness&&!r.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&U.SheenTextureEnabled&&e.setTexture("sheenRoughnessSampler",this._textureRoughness))}hasTexture(e){return this._texture===e||this._textureRoughness===e}getActiveTextures(e){this._texture&&e.push(this._texture),this._textureRoughness&&e.push(this._textureRoughness)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&e.push(this._textureRoughness)}dispose(e){e&&(this._texture?.dispose(),this._textureRoughness?.dispose())}getClassName(){return"PBRSheenConfiguration"}addFallbacks(e,t,i){return e.SHEEN&&t.addFallback(i++,"SHEEN"),i}getSamplers(e){e.push("sheenSampler","sheenRoughnessSampler")}getUniforms(){return{ubo:[{name:"vSheenColor",size:4,type:"vec4"},{name:"vSheenRoughness",size:1,type:"float"},{name:"vSheenInfos",size:4,type:"vec4"},{name:"sheenMatrix",size:16,type:"mat4"},{name:"sheenRoughnessMatrix",size:16,type:"mat4"}]}}}T([R(),B("_markAllSubMeshesAsTexturesDirty")],li.prototype,"isEnabled",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],li.prototype,"linkSheenWithAlbedo",void 0);T([R()],li.prototype,"intensity",void 0);T([At()],li.prototype,"color",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],li.prototype,"texture",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],li.prototype,"useRoughnessFromMainTexture",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],li.prototype,"roughness",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],li.prototype,"textureRoughness",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],li.prototype,"albedoScaling",void 0);class wd extends Si{constructor(){super(...arguments),this.SUBSURFACE=!1,this.SS_REFRACTION=!1,this.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=!1,this.SS_TRANSLUCENCY=!1,this.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=!1,this.SS_SCATTERING=!1,this.SS_DISPERSION=!1,this.SS_THICKNESSANDMASK_TEXTURE=!1,this.SS_THICKNESSANDMASK_TEXTUREDIRECTUV=0,this.SS_HAS_THICKNESS=!1,this.SS_REFRACTIONINTENSITY_TEXTURE=!1,this.SS_REFRACTIONINTENSITY_TEXTUREDIRECTUV=0,this.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,this.SS_TRANSLUCENCYINTENSITY_TEXTUREDIRECTUV=0,this.SS_TRANSLUCENCYCOLOR_TEXTURE=!1,this.SS_TRANSLUCENCYCOLOR_TEXTUREDIRECTUV=0,this.SS_TRANSLUCENCYCOLOR_TEXTURE_GAMMA=!1,this.SS_REFRACTIONMAP_3D=!1,this.SS_REFRACTIONMAP_OPPOSITEZ=!1,this.SS_LODINREFRACTIONALPHA=!1,this.SS_GAMMAREFRACTION=!1,this.SS_RGBDREFRACTION=!1,this.SS_LINEARSPECULARREFRACTION=!1,this.SS_LINKREFRACTIONTOTRANSPARENCY=!1,this.SS_ALBEDOFORREFRACTIONTINT=!1,this.SS_ALBEDOFORTRANSLUCENCYTINT=!1,this.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,this.SS_USE_THICKNESS_AS_DEPTH=!1,this.SS_USE_GLTF_TEXTURES=!1,this.SS_APPLY_ALBEDO_AFTER_SUBSURFACE=!1,this.SS_TRANSLUCENCY_LEGACY=!1}}class Ce extends Qt{get scatteringDiffusionProfile(){return this._scene.subSurfaceConfiguration?this._scene.subSurfaceConfiguration.ssDiffusionProfileColors[this._scatteringDiffusionProfileIndex]:null}set scatteringDiffusionProfile(e){this._scene.enableSubSurfaceForPrePass()&&e&&(this._scatteringDiffusionProfileIndex=this._scene.subSurfaceConfiguration.addDiffusionProfile(e))}get volumeIndexOfRefraction(){return this._volumeIndexOfRefraction>=1?this._volumeIndexOfRefraction:this._indexOfRefraction}set volumeIndexOfRefraction(e){e>=1?this._volumeIndexOfRefraction=e:this._volumeIndexOfRefraction=-1}get legacyTransluceny(){return this.legacyTranslucency}set legacyTransluceny(e){this.legacyTranslucency=e}_markAllSubMeshesAsTexturesDirty(){this._enable(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}_markScenePrePassDirty(){this._enable(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled),this._internalMarkAllSubMeshesAsTexturesDirty(),this._internalMarkScenePrePassDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRSubSurface",130,new wd,t),this._isRefractionEnabled=!1,this.isRefractionEnabled=!1,this._isTranslucencyEnabled=!1,this.isTranslucencyEnabled=!1,this._isDispersionEnabled=!1,this.isDispersionEnabled=!1,this._isScatteringEnabled=!1,this.isScatteringEnabled=!1,this._scatteringDiffusionProfileIndex=0,this.refractionIntensity=1,this.translucencyIntensity=1,this._useAlbedoToTintRefraction=!1,this.useAlbedoToTintRefraction=!1,this._useAlbedoToTintTranslucency=!1,this.useAlbedoToTintTranslucency=!1,this._thicknessTexture=null,this.thicknessTexture=null,this._refractionTexture=null,this.refractionTexture=null,this._indexOfRefraction=1.5,this.indexOfRefraction=1.5,this._volumeIndexOfRefraction=-1,this._invertRefractionY=!1,this.invertRefractionY=!1,this._linkRefractionWithTransparency=!1,this.linkRefractionWithTransparency=!1,this.minimumThickness=0,this.maximumThickness=1,this.useThicknessAsDepth=!1,this.tintColor=q.White(),this.tintColorAtDistance=1,this.dispersion=0,this.diffusionDistance=q.White(),this._useMaskFromThicknessTexture=!1,this.useMaskFromThicknessTexture=!1,this._refractionIntensityTexture=null,this.refractionIntensityTexture=null,this._translucencyIntensityTexture=null,this.translucencyIntensityTexture=null,this.translucencyColor=null,this._translucencyColorTexture=null,this.translucencyColorTexture=null,this._useGltfStyleTextures=!0,this.useGltfStyleTextures=!0,this.applyAlbedoAfterSubSurface=Ce.DEFAULT_APPLY_ALBEDO_AFTERSUBSURFACE,this.legacyTranslucency=Ce.DEFAULT_LEGACY_TRANSLUCENCY,this._scene=e.getScene(),this.registerForExtraEvents=!0,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[1],this._internalMarkScenePrePassDirty=e._dirtyCallbacks[32]}isReadyForSubMesh(e,t){if(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled)return!0;
vendor: 16,384 bytes, line 56
56if(e._areTexturesDirty&&t.texturesEnabled){if(this._thicknessTexture&&U.ThicknessTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking()||this._refractionIntensityTexture&&U.RefractionIntensityTextureEnabled&&!this._refractionIntensityTexture.isReadyOrNotBlocking()||this._translucencyColorTexture&&U.TranslucencyColorTextureEnabled&&!this._translucencyColorTexture.isReadyOrNotBlocking()||this._translucencyIntensityTexture&&U.TranslucencyIntensityTextureEnabled&&!this._translucencyIntensityTexture.isReadyOrNotBlocking())return!1;const i=this._getRefractionTexture(t);if(i&&U.RefractionTextureEnabled&&!i.isReadyOrNotBlocking())return!1}return!0}prepareDefinesBeforeAttributes(e,t){if(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled){e.SUBSURFACE=!1,e.SS_DISPERSION=!1,e.SS_TRANSLUCENCY=!1,e.SS_SCATTERING=!1,e.SS_REFRACTION=!1,e.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_THICKNESSANDMASK_TEXTUREDIRECTUV=0,e.SS_HAS_THICKNESS=!1,e.SS_REFRACTIONINTENSITY_TEXTURE=!1,e.SS_REFRACTIONINTENSITY_TEXTUREDIRECTUV=0,e.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,e.SS_TRANSLUCENCYINTENSITY_TEXTUREDIRECTUV=0,e.SS_REFRACTIONMAP_3D=!1,e.SS_REFRACTIONMAP_OPPOSITEZ=!1,e.SS_LODINREFRACTIONALPHA=!1,e.SS_GAMMAREFRACTION=!1,e.SS_RGBDREFRACTION=!1,e.SS_LINEARSPECULARREFRACTION=!1,e.SS_LINKREFRACTIONTOTRANSPARENCY=!1,e.SS_ALBEDOFORREFRACTIONTINT=!1,e.SS_ALBEDOFORTRANSLUCENCYTINT=!1,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,e.SS_USE_THICKNESS_AS_DEPTH=!1,e.SS_USE_GLTF_TEXTURES=!1,e.SS_TRANSLUCENCYCOLOR_TEXTURE=!1,e.SS_TRANSLUCENCYCOLOR_TEXTUREDIRECTUV=0,e.SS_TRANSLUCENCYCOLOR_TEXTURE_GAMMA=!1,e.SS_APPLY_ALBEDO_AFTER_SUBSURFACE=!1;return}if(e._areTexturesDirty){if(e.SUBSURFACE=!0,e.SS_DISPERSION=this._isDispersionEnabled,e.SS_TRANSLUCENCY=this._isTranslucencyEnabled,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_TRANSLUCENCY_LEGACY=this.legacyTranslucency,e.SS_SCATTERING=this._isScatteringEnabled,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_REFRACTIONINTENSITY_TEXTURE=!1,e.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,e.SS_HAS_THICKNESS=!1,e.SS_USE_GLTF_TEXTURES=!1,e.SS_REFRACTION=!1,e.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_REFRACTIONMAP_3D=!1,e.SS_GAMMAREFRACTION=!1,e.SS_RGBDREFRACTION=!1,e.SS_LINEARSPECULARREFRACTION=!1,e.SS_REFRACTIONMAP_OPPOSITEZ=!1,e.SS_LODINREFRACTIONALPHA=!1,e.SS_LINKREFRACTIONTOTRANSPARENCY=!1,e.SS_ALBEDOFORREFRACTIONTINT=!1,e.SS_ALBEDOFORTRANSLUCENCYTINT=!1,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,e.SS_USE_THICKNESS_AS_DEPTH=!1,e.SS_TRANSLUCENCYCOLOR_TEXTURE=!1,e.SS_APPLY_ALBEDO_AFTER_SUBSURFACE=this.applyAlbedoAfterSubSurface,e._areTexturesDirty&&t.texturesEnabled&&(this._thicknessTexture&&U.ThicknessTextureEnabled&&Ne(this._thicknessTexture,e,"SS_THICKNESSANDMASK_TEXTURE"),this._refractionIntensityTexture&&U.RefractionIntensityTextureEnabled&&Ne(this._refractionIntensityTexture,e,"SS_REFRACTIONINTENSITY_TEXTURE"),this._translucencyIntensityTexture&&U.TranslucencyIntensityTextureEnabled&&Ne(this._translucencyIntensityTexture,e,"SS_TRANSLUCENCYINTENSITY_TEXTURE"),this._translucencyColorTexture&&U.TranslucencyColorTextureEnabled&&(Ne(this._translucencyColorTexture,e,"SS_TRANSLUCENCYCOLOR_TEXTURE"),e.SS_TRANSLUCENCYCOLOR_TEXTURE_GAMMA=this._translucencyColorTexture.gammaSpace)),e.SS_HAS_THICKNESS=this.maximumThickness-this.minimumThickness!==0,e.SS_USE_GLTF_TEXTURES=this._useGltfStyleTextures,e.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=this._useMaskFromThicknessTexture&&!this._refractionIntensityTexture,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=this._useMaskFromThicknessTexture&&!this._translucencyIntensityTexture,this._isRefractionEnabled&&t.texturesEnabled){const i=this._getRefractionTexture(t);i&&U.RefractionTextureEnabled&&(e.SS_REFRACTION=!0,e.SS_REFRACTIONMAP_3D=i.isCube,e.SS_GAMMAREFRACTION=i.gammaSpace,e.SS_RGBDREFRACTION=i.isRGBD,e.SS_LINEARSPECULARREFRACTION=i.linearSpecularLOD,e.SS_REFRACTIONMAP_OPPOSITEZ=this._scene.useRightHandedSystem&&i.isCube?!i.invertZ:i.invertZ,e.SS_LODINREFRACTIONALPHA=i.lodLevelInAlpha,e.SS_LINKREFRACTIONTOTRANSPARENCY=this._linkRefractionWithTransparency,e.SS_ALBEDOFORREFRACTIONTINT=this._useAlbedoToTintRefraction,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=i.isCube&&i.boundingBoxSize,e.SS_USE_THICKNESS_AS_DEPTH=this.useThicknessAsDepth)}this._isTranslucencyEnabled&&(e.SS_ALBEDOFORTRANSLUCENCYTINT=this._useAlbedoToTintTranslucency)}}hardBindForSubMesh(e,t,i,s){if(!(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled))if(this.maximumThickness===0&&this.minimumThickness===0)e.updateFloat2("vThicknessParam",0,0);else{s.getRenderingMesh().getWorldMatrix().decompose(v.Vector3[0]);const r=Math.max(Math.abs(v.Vector3[0].x),Math.abs(v.Vector3[0].y),Math.abs(v.Vector3[0].z));e.updateFloat2("vThicknessParam",this.minimumThickness*r,(this.maximumThickness-this.minimumThickness)*r)}}bindForSubMesh(e,t,i,s){if(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled)return;const r=s.materialDefines,n=this._material.isFrozen,o=this._material.realTimeFiltering,h=r.LODBASEDMICROSFURACE,l=this._getRefractionTexture(t);if(!e.useUbo||!n||!e.isSync){if(this._thicknessTexture&&U.ThicknessTextureEnabled&&(e.updateFloat2("vThicknessInfos",this._thicknessTexture.coordinatesIndex,this._thicknessTexture.level),Ue(this._thicknessTexture,e,"thickness")),this._refractionIntensityTexture&&U.RefractionIntensityTextureEnabled&&r.SS_REFRACTIONINTENSITY_TEXTURE&&(e.updateFloat2("vRefractionIntensityInfos",this._refractionIntensityTexture.coordinatesIndex,this._refractionIntensityTexture.level),Ue(this._refractionIntensityTexture,e,"refractionIntensity")),this._translucencyColorTexture&&U.TranslucencyColorTextureEnabled&&r.SS_TRANSLUCENCYCOLOR_TEXTURE&&(e.updateFloat2("vTranslucencyColorInfos",this._translucencyColorTexture.coordinatesIndex,this._translucencyColorTexture.level),Ue(this._translucencyColorTexture,e,"translucencyColor")),this._translucencyIntensityTexture&&U.TranslucencyIntensityTextureEnabled&&r.SS_TRANSLUCENCYINTENSITY_TEXTURE&&(e.updateFloat2("vTranslucencyIntensityInfos",this._translucencyIntensityTexture.coordinatesIndex,this._translucencyIntensityTexture.level),Ue(this._translucencyIntensityTexture,e,"translucencyIntensity")),l&&U.RefractionTextureEnabled){e.updateMatrix("refractionMatrix",l.getRefractionTextureMatrix());let c=1;l.isCube||l.depth&&(c=l.depth);const u=l.getSize().width,f=this.volumeIndexOfRefraction;if(e.updateFloat4("vRefractionInfos",l.level,1/f,c,this._invertRefractionY?-1:1),e.updateFloat4("vRefractionMicrosurfaceInfos",u,l.lodGenerationScale,l.lodGenerationOffset,1/this.indexOfRefraction),o&&e.updateFloat2("vRefractionFilteringInfo",u,Math.log2(u)),l.boundingBoxSize){const d=l;e.updateVector3("vRefractionPosition",d.boundingBoxPosition),e.updateVector3("vRefractionSize",d.boundingBoxSize)}}this._isScatteringEnabled&&e.updateFloat("scatteringDiffusionProfile",this._scatteringDiffusionProfileIndex),e.updateColor3("vDiffusionDistance",this.diffusionDistance),e.updateFloat4("vTintColor",this.tintColor.r,this.tintColor.g,this.tintColor.b,Math.max(1e-5,this.tintColorAtDistance)),e.updateColor4("vTranslucencyColor",this.translucencyColor??this.tintColor,0),e.updateFloat3("vSubSurfaceIntensity",this.refractionIntensity,this.translucencyIntensity,0),e.updateFloat("dispersion",this.dispersion)}t.texturesEnabled&&(this._thicknessTexture&&U.ThicknessTextureEnabled&&e.setTexture("thicknessSampler",this._thicknessTexture),this._refractionIntensityTexture&&U.RefractionIntensityTextureEnabled&&r.SS_REFRACTIONINTENSITY_TEXTURE&&e.setTexture("refractionIntensitySampler",this._refractionIntensityTexture),this._translucencyIntensityTexture&&U.TranslucencyIntensityTextureEnabled&&r.SS_TRANSLUCENCYINTENSITY_TEXTURE&&e.setTexture("translucencyIntensitySampler",this._translucencyIntensityTexture),this._translucencyColorTexture&&U.TranslucencyColorTextureEnabled&&r.SS_TRANSLUCENCYCOLOR_TEXTURE&&e.setTexture("translucencyColorSampler",this._translucencyColorTexture),l&&U.RefractionTextureEnabled&&(h?e.setTexture("refractionSampler",l):(e.setTexture("refractionSampler",l._lodTextureMid||l),e.setTexture("refractionSamplerLow",l._lodTextureLow||l),e.setTexture("refractionSamplerHigh",l._lodTextureHigh||l))))}_getRefractionTexture(e){return this._refractionTexture?this._refractionTexture:this._isRefractionEnabled?e.environmentTexture:null}get disableAlphaBlending(){return this._isRefractionEnabled&&this._linkRefractionWithTransparency}fillRenderTargetTextures(e){U.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget&&e.push(this._refractionTexture)}hasTexture(e){return this._thicknessTexture===e||this._refractionTexture===e||this._refractionIntensityTexture===e||this._translucencyIntensityTexture===e||this._translucencyColorTexture===e}hasRenderTargetTextures(){return!!(U.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)}getActiveTextures(e){this._thicknessTexture&&e.push(this._thicknessTexture),this._refractionTexture&&e.push(this._refractionTexture),this._refractionIntensityTexture&&e.push(this._refractionIntensityTexture),this._translucencyColorTexture&&e.push(this._translucencyColorTexture),this._translucencyIntensityTexture&&e.push(this._translucencyIntensityTexture)}getAnimatables(e){this._thicknessTexture&&this._thicknessTexture.animations&&this._thicknessTexture.animations.length>0&&e.push(this._thicknessTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),this._refractionIntensityTexture&&this._refractionIntensityTexture.animations&&this._refractionIntensityTexture.animations.length>0&&e.push(this._refractionIntensityTexture),this._translucencyColorTexture&&this._translucencyColorTexture.animations&&this._translucencyColorTexture.animations.length>0&&e.push(this._translucencyColorTexture),this._translucencyIntensityTexture&&this._translucencyIntensityTexture.animations&&this._translucencyIntensityTexture.animations.length>0&&e.push(this._translucencyIntensityTexture)}dispose(e){e&&(this._thicknessTexture&&this._thicknessTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose(),this._refractionIntensityTexture&&this._refractionIntensityTexture.dispose(),this._translucencyColorTexture&&this._translucencyColorTexture.dispose(),this._translucencyIntensityTexture&&this._translucencyIntensityTexture.dispose())}getClassName(){return"PBRSubSurfaceConfiguration"}addFallbacks(e,t,i){return e.SS_SCATTERING&&t.addFallback(i++,"SS_SCATTERING"),e.SS_TRANSLUCENCY&&t.addFallback(i++,"SS_TRANSLUCENCY"),i}getSamplers(e){e.push("thicknessSampler","refractionIntensitySampler","translucencyIntensitySampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh","translucencyColorSampler")}getUniforms(){return{ubo:[{name:"vRefractionMicrosurfaceInfos",size:4,type:"vec4"},{name:"vRefractionFilteringInfo",size:2,type:"vec2"},{name:"vTranslucencyIntensityInfos",size:2,type:"vec2"},{name:"vRefractionInfos",size:4,type:"vec4"},{name:"refractionMatrix",size:16,type:"mat4"},{name:"vThicknessInfos",size:2,type:"vec2"},{name:"vRefractionIntensityInfos",size:2,type:"vec2"},{name:"thicknessMatrix",size:16,type:"mat4"},{name:"refractionIntensityMatrix",size:16,type:"mat4"},{name:"translucencyIntensityMatrix",size:16,type:"mat4"},{name:"vThicknessParam",size:2,type:"vec2"},{name:"vDiffusionDistance",size:3,type:"vec3"},{name:"vTintColor",size:4,type:"vec4"},{name:"vSubSurfaceIntensity",size:3,type:"vec3"},{name:"vRefractionPosition",size:3,type:"vec3"},{name:"vRefractionSize",size:3,type:"vec3"},{name:"scatteringDiffusionProfile",size:1,type:"float"},{name:"dispersion",size:1,type:"float"},{name:"vTranslucencyColor",size:4,type:"vec4"},{name:"vTranslucencyColorInfos",size:2,type:"vec2"},{name:"translucencyColorMatrix",size:16,type:"mat4"}]}}}Ce.DEFAULT_APPLY_ALBEDO_AFTERSUBSURFACE=!1;Ce.DEFAULT_LEGACY_TRANSLUCENCY=!1;T([R(),B("_markAllSubMeshesAsTexturesDirty")],Ce.prototype,"isRefractionEnabled",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],Ce.prototype,"isTranslucencyEnabled",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],Ce.prototype,"isDispersionEnabled",void 0);T([R(),B("_markScenePrePassDirty")],Ce.prototype,"isScatteringEnabled",void 0);T([R()],Ce.prototype,"_scatteringDiffusionProfileIndex",void 0);T([R()],Ce.prototype,"refractionIntensity",void 0);T([R()],Ce.prototype,"translucencyIntensity",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],Ce.prototype,"useAlbedoToTintRefraction",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],Ce.prototype,"useAlbedoToTintTranslucency",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],Ce.prototype,"thicknessTexture",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],Ce.prototype,"refractionTexture",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],Ce.prototype,"indexOfRefraction",void 0);T([R()],Ce.prototype,"_volumeIndexOfRefraction",void 0);T([B("_markAllSubMeshesAsTexturesDirty")],Ce.prototype,"volumeIndexOfRefraction",null);T([R(),B("_markAllSubMeshesAsTexturesDirty")],Ce.prototype,"invertRefractionY",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],Ce.prototype,"linkRefractionWithTransparency",void 0);T([R()],Ce.prototype,"minimumThickness",void 0);T([R()],Ce.prototype,"maximumThickness",void 0);T([R()],Ce.prototype,"useThicknessAsDepth",void 0);T([At()],Ce.prototype,"tintColor",void 0);T([R()],Ce.prototype,"tintColorAtDistance",void 0);T([R()],Ce.prototype,"dispersion",void 0);T([At()],Ce.prototype,"diffusionDistance",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],Ce.prototype,"useMaskFromThicknessTexture",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],Ce.prototype,"refractionIntensityTexture",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],Ce.prototype,"translucencyIntensityTexture",void 0);T([At()],Ce.prototype,"translucencyColor",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],Ce.prototype,"translucencyColorTexture",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],Ce.prototype,"useGltfStyleTextures",void 0);T([R()],Ce.prototype,"applyAlbedoAfterSubSurface",void 0);T([R()],Ce.prototype,"legacyTranslucency",void 0);class Ld extends Si{constructor(){super(...arguments),this.DETAIL=!1,this.DETAILDIRECTUV=0,this.DETAIL_NORMALBLENDMETHOD=0}}class ss extends Qt{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"DetailMap",140,new Ld,t),this._texture=null,this.diffuseBlendLevel=1,this.roughnessBlendLevel=1,this.bumpLevel=1,this._normalBlendMethod=F.MATERIAL_NORMALBLENDMETHOD_WHITEOUT,this._isEnabled=!1,this.isEnabled=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[1]}isReadyForSubMesh(e,t,i){return this._isEnabled?!(e._areTexturesDirty&&t.texturesEnabled&&i.getCaps().standardDerivatives&&this._texture&&U.DetailTextureEnabled&&!this._texture.isReady()):!0}prepareDefines(e,t){if(this._isEnabled){e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod;const i=t.getEngine();e._areTexturesDirty&&(i.getCaps().standardDerivatives&&this._texture&&U.DetailTextureEnabled&&this._isEnabled?(Ne(this._texture,e,"DETAIL"),e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod):e.DETAIL=!1)}else e.DETAIL=!1}bindForSubMesh(e,t){if(!this._isEnabled)return;const i=this._material.isFrozen;(!e.useUbo||!i||!e.isSync)&&this._texture&&U.DetailTextureEnabled&&(e.updateFloat4("vDetailInfos",this._texture.coordinatesIndex,this.diffuseBlendLevel,this.bumpLevel,this.roughnessBlendLevel),Ue(this._texture,e,"detail")),t.texturesEnabled&&this._texture&&U.DetailTextureEnabled&&e.setTexture("detailSampler",this._texture)}hasTexture(e){return this._texture===e}getActiveTextures(e){this._texture&&e.push(this._texture)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)}dispose(e){e&&this._texture?.dispose()}getClassName(){return"DetailMapConfiguration"}getSamplers(e){e.push("detailSampler")}getUniforms(){return{ubo:[{name:"vDetailInfos",size:4,type:"vec4"},{name:"detailMatrix",size:16,type:"mat4"}]}}}T([Oe("detailTexture"),B("_markAllSubMeshesA
56sTexturesDirty")],ss.prototype,"texture",void 0);T([R()],ss.prototype,"diffuseBlendLevel",void 0);T([R()],ss.prototype,"roughnessBlendLevel",void 0);T([R()],ss.prototype,"bumpLevel",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],ss.prototype,"normalBlendMethod",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],ss.prototype,"isEnabled",void 0);var Ga;(function(a){a[a.Zero=0]="Zero",a[a.One=1]="One",a[a.MaxViewZ=2]="MaxViewZ",a[a.NoClear=3]="NoClear"})(Ga||(Ga={}));class It{static CreateConfiguration(e){return It._Configurations[e]={defines:{},previousWorldMatrices:{},previousViewProjection:P.Zero(),currentViewProjection:P.Zero(),previousBones:{},lastUpdateFrameId:-1,excludedSkinnedMesh:[],reverseCulling:!1},It._Configurations[e]}static DeleteConfiguration(e){delete It._Configurations[e]}static GetConfiguration(e){return It._Configurations[e]}static AddUniformsAndSamplers(e,t){e.push("previousWorld","previousViewProjection","mPreviousBones")}static MarkAsDirty(e,t){for(const i of t)if(i.subMeshes)for(const s of i.subMeshes)s._removeDrawWrapper(e)}static PrepareDefines(e,t,i){if(!i._arePrePassDirty)return;const s=It._Configurations[e];if(!s)return;i.PREPASS=!0;let r=0;for(let n=0;n<It.GeometryTextureDescriptions.length;n++){const o=It.GeometryTextureDescriptions[n],h=o.define,l=o.defineIndex,c=s.defines[l];c!==void 0?(i[h]=!0,i[l]=c,r++):(i[h]=!1,delete i[l])}i.SCENE_MRT_COUNT=r,i.BONES_VELOCITY_ENABLED=t.useBones&&t.computeBonesUsingShaders&&t.skeleton&&!t.skeleton.isUsingTextureForMatrices&&s.excludedSkinnedMesh.indexOf(t)===-1}static Bind(e,t,i,s,r){const n=It._Configurations[e];if(!n)return;const o=i.getScene(),h=o.getEngine();if(n.reverseCulling&&h.setStateCullFaceType(o._mirroredCameraPosition?r.cullBackFaces:!r.cullBackFaces),(n.defines.PREPASS_VELOCITY_INDEX!==void 0||n.defines.PREPASS_VELOCITY_LINEAR_INDEX!==void 0)&&(n.previousWorldMatrices[i.uniqueId]||(n.previousWorldMatrices[i.uniqueId]=s.clone()),n.previousViewProjection||(n.previousViewProjection=o.getTransformMatrix().clone(),n.currentViewProjection=o.getTransformMatrix().clone()),n.currentViewProjection.updateFlag!==o.getTransformMatrix().updateFlag?(n.lastUpdateFrameId=h.frameId,n.previousViewProjection.copyFrom(n.currentViewProjection),n.currentViewProjection.copyFrom(o.getTransformMatrix())):n.lastUpdateFrameId!==h.frameId&&(n.lastUpdateFrameId=h.frameId,n.previousViewProjection.copyFrom(n.currentViewProjection)),t.setMatrix("previousWorld",n.previousWorldMatrices[i.uniqueId]),t.setMatrix("previousViewProjection",n.previousViewProjection),n.previousWorldMatrices[i.uniqueId]=s.clone(),i.useBones&&i.computeBonesUsingShaders&&i.skeleton)){const l=i.skeleton;if(!l.isUsingTextureForMatrices||t.getUniformIndex("boneTextureWidth")===-1){const c=l.getTransformMatrices(i);c&&(n.previousBones[i.uniqueId]||(n.previousBones[i.uniqueId]=c.slice()),t.setMatrices("mPreviousBones",n.previousBones[i.uniqueId]),n.previousBones[i.uniqueId].set(c))}}}}It.GeometryTextureDescriptions=[{type:0,name:"Irradiance",clearType:0,define:"PREPASS_IRRADIANCE",defineIndex:"PREPASS_IRRADIANCE_INDEX"},{type:1,name:"WorldPosition",clearType:0,define:"PREPASS_POSITION",defineIndex:"PREPASS_POSITION_INDEX"},{type:2,name:"Velocity",clearType:0,define:"PREPASS_VELOCITY",defineIndex:"PREPASS_VELOCITY_INDEX"},{type:3,name:"Reflectivity",clearType:0,define:"PREPASS_REFLECTIVITY",defineIndex:"PREPASS_REFLECTIVITY_INDEX"},{type:5,name:"ViewDepth",clearType:2,define:"PREPASS_DEPTH",defineIndex:"PREPASS_DEPTH_INDEX"},{type:6,name:"ViewNormal",clearType:0,define:"PREPASS_NORMAL",defineIndex:"PREPASS_NORMAL_INDEX"},{type:7,name:"AlbedoSqrt",clearType:0,define:"PREPASS_ALBEDO_SQRT",defineIndex:"PREPASS_ALBEDO_SQRT_INDEX"},{type:8,name:"WorldNormal",clearType:0,define:"PREPASS_WORLD_NORMAL",defineIndex:"PREPASS_WORLD_NORMAL_INDEX"},{type:9,name:"LocalPosition",clearType:0,define:"PREPASS_LOCAL_POSITION",defineIndex:"PREPASS_LOCAL_POSITION_INDEX"},{type:10,name:"ScreenDepth",clearType:1,define:"PREPASS_SCREENSPACE_DEPTH",defineIndex:"PREPASS_SCREENSPACE_DEPTH_INDEX"},{type:11,name:"LinearVelocity",clearType:0,define:"PREPASS_VELOCITY_LINEAR",defineIndex:"PREPASS_VELOCITY_LINEAR_INDEX"},{type:12,name:"Albedo",clearType:0,define:"PREPASS_ALBEDO",defineIndex:"PREPASS_ALBEDO_INDEX"}
56,{type:13,name:"NormalizedViewDepth",clearType:1,define:"PREPASS_NORMALIZED_VIEW_DEPTH",defineIndex:"PREPASS_NORMALIZED_VIEW_DEPTH_INDEX"},{type:4,name:"Color",clearType:3,define:"PREPASS_COLOR",defineIndex:"PREPASS_COLOR_INDEX"}];It._Configurations={};function Bd(a){return class extends a{constructor(){super(...arguments),this.MAINUV1=!1,this.MAINUV2=!1,this.MAINUV3=!1,this.MAINUV4=!1,this.MAINUV5=!1,this.MAINUV6=!1,this.UV1=!1,this.UV2=!1,this.UV3=!1,this.UV4=!1,this.UV5=!1,this.UV6=!1}}}const as={effect:null,subMesh:null};class Nd extends Bd(Si){}class Ha extends Ph(Nd){constructor(e){super(e),this.PBR=!0,this.NUM_SAMPLES="0",this.REALTIME_FILTERING=!1,this.IBL_CDF_FILTERING=!1,this.ALBEDO=!1,this.GAMMAALBEDO=!1,this.ALBEDODIRECTUV=0,this.VERTEXCOLOR=!1,this.BASE_WEIGHT=!1,this.BASE_WEIGHTDIRECTUV=0,this.BASE_DIFFUSE_ROUGHNESS=!1,this.BASE_DIFFUSE_ROUGHNESSDIRECTUV=0,this.BAKED_VERTEX_ANIMATION_TEXTURE=!1,this.AMBIENT=!1,this.AMBIENTDIRECTUV=0,this.AMBIENTINGRAYSCALE=!1,this.OPACITY=!1,this.VERTEXALPHA=!1,this.OPACITYDIRECTUV=0,this.OPACITYRGB=!1,this.ALPHATEST=!1,this.DEPTHPREPASS=!1,this.ALPHABLEND=!1,this.ALPHAFROMALBEDO=!1,this.ALPHATESTVALUE="0.5",this.SPECULAROVERALPHA=!1,this.RADIANCEOVERALPHA=!1,this.ALPHAFRESNEL=!1,this.LINEARALPHAFRESNEL=!1,this.PREMULTIPLYALPHA=!1,this.EMISSIVE=!1,this.EMISSIVEDIRECTUV=0,this.GAMMAEMISSIVE=!1,this.REFLECTIVITY=!1,this.REFLECTIVITY_GAMMA=!1,this.REFLECTIVITYDIRECTUV=0,this.SPECULARTERM=!1,this.MICROSURFACEFROMREFLECTIVITYMAP=!1,this.MICROSURFACEAUTOMATIC=!1,this.LODBASEDMICROSFURACE=!1,this.MICROSURFACEMAP=!1,this.MICROSURFACEMAPDIRECTUV=0,this.METALLICWORKFLOW=!1,this.ROUGHNESSSTOREINMETALMAPALPHA=!1,this.ROUGHNESSSTOREINMETALMAPGREEN=!1,this.METALLNESSSTOREINMETALMAPBLUE=!1,this.AOSTOREINMETALMAPRED=!1,this.METALLIC_REFLECTANCE=!1,this.METALLIC_REFLECTANCE_GAMMA=!1,this.METALLIC_REFLECTANCEDIRECTUV=0,this.METALLIC_REFLECTANCE_USE_ALPHA_ONLY=!1,this.REFLECTANCE=!1,this.REFLECTANCE_GAMMA=!1,this.REFLECTANCEDIRECTUV=0,this.ENVIRONMENTBRDF=!1,this.ENVIRONMENTBRDF_RGBD=!1,this.NORMAL=!1,this.TANGENT=!1,this.BUMP=!1,this.BUMPDIRECTUV=0,this.OBJECTSPACE_NORMALMAP=!1,this.PARALLAX=!1,this.PARALLAX_RHS=!1,this.PARALLAXOCCLUSION=!1,this.NORMALXYSCALE=!0,this.LIGHTMAP=!1,this.LIGHTMAPDIRECTUV=0,this.USELIGHTMAPASSHADOWMAP=!1,this.GAMMALIGHTMAP=!1,this.RGBDLIGHTMAP=!1,this.REFLECTION=!1,this.REFLECTIONMAP_3D=!1,this.REFLECTIONMAP_SPHERICAL=!1,this.REFLECTIONMAP_PLANAR=!1,this.REFLECTIONMAP_CUBIC=!1,this.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,this.REFLECTIONMAP_PROJECTION=!1,this.REFLECTIONMAP_SKYBOX=!1,this.REFLECTIONMAP_EXPLICIT=!1,this.REFLECTIONMAP_EQUIRECTANGULAR=!1,this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,this.INVERTCUBICMAP=!1,this.USESPHERICALFROMREFLECTIONMAP=!1,this.USEIRRADIANCEMAP=!1,this.USE_IRRADIANCE_DOMINANT_DIRECTION=!1,this.USESPHERICALINVERTEX=!1,this.REFLECTIONMAP_OPPOSITEZ=!1,this.LODINREFLECTIONALPHA=!1,this.GAMMAREFLECTION=!1,this.RGBDREFLECTION=!1,this.LINEARSPECULARREFLECTION=!1,this.RADIANCEOCCLUSION=!1,this.HORIZONOCCLUSION=!1,this.INSTANCES=!1,this.THIN_INSTANCES=!1,this.INSTANCESCOLOR=!1,this.PREPASS=!1,this.PREPASS_COLOR=!1,this.PREPASS_COLOR_INDEX=-1,this.PREPASS_IRRADIANCE=!1,this.PREPASS_IRRADIANCE_INDEX=-1,this.PREPASS_ALBEDO=!1,this.PREPASS_ALBEDO_INDEX=-1,this.PREPASS_ALBEDO_SQRT=!1,this.PREPASS_ALBEDO_SQRT_INDEX=-1,this.PREPASS_DEPTH=!1,this.PREPASS_DEPTH_INDEX=-1,this.PREPASS_SCREENSPACE_DEPTH=!1,this.PREPASS_SCREENSPACE_DEPTH_INDEX=-1,this.PREPASS_NORMALIZED_VIEW_DEPTH=!1,this.PREPASS_NORMALIZED_VIEW_DEPTH_INDEX=-1,this.PREPASS_NORMAL=!1,this.PREPASS_NORMAL_INDEX=-1,this.PREPASS_NORMAL_WORLDSPACE=!1,this.PREPASS_WORLD_NORMAL=!1,this.PREPASS_WORLD_NORMAL_INDEX=-1,this.PREPASS_POSITION=!1,this.PREPASS_POSITION_INDEX=-1,this.PREPASS_LOCAL_POSITION=!1,this.PREPASS_LOCAL_POSITION_INDEX=-1,this.PREPASS_VELOCITY=!1,this.PREPASS_VELOCITY_INDEX=-1,this.PREPASS_VELOCITY_LINEAR=!1,this.PREPASS_VELOCITY_LINEAR_INDEX=-1,this.PREPASS_REFLECTIVITY=!1,this.PREPASS_REFLECTIVITY_INDEX=-1,this.SCENE_MRT_COUNT=0,this.NUM_BONE_INFLUENCERS=0,this.BonesPerMesh=0,this.BONETEXTURE=!1,this.BONES_VELOCITY_ENABLED=!1,this.NONUNIFORMSCALING=!1,this.MORPHTARGETS=!1,this.MORPHTARGETS_POSITION=!1,this.MORPHTARGETS_NORMAL=!1,this.MORPHTARGETS_TANGENT=!1,this.MORPHTARGETS_
vendor: 8,704 bytes, line 56
56UV=!1,this.MORPHTARGETS_UV2=!1,this.MORPHTARGETS_COLOR=!1,this.MORPHTARGETTEXTURE_HASPOSITIONS=!1,this.MORPHTARGETTEXTURE_HASNORMALS=!1,this.MORPHTARGETTEXTURE_HASTANGENTS=!1,this.MORPHTARGETTEXTURE_HASUVS=!1,this.MORPHTARGETTEXTURE_HASUV2S=!1,this.MORPHTARGETTEXTURE_HASCOLORS=!1,this.NUM_MORPH_INFLUENCERS=0,this.MORPHTARGETS_TEXTURE=!1,this.MULTIVIEW=!1,this.ORDER_INDEPENDENT_TRANSPARENCY=!1,this.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!1,this.USEPHYSICALLIGHTFALLOFF=!1,this.USEGLTFLIGHTFALLOFF=!1,this.TWOSIDEDLIGHTING=!1,this.MIRRORED=!1,this.SHADOWFLOAT=!1,this.CLIPPLANE=!1,this.CLIPPLANE2=!1,this.CLIPPLANE3=!1,this.CLIPPLANE4=!1,this.CLIPPLANE5=!1,this.CLIPPLANE6=!1,this.POINTSIZE=!1,this.FOG=!1,this.LOGARITHMICDEPTH=!1,this.CAMERA_ORTHOGRAPHIC=!1,this.CAMERA_PERSPECTIVE=!1,this.AREALIGHTSUPPORTED=!0,this.FORCENORMALFORWARD=!1,this.SPECULARAA=!1,this.UNLIT=!1,this.DECAL_AFTER_DETAIL=!1,this.DEBUGMODE=0,this.USE_VERTEX_PULLING=!1,this.RIGHT_HANDED=!1,this.CLUSTLIGHT_SLICES=0,this.CLUSTLIGHT_BATCH=0,this.rebuild()}reset(){super.reset(),this.ALPHATESTVALUE="0.5",this.PBR=!0,this.NORMALXYSCALE=!0}}class Ud extends Dh(Ih){}class ve extends Ud{get realTimeFiltering(){return this._realTimeFiltering}set realTimeFiltering(e){this._realTimeFiltering=e,this.markAsDirty(1)}get realTimeFilteringQuality(){return this._realTimeFilteringQuality}set realTimeFilteringQuality(e){this._realTimeFilteringQuality=e,this.markAsDirty(1)}get canRenderToMRT(){return!0}constructor(e,t,i=!1){super(e,t,void 0,i||ve.ForceGLSL),this._directIntensity=1,this._emissiveIntensity=1,this._environmentIntensity=1,this._specularIntensity=1,this._lightingInfos=new ge(this._directIntensity,this._emissiveIntensity,this._environmentIntensity,this._specularIntensity),this._disableBumpMap=!1,this._albedoTexture=null,this._baseWeightTexture=null,this._baseDiffuseRoughnessTexture=null,this._ambientTexture=null,this._ambientTextureStrength=1,this._ambientTextureImpactOnAnalyticalLights=ve.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,this._opacityTexture=null,this._reflectionTexture=null,this._emissiveTexture=null,this._reflectivityTexture=null,this._metallicTexture=null,this._metallic=null,this._roughness=null,this._metallicF0Factor=1,this._metallicReflectanceColor=q.White(),this._useOnlyMetallicFromMetallicReflectanceTexture=!1,this._metallicReflectanceTexture=null,this._reflectanceTexture=null,this._microSurfaceTexture=null,this._bumpTexture=null,this._lightmapTexture=null,this._ambientColor=new q(0,0,0),this._albedoColor=new q(1,1,1),this._baseWeight=1,this._baseDiffuseRoughness=null,this._reflectivityColor=new q(1,1,1),this._reflectionColor=new q(1,1,1),this._emissiveColor=new q(0,0,0),this._microSurface=.9,this._useLightmapAsShadowmap=!1,this._useHorizonOcclusion=!0,this._useRadianceOcclusion=!0,this._useAlphaFromAlbedoTexture=!1,this._useSpecularOverAlpha=!0,this._useMicroSurfaceFromReflectivityMapAlpha=!1,this._useRoughnessFromMetallicTextureAlpha=!0,this._useRoughnessFromMetallicTextureGreen=!1,this._useMetallnessFromMetallicTextureBlue=!1,this._useAmbientOcclusionFromMetallicTextureRed=!1,this._useAmbientInGrayScale=!1,this._useAutoMicroSurfaceFromReflectivityMap=!1,this._lightFalloff=ve.LIGHTFALLOFF_PHYSICAL,this._useRadianceOverAlpha=!0,this._useObjectSpaceNormalMap=!1,this._useParallax=!1,this._useParallaxOcclusion=!1,this._parallaxScaleBias=.05,this._disableLighting=!1,this._maxSimultaneousLights=4,this._invertNormalMapX=!1,this._invertNormalMapY=!1,this._twoSidedLighting=!1,this._alphaCutOff=.4,this._useAlphaFresnel=!1,this._useLinearAlphaFresnel=!1,this._environmentBRDFTexture=null,this._forceIrradianceInFragment=!1,this._realTimeFiltering=!1,this._realTimeFilteringQuality=8,this._forceNormalForward=!1,this._enableSpecularAntiAliasing=!1,this._renderTargets=new it(16),this._globalAmbientColor=new q(0,0,0),this._unlit=!1,this._applyDecalMapAfterDetailMap=!1,this._debugMode=0,this._shadersLoaded=!1,this._breakShaderLoadedCheck=!1,this.debugMode=0,this.debugLimit=-1,this.debugFactor=1,this._cacheHasRenderTargetTextures=!1,this.brdf=new xe(this),this.clearCoat=new dt(this),this.iridescence=new Mt(this),this.anisotropy=new Ms(this),this.sheen=new li(this),this.subSurface=new Ce(this),this.detailMap=new ss(this),this._attachImageProcessingConfiguration(null),this.getRenderTargetTextures=()=>(this._renderTargets.reset(),U.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._renderTargets.push(this._reflectionTexture),this._eventInfo.renderTargets=this._renderTargets,this._callbackPluginEventFillRenderTargetTextures(this._eventInfo),this._renderTargets),this._environmentBRDFTexture=Gh(this.getScene()),this.prePassConfiguration=new ka}get hasRenderTargetTextures(){return U.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget?!0:this._cacheHasRenderTargetTextures}get isPrePassCapable(){return!this.disableDepthWrite}getClassName(){return"PBRBaseMaterial"}get _disableAlphaBlending(){return this._transparencyMode===ve.PBRMATERIAL_OPAQUE||this._transparencyMode===ve.PBRMATERIAL_ALPHATEST||this.subSurface?.disableAlphaBlending}needAlphaBlending(){return this._hasTransparencyMode?this._transparencyModeIsBlend:this._disableAlphaBlending?!1:this.alpha<1||this._opacityTexture!=null||this._shouldUseAlphaFromAlbedoTexture()}needAlphaTesting(){return this._hasTransparencyMode?this._transparencyModeIsTest:this.subSurface?.disableAlphaBlending?!1:this._hasAlphaChannel()&&(this._transparencyMode==null||this._transparencyMode===ve.PBRMATERIAL_ALPHATEST)}_shouldUseAlphaFromAlbedoTexture(){return this._albedoTexture!=null&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture&&this._transparencyMode!==ve.PBRMATERIAL_OPAQUE}_hasAlphaChannel(){return this._albedoTexture!=null&&this._albedoTexture.hasAlpha||this._opacityTexture!=null}getAlphaTestTexture(){return this._albedoTexture}isReadyForSubMesh(e,t,i){this._uniformBufferLayoutBuilt||this.buildUniformLayout();const s=t._drawWrapper;if(s.effect&&this.isFrozen&&s._wasPreviouslyReady&&s._wasPreviouslyUsingInstances===i)return!0;t.materialDefines||(this._callbackPluginEventGeneric(4,this._eventInfo),t.materialDefines=new Ha(this._eventInfo.defineNames));const r=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;const n=this.getScene(),o=n.getEngine();if(r._areTexturesDirty&&(this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._cacheHasRenderTargetTextures=this._eventInfo.hasRenderTargetTextures,n.texturesEnabled)){if(this._albedoTexture&&U.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking()||this._baseWeightTexture&&U.BaseWeightTextureEnabled&&!this._baseWeightTexture.isReadyOrNotBlocking()||this._baseDiffuseRoughnessTexture&&U.BaseDiffuseRoughnessTextureEnabled&&!this._baseDiffuseRoughnessTexture.isReadyOrNotBlocking()||this._ambientTexture&&U.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking()||this._opacityTexture&&U.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;const f=this._getReflectionTexture();if(f&&U.ReflectionTextureEnabled){if(!f.isReadyOrNotBlocking())return!1;if(f.irradianceTexture){if(!f.irradianceTexture.isReadyOrNotBlocking())return!1}else if(!f.sphericalPolynomial&&f.getInternalTexture()?._sphericalPolynomialPromise)return!1}if(this._lightmapTexture&&U.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking()||this._emissiveTexture&&U.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if(U.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1}else if(this._reflectivityTexture&&!this._reflectivityTexture.isReadyOrNotBlocking())return!1;if(this._metallicReflectanceTexture&&!this._metallicReflectanceTexture.isReadyOrNotBlocking()||this._reflectanceTexture&&!this._reflectanceTexture.isReadyOrNotBlocking()||this._microSurfaceTexture&&!this._microSurfaceTexture.isReadyOrNotBlocking())return!1}if(o.getCaps().standardDerivatives&&this._bumpTexture&&U.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady()||this._environmentBRDFTexture&&U.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady())return!1}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=r,this._eventInfo.subMesh=t,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh||r._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;if(r.AREALIGHTUSED||r.CLUSTLIGHT_BATCH){for(let f=0;f<e.lightSources.length;f++)if(!e.lightSources[f]._isReady())return!1}
56!o.getCaps().standardDerivatives&&!e.isVerticesDataPresent(b.NormalKind)&&(e.createNormals(!0),w.Warn("PBRMaterial: Normals have been created for the mesh: "+e.name));const h=t.effect,l=r._areLightsDisposed;let c=this._prepareEffect(e,t.getRenderingMesh(),r,this.onCompiled,this.onError,i,null),u=!1;if(c)if(this._onEffectCreatedObservable&&(as.effect=c,as.subMesh=t,this._onEffectCreatedObservable.notifyObservers(as)),this.allowShaderHotSwapping&&h&&!c.isReady()){if(c=h,r.markAsUnprocessed(),u=this.isFrozen,l)return r._areLightsDisposed=!0,!1}else n.resetCachedMaterial(),t.setEffect(c,r,this._materialContext);return!t.effect||!t.effect.isReady()?!1:(r._renderId=n.getRenderId(),s._wasPreviouslyReady=!u,s._wasPreviouslyUsingInstances=!!i,this._checkScenePerformancePriority(),!0)}isMetallicWorkflow(){return!!(this._metallic!=null||this._roughness!=null||this._metallicTexture)}_prepareEffect(e,t,i,s=null,r=null,n=null,o=null){if(this._prepareDefines(e,t,i,n,o),!i.isDirty)return null;i.markAsProcessed();const l=this.getScene().getEngine(),c=new vh;let u=0;i.USESPHERICALINVERTEX&&c.addFallback(u++,"USESPHERICALINVERTEX"),i.FOG&&c.addFallback(u,"FOG"),i.SPECULARAA&&c.addFallback(u,"SPECULARAA"),i.POINTSIZE&&c.addFallback(u,"POINTSIZE"),i.LOGARITHMICDEPTH&&c.addFallback(u,"LOGARITHMICDEPTH"),i.PARALLAX&&c.addFallback(u,"PARALLAX"),i.PARALLAX_RHS&&c.addFallback(u,"PARALLAX_RHS"),i.PARALLAXOCCLUSION&&c.addFallback(u++,"PARALLAXOCCLUSION"),i.ENVIRONMENTBRDF&&c.addFallback(u++,"ENVIRONMENTBRDF"),i.TANGENT&&c.addFallback(u++,"TANGENT"),i.BUMP&&c.addFallback(u++,"BUMP"),u=oh(i,c,this._maxSimultaneousLights,u++),i.SPECULARTERM&&c.addFallback(u++,"SPECULARTERM"),i.USESPHERICALFROMREFLECTIONMAP&&c.addFallback(u++,"USESPHERICALFROMREFLECTIONMAP"),i.USEIRRADIANCEMAP&&c.addFallback(u++,"USEIRRADIANCEMAP"),i.LIGHTMAP&&c.addFallback(u++,"LIGHTMAP"),i.NORMAL&&c.addFallback(u++,"NORMAL"),i.AMBIENT&&c.addFallback(u++,"AMBIENT"),i.EMISSIVE&&c.addFallback(u++,"EMISSIVE"),i.VERTEXCOLOR&&c.addFallback(u++,"VERTEXCOLOR"),i.MORPHTARGETS&&c.addFallback(u++,"MORPHTARGETS"),i.MULTIVIEW&&c.addFallback(0,"MULTIVIEW");const f=[b.PositionKind];i.NORMAL&&f.push(b.NormalKind),i.TANGENT&&f.push(b.TangentKind);for(let C=1;C<=6;++C)i["UV"+C]&&f.push(`uv${C===1?"":C}`);i.VERTEXCOLOR&&f.push(b.ColorKind),nh(f,e,i,c),ah(f,i),Jo(f,e,i),qc(f,e,i);let d="pbr";const g=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","baseWeight","baseDiffuseRoughness","vReflectivityColor","vMetallicReflectanceFactors","vEmissiveColor","visibility","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vBaseWeightInfos","vBaseDiffuseRoughnessInfos","vAmbientInfos","vOpacityInfos","vEmissiveInfos","vReflectivityInfos","vMetallicReflectanceInfos","vReflectanceInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","mBones","albedoMatrix","baseWeightMatrix","baseDiffuseRoughnessMatrix","ambientMatrix","opacityMatrix","emissiveMatrix","reflectivityMatrix","normalMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","metallicReflectanceMatrix","reflectanceMatrix","vLightingIntensity","logarithmicDepthConstant","vTangentSpaceParams","boneTextureWidth","vDebugMode","morphTargetTextureInfo","morphTargetTextureIndices","cameraInfo"],p=["albedoSampler","baseWeightSampler","baseDiffuseRoughnessSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","microSurfaceSampler","environmentBrdfSampler","boneSampler","metallicReflectanceSampler","reflectanceSampler","morphTargets","oitDepthSampler","oitFrontColorSampler","areaLightsLTC1Sampler","areaLightsLTC2Sampler"];_h(g,p,!0);const m=["Material","Scene","Mesh"],A={maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:i.NUM_MORPH_INFLUENCERS};this._eventInfo.fallbacks=c,this._eventInfo.fallbackRank=u,this._eventInfo.defines=i,this._eventInfo.uniforms=g,this._eventInfo.attributes=f,this._eventInfo.samplers=p,this._eventInfo.uniformBuffersNames=m,this._eventInfo.customCode=void 0,this._eventInfo.mesh=e,this._eventInfo.indexParameters=A,this._callbackPluginEventGeneric(128,this._eventInfo),It.AddUniformsAndSamplers(g,p),ka.AddUniforms(g),qo(g),ue&&(ue.PrepareUniforms(g,i),ue.PrepareSamplers(p,i)),gh({uniformsNames:g,uniformBuffersNames:m,samplers:p,defines:i,maxSimultaneousLights:this._maxSimultaneousLights});const E={};this.customShaderNameResolve&&(d=this.customShaderNameResolve(d,g,m,p,i,f,E));
vendor: 5,695 bytes, line 56
56const I=i.toString(),M=l.createEffect(d,{attributes:f,uniformsNames:g,uniformBuffersNames:m,samplers:p,defines:I,fallbacks:c,onCompiled:s,onError:r,indexParameters:A,processFinalCode:E.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:i.PREPASS,shaderLanguage:this._shaderLanguage,extraInitializationsAsync:this._shadersLoaded?void 0:async()=>{this.shaderLanguage===1?await Promise.all([G(()=>import("./pbr.vertex-Bqe2YxDs.js"),__vite__mapDeps([62,63,2,64,65,66,3,67,4,5,6,68,69,7,8,9,70,10,71,11,12,72,13,14]),import.meta.url),G(()=>import("./pbr.fragment-C_KvfDGd.js"),__vite__mapDeps([73,74,63,2,64,75,66,16,76,17,19,10,20,3,77,68,67,78,79,21,13,14]),import.meta.url)]):await Promise.all([G(()=>import("./pbr.vertex-D3wqzG3a.js"),__vite__mapDeps([80,81,82,24,83,84,25,85,26,27,86,87,28,29,30,88,31,89,13,14]),import.meta.url),G(()=>import("./pbr.fragment-_GS9UE3N.js"),__vite__mapDeps([90,91,82,24,83,92,84,33,93,34,37,31,38,25,94,86,85,95,36,13,14]),import.meta.url)]),this._shadersLoaded=!0}},l);return this._eventInfo.customCode=void 0,M}_prepareDefines(e,t,i,s=null,r=null){const n=t.hasThinInstances,o=this.getScene(),h=o.getEngine();lh(o,e,i,!0,this._maxSimultaneousLights,this._disableLighting),i._needNormals=!0,fh(o,i);const l=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if(su(o,i,this.canRenderToMRT&&!l),iu(o,i,l),It.PrepareDefines(h.currentRenderPassId,e,i),i.METALLICWORKFLOW=this.isMetallicWorkflow(),i._areTexturesDirty){i._needUVs=!1;for(let c=1;c<=6;++c)i["MAINUV"+c]=!1;if(o.texturesEnabled){i.ALBEDODIRECTUV=0,i.BASE_WEIGHTDIRECTUV=0,i.BASE_DIFFUSE_ROUGHNESSDIRECTUV=0,i.AMBIENTDIRECTUV=0,i.OPACITYDIRECTUV=0,i.EMISSIVEDIRECTUV=0,i.REFLECTIVITYDIRECTUV=0,i.MICROSURFACEMAPDIRECTUV=0,i.METALLIC_REFLECTANCEDIRECTUV=0,i.REFLECTANCEDIRECTUV=0,i.BUMPDIRECTUV=0,i.LIGHTMAPDIRECTUV=0,h.getCaps().textureLOD&&(i.LODBASEDMICROSFURACE=!0),this._albedoTexture&&U.DiffuseTextureEnabled?(Ne(this._albedoTexture,i,"ALBEDO"),i.GAMMAALBEDO=this._albedoTexture.gammaSpace):i.ALBEDO=!1,this._baseWeightTexture&&U.BaseWeightTextureEnabled?Ne(this._baseWeightTexture,i,"BASE_WEIGHT"):i.BASE_WEIGHT=!1,this._baseDiffuseRoughnessTexture&&U.BaseDiffuseRoughnessTextureEnabled?Ne(this._baseDiffuseRoughnessTexture,i,"BASE_DIFFUSE_ROUGHNESS"):i.BASE_DIFFUSE_ROUGHNESS=!1,this._ambientTexture&&U.AmbientTextureEnabled?(Ne(this._ambientTexture,i,"AMBIENT"),i.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):i.AMBIENT=!1,this._opacityTexture&&U.OpacityTextureEnabled?(Ne(this._opacityTexture,i,"OPACITY"),i.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):i.OPACITY=!1;const c=this._getReflectionTexture(),u=this._forceIrradianceInFragment||this.realTimeFiltering||this._twoSidedLighting||h.getCaps().maxVaryingVectors<=8||this._baseDiffuseRoughnessTexture!=null;ch(o,c,i,this.realTimeFiltering,this.realTimeFilteringQuality,!u),this._lightmapTexture&&U.LightmapTextureEnabled?(Ne(this._lightmapTexture,i,"LIGHTMAP"),i.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,i.GAMMALIGHTMAP=this._lightmapTexture.gammaSpace,i.RGBDLIGHTMAP=this._lightmapTexture.isRGBD):i.LIGHTMAP=!1,this._emissiveTexture&&U.EmissiveTextureEnabled?(Ne(this._emissiveTexture,i,"EMISSIVE"),i.GAMMAEMISSIVE=this._emissiveTexture.gammaSpace):i.EMISSIVE=!1,U.SpecularTextureEnabled?(this._metallicTexture?(Ne(this._metallicTexture,i,"REFLECTIVITY"),i.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,i.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,i.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,i.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed,i.REFLECTIVITY_GAMMA=!1):this._reflectivityTexture?(Ne(this._reflectivityTexture,i,"REFLECTIVITY"),i.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,i.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap,i.REFLECTIVITY_GAMMA=this._reflectivityTexture.gammaSpace):i.REFLECTIVITY=!1,this._metallicReflectanceTexture||this._reflectanceTexture?(i.METALLIC_REFLECTANCE_USE_ALPHA_ONLY=this._useOnlyMetallicFromMetallicReflectanceTexture,this._metallicReflectanceTexture?(Ne(this._metallicReflectanceTexture,i,"METALLIC_REFLECTANCE"),i.METALLIC_REFLECTANCE_GAMMA=this._metallicReflectanceTexture.gammaSpace):i.METALLIC_REFLECTANCE=!1,this._reflectanceTexture&&(!this._metallicReflectanceTexture||this._metallicReflectanceTexture&&this._useOnlyMetallicFromMetallicReflectanceTexture)?(Ne(this._reflectanceTexture,i,"REFLECTANCE"),i.REFLECTANCE_GAMMA=this._reflectanceTexture.gammaSpace):i.REFLECTANCE=!1):(i.METALLIC_REFLECTANCE=!1,i.REFLECTANCE=!1),this._microSurfaceTexture?Ne(this._microSurfaceTexture,i,"MICROSURFACEMAP"):i.MICROSURFACEMAP=!1):(i.REFLECTIVITY=!1,i.MICROSURFACEMAP=!1),h.getCaps().standardDerivatives&&this._bumpTexture&&U.BumpTextureEnabled&&!this._disableBumpMap?(Ne(this._bumpTexture,i,"BUMP"),this._useParallax&&this._albedoTexture&&U.DiffuseTextureEnabled?(i.PARALLAX=!0,i.PARALLAX_RHS=o.useRightHandedSystem,i.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):i.PARALLAX=!1,i.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):(i.BUMP=!1,i.PARALLAX=!1,i.PARALLAX_RHS=!1,i.PARALLAXOCCLUSION=!1,i.OBJECTSPACE_NORMALMAP=!1),this._environmentBRDFTexture&&U.ReflectionTextureEnabled?(i.ENVIRONMENTBRDF=!0,i.ENVIRONMENTBRDF_RGBD=this._environmentBRDFTexture.isRGBD):(i.ENVIRONMENTBRDF=!1,i.ENVIRONMENTBRDF_RGBD=!1),this._shouldUseAlphaFromAlbedoTexture()?i.ALPHAFROMALBEDO=!0:i.ALPHAFROMALBEDO=!1}i.SPECULAROVERALPHA=this._useSpecularOverAlpha,this._lightFalloff===ve.LIGHTFALLOFF_STANDARD?(i.USEPHYSICALLIGHTFA
vendor: 10,636 bytes, line 56
56LLOFF=!1,i.USEGLTFLIGHTFALLOFF=!1):this._lightFalloff===ve.LIGHTFALLOFF_GLTF?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!0):(i.USEPHYSICALLIGHTFALLOFF=!0,i.USEGLTFLIGHTFALLOFF=!1),i.RADIANCEOVERALPHA=this._useRadianceOverAlpha,!this.backFaceCulling&&this._twoSidedLighting?i.TWOSIDEDLIGHTING=!0:i.TWOSIDEDLIGHTING=!1,i.MIRRORED=!!o._mirroredCameraPosition,i.SPECULARAA=h.getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}(i._areTexturesDirty||i._areMiscDirty)&&(i.ALPHATESTVALUE=`${this._alphaCutOff}${this._alphaCutOff%1===0?".":""}`,i.PREMULTIPLYALPHA=this.alphaMode===7||this.alphaMode===8,i.ALPHABLEND=this.needAlphaBlendingForMesh(e),i.ALPHAFRESNEL=this._useAlphaFresnel||this._useLinearAlphaFresnel,i.LINEARALPHAFRESNEL=this._useLinearAlphaFresnel),i._areImageProcessingDirty&&this._imageProcessingConfiguration&&this._imageProcessingConfiguration.prepareDefines(i),i.FORCENORMALFORWARD=this._forceNormalForward,i.RADIANCEOCCLUSION=this._useRadianceOcclusion,i.HORIZONOCCLUSION=this._useHorizonOcclusion,i._areMiscDirty&&(hh(e,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this.needAlphaTestingForMesh(e),i,this._applyDecalMapAfterDetailMap,this._useVertexPulling,t,this._isVertexOutputInvariant),i.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(b.NormalKind),i.DEBUGMODE=this._debugMode),uh(o,h,this,i,!!s,r,n),this._eventInfo.defines=i,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo),dh(e,i,!0,!0,!0,this._transparencyMode!==ve.PBRMATERIAL_OPAQUE),this._callbackPluginEventPrepareDefines(this._eventInfo)}forceCompilation(e,t,i){const s={clipPlane:!1,useInstances:!1,...i};this._uniformBufferLayoutBuilt||this.buildUniformLayout(),this._callbackPluginEventGeneric(4,this._eventInfo),(()=>{if(this._breakShaderLoadedCheck)return;const n=new Ha(this._eventInfo.defineNames),o=this._prepareEffect(e,e,n,void 0,void 0,s.useInstances,s.clipPlane);this._onEffectCreatedObservable&&(as.effect=o,as.subMesh=null,this._onEffectCreatedObservable.notifyObservers(as)),o.isReady()?t&&t(this):o.onCompileObservable.add(()=>{t&&t(this)})})()}buildUniformLayout(){const e=this._uniformBuffer;e.addUniform("vAlbedoInfos",2),e.addUniform("vBaseWeightInfos",2),e.addUniform("vBaseDiffuseRoughnessInfos",2),e.addUniform("vAmbientInfos",4),e.addUniform("vOpacityInfos",2),e.addUniform("vEmissiveInfos",2),e.addUniform("vLightmapInfos",2),e.addUniform("vReflectivityInfos",3),e.addUniform("vMicroSurfaceSamplerInfos",2),e.addUniform("vBumpInfos",3),e.addUniform("albedoMatrix",16),e.addUniform("baseWeightMatrix",16),e.addUniform("baseDiffuseRoughnessMatrix",16),e.addUniform("ambientMatrix",16),e.addUniform("opacityMatrix",16),e.addUniform("emissiveMatrix",16),e.addUniform("lightmapMatrix",16),e.addUniform("reflectivityMatrix",16),e.addUniform("microSurfaceSamplerMatrix",16),e.addUniform("bumpMatrix",16),e.addUniform("vTangentSpaceParams",2),e.addUniform("vAlbedoColor",4),e.addUniform("baseWeight",1),e.addUniform("baseDiffuseRoughness",1),e.addUniform("vLightingIntensity",4),e.addUniform("pointSize",1),e.addUniform("vReflectivityColor",4),e.addUniform("vEmissiveColor",3),e.addUniform("vAmbientColor",3),e.addUniform("vDebugMode",2),e.addUniform("vMetallicReflectanceFactors",4),e.addUniform("vMetallicReflectanceInfos",2),e.addUniform("metallicReflectanceMatrix",16),e.addUniform("vReflectanceInfos",2),e.addUniform("reflectanceMatrix",16),e.addUniform("cameraInfo",4),ph(e,!0,!0,!0,!0,!0),super.buildUniformLayout()}bindForSubMesh(e,t,i){const s=this.getScene(),r=i.materialDefines;if(!r)return;const n=i.effect;if(!n)return;this._activeEffect=n,t.getMeshUniformBuffer().bindToEffect(n,"Mesh"),t.transferToEffect(e);const o=s.getEngine();this._uniformBuffer.bindToEffect(n,"Material"),this.prePassConfiguration.bindForSubMesh(this._activeEffect,s,t,e,this.isFrozen),It.Bind(o.currentRenderPassId,this._activeEffect,t,e,this);const h=s.activeCamera;h?this._uniformBuffer.updateFloat4("cameraInfo",h.minZ,h.maxZ,0,0):this._uniformBuffer.updateFloat4("cameraInfo",0,0,0,0),this._eventInfo.subMesh=i,this._callbackPluginEventHardBindForSubMesh(this._eventInfo),r.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));const l=this._mustRebind(s,n,i,t.visibility);sh(t,this._activeEffect,this.prePassConfiguration);let c=null;const u=this._uniformBuffer;if(l){if(this.bindViewProjection(n),c=this._getReflectionTexture(),!u.useUbo||!this.isFrozen||!u.isSync||i._drawWrapper._forceRebindOnNextCall){if(s.texturesEnabled&&(this._albedoTexture&&U.DiffuseTextureEnabled&&(u.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),Ue(this._albedoTexture,u,"albedo")),this._baseWeightTexture&&U.BaseWeightTextureEnabled&&(u.updateFloat2("vBaseWeightInfos",this._baseWeightTexture.coordinatesIndex,this._baseWeightTexture.level),Ue(this._baseWeightTexture,u,"baseWeight")),this._baseDiffuseRoughnessTexture&&U.BaseDiffuseRoughnessTextureEnabled&&(u.updateFloat2("vBaseDiffuseRoughnessInfos",this._baseDiffuseRoughnessTexture.coordinatesIndex,this._baseDiffuseRoughnessTexture.level),Ue(this._baseDiffuseRoughnessTexture,u,"baseDiffuseRoughness")),this._ambientTexture&&U.AmbientTextureEnabled&&(u.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),Ue(this._ambientTexture,u,"ambient")),this._opacityTexture&&U.OpacityTextureEnabled&&(u.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),Ue(this._opacityTexture,u,"opacity")),this._emissiveTexture&&U.EmissiveTextureEnabled&&(u.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),Ue(this._emissiveTexture,u,"emissive")),this._lightmapTexture&&U.LightmapTextureEnabled&&(u.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),Ue(this._lightmapTexture,u,"lightmap")),U.SpecularTextureEnabled&&(this._metallicTexture?(u.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),Ue(this._metallicTexture,u,"reflectivity")):this._reflectivityTexture&&(u.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),Ue(this._reflectivityTexture,u,"reflectivity")),this._metallicReflectanceTexture&&(u.updateFloat2("vMetallicReflectanceInfos",this._metallicReflectanceTexture.coordinatesIndex,this._metallicReflectanceTexture.level),Ue(this._metallicReflectanceTexture,u,"metallicReflectance")),this._reflectanceTexture&&r.REFLECTANCE&&(u.updateFloat2("vReflectanceInfos",this._reflectanceTexture.coordinatesIndex,this._reflectanceTexture.level),Ue(this._reflectanceTexture,u,"reflectance")),this._microSurfaceTexture&&(u.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),Ue(this._microSurfaceTexture,u,"microSurfaceSampler"))),this._bumpTexture&&o.getCaps().standardDerivatives&&U.BumpTextureEnabled&&!this._disableBumpMap&&(u.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),Ue(this._bumpTexture,u,"bump"),s._mirroredCameraPosition?u.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):u.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),th(s,r,u,this._reflectionColor,c,this.realTimeFiltering,!0,!0,!0,!0,!0)),this.pointsCloud&&u.updateFloat("pointSize",this.pointSize),r.METALLICWORKFLOW){Vt.Color4[0].r=this._metallic===void 0||this._metallic===null?1:this._metallic,Vt.Color4[0].g=this._roughness===void 0||this._roughness===null?1:this._roughness;const f=this.subSurface?._indexOfRefraction??1.5,d=1;Vt.Color4[0].b=f;const g=Math.pow((f-d)/(f+d),2);Vt.Color4[0].a=g,u.updateDirectColor4("vReflectivityColor",Vt.Color4[0]),u.updateColor4("vMetallicReflectanceFactors",this._metallicReflectanceColor,this._metallicF0Factor)}else u.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface);u.updateColor3("vEmissiveColor",U.EmissiveTextureEnabled?this._emissiveColor:q.BlackReadOnly),!r.SS_REFRACTION&&this.subSurface?._linkRefractionWithTransparency?u.updateColor4("vAlbedoColor",this._albedoColor,1):u.updateColor4("vAlbedoColor",this._albedoColor,this.alpha),u.updateFloat("baseWeight",this._baseWeight),u.updateFloat("baseDiffuseRoughness",this._baseDiffuseRoughness||0),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity*s.environmentIntensity,this._lightingInfos.w=this._specularIntensity,u.updateVector4("vLightingIntensity",this._lightingInfos),s.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor),u.updateColor3("vAmbientColor",this._globalAmbientColor),u.updateFloat2("vDebugMode",this.debugLimit,this.debugFactor)}s.texturesEnabled&&(this._albedoTexture&&U.DiffuseTextureEnabled&&u.setTexture("albedoSampler",this._albedoTexture),this._baseWeightTexture&&U.BaseWeightTextureEnabled&&u.setTexture("baseWeightSampler",this._baseWeightTexture),this._baseDiffuseRoughnessTexture&&U.BaseDiffuseRoughnessTextureEnabled&&u.setTexture("baseDiffuseRoughnessSampler",this._baseDiffuseRoughnessTexture),this._ambientTexture&&U.AmbientTextureEnabled&&u.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&U.OpacityTextureEnabled&&u.setTexture("opacitySampler",this._opacityTexture),ih(s,r,u,c,this.realTimeFiltering),r.ENVIRONMENTBRDF&&u.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),this._emissiveTexture&&U.EmissiveTextureEnabled&&u.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&U.LightmapTextureEnabled&&u.setTexture("lightmapSampler",this._lightmapTexture),U.SpecularTextureEnabled&&(this._metallicTexture?u.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&u.setTexture("reflectivitySampler",this._reflectivityTexture),this._metallicReflectanceTexture&&u.setTexture("metallicReflectanceSampler",this._metallicReflectanceTexture),this._reflectanceTexture&&r.REFLECTANCE&&u.setTexture("reflectanceSampler",this._reflectanceTexture),this._microSurfaceTexture&&u.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&o.getCaps().standardDerivatives&&U.BumpTextureEnabled&&!this._disableBumpMap&&u.setTexture("bumpSampler",this._bumpTexture)),this.get
vendor: 38,035 bytes, line 56
56Scene().useOrderIndependentTransparency&&this.needAlphaBlendingForMesh(t)&&this.getScene().depthPeelingRenderer.bind(n),this._eventInfo.subMesh=i,this._callbackPluginEventBindForSubMesh(this._eventInfo),jo(this._activeEffect,this,s),this.bindEyePosition(n)}else s.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);(l||!this.isFrozen)&&(s.lightsEnabled&&!this._disableLighting&&rh(s,t,this._activeEffect,r,this._maxSimultaneousLights),(s.fogEnabled&&t.applyFog&&s.fogMode!==tt.FOGMODE_NONE||c||this.subSurface.refractionTexture||t.receiveShadows||r.PREPASS||r.CLUSTLIGHT_BATCH)&&this.bindView(n),$o(s,t,this._activeEffect,!0),r.NUM_MORPH_INFLUENCERS&&eh(t,this._activeEffect),r.BAKED_VERTEX_ANIMATION_TEXTURE&&t.bakedVertexAnimationManager?.bind(n,r.INSTANCES),this._imageProcessingConfiguration.bind(this._activeEffect),Zo(r,this._activeEffect,s)),this._afterBind(t,this._activeEffect,i),u.update()}getAnimatables(){const e=super.getAnimatables();return this._albedoTexture&&this._albedoTexture.animations&&this._albedoTexture.animations.length>0&&e.push(this._albedoTexture),this._baseWeightTexture&&this._baseWeightTexture.animations&&this._baseWeightTexture.animations.length>0&&e.push(this._baseWeightTexture),this._baseDiffuseRoughnessTexture&&this._baseDiffuseRoughnessTexture.animations&&this._baseDiffuseRoughnessTexture.animations.length>0&&e.push(this._baseDiffuseRoughnessTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._metallicTexture&&this._metallicTexture.animations&&this._metallicTexture.animations.length>0?e.push(this._metallicTexture):this._reflectivityTexture&&this._reflectivityTexture.animations&&this._reflectivityTexture.animations.length>0&&e.push(this._reflectivityTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._metallicReflectanceTexture&&this._metallicReflectanceTexture.animations&&this._metallicReflectanceTexture.animations.length>0&&e.push(this._metallicReflectanceTexture),this._reflectanceTexture&&this._reflectanceTexture.animations&&this._reflectanceTexture.animations.length>0&&e.push(this._reflectanceTexture),this._microSurfaceTexture&&this._microSurfaceTexture.animations&&this._microSurfaceTexture.animations.length>0&&e.push(this._microSurfaceTexture),e}_getReflectionTexture(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture}getActiveTextures(){const e=super.getActiveTextures();return this._albedoTexture&&e.push(this._albedoTexture),this._baseWeightTexture&&e.push(this._baseWeightTexture),this._baseDiffuseRoughnessTexture&&e.push(this._baseDiffuseRoughnessTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._reflectivityTexture&&e.push(this._reflectivityTexture),this._metallicTexture&&e.push(this._metallicTexture),this._metallicReflectanceTexture&&e.push(this._metallicReflectanceTexture),this._reflectanceTexture&&e.push(this._reflectanceTexture),this._microSurfaceTexture&&e.push(this._microSurfaceTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),e}hasTexture(e){return!!(super.hasTexture(e)||this._albedoTexture===e||this._baseWeightTexture===e||this._baseDiffuseRoughnessTexture===e||this._ambientTexture===e||this._opacityTexture===e||this._reflectionTexture===e||this._emissiveTexture===e||this._reflectivityTexture===e||this._metallicTexture===e||this._metallicReflectanceTexture===e||this._reflectanceTexture===e||this._microSurfaceTexture===e||this._bumpTexture===e||this._lightmapTexture===e)}setPrePassRenderer(){if(!this.subSurface?.isScatteringEnabled)return!1;const e=this.getScene().enableSubSurfaceForPrePass();return e&&(e.enabled=!0),!0}dispose(e,t){this._breakShaderLoadedCheck=!0,t&&(this._environmentBRDFTexture&&this.getScene().environmentBRDFTexture!==this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),this._albedoTexture?.dispose(),this._baseWeightTexture?.dispose(),this._baseDiffuseRoughnessTexture?.dispose(),this._ambientTexture?.dispose(),this._opacityTexture?.dispose(),this._reflectionTexture?.dispose(),this._emissiveTexture?.dispose(),this._metallicTexture?.dispose(),this._reflectivityTexture?.dispose(),this._bumpTexture?.dispose(),this._lightmapTexture?.dispose(),this._metallicReflectanceTexture?.dispose(),this._reflectanceTexture?.dispose(),this._microSurfaceTexture?.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),super.dispose(e,t)}}ve.PBRMATERIAL_OPAQUE=F.MATERIAL_OPAQUE;ve.PBRMATERIAL_ALPHATEST=F.MATERIAL_ALPHATEST;ve.PBRMATERIAL_ALPHABLEND=F.MATERIAL_ALPHABLEND;ve.PBRMATERIAL_ALPHATESTANDBLEND=F.MATERIAL_ALPHATESTANDBLEND;ve.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=0;ve.LIGHTFALLOFF_PHYSICAL=0;ve.LIGHTFALLOFF_GLTF=1;ve.LIGHTFALLOFF_STANDARD=2;ve.ForceGLSL=!1;T([B("_markAllSubMeshesAsMiscDirty")],ve.prototype,"debugMode",void 0);class j extends ve{get refractionTexture(){return this.subSurface.refractionTexture}set refractionTexture(e){this.subSurface.refractionTexture=e,e?this.subSurface.isRefractionEnabled=!0:this.subSurface.linkRefractionWithTransparency||(this.subSurface.isRefractionEnabled=!1)}get indexOfRefraction(){return this.subSurface.indexOfRefraction}set indexOfRefraction(e){this.subSurface.indexOfRefraction=e}get invertRefractionY(){return this.subSurface.invertRefractionY}set invertRefractionY(e){this.subSurface.invertRefractionY=e}get linkRefractionWithTransparency(){return this.subSurface.linkRefractionWithTransparency}set linkRefractionWithTransparency(e){this.subSurface.linkRefractionWithTransparency=e,e&&(this.subSurface.isRefractionEnabled=!0)}get usePhysicalLightFalloff(){return this._lightFalloff===ve.LIGHTFALLOFF_PHYSICAL}set usePhysicalLightFalloff(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),e?this._lightFalloff=ve.LIGHTFALLOFF_PHYSICAL:this._lightFalloff=ve.LIGHTFALLOFF_STANDARD)}get useGLTFLightFalloff(){return this._lightFalloff===ve.LIGHTFALLOFF_GLTF}set useGLTFLightFalloff(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),e?this._lightFalloff=ve.LIGHTFALLOFF_GLTF:this._lightFalloff=ve.LIGHTFALLOFF_STANDARD)}constructor(e,t,i=!1){super(e,t,i),this.directIntensity=1,this.emissiveIntensity=1,this.environmentIntensity=1,this.specularIntensity=1,this.disableBumpMap=!1,this.ambientTextureStrength=1,this.ambientTextureImpactOnAnalyticalLights=j.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,this.metallicF0Factor=1,this.metallicReflectanceColor=q.White(),this.useOnlyMetallicFromMetallicReflectanceTexture=!1,this.ambientColor=new q(0,0,0),this.albedoColor=new q(1,1,1),this.baseWeight=1,this.reflectivityColor=new q(1,1,1),this.reflectionColor=new q(1,1,1),this.emissiveColor=new q(0,0,0),this.microSurface=1,this.useLightmapAsShadowmap=!1,this.useAlphaFromAlbedoTexture=!1,this.forceAlphaTest=!1,this.alphaCutOff=.4,this.useSpecularOverAlpha=!0,this.useMicroSurfaceFromReflectivityMapAlpha=!1,this.useRoughnessFromMetallicTextureAlpha=!0,this.useRoughnessFromMetallicTextureGreen=!1,this.useMetallnessFromMetallicTextureBlue=!1,this.useAmbientOcclusionFromMetallicTextureRed=!1,this.useAmbientInGrayScale=!1,this.useAutoMicroSurfaceFromReflectivityMap=!1,this.useRadianceOverAlpha=!0,this.useObjectSpaceNormalMap=!1,this.useParallax=!1,this.useParallaxOcclusion=!1,this.parallaxScaleBias=.05,this.disableLighting=!1,this.forceIrradianceInFragment=!1,this.maxSimultaneousLights=4,this.invertNormalMapX=!1,this.invertNormalMapY=!1,this.twoSidedLighting=!1,this.useAlphaFresnel=!1,this.useLinearAlphaFresnel=!1,this.environmentBRDFTexture=null,this.forceNormalForward=!1,this.enableSpecularAntiAliasing=!1,this.useHorizonOcclusion=!0,this.useRadianceOcclusion=!0,this.unlit=!1,this.applyDecalMapAfterDetailMap=!1,this._environmentBRDFTexture=Gh(this.getScene())}getClassName(){return"PBRMaterial"}clone(e,t=!0,i=""){const s=le.Clone(()=>new j(e,this.getScene()),this,{cloneTexturesOnlyOnce:t});return s.id=e,s.name=e,this.stencil.copyTo(s.stencil),this._clonePlugins(s,i),s}serialize(){const e=super.serialize();return e.customType="BABYLON.PBRMaterial",e}static Parse(e,t,i){const s=le.Parse(()=>new j(e.name,t),e,t,i);return e.stencil&&s.stencil.parse(e.stencil,t,i),F._ParsePlugins(e,s,t,i),e.clearCoat&&s.clearCoat.parse(e.clearCoat,t,i),e.anisotropy&&s.anisotropy.parse(e.anisotropy,t,i),e.brdf&&s.brdf.parse(e.brdf,t,i),e.sheen&&s.sheen.parse(e.sheen,t,i),e.subSurface&&s.subSurface.parse(e.subSurface,t,i),e.iridescence&&s.iridescence.parse(e.iridescence,t,i),s}}j.PBRMATERIAL_OPAQUE=ve.PBRMATERIAL_OPAQUE;j.PBRMATERIAL_ALPHATEST=ve.PBRMATERIAL_ALPHATEST;j.PBRMATERIAL_ALPHABLEND=ve.PBRMATERIAL_ALPHABLEND;j.PBRMATERIAL_ALPHATESTANDBLEND=ve.PBRMATERIAL_ALPHATESTANDBLEND;j.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=ve.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"directIntensity",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"emissiveIntensity",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"environmentIntensity",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"specularIntensity",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"disableBumpMap",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"albedoTexture",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"baseWeightTexture",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"baseDiffuseRoughnessTexture",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"ambientTexture",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"ambientTextureStrength",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"ambientTextureImpactOnAnalyticalLights",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesAndMiscDirty")],j.prototype,"opacityTexture",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"reflectionTexture",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"emissiveTexture",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"reflectivityTexture",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"metallicTexture",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"metallic",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"roughness",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"metallicF0Factor",void 0);T([At(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"metallicReflectanceColor",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"useOnlyMetallicFromMetallicReflectanceTexture",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"metallicReflectanceTexture",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"reflectanceTexture",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"microSurfaceTexture",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"bumpTexture",void 0);T([Oe(),B("_markAllSubMeshesAsTexturesDirty",null)],j.prototype,"lightmapTexture",void 0);T([At("ambient"),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"ambientColor",void 0);T([At("albedo"),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"albedoColor",void 0);T([R("baseWeight"),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"baseWeight",void 0);T([R("baseDiffuseRoughness"),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"baseDiffuseRoughness",void 0);T([At("reflectivity"),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"reflectivityColor",void 0);T([At("reflection"),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"reflectionColor",void 0);T([At("emissive"),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"emissiveColor",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"microSurface",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"useLightmapAsShadowmap",void 0);T([R(),B("_markAllSubMeshesAsTexturesAndMiscDirty")],j.prototype,"useAlphaFromAlbedoTexture",void 0);T([R(),B("_markAllSubMeshesAsTexturesAndMiscDirty")],j.prototype,"forceAlphaTest",void 0);T([R(),B("_markAllSubMeshesAsTexturesAndMiscDirty")],j.prototype,"alphaCutOff",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"useSpecularOverAlpha",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"useRoughnessFromMetallicTextureAlpha",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"useRoughnessFromMetallicTextureGreen",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"useMetallnessFromMetallicTextureBlue",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"useAmbientInGrayScale",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0);T([R()],j.prototype,"usePhysicalLightFalloff",null);T([R()],j.prototype,"useGLTFLightFalloff",null);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"useRadianceOverAlpha",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"useObjectSpaceNormalMap",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"useParallax",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"useParallaxOcclusion",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"parallaxScaleBias",void 0);T([R(),B("_markAllSubMeshesAsLightsDirty")],j.prototype,"disableLighting",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"forceIrradianceInFragment",void 0);T([R(),B("_markAllSubMeshesAsLightsDirty")],j.prototype,"maxSimultaneousLights",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"invertNormalMapX",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"invertNormalMapY",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"twoSidedLighting",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"useAlphaFresnel",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"useLinearAlphaFresnel",void 0);T([B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"environmentBRDFTexture",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"forceNormalForward",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"enableSpecularAntiAliasing",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"useHorizonOcclusion",void 0);T([R(),B("_markAllSubMeshesAsTexturesDirty")],j.prototype,"useRadianceOcclusion",void 0);T([R(),B("_markAllSubMeshesAsMiscDirty")],j.prototype,"unlit",void 0);T([R(),B("_markAllSubMeshesAsMiscDirty")],j.prototype,"applyDecalMapAfterDetailMap",void 0);nt("BABYLON.PBRMaterial",j);const I_=Object.freeze(Object.defineProperty({__proto__:null,PBRMaterial:j},Symbol.toStringTag,{value:"Module"}));function vs(a,e,t){const i=a.getVertexBuffer(t);if(!i)return null;const s=i.getData();if(!s)return null;let r;return es(s,i.byteStride*e,i.byteStride,i.getSize(),i.type,1,i.normalized,n=>r=n),r}function kd(a,e,t){const i=vs(a,e,b.PositionKind);if(!i||i.some(s=>isNaN(s??Number.NaN)))return!1;if(a.morphTargetManager){const s=e*3;for(let r=0;r<i.length;r++){let n=i[r];for(let o=0;o<a.morphTargetManager.numTargets;o++){const h=a.morphTargetManager.getTarget(o),l=h.influence;if(l!==0){const c=h.getPositions();c&&(n+=(c[s+r]-i[r])*l)}}i[r]=n}}if(t.fromArray(i),a.skeleton){const s=vs(a,e,b.MatricesIndicesKind),r=vs(a,e,b.MatricesWeightsKind);if(s&&r){const n=a.numBoneInfluencers>4,o=n?vs(a,e,b.MatricesIndicesExtraKind):null,h=n?vs(a,e,b.MatricesWeightsExtraKind):null,l=a.skeleton.getTransformMatrices(a),c=v.Matrix[0],u=v.Matrix[1];c.reset();for(let f=0;f<r.length;f++){const d=r[f];d>0&&(P.FromFloat32ArrayToRefScaled(l,Math.floor(s[f]*16),d,u),c.addToSelf(u))}if(o&&h)for(let f=0;f<h.length;f++){const d=h[f];d>0&&(P.FromFloat32ArrayToRefScaled(l,Math.floor(o[f]*16),d,u),c.addToSelf(u))}_.TransformCoordinatesFromFloatsToRef(i[0],i[1],i[2],c,t)}}return!0}function Gd(a,e,t,i){t.set(0,0,0);for(let s=0;s<3;s++){const r=e.pointIndex[s];if(!kd(a,r,v.Vector3[s]))return!1;v.Vector3[s].scaleAndAddToRef(e.barycentric[s],t)}if(_.TransformCoordinatesToRef(t,a.getWorldMatrix(),t),i){const s=v.Vector3[0],r=v.Vector3[1],n=v.Vector3[2],o=v.Vector3[3],h=v.Vector3[4];o.copyFrom(r),o.subtractInPlace(s),h.copyFrom(n),h.subtractInPlace(s),o.normalize(),h.normalize(),_.CrossToRef(o,h,i),a.material&&a.material.sideOrientation===(a.getScene().useRightHandedSystem?0:1)&&i.scaleInPlace(-1),_.TransformNormalToRef(i,a.getWorldMatrix(),i),i.normalize()}return!0}ne._GroundMeshParser=(a,e)=>ar.Parse(a,e);class ar extends ne{constructor(e,t){super(e,t),this.generateOctree=!1}getClassName(){return"GroundMesh"}get subdivisions(){return Math.min(this._subdivisionsX,this._subdivisionsY)}get subdivisionsX(){return this._subdivisionsX}get subdivisionsY(){return this._subdivisionsY}optimize(e,t=32){this._subdivisionsX=e,this._subdivisionsY=e,this.subdivide(e);const i=this;i.createOrUpdateSubmeshesOctree&&i.createOrUpdateSubmeshesOctree(t)}getHeightAtCoordinates(e,t){const i=this.getWorldMatrix(),s=v.Matrix[5];i.invertToRef(s);const r=v.Vector3[8];if(_.TransformCoordinatesFromFloatsToRef(e,0,t,s,r),e=r.x,t=r.z,e<this._minX||e>=this._maxX||t<=this._minZ||t>this._maxZ)return this.position.y;(!this._heightQuads||this._heightQuads.length==0)&&(this._initHeightQuads(),this._computeHeightQuads());const n=this._getFacetAt(e,t),o=-(n.x*e+n.z*t+n.w)/n.y;return _.TransformCoordinatesFromFloatsToRef(0,o,0,i,r),r.y}getNormalAtCoordinates(e,t){const i=new _(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,i),i}getNormalAtCoordinatesToRef(e,t,i){const s=this.getWorldMatrix(),r=v.Matrix[5];s.invertToRef(r);const n=v.Vector3[8];if(_.TransformCoordinatesFromFloatsToRef(e,0,t,r,n),e=n.x,t=n.z,e<this._minX||e>this._maxX||t<this._minZ||t>this._maxZ)return this;(!this._heightQuads||this._heightQuads.length==0)&&(this._initHeightQuads(),this._computeHeightQuads());const o=this._getFacetAt(e,t);return _.TransformNormalFromFloatsToRef(o.x,o.y,o.z,s,i),this}updateCoordinateHeights(){return(!this._heightQuads||this._heightQuads.length==0)&&this._initHeightQuads(),this._computeHeightQuads(),this}_getFacetAt(e,t){const i=Math.floor((e+this._maxX)*this._subdivisionsX/this._width),s=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),r=this._heightQuads[s*this._subdivisionsX+i];let n;return t<r.slope.x*e+r.slope.y?n=r.facet1:n=r.facet2,n}_initHeightQuads(){const e=this._subdivisionsX,t=this._subdivisionsY;this._heightQuads=[];for(let i=0;i<t;i++)for(let s=0;s<e;s++){const r={slope:Q.Zero(),facet1:new ge(0,0,0,0),facet2:new ge(0,0,0,0)};this._heightQuads[i*e+s]=r}return this}_computeHeightQuads(){const e=this.getVerticesData(b.PositionKind);if(!e)return this;const t=v.Vector3[3],i=v.Vector3[2],s=v.Vector3[1],r=v.Vector3[0],n=v.Vector3[4],o=v.Vector3[5],h=v.Vector3[6],l=v.Vector3[7],c=v.Vector3[8];let u=0,f=0,d=0,g=0,p=0,m=0,A=0;const E=this._subdivisionsX,I=this._subdivisionsY;for(let M=0;M<I;M++)for(let C=0;C<E;C++){u=C*3,f=M*(E+1)*3,d=(M+1)*(E+1)*3,t.x=e[f+u],t.y=e[f+u+1],t.z=e[f+u+2],i.x=e[f+u+3],i.y=e[f+u+4],i.z=e[f+u+5],s.x=e[d+u],s.y=e[d+u+1],s.z=e[d+u+2],r.x=e[d+u+3],r.y=e[d+u+4],r.z=e[d+u+5],g=(r.z-t.z)/(r.x-t.x),p=t.z-g*t.x,i.subtractToRef(t,n),s.subtractToRef(t,o),r.subtractToRef(t,h),_.CrossToRef(h,o,l),_.CrossToRef(n,h,c),l.normalize(),c.normalize(),m=-(l.x*t.x+l.y*t.y+l.z*t.z),A=-(c.x*i.x+c.y*i.y+c.z*i.z);const x=this._heightQuads[M*E+C];x.slope.copyFromFloats(g,p),x.facet1.copyFromFloats(l.x,l.y,l.z,m),x.facet2.copyFromFloats(c.x,c.y,c.z,A)}return this}serialize(e){super.serialize(e),e.subdivisionsX=this._subdivisionsX,e.subdivisionsY=this._subdivisionsY,e.minX=this._minX,e.maxX=this._maxX,e.minZ=this._minZ,e.maxZ=this._maxZ,e.width=this._width,e.height=this._height}static Parse(e,t){const i=new ar(e.name,t);return i._subdivisionsX=e.subdivisionsX||1,i._subdivisionsY=e.subdivisionsY||1,i._minX=e.minX,i._maxX=e.maxX,i._minZ=e.minZ,i._maxZ=e.maxZ,i._width=e.width,i._height=e.height,i}}function Hh(a){const e=[],t=[],i=[],s=[];let r,n;const o=a.width||a.size||1,h=a.height||a.size||1,l=(a.subdivisionsX||a.subdivisions||1)|0,c=(a.subdivisionsY||a.subdivisions||1)|0;for(r=0;r<=c;r++)for(n=0;n<=l;n++){const f=new _(n*o/l-o/2,0,(c-r)*h/c-h/2),d=new _(0,1,0);t.push(f.x,f.y,f.z),i.push(d.x,d.y,d.z),s.push(n/l,1-r/c)}for(r=0;r<c;r++)for(n=0;n<l;n++)e.push(n+1+(r+1)*(l+1)),e.push(n+1+r*(l+1)),e.push(n+r*(l+1)),e.push(n+(r+1)*(l+1)),e.push(n+1+(r+1)*(l+1)),e.push(n+r*(l+1));const u=new $;return u.indices=e,u.positions=t,u.normals=i,u.uvs=s,u}function Vh(a){const e=a.xmin!==void 0&&a.xmin!==null?a.xmin:-1,t=a.zmin!==void 0&&a.zmin!==null?a.zmin:-1,i=a.xmax!==void 0&&a.xmax!==null?a.xmax:1,s=a.zmax!==void 0&&a.zmax!==null?a.zmax:1,r=a.subdivisions||{w:1,h:1},n=a.precision||{w:1,h:1},o=[],h=[],l=[],c=[];let u,f,d,g;r.h=r.h<1?1:r.h,r.w=r.w<1?1:r.w,n.w=n.w<1?1:n.w,n.h=n.h<1?1:n.h;const p={w:(i-e)/r.w,h:(s-t)/r.h};function m(E,I,M,C){const x=h.length/3,S=n.w+1;for(u=0;u<n.h;u++)for(f=0;f<n.w;f++){const D=[x+f+u*S,x+(f+1)+u*S,x+(f+1)+(u+1)*S,x+f+(u+1)*S];o.push(D[1]),o.push(D[2]),o.push(D[3]),o.push(D[0]),o.push(D[1]),o.push(D[3])}const L=_.Zero(),N=new _(0,1,0);for(u=0;u<=n.h;u++)for(L.z=u*(C-I)/n.h+I,f=0;f<=n.w;f++)L.x=f*(M-E)/n.w+E,L.y=0,h.push(L.x,L.y,L.z),l.push(N.x,N.y,N.z),c.push(f/n.w,u/n.h)}for(d=0;d<r.h;d++)for(g=0;g<r.w;g++)m(e+g*p.w,t+d*p.h,e+(g+1)*p.w,t+(d+1)*p.h);const A=new $;return A.indices=o,A.positions=h,A.normals=l,A.uvs=c,A}function zh(a){const e=[],t=[],i=[],s=[];let r,n;const o=a.colorFilter||new q(.3,.59,.11),h=a.alphaFilter||0;let l=!1;if(a.minHeight>a.maxHeight){l=!0;const u=a.maxHeight;a.maxHeight=a.minHeight,a.minHeight=u}for(r=0;r<=a.subdivisions;r++)for(n=0;n<=a.subdivisions;n++){const u=new _(n*a.width/a.subdivisions-a.width/2,0,(a.subdivisions-r)*a.height/a.subdivisions-a.height/2),f=(u.x+a.width/2)/a.width*(a.bufferWidth-1)|0,d=(1-(u.z+a.height/2)/a.height)*(a.bufferHeight-1)|0,g=(f+d*a.bufferWidth)*4;let p=a.buffer[g]/255,m=a.buffer[g+1]/255,A=a.buffer[g+2]/255;const E=a.buffer[g+3]/255;l&&(p=1-p,m=1-m,A=1-A);const I=p*o.r+m*o.g+A*o.b;E>=h?u.y=a.minHeight+(a.maxHeight-a.minHeight)*I:u.y=a.minHeight-Me,a.heightBuffer&&(a.heightBuffer[r*(a.subdivisions+1)+n]=u.y),t.push(u.x,u.y,u.z),i.push(0,0,0),s.push(n/a.subdivisions,1-r/a.subdivisions)}for(r=0;r<a.subdivisions;r++)for(n=0;n<a.subdivisions;n++){const u=n+1+(r+1)*(a.subdivisions+1),f=n+1+r*(a.subdivisions+1),d=n+r*(a.subdivisions+1),g=n+(r+1)*(a.subdivisions+1),p=t[u*3+1]>=a.minHeight,m=t[f*3+1]>=a.minHeight,A=t[d*3+1]>=a.minHeight;p&&m&&A&&(e.push(u),e.push(f),e.push(d)),t[g*3+1]>=a.minHeight&&p&&A&&(e.push(g),e.push(u),e.push(d))}$.ComputeNormals(t,e,i);const c=new $;return c.indices=e,c.positions=t,c.normals=i,c.uvs=s,c}function Hd(a,e={},t){const i=new ar(a,t);return i._setReady(!1),i._subdivisionsX=e.subdivisionsX||e.subdivisions||1,i._subdivisionsY=e.subdivisionsY||e.subdivisions||1,i._width=e.width||1,i._height=e.height||1,i._maxX=i._width/2,i._maxZ=i._height/2,i._minX=-i._maxX,i._minZ=-i._maxZ,Hh(e).applyToMesh(i,e.updatable),i._setReady(!0),i}function Vd(a,e,t=null){const i=new ne(a,t);return Vh(e).applyToMesh(i,e.updatable),i}function zd(a,e,t={},i=null){const s=t.width||10,r=t.height||10,n=t.subdivisions||1,o=t.minHeight||0,h=t.maxHeight||1,l=t.colorFilter||new q(.3,.59,.11),c=t.alphaFilter||0,u=t.updatable,f=t.onReady;i=i||Te.LastCreatedScene;const d=new ar(a,i);d._subdivisionsX=n,d._subdivisionsY=n,d._width=s,d._height=r,d._maxX=d._width/2,d._maxZ=d._height/2,d._minX=-d._maxX,d._minZ=-d._maxZ,d._setReady(!1);let g;t.passHeightBufferInCallback&&(g=new Float32Array((n+1)*(n+1)));const p=(m,A,E)=>{zh({width:s,height:r,subdivisions:n,minHeight:o,maxHeight:h,colorFilter:l,buffer:m,bufferWidth:A,bufferHeight:E,alphaFilter:c,heightBuffer:g}).applyToMesh(d,u),f&&f(d,g),d._setReady(!0)};if(typeof e=="string"){const m=A=>{const E=A.width,I=A.height;if(i.isDisposed)return;const M=i?.getEngine().resizeImageBitmap(A,E,I);p(M,E,I)};se.LoadImage(e,m,t.onError?t.onError:()=>{},i.offlineProvider)}else p(e.data,e.width,e.height);return d}$.CreateGround=Hh;$.CreateTiledGround=Vh;$.CreateGroundFromHeightMap=zh;ne.CreateGround=(a,e,t,i,s,r)=>Hd(a,{width:e,height:t,subdivisions:i,updatable:r},s);ne.CreateTiledGround=(a,e,t,i,s,r,n,o,h)=>Vd(a,{xmin:e,zmin:t,xmax:i,zmax:s,subdivisions:r,precision:n,updatable:h},o);ne.CreateGroundFromHeightMap=(a,e,t,i,s,r,n,o,h,l,c)=>zd(a,e,{width:t,height:i,subdivisions:s,minHeight:r,maxHeight:n,updatable:h,onReady:l,alphaFilter:c},o);function Wh(a){let t=[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23];const i=[0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0],s=[];let r=[];const n=a.width||a.size||1,o=a.height||a.size||1,h=a.depth||a.size||1,l=a.wrap||!1;let c=a.topBaseAt===void 0?1:a.topBaseAt,u=a.bottomBaseAt===void 0?0:a.bottomBaseAt;c=(c+4)%4,u=(u+4)%4;const f=[2,0,3,1],d=[2,0,1,3];let g=f[c],p=d[u],m=[1,-1,1,-1,-1,1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,1];if(l){t=[2,3,0,2,0,1,4,5,6,4,6,7,9,10,11,9,11,8,12,14,15,12,13,14],m=[-1,1,1,1,1,1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,1,1,1,-1,1,-1,-1,1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,-1];let S=[[1,1,1],[-1,1,1],[-1,1,-1],[1,1,-1]],L=[[-1,-1,1],[1,-1,1],[1,-1,-1],[-1,-1,-1]];const N=[17,18,19,16],D=[22,23,20,21];for(;g>0;)S.unshift(S.pop()),N.unshift(N.pop()),g--;for(;p>0;)L.unshift(L.pop()),D.unshift(D.pop()),p--;S=S.flat(),L=L.flat(),m=m.concat(S).concat(L),t.push(N[0],N[2],N[3],N[0],N[1],N[2]),t.push(D[0],D[2],D[3],D[0],D[1],D[2])}const A=[n/2,o/2,h/2];r=m.reduce((S,L,N)=>S.concat(L*A[N%3]),[]);const E=a.sideOrientation===0?0:a.sideOrientation||$.DEFAULTSIDE,I=a.faceUV||new Array(6),M=a.faceColors,C=[];for(let S=0;S<6;S++)I[S]===void 0&&(I[S]=new ge(0,0,1,1)),M&&M[S]===void 0&&(M[S]=new fe(1,1,1,1));for(let S=0;S<6;S++)if(s.push(I[S].z,I[S].w),s.push(I[S].x,I[S].w),s.push(I[S].x,I[S].y),s.push(I[S].z,I[S].y),M)for(let L=0;L<4;L++)C.push(M[S].r,M[S].g,M[S].b,M[S].a);$._ComputeSides(E,r,t,i,s,a.frontUVs,a.backUVs);const x=new $;if(x.indices=t,x.positions=r,x.normals=i,x.uvs=s,M){const S=E===$.DOUBLESIDE?C.concat(C):C;x.colors=S}return x}function Xh(a,e={},t=null){const i=new ne(a,t);return e.sideOrientation=ne._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,Wh(e).applyToMesh(i,e.updatable),i}$.CreateBox=Wh;ne.CreateBox=(a,e,t=null,i,s)=>Xh(a,{size:e,sideOrientation:s,updatable:i},t);function Va(a){const e=a.minimum.x,t=a.minimum.y,i=a.minimum.z,s=a.maximum.x,r=a.maximum.y,n=a.maximum.z;return[new _(e,t,i),new _(s,r,n),new _(s,t,i),new _(e,r,i),new _(e,t,n),new _(s,r,i),new _(e,r,n),new _(s,t,n)]}function Wd(a,e=null,t=1/6){const i=v.Vector3[0],s=new Map,r=new Map,n=a.reduce((d,g)=>Math.max(d,g.getTotalVertices()),0),o=Array.from({length:n},()=>new _),h=Array.from({length:n},()=>new _);for(const d of a){const g=d.getVerticesData(b.PositionKind);if(!g)continue;const p=d.getTotalVertices();o.length=Math.max(o.length,p),h.length=Math.max(o.length,p);for(let M=0,C=0;M<p;M++,C+=3)i.set(g[C],g[C+1],g[C+2]),o[M].copyFrom(i),h[M].copyFrom(i);const m=d.morphTargetManager;if(m)for(let M=0;M<m.numTargets;++M){const x=m.getTarget(M).getPositions();if(x)for(let S=0,L=0;S<p;S++,L+=3)i.set(x[L],x[L+1],x[L+2]),o[S].minimizeInPlace(i),h[S].maximizeInPlace(i)}const A=d.skeleton,E=A?d.getVerticesData(b.MatricesWeightsKind):null,I=A?d.getVerticesData(b.MatricesIndicesKind):null;if(E&&I){const M=d.numBoneInfluencers>4,C=M?d.getVerticesData(b.MatricesWeightsExtraKind):null,x=M?d.getVerticesData(b.MatricesIndicesExtraKind):null,S=r.get(d.uniqueId)||new Map;r.set(d.uniqueId,S);const L=(N,D,Re,pe)=>{for(let ce=D;ce<D+4;ce++)if(Re[ce]>0){const oe=pe[ce],Ye=S.get(oe);Ye?(Ye.minimum.minimizeInPlace(o[N]),Ye.maximum.maximizeInPlace(h[N])):S.set(oe,{minimum:o[N].clone(),maximum:h[N].clone()})}};for(let N=0,D=0;N<p;N++,D+=4)L(N,D,E,I),C&&x&&L(N,D,C,x)}else{const M=s.get(d.uniqueId)||{minimum:new _().setAll(Number.POSITIVE_INFINITY),maximum:new _().setAll(Number.NEGATIVE_INFINITY)};s.set(d.uniqueId,M);for(let C=0;C<p;C++)M.minimum.minimizeInPlace(o[C]),M.maximum.maximizeInPlace(h[C])}}const l=new Map,c=new Map;for(const d of a){const g=s.get(d.uniqueId);if(g)l.set(d.uniqueId,Va(g));else{const p=r.get(d.uniqueId);if(p){const m=d.skeleton.bones,A=new Map;c.set(d.uniqueId,A),p.forEach((E,I)=>{const M=Va(E),C=m[I].getAbsoluteInverseBindMatrix();for(const x of M)_.TransformCoordinatesToRef(x,C,x);A.set(I,M)})}}}const u=Array.from({length:a.length},()=>({minimum:new _().setAll(Number.POSITIVE_INFINITY),maximum:new _().setAll(Number.NEGATIVE_INFINITY)})),f=()=>{for(let d=0;d<a.length;d++){const g=a[d];if(!g.getVerticesData(b.PositionKind))continue;const m=g.computeWorldMatrix(!0),A=g.skeleton;if(A){A.prepare(!0);const E=A.bones;c.get(g.uniqueId).forEach((M,C)=>{for(const x of M){const S=E[C].getFinalMatrix().multiplyToRef(m,v.Matrix[0]);_.TransformCoordinatesToRef(x,S,i),u[d].minimum.minimizeInPlace(i),u[d].maximum.maximizeInPlace(i)}})}else for(const E of l.get(g.uniqueId))_.TransformCoordinatesToRef(E,m,i),u[d].minimum.minimizeInPlace(i),u[d].maximum.maximizeInPlace(i)}};if(e&&e.isStarted){const d=e.getCurrentFrame(),g=t/e.getLength(0,1);for(let p=e.from;p<=e.to;p+=g)e.goToFrame(p),f();e.goToFrame(d)}else f();return u}function Xd(a){const e=[b.UVKind,b.UV2Kind,b.UV3Kind,b.UV4Kind,b.UV5Kind,b.UV6Kind];for(const t of a){const i=new Set(e),s=t.material?.getActiveTextures();if(s)for(const r of s)i.delete(e[r.coordinatesIndex]);i.forEach(r=>{t.isVerticesDataPresent(r)&&t.removeVerticesData(r)})}}class Vn{get resolve(){return this._resolve}get reject(){return this._reject}constructor(){this.promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}}class Rr{constructor(){this._currentOperation=Promise.resolve()}lockAsync(e,t){t?.throwIfAborted();const i=t?()=>(t.throwIfAborted(),e()):e,s=this._currentOperation.then(i);return this._currentOperation=new Promise(r=>{s.then(()=>r(),r)}),s}static async LockAsync(e,t,i){if(i?.throwIfAborted(),t.length===0)return await e();const s=new Vn;let r=0;for(const n of t)n.lockAsync(async()=>(r++,r===t.length&&s.resolve(await e()),await s.promise),i).catch(o=>s.reject(o));return await s.promise}}function Kh(...a){const e=t=>!!t&&typeof t=="object";return a.reduce((t,i)=>{const s=Object.keys(i);for(const r of s){const n=t[r],o=i[r];Array.isArray(n)&&Array.isArray(o)?t[r]=n.concat(...o):e(n)&&e(o)?t[r]=Kh(n,o):t[r]=o}return t},{})}class Kd{constructor(e){this._factory=e}get value(){return this._factory&&(this._value=this._factory(),this._factory=void 0),this._value}}class Mi{getDescription(){return""}apply(e,t){return!0}constructor(e=0){this.priority=e}}class nn extends Mi{getDescription(){return"Reducing render target texture size to "+this.maximumSize}constructor(e=0,t=1024,i=.5){super(e),this.priority=e,this.maximumSize=t,this.step=i}apply(e,t){let i=!0;for(let s=0;s<e.textures.length;s++){const r=e.textures[s];if(!r.canRescale||r.getContext)continue;const n=r.getSize();Math.max(n.width,n.height)>this.maximumSize&&(r.scale(this.step),i=!1)}return i}}class Sn extends Mi{getDescription(){return"Setting hardware scaling level to "+this._currentScale}constructor(e=0,t=2,i=.25){super(e),this.priority=e,this.maximumScale=t,this.step=i,this._currentScale=-1,this._directionOffset=1}apply(e,t){return this._currentScale===-1&&(this._currentScale=e.getEngine().getHardwareScalingLevel(),this._currentScale>this.maximumScale&&(this._directionOffset=-1)),this._currentScale+=this._directionOffset*this.step,this._currentScale=Math.min(this.maximumScale,this._currentScale),e.getEngine().setHardwareScalingLevel(this._currentScale),this._directionOffset===1?this._currentScale>=this.maximumScale:this._currentScale<=this.maximumScale}}class an extends Mi{getDescription(){return"Turning shadows on/off"}apply(e,t){return e.shadowsEnabled=t.isInImprovementMode,!0}}class on extends Mi{getDescription(){return"Turning post-processes on/off"}apply(e,t){return e.postProcessesEnabled=t.isInImprovementMode,!0}}class hn extends Mi{getDescription(){return"Turning lens flares on/off"}apply(e,t){return e.lensFlaresEnabled=t.isInImprovementMode,!0}}class Yd extends Mi{getDescription(){return this.onGetDescription?this.onGetDescription():"Running user defined callback"}apply(e,t){return this.onApply?this.onApply(e,t):!0}}class ln extends Mi{getDescription(){return"Turning particles on/off"}apply(e,t){return e.particlesEnabled=t.isInImprovementMode,!0}}class za extends Mi{getDescription(){return"Turning render targets off"}apply(e,t){return e.renderTargetsEnabled=t.isInImprovementMode,!0}}class Di extends Mi{constructor(){super(...arguments),this._canBeMerged=e=>{if(!(e instanceof ne))return!1;const t=e;return!(t.isDisposed()||!t.isVisible||!t.isEnabled()||t.instances.length>0||t.skeleton||t.hasLODLevels||t.getTotalVertices()===0)}}static get UpdateSelectionTree(){return Di._UpdateSelectionTree}static set UpdateSelectionTree(e){Di._UpdateSelectionTree=e}getDescription(){return"Merging similar meshes together"}apply(e,t,i){const s=e.meshes.slice(0);let r=s.length;for(let o=0;o<r;o++){const h=[],l=s[o];if(this._canBeMerged(l)){h.push(l);for(let c=o+1;c<r;c++){const u=s[c];this._canBeMerged(u)&&u.material===l.material&&u.checkCollisions===l.checkCollisions&&(h.push(u),r--,s.splice(c,1),c--)}h.length<2||ne.MergeMeshes(h,void 0,!0)}}const n=e;return n.createOrUpdateSelectionOctree&&(i!=null?i&&n.createOrUpdateSelectionOctree():Di.UpdateSelectionTree&&n.createOrUpdateSelectionOctree()),!0}}Di._UpdateSelectionTree=!1;class Ji{constructor(e=60,t=2e3){this.targetFrameRate=e,this.trackerDuration=t,this.optimizations=[]}addOptimization(e){return this.optimizations.push(e),this}addCustomOptimization(e,t,i=0){const s=new Yd(i);return s.onApply=e,s.onGetDescription=t,this.optimizations.push(s),this}static LowDegradationAllowed(e){const t=new Ji(e);let i=0;return t.addOptimization(new Di(i)),t.addOptimization(new an(i)),t.addOptimization(new hn(i)),i++,t.addOptimization(new on(i)),t.addOptimization(new ln(i)),i++,t.addOptimization(new nn(i,1024)),t}static ModerateDegradationAllowed(e){const t=new Ji(e);let i=0;return t.addOptimization(new Di(i)),t.addOptimization(new an(i)),t.addOptimization(new hn(i)),i++,t.addOptimization(new on(i)),t.addOptimization(new ln(i)),i++,t.addOptimization(new nn(i,512)),i++,t.addOptimization(new za(i)),i++,t.addOptimization(new Sn(i,2)),t}static HighDegradationAllowed(e){const t=new Ji(e);let i=0;return t.addOptimization(new Di(i)),t.addOptimization(new an(i)),t.addOptimization(new hn(i)),i++,t.addOptimization(new on(i)),t.addOptimization(new ln(i)),i++,t.addOptimization(new nn(i,256)),i++,t.addOptimization(new za(i)),i++,t.addOptimization(new Sn(i,4)),t}}class zn{get isInImprovementMode(){return this._improvementMode}set isInImprovementMode(e){this._improvementMode=e}get currentPriorityLevel(){return this._currentPriorityLevel}get currentFrameRate(){return this._currentFrameRate}get targetFrameRate(){return this._targetFrameRate}set targetFrameRate(e){this._targetFrameRate=e}get trackerDuration(){return this._trackerDuration}set trackerDuration(e){this._trackerDuration=e}get optimizations(){return this._options.optimizations}constructor(e,t,i=!0,s=!1){if(this._isRunning=!1,this._currentPriorityLevel=0,this._targetFrameRate=60,this._trackerDuration=2e3,this._currentFrameRate=0,this._improvementMode=!1,this.onSuccessObservable=new O,this.onNewOptimizationAppliedObservable=new O,this.onFailureObservable=new O,t?this._options=t:this._options=new Ji,this._options.targetFrameRate&&(this._targetFrameRate=this._options.targetFrameRate),this._options.trackerDuration&&(this._trackerDuration=this._options.trackerDuration),i){let r=0;for(const n of this._options.optimizations)n.priority=r++}this._improvementMode=s,this._scene=e||Te.LastCreatedScene,this._sceneDisposeObserver=this._scene.onDisposeObservable.add(()=>{this._sceneDisposeObserver=null,this.dispose()})}stop(){this._isRunning=!1}reset(){this._currentPriorityLevel=0}start(){this._isRunning||(this._isRunning=!0,this._scene.executeWhenReady(()=>{setTimeout(()=>{this._checkCurrentState()},this._trackerDuration)}))}_checkCurrentState(){if(!this._isRunning)return;const e=this._scene,t=this._options;if(this._currentFrameRate=Math.round(e.getEngine().getFps()),this._improvementMode&&this._currentFrameRate<=this._targetFrameRate||!this._improvementMode&&this._currentFrameRate>=this._targetFrameRate){this._isRunning=!1,this.onSuccessObservable.notifyObservers(this);return}let i=!0,s=!0;for(let r=0;r<t.optimizations.length;
56r++){const n=t.optimizations[r];n.priority===this._currentPriorityLevel&&(s=!1,i=i&&n.apply(e,this),this.onNewOptimizationAppliedObservable.notifyObservers(n))}if(s){this._isRunning=!1,this.onFailureObservable.notifyObservers(this);return}i&&this._currentPriorityLevel++,e.executeWhenReady(()=>{setTimeout(()=>{this._checkCurrentState()},this._trackerDuration)})}dispose(){this.stop(),this.onSuccessObservable.clear(),this.onFailureObservable.clear(),this.onNewOptimizationAppliedObservable.clear(),this._sceneDisposeObserver&&this._scene.onDisposeObservable.remove(this._sceneDisposeObserver)}static OptimizeAsync(e,t,i,s){const r=new zn(e,t||Ji.ModerateDegradationAllowed(),!1);return i&&r.onSuccessObservable.add(()=>{i()}),s&&r.onFailureObservable.add(()=>{s()}),r.start(),r}}class Yh{constructor(e,t,i){this.name=e,this._parentTask=t,this._context=i,this.disabled=!1}setInitializeFunc(e){this._initFunc=e}setExecuteFunc(e){this._executeFunc=e}_execute(){this.disabled||this._executeFunc(this._context)}_initialize(){this._initFunc?.(this._context)}_isValid(){return this._executeFunc!==void 0?null:"Execute function is not set (call setExecuteFunc to set it)"}_dispose(){}}class Wa extends Yh{static IsObjectListPass(e){return e.setObjectList!==void 0}get objectList(){return this._objectList}setObjectList(e){this._objectList=e}constructor(e,t,i,s){super(e,t,i),this._engine=s}_isValid(){const e=super._isValid();return e||(this._objectList!==void 0?null:"Object list is not set (call setObjectList to set it)")}}class Mn extends Yh{static IsRenderPass(e){return e.setRenderTarget!==void 0}get renderTarget(){return this._renderTarget}get renderTargetDepth(){return this._renderTargetDepth}get frameGraphRenderTarget(){return this._frameGraphRenderTarget}constructor(e,t,i,s){super(e,t,i),this._dependencies=new Set,this.depthReadOnly=!1,this.stencilReadOnly=!1,this._engine=s}setRenderTarget(e){this._renderTarget=e}setRenderTargetDepth(e){this._renderTargetDepth=e}addDependencies(e){if(e!==void 0)if(Array.isArray(e))for(const t of e)this._dependencies.add(t);else this._dependencies.add(e)}collectDependencies(e){const t=this._dependencies.keys();for(let i=t.next();i.done!==!0;i=t.next())e.add(i.value);if(this._renderTarget!==void 0)if(Array.isArray(this._renderTarget))for(const i of this._renderTarget)i!==void 0&&e.add(i);else e.add(this._renderTarget);this._renderTargetDepth!==void 0&&e.add(this._renderTargetDepth)}setOutputLayerAndFaceIndices(e){const t=this.frameGraphRenderTarget.renderTargetWrapper;if(t)for(const i of e)t.setLayerAndFaceIndex(i.targetIndex,i.layerIndex,i.faceIndex)}_initialize(){this._frameGraphRenderTarget=this._context.createRenderTarget(this.name,this._renderTarget,this._renderTargetDepth,this.depthReadOnly,this.stencilReadOnly),super._initialize()}_execute(){const e=this._context.enableDebugMarkers;this._context.enableDebugMarkers=!this._parentTask._disableDebugMarkers,this._context.bindRenderTarget(this._frameGraphRenderTarget),super._execute(),this._context.restoreDefaultFramebuffer(),this._context.enableDebugMarkers=e}_isValid(){const e=super._isValid();return e||(this._renderTarget!==void 0||this.renderTargetDepth!==void 0?null:"Render target and render target depth cannot both be undefined.")}_dispose(){this._frameGraphRenderTarget?.dispose()}}class or{get name(){return this._name}set name(e){this._name=e}get disabled(){return this._disabled}set disabled(e){this._disabled=e}get passes(){return this._passes}get passesDisabled(){return this._passesDisabled}getClassName(){return"FrameGraphTask"}initAsync(){return Promise.resolve()}isReady(){return!0}dispose(){this._reset(),this.onTexturesAllocatedObservable.clear(),this.onBeforeTaskExecute.clear(),this.onAfterTaskExecute.clear()}constructor(e,t){this._passes=[],this._passesDisabled=[],this._disabled=!1,this._disableDebugMarkers=!1,this.onTexturesAllocatedObservable=new O,this.onBeforeTaskExecute=new O,this.onAfterTaskExecute=new O,this.name=e,this._frameGraph=t,this._reset()}_reset(){for(const e of this._passes)e._dispose();for(const e of this._passesDisabled)e._dispose();this._passes.length=0,this._passesDisabled.length=0}_addPass(e,t){t?this._passesDisabled.push(e):this._passes.push(e)}_checkTask(){let e=null,t=null,i;for(const h of this._passes){const l=h._isValid();if(l)throw new Error(`Pass "${h.name}
56" is not valid. ${l}`);if(Mn.IsRenderPass(h)){const c=Array.isArray(h.renderTarget)?h.renderTarget:[h.renderTarget];e=[];for(const u of c)u!==void 0&&e.push(this._frameGraph.textureManager.getTextureFromHandle(u));t=h.renderTargetDepth!==void 0?this._frameGraph.textureManager.getTextureFromHandle(h.renderTargetDepth):null}else Wa.IsObjectListPass(h)&&(i=h.objectList)}let s=null,r=[],n=null,o;for(const h of this._passesDisabled){const l=h._isValid();if(l)throw new Error(`Pass "${h.name}" is not valid. ${l}`);if(Mn.IsRenderPass(h)){const c=Array.isArray(h.renderTarget)?h.renderTarget:[h.renderTarget];s=[];for(const u of c)u!==void 0&&s.push(this._frameGraph.textureManager.getTextureFromHandle(u));r=c,n=h.renderTargetDepth!==void 0?this._frameGraph.textureManager.getTextureFromHandle(h.renderTargetDepth):null}else Wa.IsObjectListPass(h)&&(o=h.objectList)}if(this._passesDisabled.length>0){if(!this._checkSameRenderTarget(e,s)){let h=!0;for(const l of r)if(l!==void 0&&!this._frameGraph.textureManager.isHistoryTexture(l)){h=!1;break}if(!h)throw new Error(`The output texture of the task "${this.name}" is different when it is enabled or disabled.`)}if(t!==n&&n!==null)throw new Error(`The output depth texture of the task "${this.name}" is different when it is enabled or disabled.`);if(i!==o&&o!==null)throw new Error(`The output object list of the task "${this.name}" is different when it is enabled or disabled.`)}}_execute(){const e=this._disabled&&this._passesDisabled.length>0?this._passesDisabled:this._passes;this.onBeforeTaskExecute.notifyObservers(this),this._disableDebugMarkers||this._frameGraph.engine._debugPushGroup?.(`${this.getClassName()} (${this.name})`);for(const t of e)t._execute();this._disableDebugMarkers||this._frameGraph.engine._debugPopGroup?.(),this.onAfterTaskExecute.notifyObservers(this)}_initializePasses(){this._disableDebugMarkers||this._frameGraph.engine._debugPushGroup?.(`${this.getClassName()} (${this.name})`);for(const e of this._passes)e._initialize();for(const e of this._passesDisabled)e._initialize();this._disableDebugMarkers||this._frameGraph.engine._debugPopGroup?.()}_checkSameRenderTarget(e,t){if(e===null||t===null)return e===t;if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}}const Ut=0,ni=1;class qh extends or{constructor(){super(...arguments),this._layerAndFaceIndicesUpdated=!1}setOutputLayerAndFaceIndices(e){this._outputLayerAndFaceIndices=e,this._layerAndFaceIndicesUpdated=e.length>0}_updateLayerAndFaceIndices(e){this._layerAndFaceIndicesUpdated&&(e.setOutputLayerAndFaceIndices(this._outputLayerAndFaceIndices),this._layerAndFaceIndicesUpdated=!1)}}he.prototype.restoreSingleAttachment=function(){const a=this._gl;this.bindAttachments([a.BACK])};he.prototype.restoreSingleAttachmentForRenderTarget=function(){const a=this._gl;this.bindAttachments([a.COLOR_ATTACHMENT0])};he.prototype.buildTextureLayout=function(a,e=!1){const t=this._gl,i=[];if(e)i.push(t.BACK);else for(let s=0;s<a.length;s++)a[s]?i.push(t["COLOR_ATTACHMENT"+s]):i.push(t.NONE);return i};he.prototype.bindAttachments=function(a){this._gl.drawBuffers(a)};he.prototype.unBindMultiColorAttachmentFramebuffer=function(a,e=!1,t){this._currentRenderTarget=null,a.disableAutomaticMSAAResolve||this.resolveMultiFramebuffer(a),e||this.generateMipMapsMultiFramebuffer(a),t&&(a._MSAAFramebuffer&&this._bindUnboundFramebuffer(a._framebuffer),t()),this._bindUnboundFramebuffer(null)};he.prototype.createMultipleRenderTarget=function(a,e,t=!0){let i=!1,s=!0,r=!1,n=!1,o,h=1,l=1;const c=0,u=3,f=!1,d=5,g=3553;let p=[],m=[],A=[],E=[],I=[],M=[],C=[],x=[],S=[],L=!1;const N=this._createHardwareRenderTargetWrapper(!0,!1,a);e!==void 0&&(i=e.generateMipMaps===void 0?!1:e.generateMipMaps,s=e.generateDepthBuffer===void 0?!0:e.generateDepthBuffer,r=e.generateStencilBuffer===void 0?!1:e.generateStencilBuffer,n=e.generateDepthTexture===void 0?!1:e.generateDepthTexture,h=e.textureCount??1,l=e.samples??l,p=e.types||p,m=e.samplingModes||m,A=e.useSRGBBuffers||A,E=e.formats||E,I=e.targetTypes||I,M=e.faceIndex||M,C=e.layerIndex||C,x=e.layerCounts||x,S=e.labels||S,L=e.dontCreateTextures??!1,this.webGLVersion>1&&(e.depthTextureFormat===13||e.depthTextureFormat===17||e.depthTextureFormat===16||e.depthTextureFormat===14||e.depthTextureFormat===18)&&(o=e.depthTextureFormat)),o===void 0&&(o=r?13:14);const D=this._gl,Re=this._currentFramebuffer,pe=D.createFramebuffer();this._bindUnboundFramebuffer(pe);const ce=a.width??a,oe=a.height??a,Ye=[],Qe=[],ft=this.webGLVersion>1&&(o===13||o===17||o===18);N.label=e?.label??"MultiRenderTargetWrapper",N._framebuffer=pe,N._generateDepthBuffer=n||s,N._generateStencilBuffer=n?ft:r,N._depthStencilBuffer=this._setupFramebufferDepthAttachments(N._generateStencilBuffer,N._generateDepthBuffer,ce,oe,1,o),N._attachments=Qe;for(let de=0;de<h;de++){let Fe=m[de]||u,we=p[de]||c,$e=A[de]||f;const at=E[de]||d,ke=I[de]||g,Ni=x[de]??1;(we===1&&!this._caps.textureFloatLinearFiltering||we===2&&!this._caps.textureHalfFloatLinearFiltering)&&(Fe=1);const Ui=this._getSamplingParameters(Fe,i);we===1&&!this._caps.textureFloat&&(we=0,w.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),$e=$e&&this._caps.supportSRGBBuffers&&(this.webGLVersion>1||this.isWebGPU);const ki=this.webGLVersion>1,Cs=D[ki?"COLOR_ATTACHMENT"+de:"COLOR_ATTACHMENT"+de+"_WEBGL"];if(Qe.push(Cs),ke===-1||L)continue;const Ze=new Et(this,6);Ye[de]=Ze,D.activeTexture(D["TEXTURE"+de]),D.bindTexture(ke,Ze._hardwareTexture.underlyingResource),D.texParameteri(ke,D.TEXTURE_MAG_FILTER,Ui.mag),D.texParameteri(ke,D.TEXTURE_MIN_FILTER,Ui.min),D.texParameteri(ke,D.TEXTURE_WRAP_S,D.CLAMP_TO_EDGE),D.texParameteri(ke,D.TEXTURE_WRAP_T,D.CLAMP_TO_EDGE);const Gi=this._getRGBABufferInternalSizedFormat(we,at,$e),Hi=this._getInternalFormat(at),Vi=this._getWebGLTextureType(we);if(ki&&(ke===35866||ke===32879))ke===35866?Ze.is2DArray=!0:Ze.is3D=!0,Ze.baseDepth=Ze.depth=Ni,D.texImage3D(ke,0,Gi,ce,oe,Ni,0,Hi,Vi,null);else if(ke===34067){for(let zi=0;zi<6;zi++)D.texImage2D(D.TEXTURE_CUBE_MAP_POSITIVE_X+zi,0,Gi,ce,oe,0,Hi,Vi,null);Ze.isCube=!0}else D.texImage2D(D.TEXTURE_2D,0,Gi,ce,oe,0,Hi,Vi,null);i&&D.generateMipmap(ke),this._bindTextureDirectly(ke,null),Ze.baseWidth=ce,Ze.baseHeight=oe,Ze.width=ce,Ze.he
56ight=oe,Ze.isReady=!0,Ze.samples=1,Ze.generateMipMaps=i,Ze.samplingMode=Fe,Ze.type=we,Ze._useSRGBBuffer=$e,Ze.format=at,Ze.label=S[de]??N.label+"-Texture"+de,this._internalTexturesCache.push(Ze)}if(n&&this._caps.depthTextureExtension&&!L){const de=new Et(this,14);let Fe=5,we=D.DEPTH_COMPONENT16,$e=D.DEPTH_COMPONENT,at=D.UNSIGNED_SHORT,ke=D.DEPTH_ATTACHMENT;this.webGLVersion<2?we=D.DEPTH_COMPONENT:o===14?(Fe=1,at=D.FLOAT,we=D.DEPTH_COMPONENT32F):o===18?(Fe=0,at=D.FLOAT_32_UNSIGNED_INT_24_8_REV,we=D.DEPTH32F_STENCIL8,$e=D.DEPTH_STENCIL,ke=D.DEPTH_STENCIL_ATTACHMENT):o===16?(Fe=0,at=D.UNSIGNED_INT,we=D.DEPTH_COMPONENT24,ke=D.DEPTH_ATTACHMENT):(o===13||o===17)&&(Fe=12,at=D.UNSIGNED_INT_24_8,we=D.DEPTH24_STENCIL8,$e=D.DEPTH_STENCIL,ke=D.DEPTH_STENCIL_ATTACHMENT),this._bindTextureDirectly(D.TEXTURE_2D,de,!0),D.texParameteri(D.TEXTURE_2D,D.TEXTURE_MAG_FILTER,D.NEAREST),D.texParameteri(D.TEXTURE_2D,D.TEXTURE_MIN_FILTER,D.NEAREST),D.texParameteri(D.TEXTURE_2D,D.TEXTURE_WRAP_S,D.CLAMP_TO_EDGE),D.texParameteri(D.TEXTURE_2D,D.TEXTURE_WRAP_T,D.CLAMP_TO_EDGE),D.texImage2D(D.TEXTURE_2D,0,we,ce,oe,0,$e,at,null),D.framebufferTexture2D(D.FRAMEBUFFER,ke,D.TEXTURE_2D,de._hardwareTexture.underlyingResource,0),this._bindTextureDirectly(D.TEXTURE_2D,null),N._depthStencilTexture=de,N._depthStencilTextureWithStencil=ft,de.baseWidth=ce,de.baseHeight=oe,de.width=ce,de.height=oe,de.isReady=!0,de.samples=1,de.generateMipMaps=i,de.samplingMode=1,de.format=o,de.type=Fe,de.label=N.label+"-DepthStencil",Ye[h]=de,this._internalTexturesCache.push(de)}if(N.setTextures(Ye),t&&D.drawBuffers(Qe),this._bindUnboundFramebuffer(Re),N.setLayerAndFaceIndices(C,M),this.resetTextureCache(),!L)this.updateMultipleRenderTargetTextureSampleCount(N,l,t);else if(l>1){const de=D.createFramebuffer();if(!de)throw new Error("Unable to create multi sampled framebuffer");N._samples=l,N._MSAAFramebuffer=de,h>0&&t&&(this._bindUnboundFramebuffer(de),D.drawBuffers(Qe),this._bindUnboundFramebuffer(Re))}return N};he.prototype.updateMultipleRenderTargetTextureSampleCount=function(a,e,t=!0){if(this.webGLVersion<2||!a)return 1;if(a.samples===e)return e;const i=this._gl;e=Math.min(e,this.getCaps().maxMSAASamples),a._depthStencilBuffer&&(i.deleteRenderbuffer(a._depthStencilBuffer),a._depthStencilBuffer=null),a._MSAAFramebuffer&&(i.deleteFramebuffer(a._MSAAFramebuffer),a._MSAAFramebuffer=null);const s=a._attachments.length;for(let n=0;n<s;n++)a.textures[n]._hardwareTexture?.releaseMSAARenderBuffers();if(e>1&&typeof i.renderbufferStorageMultisample=="function"){const n=i.createFramebuffer();if(!n)throw new Error("Unable to create multi sampled framebuffer");a._MSAAFramebuffer=n,this._bindUnboundFramebuffer(n);const o=[];for(let h=0;h<s;h++){const l=a.textures[h],c=l._hardwareTexture,u=i[this.webGLVersion>1?"COLOR_ATTACHMENT"+h:"COLOR_ATTACHMENT"+h+"_WEBGL"],f=this._createRenderBuffer(l.width,l.height,e,-1,this._getRGBABufferInternalSizedFormat(l.type,l.format,l._useSRGBBuffer),u);if(!f)throw new Error("Unable to create multi sampled framebuffer");c.addMSAARenderBuffer(f),l.samples=e,o.push(u)}t&&i.drawBuffers(o)}else this._bindUnboundFramebuffer(a._framebuffer);const r=a._depthStencilTexture?a._depthStencilTexture.format:void 0;return a._depthStencilBuffer=this._setupFramebufferDepthAttachments(a._generateStencilBuffer,a._generateDepthBuffer,a.width,a.height,e,r),this._bindUnboundFramebuffer(null),a._samples=e,e};he.prototype.generateMipMapsMultiFramebuffer=function(a){const e=a,t=this._gl;if(e.isMulti)for(let i=0;i<e._attachments.length;i++){const s=e.textures[i];s?.generateMipMaps&&!s?.isCube&&!s?.is3D&&(this._bindTextureDirectly(t.TEXTURE_2D,s,!0),t.generateMipmap(t.TEXTURE_2D),this._bindTextureDirectly(t.TEXTURE_2D,null))}};he.prototype.resolveMultiFramebuffer=function(a){const e=a,t=this._gl;if(!e._MSAAFramebuffer||!e.isMulti)return;let i=e.resolveMSAAColors?t.COLOR_BUFFER_BIT:0;i|=e._generateDepthBuffer&&e.resolveMSAADepth?t.DEPTH_BUFFER_BIT:0,i|=e._generateStencilBuffer&&e.resolveMSAAStencil?t.STENCIL_BUFFER_BIT:0;const s=e._attachments,r=s.length;t.bindFramebuffer(t.READ_FRAMEBUFFER,e._MSAAFramebuffer),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,e._framebuffer);for(let n=0;n<r;n++){const o=e.textures[n];for(let h=0;h<r;h++)s[h]=t.NONE;s[n]=t[this.webGLVersion>1?"COLOR_ATTACHMENT"+n:"COLOR_ATTACHMENT"+n+"_WEBGL"],t.readBuffer(s[n]),t.drawBuffers(s),t.blitFramebuffer(0,0,o.width,o.height,0,0,o.width,o.height,i,t.NEAREST)}for(let n=0;n<r;n++)s[n]=t[this.webGLVersion>1?"COLOR_ATTACHMENT"+n:"COLOR_ATTACHMENT"+n+"_WEBGL"];t.drawBuffers(s),t.bindFramebuffer(this._gl.FRAMEBUFFER,e._MSAAFramebuffer)};const jh=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));class Ds extends Bi{get isSupported(){return this._engine?.getCaps().drawBuffersExtension??!1}get textures(){return this._textures}get count(){return this._count}get depthTexture(){return this._textures[this._textures.length-1]}set wrapU(e){if(this._textures)for(let t=0;t<this._textures.length;t++)this._textures[t].wrapU=e}set wrapV(e){if(this._textures)for(let t=0;t<this._textures.length;t++)this._textures[t].wrapV=e}constructor(e,t,i,s,r,n){const o=r&&r.generateMipMaps?r.generateMipMaps:!1,h=r&&r.generateDepthTexture?r.generateDepthTexture:!1,l=r&&r.depthTextureFormat?r.depthTextureFormat:15,c=!r||r.doNotChangeAspectRatio===void 0?!0:r.doNotChangeAspectRatio,u=r&&r.drawOnlyOnFirstAttachmentByDefault?r.drawOnlyOnFirstAttachmentByDefault:!1;if(super(e,t,s,o,c,void 0,void 0,void 0,void 0,void 0,void 0,void 0,!0),!this.isSupported){this.dispose();return}this._textureNames=n;const f=[],d=[],g=[],p=[],m=[],A=[],E=[],I=[];
56this._initTypes(i,f,d,g,p,m,A,E,I,r);const M=!r||r.generateDepthBuffer===void 0?!0:r.generateDepthBuffer,C=!r||r.generateStencilBuffer===void 0?!1:r.generateStencilBuffer,x=r&&r.samples?r.samples:1;this._multiRenderTargetOptions={samplingModes:d,generateMipMaps:o,generateDepthBuffer:M,generateStencilBuffer:C,generateDepthTexture:h,depthTextureFormat:l,types:f,textureCount:i,useSRGBBuffers:g,samples:x,formats:p,targetTypes:m,faceIndex:A,layerIndex:E,layerCounts:I,labels:n,label:e},this._count=i,this._drawOnlyOnFirstAttachmentByDefault=u,i>0&&(this._createInternalTextures(),this._createTextures(n))}_initTypes(e,t,i,s,r,n,o,h,l,c){for(let u=0;u<e;u++)c&&c.types&&c.types[u]!==void 0?t.push(c.types[u]):t.push(c&&c.defaultType?c.defaultType:0),c&&c.samplingModes&&c.samplingModes[u]!==void 0?i.push(c.samplingModes[u]):i.push(z.BILINEAR_SAMPLINGMODE),c&&c.useSRGBBuffers&&c.useSRGBBuffers[u]!==void 0?s.push(c.useSRGBBuffers[u]):s.push(!1),c&&c.formats&&c.formats[u]!==void 0?r.push(c.formats[u]):r.push(5),c&&c.targetTypes&&c.targetTypes[u]!==void 0?n.push(c.targetTypes[u]):n.push(3553),c&&c.faceIndex&&c.faceIndex[u]!==void 0?o.push(c.faceIndex[u]):o.push(0),c&&c.layerIndex&&c.layerIndex[u]!==void 0?h.push(c.layerIndex[u]):h.push(0),c&&c.layerCounts&&c.layerCounts[u]!==void 0?l.push(c.layerCounts[u]):l.push(1)}_createInternaTextureIndexMapping(){const e={},t=[];if(!this._renderTarget)return t;const i=this._renderTarget.textures;for(let s=0;s<i.length;s++){const r=i[s];if(!r)continue;const n=e[r.uniqueId];n!==void 0?t[s]=n:e[r.uniqueId]=s}return t}_rebuild(e=!1,t=!1,i){if(this._count<1||e)return;const s=this._createInternaTextureIndexMapping();this.releaseInternalTextures(),this._createInternalTextures(),t&&(this._releaseTextures(),this._createTextures(i));const r=this._renderTarget.textures;for(let n=0;n<r.length;n++){const o=this._textures[n];s[n]!==void 0&&this._renderTarget.setTexture(r[s[n]],n),o._texture=r[n],o._texture&&(o._noMipmap=!o._texture.useMipMaps,o._useSRGBBuffer=o._texture._useSRGBBuffer)}this.samples!==1&&this._renderTarget.setSamples(this.samples,!this._drawOnlyOnFirstAttachmentByDefault,!0)}_createInternalTextures(){this._renderTarget=this._getEngine().createMultipleRenderTarget(this._size,this._multiRenderTargetOptions,!this._drawOnlyOnFirstAttachmentByDefault),this._texture=this._renderTarget.texture}_releaseTextures(){if(this._textures)for(let e=0;e<this._textures.length;e++)this._textures[e]._texture=null,this._textures[e].dispose()}_createTextures(e){const t=this._renderTarget.textures;this._textures=[];for(let i=0;i<t.length;i++){const s=new z(null,this.getScene());e?.[i]&&(s.name=e[i]),s._texture=t[i],s._texture&&(s._noMipmap=!s._texture.useMipMaps,s._useSRGBBuffer=s._texture._useSRGBBuffer),this._textures.push(s)}}setInternalTexture(e,t,i=!0){if(this.renderTarget&&(t===0&&(this._texture=e),this.renderTarget.setTexture(e,t,i),this.textures[t]||(this.textures[t]=new z(null,this.getScene()),this.textures[t].name=this._textureNames?.[t]??this.textures[t].name),this.textures[t]._texture=e,this.textures[t]._noMipmap=!e.useMipMaps,this.textures[t]._useSRGBBuffer=e._useSRGBBuffer,this._count=this.renderTarget.textures?this.renderTarget.textures.length:0,this._multiRenderTargetOptions.types&&(this._multiRenderTargetOptions.types[t]=e.type),this._multiRenderTargetOptions.samplingModes&&(this._multiRenderTargetOptions.samplingModes[t]=e.samplingMode),this._multiRenderTargetOptions.useSRGBBuffers&&(this._multiRenderTargetOptions.useSRGBBuffers[t]=e._useSRGBBuffer),this._multiRenderTargetOptions.targetTypes&&this._multiRenderTargetOptions.targetTypes[t]!==-1)){let s=0;e.is2DArray?s=35866:e.isCube?s=34067:e.is3D?s=32879:s=3553,this._multiRenderTargetOptions.targetTypes[t]=s}}setLayerAndFaceIndex(e,t=-1,i=-1){!this.textures[e]||!this.renderTarget||(this._multiRenderTargetOptions.layerIndex&&(this._multiRenderTargetOptions.layerIndex[e]=t),this._multiRenderTargetOptions.faceIndex&&(this._multiRenderTargetOptions.faceIndex[e]=i),this.renderTarget.setLayerAndFaceIndex(e,t,i))}setLayerAndFaceIndices(e,t){this.renderTarget&&(this._multiRenderTargetOptions.layerIndex=e,this._multiRenderTargetOptions.faceIndex=t,this.renderTarget.setLayerAndFaceIndices(e,t))}get samples(){return this._samples}set samples(e){this._renderTarget?this._samples=this._renderTarget.setSamples(e):this._samples=e}resize(e){this._processSizeParameter(e),this._rebuild(!1,void 0,this._textureNames)}updateCount(e,t,i){this._multiRenderTargetOptions.textureCount=e,this._count=e;const s=[],r=[],n=[],o=[],h=[],l=[],c=[],u=[];this._textureNames=i,this._initTypes(e,s,r,n,o,h,l,c,u,t),this._multiRenderTargetOptions.types=s,this._multiRenderTargetOptions.samplingModes=r,this._multiRenderTargetOptions.useSRGBBuffers=n,this._multiRenderTargetOptions.formats=o,this._multiRenderTargetOptions.targetTypes=h,this._multiRenderTargetOptions.faceIndex=l,this._multiRenderTargetOptions.layerIndex=c,this._multiRenderTargetOptions.layerCounts=u,this._multiRenderTargetOptions.labels=i,this._rebuild(!1,!0,i)}_unbindFrameBuffer(e,t){this._renderTarget&&e.unBindMultiColorAttachmentFramebuffer(this._renderTarget,this.isCube,()=>{this.onAfterRenderObservable.notifyObservers(t)})}dispose(e=!1){this._releaseTextures(),e?this._texture=null:this.releaseInternalTextures(),super.dispose()}releaseInternalTextures(){const e=this._renderTarget?.textures;if(e){for(let t=e.length-1;t>=0;t--)this._textures[t]._texture=null;this._renderTarget?.dispose(),this._renderTarget=null}}}class Ei{get passCount(){return this._passCount}set passCount(e){this._passCount!==e&&(this._passCount=e,this._createRenderPassIds())}get useRenderPasses(){return this._useRenderPasses}set useRenderPasses(e){this._useRenderPasses!==e&&(this._useRenderPasses=e,this._createRenderPassIds())}addExcludedMesh(e){this._excludedMeshes.indexOf(e.uniqueId)===-1&&this._excludedMeshes.push(e.uniqueId)}removeExcludedMesh(e){const t=this._excludedMeshes.indexOf(e.uniqueId);t!==-1&&this._excludedMeshes.splice(t,1)}get shaderLanguage(){return this._shaderLanguage}get blendOutput(){return this._blendOutput}set blendOutput(e){this._blendOutput=e,this._disposeTextures(),e&&this._createTextures()}constructor(e,t=5){this._depthMrts=[],this._thinTextures=[],this._colorMrts=[],this._currentPingPongState=0,this._layoutCac
56heFormat=[[!0],[!0,!0],[!0,!0,!0]],this._layoutCache=[],this._candidateSubMeshes=new it(10),this._excludedSubMeshes=new it(10),this._excludedMeshes=[],this._colorCache=[new fe(Ei._DEPTH_CLEAR_VALUE,Ei._DEPTH_CLEAR_VALUE,0,0),new fe(-Ei._MIN_DEPTH,Ei._MAX_DEPTH,0,0),new fe(0,0,0,0)],this._shaderLanguage=0,this._scene=e,this._engine=e.getEngine(),this._passCount=t;for(let i=0;i<this._layoutCacheFormat.length;++i)this._layoutCache[i]=this._engine.buildTextureLayout(this._layoutCacheFormat[i]);this._renderPassIds=[],this.useRenderPasses=!1,this._engine.isWebGPU&&(this._shaderLanguage=1),this._createEffects("oitFinalSimpleBlend",["uFrontColor"])}_createRenderPassIds(){if(this._releaseRenderPassIds(),this._useRenderPasses)for(let e=0;e<this._passCount+1;++e)this._renderPassIds[e]||(this._renderPassIds[e]=this._engine.createRenderPassId(`DepthPeelingRenderer - pass #${e}`))}_releaseRenderPassIds(){for(let e=0;e<this._renderPassIds.length;++e)this._engine.releaseRenderPassId(this._renderPassIds[e]);this._renderPassIds=[]}_getTextureSize(){return this._blendOutput?{width:this._blendOutput.width,height:this._blendOutput.height}:{width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight()}}_createTextures(){const e=this._getTextureSize();this._depthMrts=[new Ds("depthPeelingDepth0MRT",e,3,this._scene,void 0,["depthPeelingDepth0MRT_depth","depthPeelingDepth0MRT_frontColor","depthPeelingDepth0MRT_backColor"]),new Ds("depthPeelingDepth1MRT",e,3,this._scene,void 0,["depthPeelingDepth1MRT_depth","depthPeelingDepth1MRT_frontColor","depthPeelingDepth1MRT_backColor"])],this._colorMrts=[new Ds("depthPeelingColor0MRT",e,2,this._scene,{generateDepthBuffer:!1},["depthPeelingColor0MRT_frontColor","depthPeelingColor0MRT_backColor"]),new Ds("depthPeelingColor1MRT",e,2,this._scene,{generateDepthBuffer:!1},["depthPeelingColor1MRT_frontColor","depthPeelingColor1MRT_backColor"])],this._blendBackMrt=new Ds("depthPeelingBackMRT",e,1,this._scene,{generateDepthBuffer:!1},["depthPeelingBackMRT_blendBack"]),this._blendOutput&&this._blendBackMrt.setInternalTexture(this._blendOutput.texture,0);const t=[{format:7,samplingMode:1,type:this._engine.getCaps().textureFloatLinearFiltering?1:2,label:"DepthPeelingRenderer-DepthTexture"},{format:5,samplingMode:1,type:2,label:"DepthPeelingRenderer-ColorTexture"}];for(let i=0;i<2;i++){const s=this._engine._createInternalTexture(e,t[0],!1),r=this._engine._createInternalTexture(e,t[1],!1),n=this._engine._createInternalTexture(e,t[1],!1);this._depthMrts[i].setInternalTexture(s,0),this._depthMrts[i].setInternalTexture(r,1),this._depthMrts[i].setInternalTexture(n,2),this._colorMrts[i].setInternalTexture(r,0),this._colorMrts[i].setInternalTexture(n,1),this._thinTextures.push(new fs(s),new fs(r),new fs(n))}this._blendOutput&&this._blendOutput.shareDepth(this._depthMrts[0].renderTarget)}_disposeTextures(){for(let e=0;e<this._thinTextures.length;e++)this._thinTextures[e].dispose();for(let e=0;e<this._depthMrts.length;e++)this._depthMrts[e].dispose(!0),this._colorMrts[e].dispose(!0),this._blendBackMrt.dispose(!0);this._thinTextures=[],this._colorMrts=[],this._depthMrts=[]}_createEffects(e,t){this._blendBackEffectWrapper=new rt({fragmentShader:"oitBackBlend",useShaderStore:!0,engine:this._engine,samplerNames:["uBackColor"],uniformNames:[],shaderLanguage:this._shaderLanguage,extraInitializationsAsync:async()=>{this._shaderLanguage===1?await G(()=>import("./oitBackBlend.fragment-B3_VdH0k.js"),__vite__mapDeps([96,13,14]),import.meta.url):await G(()=>import("./oitBackBlend.fragment-BO1eLYKG.js"),__vite__mapDeps([97,13,14]),import.meta.url)}}),this._blendBackEffectWrapperPingPong=new rt({fragmentShader:"oitBackBlend",useShaderStore:!0,engine:this._engine,samplerNames:["uBackColor"],uniformNames:[],shaderLanguage:this._shaderLanguage,extraInitializationsAsync:async()=>{this._shaderLanguage===1?await G(()=>import("./oitBackBlend.fragment-B3_VdH0k.js"),__vite__mapDeps([96,13,14]),import.meta.url):await G(()=>import("./oitBackBlend.fragment-BO1eLYKG.js"),__vite__mapDeps([97,13,14]),import.meta.url)}}),this._finalEffectWrapper=new rt({fragmentShader:e,useShaderStore:!0,engine:this._engine,samplerNames:t,uniformNames:[],shaderLanguage:this._shaderLanguage,extraInitializationsAsync:async()=>{this._shaderLanguage===1?await G(()=>import("./oitFinalSimpleBlend.fragment-C7Ov88Rz.js"),__vite__mapDeps([98,13,14]),import.meta.url):await G(()=>import("./oitFinalSimpleBlend.fragment-FJJQ4Luz.js"),__vite__mapDeps([99,13,14]),import.meta.url)}}),this._effectRenderer=new $u(this._engine)}setPrePassRenderer(e){}bind(e){e.setTexture("oitDepthSampler",this._thinTextures[this._currentPingPongState*3]),e.setTexture("oitFrontColorSampler",this._thinTextures[this._currentPingPongState*3+1])}_renderSubMeshes(e){let t;this._useRenderPasses&&(t={});for(let i=0;i<e.length;i++){const s=e.data[i].getMaterial();let r=!0,n=!1;const o=e.data[i];let h,l=!1;if(this._useRenderPasses&&(h=o._getDrawWrapper(),l=!h),s&&(r=s.allowShaderHotSwapping,n=s.backFaceCulling,s.allowShaderHotSwapping=!1,s.backFaceCulling=!1),o.render(!1),l&&(h=o._getDrawWrapper(),h.materialContext)){let c=t[h.materialContext.uniqueId];c||(c=t[h.materialContext.uniqueId]=this._engine.createMaterialContext()),o._getDrawWrapper().materialContext=c}s&&(s.allowShaderHotSwapping=r,s.backFaceCulling=n)}}
56_finalCompose(e){this._engine.bindFramebuffer(this._blendOutput),this._engine.setAlphaMode(7),this._engine.depthCullingState.depthMask=!1,this._engine.depthCullingState.depthTest=!1,this._engine.applyStates(),this._engine.enableEffect(this._finalEffectWrapper.drawWrapper),this._finalEffectWrapper.effect.setTexture("uFrontColor",this._thinTextures[e*3+1]),this._effectRenderer.render(this._finalEffectWrapper)}isReady(){return this._blendBackEffectWrapper.effect.isReady()&&this._blendBackEffectWrapperPingPong.effect.isReady()&&this._finalEffectWrapper.effect.isReady()}_beforeRender(){}_afterRender(){}_noTransparentMeshes(){}render(e){if(this._candidateSubMeshes.length=0,this._excludedSubMeshes.length=0,!this.isReady())return this._excludedSubMeshes;this._scene.activeCamera&&this._engine.setViewport(this._scene.activeCamera.viewport);for(let r=0;r<e.length;r++){const n=e.data[r],o=n.getMaterial(),h=o&&n.getRenderingMesh()._getRenderingFillMode(o.fillMode);o&&(h===F.TriangleFanDrawMode||h===F.TriangleFillMode||h===F.TriangleStripDrawMode)&&this._excludedMeshes.indexOf(n.getMesh().uniqueId)===-1?this._candidateSubMeshes.push(n):this._excludedSubMeshes.push(n)}if(!this._candidateSubMeshes.length)return this._noTransparentMeshes(),this._excludedSubMeshes;const t=this._engine.currentRenderPassId;this._beforeRender(),this._useRenderPasses&&(this._engine.currentRenderPassId=this._renderPassIds[0]),this._engine.bindFramebuffer(this._depthMrts[0].renderTarget),this._engine.bindAttachments(this._layoutCac
56he[0]),this._engine.clear(this._colorCache[0],!0,!1,!1),this._engine.unBindFramebuffer(this._depthMrts[0].renderTarget),this._engine.bindFramebuffer(this._depthMrts[1].renderTarget),this._engine.bindAttachments(this._layoutCache[0]),this._engine.clear(this._colorCache[1],!0,!1,!1),this._engine.unBindFramebuffer(this._depthMrts[1].renderTarget),this._engine.bindFramebuffer(this._colorMrts[0].renderTarget),this._engine.bindAttachments(this._layoutCache[1]),this._engine.clear(this._colorCache[2],!0,!1,!1),this._engine.unBindFramebuffer(this._colorMrts[0].renderTarget),this._engine.bindFramebuffer(this._colorMrts[1].renderTarget),this._engine.bindAttachments(this._layoutCache[1]),this._engine.clear(this._colorCache[2],!0,!1,!1),this._engine.unBindFramebuffer(this._colorMrts[1].renderTarget),this._engine.bindFramebuffer(this._depthMrts[0].renderTarget),this._engine.bindAttachments(this._layoutCache[0]),this._engine.setAlphaMode(11),this._engine.setAlphaEquation(3),this._engine.depthCullingState.depthMask=!1,this._engine.depthCullingState.depthTest=!0,this._engine.applyStates(),this._currentPingPongState=1,this._renderSubMeshes(this._candidateSubMeshes),this._engine.unBindFramebuffer(this._depthMrts[0].renderTarget),this._scene.resetCachedMaterial();let i=0,s=0;for(let r=0;r<this._passCount;r++){i=r%2,s=1-i,this._currentPingPongState=i,this._useRenderPasses&&(this._engine.currentRenderPassId=this._renderPassIds[r+1]),this._scene.activeCamera&&this._engine.setViewport(this._scene.activeCamera.viewport),this._engine.bindFramebuffer(this._depthMrts[s].renderTarget),this._engine.bindAttachments(this._layoutCac
56he[0]),this._engine.clear(this._colorCache[0],!0,!1,!1),this._engine.unBindFramebuffer(this._depthMrts[s].renderTarget),this._engine.bindFramebuffer(this._colorMrts[s].renderTarget),this._engine.bindAttachments(this._layoutCache[1]),this._engine.clear(this._colorCache[2],!0,!1,!1),this._engine.unBindFramebuffer(this._colorMrts[s].renderTarget),this._engine.bindFramebuffer(this._depthMrts[s].renderTarget),this._engine.bindAttachments(this._layoutCache[2]),this._engine.setAlphaMode(11),this._engine.setAlphaEquation(3),this._engine.depthCullingState.depthTest=!1,this._engine.applyStates(),this._renderSubMeshes(this._candidateSubMeshes),this._engine.unBindFramebuffer(this._depthMrts[s].renderTarget),this._scene.resetCachedMaterial(),this._engine.bindFramebuffer(this._blendBackMrt.renderTarget),this._engine.bindAttachments(this._layoutCache[0]),this._engine.setAlphaEquation(0),this._engine.setAlphaMode(17),this._engine.applyStates();const n=s===0||!this._useRenderPasses?this._blendBackEffectWrapper:this._blendBackEffectWrapperPingPong;this._engine.enableEffect(n.drawWrapper),n.effect.setTexture("uBackColor",this._thinTextures[s*3+2]),this._effectRenderer.render(n),this._engine.unBindFramebuffer(this._blendBackMrt.renderTarget)}return this._engine.currentRenderPassId=t,this._finalCompose(s),this._engine.setAlphaMode(0),this._engine.depthCullingState.depthMask=!0,this._engine.depthCullingState.depthTest=!0,this._afterRender(),this._excludedSubMeshes}dispose(){this._disposeTextures(),this._blendBackEffectWrapper.dispose(),this._finalEffectWrapper.dispose(),this._effectRenderer.dispose(),this._releaseRenderPassIds()}}Ei._DEPTH_CLEAR_VALUE=-99999;Ei._MIN_DEPTH=0;Ei._MAX_DEPTH=1;class Qh{constructor(e,t,i,s){this._isBackBuffer=!1,this.name=e,this._textureManager=t,this._renderTargets=i===void 0?void 0:Array.isArray(i)?i:[i],this._renderTargetDepth=s}get renderTargetWrapper(){if(!this._isBackBuffer){if(!this._renderTargetWrapper){const e=this._textureManager.engine,t=this._renderTargets===void 0||this._renderTargets.length===0?this._renderTargetDepth:this._renderTargets[0];if(this._textureManager.isBackbuffer(t)){this._isBackBuffer=!0;return}const i=this._textureManager.getTextureDescription(t),s={textureCount:this._renderTargets?.length??0,generateDepthBuffer:!1,label:this.name,samples:i.options.samples??1,dontCreateTextures:!0};this._renderTargetWrapper=e.createMultipleRenderTarget(i.size,s,!0);for(let r=0;r<s.textureCount;r++){const n=this._renderTargets[r],o=this._textureManager.getTextureFromHandle(n);if(!o)throw new Error(`FrameGraphRenderTarget.renderTargetWrapper: Failed to get texture from handle. handle: ${n}, name: ${this.name}, index: ${r}, renderTargets: ${this._renderTargets}`);o.incrementReferences(),this._renderTargetWrapper.setTexture(o,r,!1)}this._renderTargetDepth!==void 0&&this._renderTargetWrapper.setDepthStencilTexture(this._textureManager.getTextureFromHandle(this._renderTargetDepth),!1)}return this._renderTargetWrapper}}equals(e){const t=this._renderTargets,i=e._renderTargets;if(t!==void 0&&i!==void 0){if(t.length!==i.length)return!1;for(let s=0;s<t.length;s++)if(t[s]!==i[s])return!1}else if(t===void 0&&i!==void 0||t!==void 0&&i===void 0)return!1;return this._renderTargetDepth===e._renderTargetDepth}dispose(){this._renderTargetWrapper?.dispose()}}class Zh extends qh{get camera(){return this._camera}set camera(e){this._camera=e,this._renderer.activeCamera=this.camera}get disableImageProcessing(){return this._disableImageProcessing}set disableImageProcessing(e){e!==this._disableImageProcessing&&(this._disableImageProcessing=e,this._renderer.disableImageProcessing=e)}get renderMeshes(){return this._renderMeshes}set renderMeshes(e){e!==this._renderMeshes&&(this._renderMeshes=e,this._renderer.renderMeshes=e)}get renderDepthOnlyMeshes(){return this._renderDepthOnlyMeshes}set renderDepthOnlyMeshes(e){e!==this._renderDepthOnlyMeshes&&(this._renderDepthOnlyMeshes=e,this._renderer.renderDepthOnlyMeshes=e)}get renderOpaqueMeshes(){return this._renderOpaqueMeshes}set renderOpaqueMeshes(e){e!==this._renderOpaqueMeshes&&(this._renderOpaqueMeshes=e,this._renderer.renderOpaqueMeshes=e)}get renderAlphaTestMeshes(){return this._renderAlphaTestMeshes}set renderAlphaTestMeshes(e){e!==this._renderAlphaTestMeshes&&(this._renderAlphaTestMeshes=e,this._renderer.renderAlphaTestMeshes=e)}get renderTransparentMeshes(){return this._renderTransparentMeshes}set renderTransparentMeshes(e){e!==this._renderTransparentMeshes&&(this._renderTransparentMeshes=e,this._renderer.renderTransparentMeshes=e)}get useOITForTransparentMeshes(){return this._useOITForTransparentMeshes}set useOITForTransparentMeshes(e){e!==this._useOITForTransparentMeshes&&(this._useOITForTransparentMeshes=e,this._renderer.customRenderTransparentSubMeshes=this._useOITForTransparentMeshes?this._renderTransparentMeshesWithOIT.bind(this):void 0,this._oitRenderer.blendOutput=e&&this._rtForOrderIndependentTrans
vendor: 4,134 bytes, line 56
56parency?this._rtForOrderIndependentTransparency.renderTargetWrapper:null)}get oitPassCount(){return this._oitRenderer.passCount}set oitPassCount(e){e!==this._oitRenderer.passCount&&(this._oitRenderer.passCount=e)}get renderParticles(){return this._renderParticles}set renderParticles(e){e!==this._renderParticles&&(this._renderParticles=e,this._renderer.renderParticles=e)}get renderSprites(){return this._renderSprites}set renderSprites(e){e!==this._renderSprites&&(this._renderSprites=e,this._renderer.renderSprites=e)}get forceLayerMaskCheck(){return this._forceLayerMaskCheck}set forceLayerMaskCheck(e){e!==this._forceLayerMaskCheck&&(this._forceLayerMaskCheck=e,this._renderer.forceLayerMaskCheck=e)}get enableBoundingBoxRendering(){return this._enableBoundingBoxRendering}set enableBoundingBoxRendering(e){e!==this._enableBoundingBoxRendering&&(this._enableBoundingBoxRendering=e,this._renderer.enableBoundingBoxRendering=e)}get enableOutlineRendering(){return this._enableOutlineRendering}set enableOutlineRendering(e){e!==this._enableOutlineRendering&&(this._enableOutlineRendering=e,this._renderer.enableOutlineRendering=e)}get objectRenderer(){return this._renderer}get name(){return this._name}set name(e){this._name=e,this._renderer&&(this._renderer.name=e)}constructor(e,t,i,s,r){super(e,t),this.shadowGenerators=[],this.depthTest=!0,this.depthWrite=!0,this.disableShadows=!1,this._disableImageProcessing=!1,this.isMainObjectRenderer=!1,this._renderMeshes=!0,this._renderDepthOnlyMeshes=!0,this._renderOpaqueMeshes=!0,this._renderAlphaTestMeshes=!0,this._renderTransparentMeshes=!0,this._useOITForTransparentMeshes=!1,this._renderParticles=!0,this._renderSprites=!0,this._forceLayerMaskCheck=!0,this._enableBoundingBoxRendering=!0,this._enableOutlineRendering=!0,this.resolveMSAAColors=!0,this.resolveMSAADepth=!1,this._onBeforeRenderObservable=null,this._onAfterRenderObservable=null,this._externalObjectRenderer=!1,this._scene=i,this._engine=i.getEngine(),this._externalObjectRenderer=!!r,this._renderer=r??new Kt(e,i,s),this.name=e,this._renderer.disableImageProcessing=this._disableImageProcessing,this._renderer.renderParticles=this._renderParticles,this._renderer.renderSprites=this._renderSprites,this._renderer.enableBoundingBoxRendering=this._enableBoundingBoxRendering,this._renderer.forceLayerMaskCheck=this._forceLayerMaskCheck,this._externalObjectRenderer||this._renderer.onBeforeRenderingManagerRenderObservable.add(()=>{this._renderer.options.doNotChangeAspectRatio||i.updateTransformMatrix(!0)}),this._oitRenderer=new Ei(i),this._oitRenderer.useRenderPasses=!0,this.outputTexture=this._frameGraph.textureManager.createDanglingHandle(),this.outputDepthTexture=this._frameGraph.textureManager.createDanglingHandle(),this.onBeforeTaskExecute.add(()=>{this._disableDebugMarkers=this._engine._enableGPUDebugMarkers&&this._sceneHasClusteredLights()})}isReady(){return this._renderer.renderList=this.objectList.meshes,this._renderer.particleSystemList=this.objectList.particleSystems,this._renderer.isReadyForRendering(this._textureWidth,this._textureHeight)}getClassName(){return"FrameGraphObjectRendererTask"}record(e=!1,t){this._checkParameters();const i=this._getTargetHandles(),s=this._checkTextureCompatibility(i);this._resolveDanglingHandles(i),this._setLightsForShadow(),this._rtForOrderIndependentTransparency?.dispose();const r=this._frameGraph.addRenderPass(this.name);if(r.setRenderTarget(i),r.setRenderTargetDepth(this.depthTexture),r.setInitializeFunc(()=>{this._rtForOrderIndependentTransparency=new Qh(this.name+"_oitRT",this._frameGraph.textureManager,this.targetTexture,this.depthTexture)}),r.setExecuteFunc(n=>{this._renderer.renderList=this.objectList.meshes,this._renderer.particleSystemList=this.objectList.particleSystems,this._updateLayerAndFaceIndices(r);const o=r.frameGraphRenderTarget.renderTargetWrapper;o&&(o.resolveMSAAColors=this.resolveMSAAColors,o.resolveMSAADepth=this.resolveMSAADepth),this._useOITForTransparentMeshes&&this._oitRenderer.blendOutput!==this._rtForOrderIndependentTransparency.renderTargetWrapper&&(this._oitRenderer.blendOutput=this._rtForOrderIndependentTrans
56parency.renderTargetWrapper);const h=this.getBoundingBoxRenderer?.(),l=h&&h.renderList.length>0?h.renderList.data.slice():[];h&&(l.length=h.renderList.length);const c=this._prepareRendering(n,s),u=this._scene._depthPeelingRenderer;this._scene._depthPeelingRenderer=this._oitRenderer;const f=this._renderer.activeCamera;if(f&&f.cameraRigMode!==0&&!f._renderingMultiview){for(let d=0;d<f._rigCameras.length;d++){const g=f._rigCameras[d];g.rigParent=void 0,this._renderer.activeCamera=g,n.pushDebugGroup(`Render objects for camera rig ${d} "${g.name}"`),n.bindRenderTarget(r.frameGraphRenderTarget),c&&n.bindAttachments(c),n.render(this._renderer,this._textureWidth,this._textureHeight,!0),n.popDebugGroup(),g.rigParent=f}this._renderer.activeCamera=f}else n.pushDebugGroup(`Render objects for camera "${this._renderer.activeCamera?.name??"undefined"}"`),n.bindRenderTarget(r.frameGraphRenderTarget),c&&n.bindAttachments(c),n.render(this._renderer,this._textureWidth,this._textureHeight,!0),n.popDebugGroup();t?.(n),this._scene._depthPeelingRenderer=u,h&&(h.renderList.data=l,h.renderList.length=l.length)}),!e){const n=this._frameGraph.addRenderPass(this.name+"_disabled",!0);n.setRenderTarget(i),n.setRenderTargetDepth(this.depthTexture),n.setExecuteFunc(o=>{})}return r}dispose(){this._renderer.onBeforeRenderObservable.remove(this._onBeforeRenderObservable),this._renderer.onAfterRenderObservable.remove(this._onAfterRenderObservable),this._externalObjectRenderer||this._renderer.dispose(),this._oitRenderer.dispose(),this._rtForOrderIndependentTransparency?.dispose(),super.dispose()}_resolveDanglingHandles(e){e.length>0&&this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture,e[0]),this.depthTexture!==void 0&&this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture,this.depthTexture)}_checkParameters(){if(this.targetTexture===void 0||this.objectList===void 0||this.camera===void 0)throw new Error(`FrameGraphObjectRendererTask ${this.name}: targetTexture, objectList, and camera are required`)}_checkTextureCompatibility(e){const t=this.getClassName();let i=e.length>0?this._frameGraph.textureManager.getTextureDescription(e[0]):null,s=!1;if(this.depthTexture!==void 0){if(i&&this.depthTexture!==ni&&e[0]===Ut)throw new Error(`${t} ${this.name}: the back buffer depth/stencil texture is the only depth texture allowed when the target is the back buffer color`);const r=this._frameGraph.textureManager.getTextureDescription(this.depthTexture);if(i||(i=r),r.options.samples!==i.options.samples)throw new Error(`${t} ${this.name}: the depth texture "${r.options.labels?.[0]??"noname"}" (${r.options.samples} samples) and the output texture "${i.options.labels?.[0]??"noname"}" (${i.options.samples} samples) must have the same number of samples`);if(r.size.width!==i.size.width||r.size.height!==i.size.height)throw new Error(`${t} ${this.name}: the depth texture (size: ${r.size.width}x${r.size.height}) and the target texture (size: ${i.size.width}x${i.size.height}) must have the same dimensions.`);s=!0}return this._textureWidth=i?.size.width??1,this._textureHeight=i?.size.height??1,s}_getTargetHandles(){return Array.isArray(this.targetTexture)?this.targetTexture:[this.targetTexture]}_prepareRendering(e,t){return e.setDepthStates(this.depthTest&&t,this.depthWrite&&t),null}_setLightsForShadow(){const e=new Set,t=new Map;if(this.shadowGenerators)for(const i of this.shadowGenerators){const s=i.shadowGenerator,r=s.getLight();r.isEnabled()&&r.shadowEnabled&&(e.add(r),i.getClassName()==="FrameGraphCascadedShadowGeneratorTask"?r._shadowGenerators.set(i.camera,s):r._shadowGenerators.set(null,s))}this._renderer.onBeforeRenderObservable.remove(this._onBeforeRenderObservable),this._onBeforeRenderObservable=this._renderer.onBeforeRenderObservable.add(()=>{for(let i=0;i<this._scene.lights.length;i++){const s=this._scene.lights[i];s.setShadowProjectionMatrix&&(t.set(s,s.shadowEnabled),s.shadowEnabled=!this.disableShadows&&e.has(s))}}),this._renderer.onAfterRenderObservable.remove(this._onAfterRenderObservable),this._onAfterRenderObservable=this._renderer.onAfterRenderObservable.add(()=>{for(let i=0;i<this._scene.lights.length;i++){const s=this._scene.lights[i];s.setShadowProjectionMatrix&&(s.shadowEnabled=t.get(s))}})}_renderTransparentMeshesWithOIT(e){const t=this._renderer.renderingManager.renderingGroups,i=this._scene._useOrderIndependentTrans
56parency;this._scene._useOrderIndependentTransparency=!0;for(let s=ct.MIN_RENDERINGGROUPS;s<ct.MAX_RENDERINGGROUPS;s++){const r=t[s];if(!r||r._empty)continue;const n=this._oitRenderer.render(e);n.length&&r._renderTransparent(n)}this._scene._useOrderIndependentTransparency=i}_sceneHasClusteredLights(){for(const e of this._scene.lights)if(e.getTypeID()===Ee.LIGHTTYPEID_CLUSTERED_CONTAINER&&e.isSupported)return!0;return!1}}class qd extends qh{constructor(e,t){super(e,t),this.color=new fe(.2,.2,.3,1),this.clearColor=!0,this.convertColorToLinearSpace=!1,this.clearDepth=!1,this.clearStencil=!1,this.stencilValue=0,this.outputTexture=this._frameGraph.textureManager.createDanglingHandle(),this.outputDepthTexture=this._frameGraph.textureManager.createDanglingHandle()}getClassName(){return"FrameGraphClearTextureTask"}record(e=!1){if(this.targetTexture===void 0&&this.depthTexture===void 0)throw new Error(`FrameGraphClearTextureTask ${this.name}: targetTexture and depthTexture can't both be undefined.`);const t=this._frameGraph.textureManager,i=this.targetTexture!==void 0?Array.isArray(this.targetTexture)?this.targetTexture:[this.targetTexture]:void 0;if(this.targetTexture!==void 0&&t.resolveDanglingHandle(this.outputTexture,i[0]),this.depthTexture!==void 0&&t.resolveDanglingHandle(this.outputDepthTexture,this.depthTexture),this.targetTexture!==void 0&&this.depthTexture!==void 0){const o=t.getTextureDescription(i[0]),h=t.getTextureDescription(this.depthTexture);if(o.size.width!==h.size.width||o.size.height!==h.size.height)throw new Error(`FrameGraphClearTextureTask ${this.name}: the depth texture (size: ${h.size.width}x${h.size.height}) and the target texture (size: ${o.size.width}x${o.size.height}) must have the same dimensions.`);const l=o.options.samples||1,c=h.options.samples||1;if(l!==c&&l!==0&&c!==0)throw new Error(`FrameGraphClearTextureTask ${this.name}: the depth texture (${c} samples) and the target texture (${l} samples) must have the same number of samples.`)}const s=this._frameGraph.engine.buildTextureLayout(i?Array(i.length).fill(!0):[],this.targetTexture===Ut&&!this._frameGraph.textureManager.backBufferTextureOverriden),r=Vt.Color4[0],n=this._frameGraph.addRenderPass(this.name);if(n.setRenderTarget(i),n.setRenderTargetDepth(this.depthTexture),n.setInitializeFunc(()=>{const o=n.frameGraphRenderTarget.renderTargetWrapper;o&&(o.disableAutomaticMSAAResolve=!0)}),n.setExecuteFunc(o=>{this._updateLayerAndFaceIndices(n),r.copyFrom(this.color),this.convertColorToLinearSpace&&r.toLinearSpaceToRef(r),o.clearAttachments(r,s,!!this.clearColor,!!this.clearDepth,!!this.clearStencil,this.stencilValue)}),!e){const o=this._frameGraph.addRenderPass(this.name+"_disabled",!0);o.setRenderTarget(i),o.setRenderTargetDepth(this.depthTexture),o.setExecuteFunc(h=>{})}return n}}class hi extends rt{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([G(()=>import("./kernelBlur.fragment-UGmt1RMc.js"),__vite__mapDeps([100,101,102,13,14]),import.meta.url),G(()=>import("./kernelBlur.vertex-BrtXS4hd.js"),__vite__mapDeps([103,101,13,14]),import.meta.url)]))):t.push(Promise.all([G(()=>import("./kernelBlur.fragment-DSmQ2hZx.js"),__vite__mapDeps([104,105,106,13,14]),import.meta.url),G(()=>import("./kernelBlur.vertex-CqRKMVhS.js"),__vite__mapDeps([107,105,13,14]),import.meta.url)]))}constructor(e,t=null,i,s,r){const n=!!r?.blockCompilation;super({...r,name:e,engine:t||V.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:hi.FragmentUrl,uniforms:hi.Uniforms,samplers:hi.Samplers,vertexUrl:hi.VertexUrl,blockCompilation:!0}),this._packedFloat=!1,this._staticDefines="",this.textureWidth=0,this.textureHeight=0,this._staticDefines=r?Array.isArray(r.defines)?r.defines.join(`
57`):r.defines||"":"",this.options.blockCompilation=n,i!==void 0&&(this.direction=i),s!==void 0&&(this.kernel=s)}set kernel(e){this._idealKernel!==e&&(e=Math.max(e,1),this._idealKernel=e,this._kernel=this._nearestBestKernel(e),this.options.blockCompilation||this._updateParameters())}get kernel(){return this._idealKernel}set packedFloat(e){this._packedFloat!==e&&(this._packedFloat=e,this.options.blockCompilation||this._updateParameters())}get packedFloat(){return this._packedFloat}bind(e=!1){super.bind(e),this._drawWrapper.effect.setFloat2("delta",1/this.textureWidth*this.direction.x,
571/this.textureHeight*this.direction.y)}_updateParameters(e,t){const i=this._kernel,s=(i-1)/2;let r=[],n=[],o=0;for(let m=0;m<i;m++){const A=m/(i-1),E=this._gaussianWeight(A*2-1);r[m]=m-s,n[m]=E,o+=E}for(let m=0;m<n.length;m++)n[m]/=o;const h=[],l=[],c=[];for(let m=0;m<=s;m+=2){const A=Math.min(m+1,Math.floor(s));if(m===A)c.push({o:r[m],w:n[m]});else{const I=A===s,M=n[m]+n[A]*(I?.5:1),C=r[m]+1/(1+n[m]/n[A]);C===0?(c.push({o:r[m],w:n[m]}),c.push({o:r[m+1],w:n[m+1]})):(c.push({o:C,w:M}),c.push({o:-C,w:M}))}}for(let m=0;m<c.length;m++)l[m]=c[m].o,h[m]=c[m].w;r=l,n=h;const u=this.options.engine.getCaps().maxVaryingVectors-(this.options.shaderLanguage===1?1:0),f=Math.max(u,0)-1;let d=Math.min(r.length,f),g="";g+=this._staticDefines,this._staticDefines.indexOf("DOF")!=-1&&(g+=`#define CENTER_WEIGHT ${this._glslFloat(n[d-1])}
58`,d--);for(let m=0;m<d;m++)g+=`#define KERNEL_OFFSET${m} ${this._glslFloat(r[m])}
59`,g+=`#define KERNEL_WEIGHT${m} ${this._glslFloat(n[m])}
60`;let p=0;for(let m=f;m<r.length;m++)g+=`#define KERNEL_DEP_OFFSET${p} ${this._glslFloat(r[m])}
61`,g+=`#define KERNEL_DEP_WEIGHT${p} ${this._glslFloat(n[m])}
62`,p++;this.packedFloat&&(g+="#define PACKEDFLOAT 1"),this.options.blockCompilation=!1,this.updateEffect(g,null,null,{varyingCount:d,depCount:p},e,t)}_nearestBestKernel(e){const t=Math.round(e);for(const i of[t,t-1,t+1,t-2,t+2])if(i%2!==0&&Math.floor(i/2)%2===0&&i>0)return Math.max(i,3);return Math.max(t,3)}_gaussianWeight(e){const t=.3333333333333333,i=Math.sqrt(2*Math.PI)*t,s=-(e*e/(2*t*t));return 1/i*Math.exp(s)}_glslFloat(e,t=8){return e.toFixed(t).replace(/0+$/,"")}}hi.VertexUrl="kernelBlur";hi.FragmentUrl="kernelBlur";hi.Uniforms=["delta","direction"];hi.Samplers=["circleOfConfusionSampler"];class $h extends or{get drawWrapper(){return this._postProcessDrawWrapper}constructor(e,t,i){super(e,t),this.sourceSamplingMode=2,this.depthReadOnly=!1,this.stencilReadOnly=!1,this.disableColorWrite=!1,this.drawBackFace=!1,this.depthTest=!0,this.postProcess=i,this._postProcessDrawWrapper=this.postProcess.drawWrapper,this.outputTexture=this._frameGraph.textureManager.createDanglingHandle(),this.outputDepthAttachmentTexture=this._frameGraph.textureManager.createDanglingHandle()}isReady(){return this.postProcess.isReady()}getClassName(){return"FrameGraphPostProcessTask"}record(e=!1,t,i){if(this.sourceTexture===void 0&&this.targetTexture===void 0)throw new Error(`FrameGraphPostProcessTask "${this.name}": sourceTexture or targetTexture is required`);const s=this.sourceTexture!==void 0?this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture):void 0;if(s&&(s.options.samples=1),this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture,this.targetTexture,this.name,s),this.depthAttachmentTexture!==void 0&&this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthAttachmentTexture,this.depthAttachmentTexture),s){const o=this._frameGraph.textureManager.getTextureAbsoluteDimensions(s);this._sourceWidth=o.width,this._sourceHeight=o.height}const r=this._frameGraph.textureManager.getTextureDescription(this.outputTexture);this._outputWidth=r.size.width,this._outputHeight=r.size.height;const n=this._frameGraph.addRenderPass(this.name);if(n.depthReadOnly=this.depthReadOnly,n.stencilReadOnly=this.stencilReadOnly,n.addDependencies(this.sourceTexture),n.setRenderTarget(this.outputTexture),n.setRenderTargetDepth(this.depthAttachmentTexture),n.setExecuteFunc(o=>{o.pushDebugGroup(`Apply post-process (${this.name})`),this.sourceTexture!==void 0&&o.setTextureSamplingMode(this.sourceTexture,this.sourceSamplingMode),t?.(o),this.viewport&&o.setViewport(this.viewport),o.applyFullScreenEffect(this._postProcessDrawWrapper,()=>{this.sourceTexture!==void 0&&o.bindTextureHandle(this._postProcessDrawWrapper.effect,"textureSampler",this.sourceTexture),i?.(o),this.postProcess.bind()},this.stencilState,this.disableColorWrite,this.drawBackFace,this.depthTest,this.viewport!==void 0),o.restoreDefaultFramebuffer(),o.popDebugGroup()}),!e){const o=this._frameGraph.addRenderPass(this.name+"_disabled",!0);o.depthReadOnly=this.depthReadOnly,o.stencilReadOnly=this.stencilReadOnly,o.addDependencies(this.sourceTexture),o.setRenderTarget(this.outputTexture),o.setRenderTargetDepth(this.depthAttachmentTexture),o.setExecuteFunc(h=>{this.sourceTexture!==void 0&&(this.viewport&&h.setViewport(this.viewport),h.copyTexture(this.sourceTexture,void 0,this.viewport!==void 0))})}return n}dispose(){this.postProcess.dispose(),super.dispose()}}class Xa extends $h{constructor(e,t,i){super(e,t,i||new hi(e,t.engine,new Q(1,0),10))}getClassName(){return"FrameGraphBlurTask"}
62record(e=!1,t,i){const s=super.record(e,t,i);return this.postProcess.textureWidth=this._outputWidth,this.postProcess.textureHeight=this._outputHeight,s}}function Ci(a){return a.width!==void 0}function Bs(a){return Ci(a)?{width:a.width,height:a.height}:{width:a,height:a}}var pt;(function(a){a[a.Task=0]="Task",a[a.Graph=1]="Graph",a[a.External=2]="External"})(pt||(pt={}));class ai{constructor(e,t=!1,i){this.engine=e,this._debugTextures=t,this._scene=i,this._textures=new Map,this._historyTextures=new Map,this._isRecordingTask=!1,this.showDebugLogsForTextureAllcationOptimization=!1,this._backBufferTextureEntry=null,this._backBufferDepthStencilTextureEntry=null,this._backBufferTextureOverriden=!1,this._addSystemTextures()}isBackbuffer(e){return this._backBufferTextureOverriden?!1:this._isBackbuffer(e)}_isBackbuffer(e){if(e===Ut||e===ni)return!0;const t=this._textures.get(e);return t?t.refHandle===Ut||t.refHandle===ni:!1}isBackbufferColor(e){if(this._backBufferTextureOverriden)return!1;if(e===Ut)return!0;const t=this._textures.get(e);return t?t.refHandle===Ut:!1}isBackbufferDepthStencil(e){if(this._backBufferTextureOverriden)return!1;if(e===ni)return!0;const t=this._textures.get(e);return t?t.refHandle===ni:!1}isHistoryTexture(e,t=!1){const i=this._textures.get(e);return i?(e=i.refHandle??e,t?this._textures.get(e)?.historyTexture===!0:this._historyTextures.has(e)):!1}getTextureCreationOptions(e,t=!1){e=this._textures.get(e)?.refHandle??e;const i=this._textures.get(e),s=i.creationOptions;return{size:Ci(s.size)?{...s.size}:s.size,sizeIsPercentage:s.sizeIsPercentage,options:ai.CloneTextureOptions(s.options,i.textureIndex),isHistoryTexture:t?s.isHistoryTexture:!1}}getTextureDescription(e){const t=this.getTextureCreationOptions(e);return{size:t.sizeIsPercentage?this.getAbsoluteDimensions(t.size):Ci(t.size)?t.size:{width:t.size,height:t.size},options:t.options}}getTextureHandleOrCreateTexture(e,t,i){if(e===void 0){if(t===void 0||i===void 0)throw new Error("getTextureHandleOrCreateTexture: Either handle or newTextureName and creationOptions must be provided.");return this.createRenderTargetTexture(t,i)}return e}getTextureFromHandle(e,t){const i=this._textures.get(e),s=i?.refHandle,r=s!==void 0?this._textures.get(s):i,n=s!==void 0?s:e,o=this._historyTextures.get(n);return o?o.textures[t?o.index:o.index^1]:r.texture}importTexture(e,t,i){i!==void 0&&this._freeEntry(i);const s={size:{width:t.width,height:t.height},sizeIsPercentage:!1,isHistoryTexture:!1,options:{createMipMaps:t.generateMipMaps,samples:t.samples,types:[t.type],formats:[t.format],useSRGBBuffers:[t._useSRGBBuffer],creationFlags:[t._creationFlags],labels:t.label?[t.label]:["imported"]}};return this._createHandleForTexture(e,t,s,pt.External,i)}createRenderTargetTexture(e,t,i){return this._createHandleForTexture(e,null,{size:Ci(t.size)?{...t.size}:t.size,sizeIsPercentage:t.sizeIsPercentage,isHistoryTexture:t.isHistoryTexture,options:ai.CloneTextureOptions(t.options,void 0,!0)},this._isRecordingTask?pt.Task:pt.Graph,i)}createRenderTarget(e,t,i,s,r){const n=new Qh(e,this,t,i),o=n.renderTargetWrapper;if(o!==void 0&&(o.depthReadOnly=!!s,o.stencilReadOnly=!!r,t)){const h=Array.isArray(t)?t:[t];for(let l=0;l<h.length;l++){let c=h[l];c=this._textures.get(c)?.refHandle??c;const u=this._historyTextures.get(c);u&&(u.references.push({renderTargetWrapper:o,textureIndex:l}),o.setTexture(u.textures[u.index],l,!1))}}return n}createDanglingHandle(){return ai._Counter++}resolveDanglingHandle(e,t,i,s){if(t===void 0){if(i===void 0||s===void 0)throw new Error("resolveDanglingHandle: Either handle or newTextureName and creationOptions must be provided.");this.createRenderTargetTexture(i,s,e);return}const r=this._textures.get(t);if(r===void 0)throw new Error(`resolveDanglingHandle: Handle ${t} does not exist!`);t=r.refHandle??t,this._textures.set(e,{texture:r.texture,refHandle:t,name:r.name,creationOptions:{size:{...r.creationOptions.size},options:ai.CloneTextureOptions(r.creationOptions.options),sizeIsPercentage:r.creationOptions.sizeIsPercentage,isHistoryTexture:!1},namespace:r.namespace,textureIndex:r.textureIndex})}getAbsoluteDimensions(e,t,i){if(this._backBufferTextureOverriden){const n=this._textures.get(Ut).creationOptions.size;t??(t=n.width),i??(i=n.height)}else t??(t=this.engine.getRenderWidth(!0)),i??(i=this.engine.getRenderHeight(!0));const{width:s,height:r}=Bs(e);return{width:Math.floor(s*t/100),height:Math.floor(r*i/100)}}getTextureAbsoluteDimensions(e){return typeof e=="number"&&(e=this.getTextureCreationOptions(e)),e.sizeIsPercentage?this.getAbsoluteDimensions(e.size):Ci(e.size)?e.
62size:{width:e.size,height:e.size}}computeTotalTextureSize(e,t,i){let s=0;return this._textures.forEach((r,n)=>{if(!this._backBufferTextureOverriden&&(n===Ut||n===ni)||r.refHandle!==void 0||e&&r.aliasHandle!==void 0)return;const o=r.creationOptions,h=r.textureIndex||0,l=o.sizeIsPercentage?this.getAbsoluteDimensions(o.size,t,i):Bs(o.size),c=ai._GetTextureBlockInformation(o.options.types?.[h]??0,o.options.formats[h]),u=Math.ceil(l.width/c.width)*Math.ceil(l.height/c.height)*c.length;let f=u;o.options.createMipMaps&&(f=Math.floor(f*4/3)),(o.options.samples||1)>1&&(f+=u),s+=f}),s}get backBufferTextureOverriden(){return this._backBufferTextureOverriden}setBackBufferTextures(e,t,i,s){if((e===0||t===0)&&(!i||!s)){if(this._backBufferTextureOverriden){let n=this._textures.get(Ut);n.texture?.dispose(),n.texture=null,n.debug?.dispose(),n.debug=void 0,n=this._textures.get(ni),n.texture?.dispose(),n.texture=null,n.debug?.dispose(),n.debug=void 0}this._backBufferTextureEntry=null,this._backBufferDepthStencilTextureEntry=null,this._backBufferTextureOverriden=!1,this._addSystemTextures();return}this._backBufferTextureOverriden=!0;const r={width:e,height:t};this._backBufferTextureEntry={name:"backbuffer color",texture:null,creationOptions:i??{size:r,options:{createMipMaps:!1,samples:this.engine.getCreationOptions().antialias?4:1,types:[0],formats:[5],useSRGBBuffers:[!1],creationFlags:[0],labels:["backbuffer color"]},sizeIsPercentage:!1},namespace:pt.Graph,lifespan:{firstTask:Number.MAX_VALUE,lastTask:0}},this._backBufferTextureEntry.textureDescriptionHash=this._createTextureDescriptionHash(this._backBufferTextureEntry.creationOptions),this._backBufferDepthStencilTextureEntry={name:"backbuffer depth/stencil",texture:null,creationOptions:s??{size:r,options:{createMipMaps:!1,samples:this.engine.getCreationOptions().antialias?4:1,types:[0],formats:[this.engine.isStencilEnable?13:14],useSRGBBuffers:[!1],creationFlags:[0],labels:["backbuffer depth/stencil"]},sizeIsPercentage:!1},namespace:pt.Graph,lifespan:{firstTask:Number.MAX_VALUE,lastTask:0}},this._backBufferDepthStencilTextureEntry.textureDescriptionHash=this._createTextureDescriptionHash(this._backBufferDepthStencilTextureEntry.creationOptions),this._addSystemTextures()}resetBackBufferTextures(){this.setBackBufferTextures(0,0)}get hasHistoryTextures(){return this._historyTextures.size>0}_dispose(){this._releaseTextures()}_allocateTextures(e){e&&this._optimizeTextureAllocation(e),this._textures.forEach(t=>{if(!t.texture){if(t.refHandle!==void 0){const i=this._textures.get(t.refHandle);t.texture=i.texture,t.texture?.incrementReferences(),i.refHandle===Ut&&(t.refHandle=Ut),i.refHandle===ni&&(t.refHandle=ni)}else if(t.namespace!==pt.External)if(t.aliasHandle!==void 0){const i=this._textures.get(t.aliasHandle);t.texture=i.texture,t.texture.incrementReferences()}else{const i=t.creationOptions,s=Bs(i.sizeIsPercentage?this.getAbsoluteDimensions(i.size):i.size),r=t.textureIndex||0,n=i.options.targetTypes?.[r]??3553,o=n===32879,h=n===35866||n===3735928559,l=i.options.layerCounts?.[r]??0,c={createMipMaps:i.options.createMipMaps,samples:i.options.samples,type:i.options.types?.[r],format:i.options.formats?.[r],useSRGBBuffer:i.options.useSRGBBuffers?.[r],creationFlags:i.options.creationFlags?.[r],label:i.options.labels?.[r]??`${t.name}${r>0?"#"+r:""}`,samplingMode:1,createMSAATexture:i.options.samples>1,isCube:n===34067||n===3735928559},u=xn(c.format),f=bs(c.format),d=u&&f?12:u||f?14:5,g=this.engine._createInternalTexture({width:s.width,height:s.height,depth:o?l:void 0,layers:h?l:void 0},c,!1,d);u&&(g.type=sd(g.format)),t.texture=g}}t.texture&&t.refHandle===void 0&&(t.debug?.dispose(),t.debug=this._createDebugTexture(t.name,t.texture))}),this._historyTextures.forEach(t=>{for(let i=0;i<t.handles.length;i++)t.textures[i]=this._textures.get(t.handles[i]).texture})}_releaseTextures(e=!0){this._textures.forEach((t,i)=>{t.lifespan&&(t.lifespan.firstTask=Number.MAX_VALUE,t.lifespan.lastTask=0),t.aliasHandle=void 0,(e||t.namespace!==pt.External)&&(t.debug?.dispose(),t.debug=void 0),t.namespace!==pt.External&&(t.texture?.dispose(),t.texture=null,(e||t.namespace===pt.Task)&&(this._textures.delete(i),this._historyTextures.delete(i)))}
62),this._historyTextures.forEach(t=>{for(let i=0;i<t.handles.length;i++)t.textures[i]=null}),e&&(this._textures.clear(),this._historyTextures.clear(),this._addSystemTextures())}_updateHistoryTextures(){this._historyTextures.forEach(e=>{e.index=e.index^1;const t=e.textures[e.index];if(t)for(const{renderTargetWrapper:i,textureIndex:s}of e.references)i.setTexture(t,s,!1)})}_addSystemTextures(){const e={width:this.engine.getRenderWidth(!0),height:this.engine.getRenderHeight(!0)};this._textures.set(Ut,this._backBufferTextureEntry??{name:"backbuffer color",texture:null,creationOptions:{size:e,options:{createMipMaps:!1,samples:this.engine.getCreationOptions().antialias?4:1,types:[0],formats:[5],useSRGBBuffers:[!1],creationFlags:[0],labels:["backbuffer color"]},sizeIsPercentage:!1},namespace:pt.External}),this._textures.set(ni,this._backBufferDepthStencilTextureEntry??{name:"backbuffer depth/stencil",texture:null,creationOptions:{size:e,options:{createMipMaps:!1,samples:this.engine.getCreationOptions().antialias?4:1,types:[0],formats:[16],useSRGBBuffers:[!1],creationFlags:[0],labels:["backbuffer depth/stencil"]},sizeIsPercentage:!1},namespace:pt.External})}_createDebugTexture(e,t){if(!this._debugTextures)return;const i=new z(null,this._scene);return i.name=e,i._texture=t,i._texture.incrementReferences(),i}_freeEntry(e){const t=this._textures.get(e);t&&(t.debug?.dispose(),this._textures.delete(e))}_createHandleForTexture(e,t,i,s,r,n){r=r??ai._Counter++,n=n||0;const o=i.isHistoryTexture?`${e} ping`:e;let h=i.options.labels?.[n]??"";h===o&&(h="");const l={texture:t,name:`${o}${h?" "+h:""}`,creationOptions:{size:Ci(i.size)?i.size:{width:i.size,height:i.size},options:i.options,sizeIsPercentage:i.sizeIsPercentage,isHistoryTexture:i.isHistoryTexture},namespace:s,textureIndex:n,textureDescriptionHash:this._createTextureDescriptionHash(i),lifespan:{firstTask:Number.MAX_VALUE,lastTask:0},historyTexture:i.isHistoryTexture};if(this._textures.set(r,l),s===pt.External)return r;if(i.isHistoryTexture){const c={size:{...l.creationOptions.size},options:{...l.creationOptions.options},sizeIsPercentage:l.creationOptions.sizeIsPercentage,isHistoryTexture:!1},u=this._createHandleForTexture(`${e} pong`,null,c,s);return this._textures.get(u).historyTexture=!0,this._historyTextures.set(r,{textures:[null,null],handles:[r,u],index:0,references:[]}),r}if(i.options.types&&i.options.types.length>1&&n===0){const c=i.options.types.length,u={size:Ci(i.size)?i.size:{width:i.size,height:i.size},options:i.options,sizeIsPercentage:i.sizeIsPercentage};for(let f=1;f<c;f++)this._createHandleForTexture(o,null,u,s,r+f,f);ai._Counter+=c-1}return r}_createTextureDescriptionHash(e){const t=[];return t.push(Ci(e.size)?`${e.size.width}_${e.size.height}`:`${e.size}`),t.push(e.sizeIsPercentage?"%":"A"),t.push(e.options.createMipMaps?"M":"N"),t.push(e.options.samples?`${e.options.samples}`:"S1"),t.push(e.options.targetTypes?e.options.targetTypes.join("_"):"3553"),t.push(e.options.types?e.options.types.join("_"):"0"),t.push(e.options.formats?e.options.formats.join("_"):"5"),t.push(e.options.layerCounts?e.options.layerCounts.join("_"):"0"),t.push(e.options.useSRGBBuffers?e.options.useSRGBBuffers.join("_"):"false"),t.push(e.options.creationFlags?e.options.creationFlags.join("_"):"0"),t.join("_")}_optimizeTextureAllocation(e){this._computeTextureLifespan(e),this.showDebugLogsForTextureAllcationOptimization&&w.Log("================== Optimization of texture allocation ==================");const t=new Map,i=this._textures.keys();for(let s=i.next();s.done!==!0;s=i.next()){const r=s.value,n=this._textures.get(r);if(n.refHandle!==void 0||n.namespace===pt.External||this.isHistoryTexture(r,!0))continue;const o=n.textureDescriptionHash,h=n.lifespan,l=t.get(o);if(l){let c=!1;for(const u of l){const[f,d]=u;let g=!1;for(const p of d)if(p.firstTask<=h.lastTask&&p.lastTask>=h.firstTask){g=!0;break}if(!g){this.showDebugLogsForTextureAllcationOptimization&&w.Log(`Texture ${r} (${n.name}) reuses cache entry ${f}`),d.push(h),n.aliasHandle=f,c=!0;break}}c||l.push([r,[h]])}else t.set(o,[[r,[h]]])}}_computeTextureLifespan(e){this.showDebugLogsForTextureAllcationOptimization&&w.Log("================== Dump of texture dependencies for all tasks/passes ==================");for(let t=0;t<e.length;++t){const i=e[t];i.passes.length>0&&this._computeTextureLifespanForPasses(i,t,i.passes),i.passesDisabled.length>0&&this._computeTextureLifespanForPasses(i,t,i.passesDisabled),i.dependencies&&(this.showDebugLogsForTextureAllcationOptimization&&w.Log(`task#${t} (${i.name}), global dependencies`),this._updateLifespan(t*100+99,i.dependencies))}if(this.showDebugLogsForTextureAllcationOptimization){w.Log("================== Texture lifespans ==================");const t=this._textures.keys();for(let i=t.next();i.done!==!0;i=t.next()){const s=i.value,r=this._textures.get(s);r.refHandle!==void 0||r.namespace===pt.External||this._historyTextures.has(s)||w.Log(`${s} (${r.name}): ${r.lifespan.firstTask} - ${r.lifespan.lastTask}`)}}}_computeTextureLifespanForPasses(e,t,i){for(let s=0;s<i.length;++s){const r=new Set,n=i[s];Mn.IsRenderPass(n)&&(n.collectDependencies(r),this.showDebugLogsForTextureAllcationOptimization&&w.Log(`task#${t} (${e.name}), pass#${s} (${n.name})`),this._updateLifespan(t*100+s,r))}}_updateLifespan(e,t){const i=t.keys();for(let s=i.next();s.done!==!0;s=i.next()){const r=s.value;if(this.isBackbuffer(r))continue;let n=this._textures.get(r);if(!n)throw new Error(`FrameGraph._computeTextureLifespan: Texture handle "${r}" not found in the texture manager. Make sure you didn't forget to add a task in the frame graph.`);let o=r;for(;n.refHandle!==void 0;)if(o=n.refHandle,n=this._textures.get(o),!n)throw new Error(`FrameGraph._computeTextureLifespan: Texture handle "${o}" not found in the texture manager (source handle="${r}"). Make sure you didn't forget to add a task in the frame graph.`);
62n.namespace===pt.External||this._historyTextures.has(o)||(this.showDebugLogsForTextureAllcationOptimization&&w.Log(`    ${o} (${n.name})`),n.lifespan.firstTask=Math.min(n.lifespan.firstTask,e),n.lifespan.lastTask=Math.max(n.lifespan.lastTask,e))}}static CloneTextureOptions(e,t,i){return t!==void 0?{createMipMaps:e.createMipMaps,samples:e.samples,targetTypes:e.targetTypes?[e.targetTypes[t]]:void 0,types:e.types?[e.types[t]]:void 0,formats:e.formats?[e.formats[t]]:void 0,layerCounts:e.layerCounts?[e.layerCounts[t]]:void 0,useSRGBBuffers:e.useSRGBBuffers?[e.useSRGBBuffers[t]]:void 0,creationFlags:e.creationFlags?[e.creationFlags[t]]:void 0,labels:e.labels?[e.labels[t]]:void 0}:{createMipMaps:e.createMipMaps,samples:e.samples,targetTypes:e.targetTypes?[...e.targetTypes]:void 0,types:e.types?[...e.types]:void 0,formats:e.formats?[...e.formats]:void 0,layerCounts:e.layerCounts?[...e.layerCounts]:void 0,useSRGBBuffers:e.useSRGBBuffers?[...e.useSRGBBuffers]:void 0,creationFlags:e.creationFlags?[...e.creationFlags]:void 0,labels:e.labels&&i?[...e.labels]:void 0}}static _GetTextureBlockInformation(e,t){switch(t){case 15:return{width:1,height:1,length:2};case 16:return{width:1,height:1,length:3};case 13:return{width:1,height:1,length:4};case 14:return{width:1,height:1,length:4};case 18:return{width:1,height:1,length:5};case 19:return{width:1,height:1,length:1};case 36492:return{width:4,height:4,length:16};case 36495:return{width:4,height:4,length:16};case 36494:return{width:4,height:4,length:16};case 33779:return{width:4,height:4,length:16};case 33778:return{width:4,height:4,length:16};case 33777:case 33776:return{width:4,height:4,length:8};case 37808:return{width:4,height:4,length:16};case 36196:case 37492:return{width:4,height:4,length:8};case 37496:return{width:4,height:4,length:16}}switch(e){case 3:case 0:switch(t){case 6:case 8:case 0:case 1:case 2:return{width:1,height:1,length:1};case 7:case 9:return{width:1,height:1,length:2};case 4:case 10:return{width:1,height:1,length:3};case 11:return{width:1,height:1,length:4};default:return{width:1,height:1,length:4}}case 4:case 5:switch(t){case 8:return{width:1,height:1,length:2};case 9:return{width:1,height:1,length:4};case 10:return{width:1,height:1,length:6};case 11:return{width:1,height:1,length:8};default:return{width:1,height:1,length:8}}case 6:case 7:switch(t){case 8:return{width:1,height:1,length:4};case 9:return{width:1,height:1,length:8};case 10:return{width:1,height:1,length:12};case 11:return{width:1,height:1,length:16};default:return{width:1,height:1,length:16}}case 1:switch(t){case 6:return{width:1,height:1,length:4};case 7:return{width:1,height:1,length:8};case 4:return{width:1,height:1,length:12};case 5:return{width:1,height:1,length:16};default:return{width:1,height:1,length:16}}case 2:switch(t){case 6:return{width:1,height:1,length:2};case 7:return{width:1,height:1,length:4};case 4:return{width:1,height:1,length:6};case 5:return{width:1,height:1,length:8};default:return{width:1,height:1,length:8}}case 10:return{width:1,height:1,length:2};case 13:switch(t){case 5:case 11:return{width:1,height:1,length:4};default:return{width:1,height:1,length:4}}case 14:switch(t){case 5:case 11:return{width:1,height:1,length:4};default:return{width:1,height:1,length:4}}case 8:return{width:1,height:1,length:2};case 9:return{width:1,height:1,length:2};case 11:switch(t){case 5:return{width:1,height:1,length:4};case 11:return{width:1,height:1,length:4};default:return{width:1,height:1,length:4}}}return{width:1,height:1,length:4}}}ai._Counter=2;class As extends rt{constructor(e,t=null,i,s,r){super({...r,name:e,engine:t||V.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:As.FragmentUrl,uniforms:As.Uniforms}),this.direction=i,this.kernel=s,this.textureWidth=0,this.textureHeight=0}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(G(()=>import("./glowBlurPostProcess.fragment-DWOeXimf.js"),__vite__mapDeps([108,13,14]),import.meta.url))):t.push(G(()=>import("./glowBlurPostProcess.fragment-BilEVlle.js"),__vite__mapDeps([109,13,14]),import.meta.url)),super._gatherImports(e,t)}bind(){super.bind(),this._drawWrapper.effect.setFloat2("screenSize",this.textureWidth,this.textureHeight),this._drawWrapper.effect.setVector2("direction",this.direction),this._drawWrapper.effect.setFloat("blurWidth",this.kernel)}}As.FragmentUrl="glowBlurPostProcess";As.Uniforms=["screenSize","direction","blurWidth"];class Ka extends or{isReady(){return!this.customIsReady||this.customIsReady()}constructor(e,t){super(e,t)}getClassName(){return"FrameGraphExecuteTask"}record(){if(!this.func)throw new Error("FrameGraphExecuteTask: Execute task must have a function.");const e=this._frameGraph.addPass(this.name);return e.setExecuteFunc(i=>{this.func(i)}),this._frameGraph.addPass(this.name+"_disabled",!0).setExecuteFunc(i=>{this.funcDisabled?.(i)}),e}}class Ya extends $h{constructor(e,t,i){super(e,t,i||new As(e,t.engine,new Q(1,0),1))}getClassName(){return"FrameGraphGlowBlurTask"}
62record(e=!1,t,i){const s=super.record(e,t,i);return this.postProcess.textureWidth=this._outputWidth,this.postProcess.textureHeight=this._outputHeight,s}}class jd extends or{get name(){return this._name}set name(e){if(this._name=e,this._blurX)for(let t=0;t<this._blurX.length;t++)this._blurX[t].name=`${e} Blur X${t}`,this._blurY[t].name=`${e} Blur Y${t}`;this._clearLayerTextures&&(this._clearLayerTextures.name=e+" Clear Layer"),this._objectRendererForLayer&&(this._objectRendererForLayer.name=e+" Render to Layer")}get objectRendererForLayer(){return this._objectRendererForLayer}constructor(e,t,i,s,r,n=!1,o=!1,h=!1){super(e,t),this._setRenderTargetDepth=o,this._notifyBlurObservable=h,this._blurX=[],this._blurY=[],this._onBeforeBlurTask=null,this._onAfterBlurTask=null,this._onBeforeObservableObserver=null,this._onAfterObservableObserver=null,this._onAfterRenderingGroupObserver=null,this._scene=i,this._engine=i.getEngine(),this.layer=s;for(let l=0;l<r;l++)n?(this._blurX.push(new Ya(`${e} Blur X${l}`,this._frameGraph,this.layer._postProcesses[1+l*2+0])),this._blurY.push(new Ya(`${e} Blur Y${l}`,this._frameGraph,this.layer._postProcesses[1+l*2+1]))):(this._blurX.push(new Xa(`${e} Blur X${l}`,this._frameGraph,this.layer._postProcesses[l*2+0])),this._blurY.push(new Xa(`${e} Blur Y${l}`,this._frameGraph,this.layer._postProcesses[l*2+1])));this._clearLayerTextures=new qd(e+" Clear Layer",t),this._clearLayerTextures.clearColor=!0,this._clearLayerTextures.clearDepth=!0,this._objectRendererForLayer=new Zh(e+" Render to Layer",t,i,void 0,this.layer.objectRenderer),this._notifyBlurObservable&&(this._onBeforeBlurTask=new Ka(e+" On Before Blur",t),this._onAfterBlurTask=new Ka(e+" On After Blur",t),this._onBeforeBlurTask.func=()=>{this.layer.onBeforeBlurObservable.hasObservers()&&this.layer.onBeforeBlurObservable.notifyObservers(this.layer)},this._onAfterBlurTask.func=()=>{this.layer.onAfterBlurObservable.hasObservers()&&this.layer.onAfterBlurObservable.notifyObservers(this.layer)}),this.outputTexture=this._frameGraph.textureManager.createDanglingHandle()}isReady(){return this._objectRendererForLayer.isReady()&&this.layer.isLayerReady()}getClassName(){return"FrameGraphBaseLayerTask"}record(){if(this.targetTexture===void 0||this.objectRendererTask===void 0)throw new Error(`${this.constructor.name} "${this.name}": targetTexture and objectRendererTask are required`);this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture,this.targetTexture);let e,t,i;if(this.layerTexture)i=this.layerTexture,t=this._frameGraph.textureManager.getTextureCreationOptions(this.layerTexture),e=Bs(t.size),t.size=e;else{const p=this._frameGraph.textureManager.getTextureCreationOptions(this.targetTexture),m=this.layer._options.mainTextureFixedSize?Math.max(2,this.layer._options.mainTextureFixedSize):0;e=Bs(p.size),e.width=m||Math.floor(e.width*(this.layer._options.mainTextureRatio||.1))||1,e.height=m||Math.floor(e.height*(this.layer._options.mainTextureRatio||.1))||1,t={size:e,options:{createMipMaps:!1,types:[this.layer._options.mainTextureType],formats:[5],samples:1,useSRGBBuffers:[!1],creationFlags:[0]},sizeIsPercentage:this.layer._options.mainTextureFixedSize?!1:p.sizeIsPercentage},i=this._frameGraph.textureManager.createRenderTargetTexture(`${this.name} Color`,t)}const s={size:e,options:ai.CloneTextureOptions(t.options),sizeIsPercentage:t.sizeIsPercentage};s.options.formats[0]=14;const r=this._frameGraph.textureManager.createRenderTargetTexture(`${this.name} Depth`,s);this._clearLayerTextures.targetTexture=i,this._clearLayerTextures.depthTexture=r,this._clearLayerTextures.color=this.layer.neutralColor,this._clearLayerTextures.clearDepth=!0;const n=this._clearLayerTextures.record();this._objectRendererForLayer.targetTexture=this._clearLayerTextures.outputTexture,this._objectRendererForLayer.depthTexture=this._clearLayerTextures.outputDepthTexture,this._objectRendererForLayer.camera=this.objectRendererTask.camera,this._objectRendererForLayer.objectList=this.objectRendererTask.objectList,this._objectRendererForLayer.disableShadows=!0;const o=this._objectRendererForLayer.record();let h=0;
62this._engine.getCaps().textureHalfFloatRender?h=2:h=0,t.options.types[0]=h;const l=this.layer._options.blurTextureSizeRatio!==void 0?this.layer._options.blurTextureSizeRatio||.1:void 0;l!==void 0&&(e.width=Math.floor(e.width*l)||1,e.height=Math.floor(e.height*l)||1);const c=this._onBeforeBlurTask?.record(),u=[];for(let p=0;p<this._blurX.length;p++){const m=this._frameGraph.textureManager.createRenderTargetTexture(this._blurX[p].name,t);this._blurX[p].sourceTexture=p===0?this._objectRendererForLayer.outputTexture:this._blurY[p-1].outputTexture,this._blurX[p].sourceSamplingMode=2,this._blurX[p].targetTexture=m,u.push(this._blurX[p].record(!0));const A=this._frameGraph.textureManager.createRenderTargetTexture(this._blurY[p].name,t);this._blurY[p].sourceTexture=this._blurX[p].outputTexture,this._blurY[p].sourceSamplingMode=2,this._blurY[p].targetTexture=A,u.push(this._blurY[p].record(!0)),e.width=e.width>>1,e.height=e.height>>1}const f=this._onAfterBlurTask?.record();this.objectRendererTask.objectRenderer.onBeforeRenderObservable.remove(this._onBeforeObservableObserver),this._onBeforeObservableObserver=this.objectRendererTask.objectRenderer.onBeforeRenderObservable.add(()=>{const p=this.layer.shouldRender();n.disabled=!p,o.disabled=!p,c&&(c.disabled=!p);for(let m=0;m<u.length;m++)u[m].disabled=!p;f&&(f.disabled=!p),p&&this.layer.needStencil()&&(this._engine.setStencilBuffer(!0),this._engine.setStencilFunctionReference(1))}),this.objectRendererTask.objectRenderer.onAfterRenderObservable.remove(this._onAfterObservableObserver),this._onAfterObservableObserver=this.objectRendererTask.objectRenderer.onAfterRenderObservable.add(()=>{this.layer.shouldRender()&&this.layer.needStencil()&&this._engine.setStencilBuffer(!1)}),this.layer.bindTexturesForCompose=void 0,this._clearAfterRenderingGroupObserver();const d=this._frameGraph.addRenderPass(this.name);for(let p=0;p<this._blurY.length;p++)d.addDependencies(this._blurY[p].outputTexture);d.setRenderTarget(this.outputTexture),this._setRenderTargetDepth&&d.setRenderTargetDepth(this.objectRendererTask.depthTexture),d.setInitializeFunc(p=>{this.layer.bindTexturesForCompose=m=>{for(let A=0;A<this._blurY.length;A++)p.bindTextureHandle(m,`textureSampler${A>0?A+1:""}`,this._blurY[A].outputTexture)},this.layer._options.renderingGroupId!==-1&&(this._onAfterRenderingGroupObserver=this._scene.onAfterRenderingGroupObservable.add(m=>{!this.layer.shouldRender()||m.renderingGroupId!==this.layer._options.renderingGroupId||m.renderingManager!==this.objectRendererTask.objectRenderer.renderingManager||(this._objectRendererForLayer.objectList=this.objectRendererTask.objectList,p.saveDepthStates(),p.setDepthStates(!1,!1),p._applyRenderTarget(),this.layer.compose(),p.restoreDepthStates())}))}),d.setExecuteFunc(p=>{p.setTextureSamplingMode(this._blurY[this._blurY.length-1].targetTexture,2),this.layer._options.renderingGroupId===-1&&this.layer.shouldRender()&&(this._objectRendererForLayer.objectList=this.objectRendererTask.objectList,p.setDepthStates(!1,!1),p._applyRenderTarget(),this.layer.compose())});const g=this._frameGraph.addRenderPass(this.name+"_disabled",!0);g.setRenderTarget(this.outputTexture),this._setRenderTargetDepth&&g.setRenderTargetDepth(this.objectRendererTask.depthTexture),g.setExecuteFunc(p=>{})}_clearAfterRenderingGroupObserver(){this._scene.onAfterRenderingGroupObservable.remove(this._onAfterRenderingGroupObserver),this._onAfterRenderingGroupObserver=null}dispose(){this._clearAfterRenderingGroupObserver(),this._clearLayerTextures.dispose(),this._objectRendererForLayer.dispose(),this._onBeforeBlurTask?.dispose(),this._onAfterBlurTask?.dispose(),this.layer.dis
62pose();for(let e=0;e<this._blurX.length;e++)this._blurX[e].dispose(),this._blurY[e].dispose();super.dispose()}}class ht{getRenderCamera(e){if(this._renderCamera)return this._renderCamera;{let t;return this.originalScene.activeCameras&&this.originalScene.activeCameras.length>1?t=this.originalScene.activeCameras[this.originalScene.activeCameras.length-1]:t=this.originalScene.activeCamera,e&&t&&t.isRigCamera?t.rigParent:t}}setRenderCamera(e){this._renderCamera=e}_getSharedGizmoLight(){return this._sharedGizmoLight||(this._sharedGizmoLight=new Ss("shared gizmo light",new _(0,1,0),this.utilityLayerScene),this._sharedGizmoLight.intensity=2,this._sharedGizmoLight.groundColor=q.Gray()),this._sharedGizmoLight}static get DefaultUtilityLayer(){return ht._DefaultUtilityLayer==null?ht._CreateDefaultUtilityLayerFromScene(Te.LastCreatedScene):ht._DefaultUtilityLayer}static _CreateDefaultUtilityLayerFromScene(e){return ht._DefaultUtilityLayer=new ht(e),ht._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(()=>{ht._DefaultUtilityLayer=null}),ht._DefaultUtilityLayer}static get DefaultKeepDepthUtilityLayer(){return ht._DefaultKeepDepthUtilityLayer==null&&(ht._DefaultKeepDepthUtilityLayer=new ht(Te.LastCreatedScene),ht._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,ht._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(()=>{ht._DefaultKeepDepthUtilityLayer=null})),ht._DefaultKeepDepthUtilityLayer}constructor(e,t=!0,i=!1){this.originalScene=e,this.handleEvents=t,this._pointerCaptures={},this._lastPointerEvents={},this._sharedGizmoLight=null,this._renderCamera=null,this.pickUtilitySceneFirst=!0,this.shouldRender=!0,this.onlyCheckPointerDownEvents=!0,this.processAllEvents=!1,this.pickingEnabled=!0,this.onPointerOutObservable=new O,this.utilityLayerScene=new tt(e.getEngine(),{virtual:!0,useFloatingOrigin:e.floatingOriginMode}),this.utilityLayerScene.useRightHandedSystem=e.useRightHandedSystem,this.utilityLayerScene._allowPostProcessClearColor=!1,this.utilityLayerScene.postProcessesEnabled=!1,this.utilityLayerScene.detachControl(),t&&(this._originalPointerObserver=e.onPrePointerObservable.add(s=>{if(!this.utilityLayerScene.activeCamera||!this.pickingEnabled||!this.processAllEvents&&s.type!==te.POINTERMOVE&&s.type!==te.POINTERUP&&s.type!==te.POINTERDOWN&&s.type!==te.POINTERDOUBLETAP)return;this.utilityLayerScene.pointerX=e.pointerX,this.utilityLayerScene.pointerY=e.pointerY;const r=s.event;if(e.isPointerCaptured(r.pointerId)){this._pointerCaptures[r.pointerId]=!1;return}const n=h=>{let l=null;if(s.nearInteractionPickingInfo)s.nearInteractionPickingInfo.pickedMesh.getScene()==h?l=s.nearInteractionPickingInfo:l=new ms;else if(h!==this.utilityLayerScene&&s.originalPickingInfo)l=s.originalPickingInfo;else{let c=null;this._renderCamera&&(c=h._activeCamera,h._activeCamera=this._renderCamera,s.ray=null),l=s.ray?h.pickWithRay(s.ray):h.pick(e.pointerX,e.pointerY),c&&(h._activeCamera=c)}return l},o=n(this.utilityLayerScene);if(!s.ray&&o&&(s.ray=o.ray),s.originalPickingInfo?.aimTransform&&o&&(o.aimTransform=s.originalPickingInfo.aimTransform,o.gripTransform=s.originalPickingInfo.gripTransform),this.utilityLayerScene.onPrePointerObservable.notifyObservers(s),this.onlyCheckPointerDownEvents&&s.type!=te.POINTERDOWN){s.skipOnPointerObservable||this.utilityLayerScene.onPointerObservable.notifyObservers(new kt(s.type,s.event,o),s.type),s.type===te.POINTERUP&&this._pointerCaptures[r.pointerId]&&(this._pointerCaptures[r.pointerId]=!1);return}if(this.utilityLayerScene.autoClearDepthAndStencil||this.pickUtilitySceneFirst)o&&o.hit&&(s.skipOnPointerObservable||this.utilityLayerScene.onPointerObservable.notifyObservers(new kt(s.type,s.event,o),s.type),s.skipOnPointerObservable=!0);else{const h=n(e),l=s.event;h&&o&&(o.distance===0&&h.pickedMesh?this.mainSceneTrackerPredicate&&this.mainSceneTrackerPredicate(h.pickedMesh)?(this._notifyObservers(s,h,l),s.skipOnPointerObservable=!0):s.type===te.POINTERDOWN?(this._pointerCaptures[l.pointerId]=!0,this._notifyObservers(s,h,l)):(s.type===te.POINTERMOVE||s.type===te.POINTERUP)&&(this._lastPointerEvents[l.pointerId]&&(this.onPointerOutObservable.notifyObservers(l.pointerId),delete this._lastPointerEvents[l.pointerId]),this._notifyObservers(s,h,l)):!this._pointerCaptures[l.pointerId]&&(o.distance<h.distance||h.distance===0)?(this._notifyObservers(s,o,l),s.skipOnPointerObservable||(s.skipOnPointerObservable=o.distance>0)):!this._pointerCaptures[l.pointerId]&&o.distance>=h.distance&&(this.mainSceneTrackerPredicate&&this.mainSceneTrackerPredicate(h.pickedMesh)?(this._notifyObservers(s,h,l),s.skipOnPointerObservable=!0):((s.type===te.POINTERMOVE||s.type===te.POINTERUP)&&this._lastPointerEvents[l.pointerId]&&(this.onPointerOutObservable.notifyObservers(l.pointerId),delete this._lastPointerEvents[l.pointerId]),this._notifyObservers(s,o,l))),s.type===te.POINTERUP&&this._pointerCaptures[l.pointerId]&&(this._pointerCaptures[l.pointerId]=!1))}}),this._originalPointerObserver&&e.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver)),this.utilityLayerScene.autoClear=!1,i||(this._afterRenderObserver=this.originalScene.onAfterRenderCameraObservable.add(s=>{this.shouldRender&&s==this.getRenderCamera()&&this.render()})),this._sceneDisposeObserver=this.originalScene.onDisposeObservable.add(()=>{this.dispose()}),this._updateCamera()}_notifyObservers(e,t,i){e.skipOnPointerObservable||(this.utilityLayerScene.onPointerObservable.notifyObservers(new kt(e.type,e.event,t),e.type),this._lastPointerEvents[i.pointerId]=!0)}
62render(){if(this._updateCamera(),this.utilityLayerScene.activeCamera){const e=this.utilityLayerScene.activeCamera.getScene(),t=this.utilityLayerScene.activeCamera;t._scene=this.utilityLayerScene,t.leftCamera&&(t.leftCamera._scene=this.utilityLayerScene),t.rightCamera&&(t.rightCamera._scene=this.utilityLayerScene),this.utilityLayerScene.render(!1),t._scene=e,t.leftCamera&&(t.leftCamera._scene=e),t.rightCamera&&(t.rightCamera._scene=e)}}dispose(){this.onPointerOutObservable.clear(),this._afterRenderObserver&&this.originalScene.onAfterCameraRenderObservable.remove(this._afterRenderObserver),this._sceneDisposeObserver&&this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver),this._originalPointerObserver&&this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver),this.utilityLayerScene.dispose()}_updateCamera(){this.utilityLayerScene.cameraToUseForPointers=this.getRenderCamera(),this.utilityLayerScene.activeCamera=this.getRenderCamera()}}ht._DefaultUtilityLayer=null;ht._DefaultKeepDepthUtilityLayer=null;class Qd extends or{get camera(){return this._camera}set camera(e){this._camera=e,this.layer.setRenderCamera(e),this.layer.utilityLayerScene.activeCamera=e}constructor(e,t,i,s=!0){super(e,t),this.layer=new ht(i,s,!0),this.layer.utilityLayerScene._useCurrentFrameBuffer=!0,this.outputTexture=this._frameGraph.textureManager.createDanglingHandle()}getClassName(){return"FrameGraphUtilityLayerRendererTask"}record(){if(!this.targetTexture||!this.camera)throw new Error(`FrameGraphUtilityLayerRendererTask "${this.name}": targetTexture and camera are required`);this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture,this.targetTexture);const e=this._frameGraph.addRenderPass(this.name);e.setRenderTarget(this.outputTexture),e.setExecuteFunc(i=>{i.render(this.layer)});const t=this._frameGraph.addRenderPass(this.name+"_disabled",!0);t.setRenderTarget(this.outputTexture),t.setExecuteFunc(i=>{})}
62dispose(){this.layer.dispose(),super.dispose()}}function Zd(a){const e=Wn.FindMainObjectRenderer(a);if(e)return e.camera;const t=a.tasks;for(let i=t.length-1;i>=0;i--){const s=t[i];if(s instanceof Qd)return s.camera}return null}function $d(a){const e=a.getTasksByType(Zh);let t=null;for(let i=e.length-1;i>=0;--i){const s=e[i].objectList.meshes;if(e[i].isMainObjectRenderer)return e[i];(!s||s.length>0)&&!t&&(t=e[i])}return t}function Jd(a,e=!0){const t=a.scene,i=new ht(t,e,!0);i.utilityLayerScene.activeCamera=t.activeCamera;let s=Wn.FindMainCamera(t.frameGraph);!s&&t.cameras.length>0&&(s=t.cameras[0]),s&&(i.setRenderCamera(s),i.utilityLayerScene.activeCamera=s);const r=t.onAfterRenderObservable.add(()=>{i.render()});return i.utilityLayerScene.onDisposeObservable.addOnce(()=>{t.onAfterRenderObservable.remove(r)}),i}const Wn={FindMainCamera:Zd,FindMainObjectRenderer:$d,CreateUtilityLayerRenderer:Jd};class ef{constructor(e,t){this._disableRenderingRefCount=0,this._currentPerformancePriorityMode=0,this._isEnabling=!1,this._enableCancelFunctions=new Map,this._disableCancelFunctions=new Map,this.showDebugLogs=!1,this._scene=e,this._engine=e.getEngine(),this._engine.isWebGPU&&(this._options={morphTargetsNumMaxInfluences:20,...t},this._engine.snapshotRenderingMode=1,this.fixMeshes(),this._onResizeObserver=this._engine.onResizeObservable.add(()=>{this._log("onResize","start"),this._fastSnapshotRenderingEnabled?(this.disableSnapshotRendering(),this.enableSnapshotRendering()):this._isEnabling&&(this._enableCancelFunctions.forEach(i=>i()),this._enableCancelFunctions.clear(),this._disableRenderingRefCount++,this.enableSnapshotRendering()),this._log("onResize","end")}),this._scene.onBeforeRenderObservable.add(()=>{if(!this._fastSnapshotRenderingEnabled)return;for(const s of e.skeletons)s.prepare(!0);for(const s of e.meshes)if(s.infiniteDistance&&s.transferToEffect(s.computeWorldMatrix(!0)),s.skeleton&&s.transferToEffect(s.computeWorldMatrix(!0)),s.getClassName()==="GaussianSplattingMesh"&&s._postToWorker(),s.morphTargetManager&&s.subMeshes)for(const r of s.subMeshes){const n=r._drawWrapper,o=n.effect;if(o){const h=n.drawContext.buffers.LeftOver,l=o._pipelineContext?.uniformBuffer;h&&l&&l.setDataBuffer(h)&&(s.morphTargetManager._bind(o),eh(s,o),l.update())}}let i=e.activeCamera;if(e.frameGraph&&(i=Wn.FindMainCamera(e.frameGraph)||i),e.spriteManagers&&i)for(const s of e.spriteManagers){const n=s.spriteRenderer;this._spriteRendererUpdateEffects(n._drawWrapperBase,n._drawWrapperDepth,i)}}))}get isReady(){return!this._isEnabling}enableSnapshotRendering(){if(!this._engine.isWebGPU||--this._disableRenderingRefCount>0)return;this._log("enableSnapshotRendering","called"),this._disableCancelFunctions.size>0&&this._log("enableSnapshotRendering",`cancelling ${this._disableCancelFunctions.size} "disable" callbacks`),this._disableCancelFunctions.forEach(t=>t()),this._disableCancelFunctions.clear(),this._isEnabling=!0,this._disableRenderingRefCount=0,this._currentPerformancePriorityMode=this._pendingCurrentPerformancePriorityMode??this._scene.performancePriority,this._pendingCurrentPerformancePriorityMode=void 0,this._scene.performancePriority=0;const e=()=>{this._enableCancelFunctions.delete(e);const t=this._engine.frameId+2;this._log("enableSnapshotRendering",`scene ready, add callbacks for frames ${t} and ${t+1}`),this._executeAtFrame(t,()=>{this._log("enableSnapshotRendering","callback #1, enable snapshot rendering at the engine level"),this._engine.snapshotRendering=!0}),this._executeAtFrame(t+1,()=>{this._log("enableSnapshotRendering","callback #2, signals that snapshot rendering helper is ready"),this._isEnabling=!1})};this._enableCancelFunctions.set(e,()=>this._scene.onReadyObservable.removeCallback(e)),this._scene.executeWhenReady(e)}disableSnapshotRendering(){if(this._engine.isWebGPU){if(this._log("disableSnapshotRendering","called"),this._disableRenderingRefCount===0&&(this._enableCancelFunctions.size>0&&this._log("disableSnapshotRendering",`cancelling ${this._enableCancelFunctions.size}
62 "enable" callbacks`),this._enableCancelFunctions.forEach(e=>e()),this._enableCancelFunctions.clear(),this._isEnabling=!1,this._scene.performancePriority=0,this._currentPerformancePriorityMode!==0)){this._log("disableSnapshotRendering",`makes sure that the scene is rendered once in BackwardCompatible mode (code: 0) before switching to mode ${this._currentPerformancePriorityMode}`),this._pendingCurrentPerformancePriorityMode=this._currentPerformancePriorityMode;const e=()=>{this._log("disableSnapshotRendering",`scene ready, add callback for frame ${this._engine.frameId+2}`),this._executeAtFrame(this._engine.frameId+2,()=>{this._log("disableSnapshotRendering",`switching to performance priority mode ${this._pendingCurrentPerformancePriorityMode}`),this._scene.performancePriority=this._pendingCurrentPerformancePriorityMode,this._pendingCurrentPerformancePriorityMode=void 0},"whenDisabled")};this._disableCancelFunctions.set(e,()=>this._scene.onReadyObservable.removeCallback(e)),this._scene.executeWhenReady(e)}this._engine.snapshotRendering=!1,this._disableRenderingRefCount++}}fixMeshes(e){if(this._engine.isWebGPU){e=e||this._scene.meshes;for(const t of e)t.ignoreCameraMaxZ=!1,t.morphTargetManager&&(t.morphTargetManager.numMaxInfluencers=Math.min(t.morphTargetManager.numTargets,this._options.morphTargetsNumMaxInfluences))}}updateMesh(e,t=!0){if(this._fastSnapshotRenderingEnabled){if(Array.isArray(e)){for(const i of e)(!t||!this._updateInstancedMesh(i))&&i.transferToEffect(i.computeWorldMatrix());return}(!t||!this._updateInstancedMesh(e))&&e.transferToEffect(e.computeWorldMatrix())}}_updateInstancedMesh(e){if(e.hasInstances){if(e.subMeshes){const t=e;for(const i of t.subMeshes){const s=t._getInstancesRenderList(i._id);t._updateInstancedBuffers(i,s,s.parent.instancesBufferSize,this._engine)}}return!0}else if(e.isAnInstance)return!0;return!1}updateMeshesForEffectLayer(e,t=!0){if(!this._engine.isWebGPU)return;const i=e instanceof jd?e.objectRendererForLayer.objectRenderer.renderPassId:e.mainTexture.renderPassId;t?this._onBeforeRenderObserverUpdateLayer=this._scene.onBeforeRenderObservable.add(()=>{this._updateMeshMatricesForRenderPassId(i)}):this._updateMeshMatricesForRenderPassId(i)}dispose(){this._engine.isWebGPU&&(this._scene.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._scene.onBeforeRenderObservable.remove(this._onBeforeRenderObserverUpdateLayer),this._engine.onResizeObservable.remove(this._onResizeObserver))}get _fastSnapshotRenderingEnabled(){return this._engine.snapshotRendering&&this._engine.snapshotRenderingMode===1}_updateMeshMatricesForRenderPassId(e){if(!this._fastSnapshotRenderingEnabled)return;const t=this._scene.objectRenderers.find(i=>i.renderPassId===e)?.activeCamera?.getTransformationMatrix()??this._scene.getTransformMatrix();for(let i=0;i<this._scene.meshes.length;++i){const s=this._scene.meshes[i];if(s.subMeshes)for(let r=0;r<s.subMeshes.length;++r){const n=s.subMeshes[r]._getDrawWrapper(e),o=n?.effect;if(o){const h=n.drawContext.buffers.LeftOver,l=o._pipelineContext?.uniformBuffer;h&&l&&l.setDataBuffer(h)&&(o.setMatrix("viewProjection",t),o.setMatrix("world",s.computeWorldMatrix()),l.update())}}}}_spriteRendererDirectMatrixUpdate(e,t){const i=e?.effect;if(i){const s=e.drawContext.buffers.LeftOver,r=i._pipelineContext?.uniformBuffer;s&&r&&r.setDataBuffer(s)&&(i.setMatrix("view",t.getViewMatrix()),i.setMatrix("projection",t.getProjectionMatrix()),r.update())}}_spriteRendererUpdateEffects(e,t,i){this._spriteRendererDirectMatrixUpdate(e,i),this._spriteRendererDirectMatrixUpdate(t,i)}_executeAtFrame(e,t,i="whenEnabled"){const s=()=>{this._engine.frameId>=e&&(this._engine.onEndFrameObservable.remove(r),i==="whenEnabled"?this._enableCancelFunctions.delete(s):this._disableCancelFunctions.delete(s),t())},r=this._engine.onEndFrameObservable.add(s);i==="whenEnabled"?this._enableCancelFunctions.set(s,()=>this._engine.onEndFrameObservable.remove(r)):this._disableCancelFunctions.set(s,()=>this._engine.onEndFrameObservable.remove(r))}_log(e,t){this.showDebugLogs&&w.Log(`[Frame: ${this._engine.frameId}] SnapshotRenderingHelper:${e} - ${t}`)}}function tf(a){const e=a.split("?")[0],t=e.lastIndexOf(".");return t>-1?e.substring(t).toLowerCase():""}const qa={name:"bvh",extensions:{".bvh":{isBinary:!1}}},gr="Z2xURg",ja={name:"gltf",extensions:{".gltf":{isBinary:!1,mimeType:"model/gltf+json"},".glb":{isBinary:!0,mimeType:"model/gltf-binary"}},canDirectLoad(a){return a.indexOf("asset")!==-1&&a.indexOf("version")!==-1||a.startsWith("data:base64,"+gr)||a.startsWith("data:;base64,"+gr)||a.startsWith("data:application/octet-stream;base64,"+gr)||a.startsWith("data:model/gltf-binary;base64,"+gr)}},Qa={name:"obj",extensions:".obj"},Za={name:"splat",extensions:{".splat":{isBinary:!0},".ply":{isBinary:!0},".spz":{isBinary:!0}
vendor: 23,045 bytes, line 62
62,".json":{isBinary:!1},".sog":{isBinary:!0}}},sf={name:"stl",extensions:{".stl":{isBinary:!0}}},Xn=new Map,P_=Xn;function ye(a,e,t){rf(a)&&w.Warn(`Extension with the name '${a}' already exists`),Xn.set(a,{isGLTFExtension:e,factory:t})}function rf(a){return Xn.delete(a)}function nf(){ye("EXT_lights_image_based",!0,async a=>{const{EXT_lights_image_based:e}=await G(async()=>{const{EXT_lights_image_based:t}=await import("./EXT_lights_image_based-SWSKZQUL.js");return{EXT_lights_image_based:t}},__vite__mapDeps([110,47,13,14,40,111,42,112,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("EXT_mesh_gpu_instancing",!0,async a=>{const{EXT_mesh_gpu_instancing:e}=await G(async()=>{const{EXT_mesh_gpu_instancing:t}=await import("./EXT_mesh_gpu_instancing-DeygevmA.js");return{EXT_mesh_gpu_instancing:t}},__vite__mapDeps([118,112,13,14,113,114,115,116,117,119]),import.meta.url);return new e(a)}),ye("EXT_meshopt_compression",!0,async a=>{const{EXT_meshopt_compression:e}=await G(async()=>{const{EXT_meshopt_compression:t}=await import("./EXT_meshopt_compression-Dq4crxvM.js");return{EXT_meshopt_compression:t}},__vite__mapDeps([120,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("EXT_texture_avif",!0,async a=>{const{EXT_texture_avif:e}=await G(async()=>{const{EXT_texture_avif:t}=await import("./EXT_texture_avif-C1YmES61.js");return{EXT_texture_avif:t}},__vite__mapDeps([121,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("EXT_texture_webp",!0,async a=>{const{EXT_texture_webp:e}=await G(async()=>{const{EXT_texture_webp:t}=await import("./EXT_texture_webp-ByAcJbqF.js");return{EXT_texture_webp:t}},__vite__mapDeps([122,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("ExtrasAsMetadata",!1,async a=>{const{ExtrasAsMetadata:e}=await G(async()=>{const{ExtrasAsMetadata:t}=await import("./ExtrasAsMetadata-CsKmPOtS.js");return{ExtrasAsMetadata:t}},__vite__mapDeps([123,13,14]),import.meta.url);return new e(a)}),ye("KHR_animation_pointer",!0,async a=>{const{KHR_animation_pointer:e}=await G(async()=>{const{KHR_animation_pointer:t}=await import("./KHR_animation_pointer-DzL2RBKN.js");return{KHR_animation_pointer:t}},__vite__mapDeps([124,117,125,13,14]),import.meta.url);return new e(a)}),ye("KHR_draco_mesh_compression",!0,async a=>{const{KHR_draco_mesh_compression:e}=await G(async()=>{const{KHR_draco_mesh_compression:t}=await import("./KHR_draco_mesh_compression-D6Jj04Y5.js");return{KHR_draco_mesh_compression:t}},__vite__mapDeps([126,51,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("KHR_interactivity",!0,async a=>{const{KHR_interactivity:e}=await G(async()=>{const{KHR_interactivity:t}=await import("./KHR_interactivity-CzsGlUw_.js").then(i=>i.K);return{KHR_interactivity:t}},__vite__mapDeps([127,13,14,128,117]),import.meta.url);return new e(a)}),ye("KHR_lights_punctual",!0,async a=>{const{KHR_lights:e}=await G(async()=>{const{KHR_lights:t}=await import("./KHR_lights_punctual-CFetRXv9.js");return{KHR_lights:t}},__vite__mapDeps([129,117,112,13,14,113,114,115,116]),import.meta.url);return new e(a)}),ye("EXT_lights_area",!0,async a=>{const{EXT_lights_area:e}=await G(async()=>{const{EXT_lights_area:t}=await import("./EXT_lights_area-B-tdX2Bs.js");return{EXT_lights_area:t}},__vite__mapDeps([130,115,112,13,14,113,114,116,117]),import.meta.url);return new e(a)}),ye("EXT_lights_ies",!0,async a=>{const{EXT_lights_ies:e}=await G(async()=>{const{EXT_lights_ies:t}=await import("./EXT_lights_ies-CWiJFv2A.js");return{EXT_lights_ies:t}},__vite__mapDeps([131,117,112,13,14,113,114,115,116]),import.meta.url);return new e(a)}),ye("KHR_materials_anisotropy",!0,async a=>{const{KHR_materials_anisotropy:e}=await G(async()=>{const{KHR_materials_anisotropy:t}=await import("./KHR_materials_anisotropy-DQIR3UeI.js");return{KHR_materials_anisotropy:t}},__vite__mapDeps([132,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("KHR_materials_clearcoat",!0,async a=>{const{KHR_materials_clearcoat:e}=await G(async()=>{const{KHR_materials_clearcoat:t}=await import("./KHR_materials_clearcoat-BoPbSJ8K.js");return{KHR_materials_clearcoat:t}},__vite__mapDeps([133,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("KHR_materials_diffuse_roughness",!0,async a=>{const{KHR_materials_diffuse_roughness:e}=await G(async()=>{const{KHR_materials_diffuse_roughness:t}=await import("./KHR_materials_diffuse_roughness-BG9pPBGI.js");return{KHR_materials_diffuse_roughness:t}},__vite__mapDeps([134,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("KHR_materials_diffuse_transmission",!0,async a=>{const{KHR_materials_diffuse_transmission:e}=await G(async()=>{const{KHR_materials_diffuse_transmission:t}=await import("./KHR_materials_diffuse_transmission-W7JqopJ7.js");return{KHR_materials_diffuse_transmission:t}},__vite__mapDeps([135,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("KHR_materials_dispersion",!0,async a=>{const{KHR_materials_dispersion:e}=await G(async()=>{const{KHR_materials_dispersion:t}=await import("./KHR_materials_dispersion-DQmto9Lx.js");return{KHR_materials_dispersion:t}},__vite__mapDeps([136,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("KHR_materials_emissive_strength",!0,async a=>{const{KHR_materials_emissive_strength:e}=await G(async()=>{const{KHR_materials_emissive_strength:t}=await import("./KHR_materials_emissive_strength-EM0O5p03.js");return{KHR_materials_emissive_strength:t}},__vite__mapDeps([137,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("KHR_materials_ior",!0,async a=>{const{KHR_materials_ior:e}=await G(async()=>{const{KHR_materials_ior:t}=await import("./KHR_materials_ior-BhpSkOUI.js");return{KHR_materials_ior:t}},__vite__mapDeps([138,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("KHR_materials_iridescence",!0,async a=>{const{KHR_materials_iridescence:e}=await G(async()=>{const{KHR_materials_iridescence:t}=await import("./KHR_materials_iridescence-DRoYVwZP.js");return{KHR_materials_iridescence:t}},__vite__mapDeps([139,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("KHR_materials_pbrSpecularGlossiness",!0,async a=>{const{KHR_materials_pbrSpecularGlossiness:e}=await G(async()=>{const{KHR_materials_pbrSpecularGlossiness:t}=await import("./KHR_materials_pbrSpecularGlossiness-j-GfRFkC.js");return{KHR_materials_pbrSpecularGlossiness:t}},__vite__mapDeps([140,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("KHR_materials_sheen",!0,async a=>{const{KHR_materials_sheen:e}=await G(async()=>{const{KHR_materials_sheen:t}=await import("./KHR_materials_sheen-Db4BcNFO.js");return{KHR_materials_sheen:t}},__vite__mapDeps([141,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("KHR_materials_specular",!0,async a=>{const{KHR_materials_specular:e}=await G(async()=>{const{KHR_materials_specular:t}=await import("./KHR_materials_specular-_n-vx6JM.js");return{KHR_materials_specular:t}},__vite__mapDeps([142,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("KHR_materials_transmission",!0,async a=>{const{KHR_materials_transmission:e}=await G(async()=>{const{KHR_materials_transmission:t}=await import("./KHR_materials_transmission-BeyehkfI.js");return{KHR_materials_transmission:t}},__vite__mapDeps([143,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("KHR_materials_unlit",!0,async a=>{const{KHR_materials_unlit:e}=await G(async()=>{const{KHR_materials_unlit:t}=await import("./KHR_materials_unlit-BkQ31cFN.js");return{KHR_materials_unlit:t}},__vite__mapDeps([144,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("KHR_materials_variants",!0,async a=>{const{KHR_materials_variants:e}=await G(async()=>{const{KHR_materials_variants:t}=await import("./KHR_materials_variants-Bb31meL3.js");return{KHR_materials_variants:t}},__vite__mapDeps([145,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("KHR_materials_volume",!0,async a=>{const{KHR_materials_volume:e}=await G(async()=>{const{KHR_materials_volume:t}=await import("./KHR_materials_volume-Ckg8jIwt.js");return{KHR_materials_volume:t}},__vite__mapDeps([146,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("KHR_mesh_quantization",!0,async a=>{const{KHR_mesh_quantization:e}=await G(async()=>{const{KHR_mesh_quantization:t}=await import("./KHR_mesh_quantization-DSlhHmH4.js");return{KHR_mesh_quantization:t}},__vite__mapDeps([147,13,14]),import.meta.url);return new e(a)}),ye("KHR_texture_basisu",!0,async a=>{const{KHR_texture_basisu:e}=await G(async()=>{const{KHR_texture_basisu:t}=await import("./KHR_texture_basisu-DfPjuahO.js");return{KHR_texture_basisu:t}},__vite__mapDeps([148,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("KHR_texture_transform",!0,async a=>{const{KHR_texture_transform:e}=await G(async()=>{const{KHR_texture_transform:t}=await import("./KHR_texture_transform-BSdB6Eup.js");return{KHR_texture_transform:t}},__vite__mapDeps([149,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("KHR_xmp_json_ld",!0,async a=>{const{KHR_xmp_json_ld:e}=await G(async()=>{const{KHR_xmp_json_ld:t}=await import("./KHR_xmp_json_ld-BPuUNdj6.js");return{KHR_xmp_json_ld:t}},__vite__mapDeps([150,13,14]),import.meta.url);return new e(a)}),ye("MSFT_audio_emitter",!0,async a=>{const{MSFT_audio_emitter:e}=await G(async()=>{const{MSFT_audio_emitter:t}=await import("./MSFT_audio_emitter-cYtkp1Tk.js");return{MSFT_audio_emitter:t}},__vite__mapDeps([151,152,153,154,13,14,155,156,157,158,159,112,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("MSFT_lod",!0,async a=>{const{MSFT_lod:e}=await G(async()=>{const{MSFT_lod:t}=await import("./MSFT_lod-DoZ681tI.js");return{MSFT_lod:t}},__vite__mapDeps([160,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("MSFT_minecraftMesh",!0,async a=>{const{MSFT_minecraftMesh:e}=await G(async()=>{const{MSFT_minecraftMesh:t}=await import("./MSFT_minecraftMesh-54Xw-YKx.js");return{MSFT_minecraftMesh:t}},__vite__mapDeps([161,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("MSFT_sRGBFactors",!0,async a=>{const{MSFT_sRGBFactors:e}=await G(async()=>{const{MSFT_sRGBFactors:t}=await import("./MSFT_sRGBFactors-DyM8-67K.js");return{MSFT_sRGBFactors:t}},__vite__mapDeps([162,112,13,14,113,114,115,116,117]),import.meta.url);return new e(a)}),ye("KHR_node_visibility",!0,async a=>{const{KHR_node_visibility:e}=await G(async()=>{const{KHR_node_visibility:t}=await import("./KHR_node_visibility-CdoAJ1QN.js");return{KHR_node_visibility:t}},__vite__mapDeps([163,117,13,14]),import.meta.url);return new e(a)}),ye("KHR_node_hoverability",!0,async a=>{const{KHR_node_hoverability:e}=await G(async()=>{const{KHR_node_hoverability:t}=await import("./KHR_node_hoverability-D1XQvctI.js");return{KHR_node_hoverability:t}},__vite__mapDeps([164,128,117,13,14]),import.meta.url);return new e(a)}),ye("KHR_node_selectability",!0,async a=>{const{KHR_node_selectability:e}=await G(async()=>{const{KHR_node_selectability:t}=await import("./KHR_node_selectability-57pQBFFc.js");return{KHR_node_selectability:t}},__vite__mapDeps([165,128,117,13,14]),import.meta.url);return new e(a)})}function af(){Ps({...qa,createPlugin:async a=>{const{BVHFileLoader:e}=await G(async()=>{const{BVHFileLoader:t}=await import("./bvhFileLoader-DpWcrqqc.js");return{BVHFileLoader:t}},__vite__mapDeps([166,116,113,114,115,13,14]),import.meta.url);return new e(a[qa.name])}}),Ps({...ja,createPlugin:async a=>{const{GLTFFileLoader:e}=await G(async()=>{const{GLTFFileLoader:t}=await import("./glTFLoader-BGOUmS5T.js");return{GLTFFileLoader:t}},__vite__mapDeps([112,13,14,113,114,115,116,117]),import.meta.url);return new e(a[ja.name])}}),nf(),Ps({...Qa,createPlugin:async a=>{const{OBJFileLoader:e}=await G(async()=>{const{OBJFileLoader:t}=await import("./objFileLoader-CocA2Eag.js");return{OBJFileLoader:t}},__vite__mapDeps([167,116,168,13,14]),import.meta.url);return new e(a[Qa.name])}}),Ps({...Za,createPlugin:async a=>{const{SPLATFileLoader:e}=await G(async()=>{const{SPLATFileLoader:t}=await import("./splatFileLoader-BmVJ6Kq_.js");return{SPLATFileLoader:t}},__vite__mapDeps([169,13,14,170,37,31,38,24,83,28,29,25,19,10,20,2,64,3,7,8,115,119,116,171,168]),import.meta.url);return new e(a[Za.name])}}),Ps({...sf,createPlugin:async()=>{const{STLFileLoader:a}=await G(async()=>{const{STLFileLoader:e}=await import("./stlFileLoader-C4XuwpP1.js");return{STLFileLoader:e}},__vite__mapDeps([172,116,168,13,14]),import.meta.url);return new a}})}const of=new Kd(()=>Promise.all([G(()=>import("./ssao2RenderingPipeline-eW2K8HQC.js"),__vite__mapDeps([173,174,175,13,14,37,93,25,26,88,27,24,28,89,176,115]),import.meta.url),G(()=>import("./prePassRendererSceneComponent-CQyfUu7e.js"),__vite__mapDeps([177,13,14,175,37,93,25,26,88,27,24,28,89]),import.meta.url),G(()=>import("./geometryBufferRendererSceneComponent-DkZpoIqp.js"),__vite__mapDeps([178,175,13,14,37,93,25,26,88,27,24,28,89]),import.meta.url),G(()=>Promise.resolve().then(()=>jh),void 0,import.meta.url),G(()=>import("./engine.multiRender-DNsfVgN_.js"),__vite__mapDeps([179,180,5,12,6,3,181,64,2,79,154,13,14]),import.meta.url)])),hf=["none","normal","high"],lf=["none","standard","aces","neutral"];function Jh(a){return lf.includes(a)}function cf(a){return hf.includes(a)}function cn(...a){for(const e of a)e?.throwIfAborted()}async function $a(a,e,t){t=t??tf(a);const i=await(async()=>{if(t===".hdr"){const{HDRCubeTexture:r}=await G(async()=>{const{HDRCubeTexture:n}=await import("./hdrCubeTexture-krlTyiqM.js");return{HDRCubeTexture:n}},__vite__mapDeps([182,13,14,183,115,49]),import.meta.url);return()=>new r(a,e,256,!1,!0,!1,!0,void 0,void 0,void 0,!0,!0)}else{const{CubeTexture:r}=await G(async()=>{const{CubeTexture:n}=await import("./cubeTexture-B_klqm5V.js");return{CubeTexture:n}},__vite__mapDeps([111,42,13,14]),import.meta.url);return()=>new r(a,e,null,!1,null,null,null,void 0,!0,t,!0)}})(),s=e.useDelayedTextureLoading;try{return e.useDelayedTextureLoading=!1,i()}finally{e.useDelayedTextureLoading=s}}function uf(a,e,t,i){const s=a.blockMaterialDirtyMechanism;a.blockMaterialDirtyMechanism=!0;try{const r=Xh("hdrSkyBox",{sideOrientation:ne.BACKSIDE},a),n=new _e("skyBox",a);return n.imageProcessingConfiguration=new ue,n.reflectionTexture=t,t.coordinatesMode=z.SKYBOX_MODE,n.reflectionBlur=i,r.material=n,r.isPickable=!1,r.infiniteDistance=!0,r.applyFog=!1,el(r,e),r}finally{a.blockMaterialDirtyMechanism=s}}function el(a,e){a?.scaling.setAll((e.maxZ-e.minZ)/2)}function df(a){return a.flatMap(e=>Wd(e.assetContainer.meshes,e.assetContainer.animationGroups[e.selectedAnimation]))}function ff(a){if(a.length===0)return null;const e=new _(Math.min(...a.map(r=>r.minimum.x)),Math.min(...a.map(r=>r.minimum.y)),Math.min(...a.map(r=>r.minimum.z))),t=new _(Math.max(...a.map(r=>r.maximum.x)),Math.max(...a.map(r=>r.maximum.y)),Math.max(...a.map(r=>r.maximum.z))),i=t.subtract(e),s=e.add(i.scale(.5));return{extents:{min:e.asArray(),max:t.asArray()},size:i.asArray(),center:s.asArray()}}function _f(a){const s=a.clone();return s.y>0&&(s.y*=-1),s.y>-.01&&(s.y=Math.min(s.y*10,-.05)),s}function pr(a){const e=df(a);return ff(e)}function $t(a){(async()=>{try{await a}catch(e){e instanceof Ot||w.Error(e)}})()}async function tl(a,e){await G(()=>import("./ray-gjj8VnBP.js"),__vite__mapDeps([171,13,14]),import.meta.url);const t=a.assetContainer.scene,i=e.getForwardRay(100,e.getWorldMatrix(),e.globalPosition),s=e.globalPosition.clone();let r=1e-4;const n=_.Zero(),o=t.pickWithRay(i,f=>a.assetContainer.meshes.includes(f));if(o&&o.hit)n.copyFrom(o.pickedPoint);else{const f=a.getWorldBounds(),d=f?f.center:[0,0,0],g=_.FromArray(d),p=i.direction.clone();n.copyFrom(s),r=_.Distance(s,g),p.scaleAndAddToRef(r,n)}const h=_.Zero();s.subtractToRef(n,h),o&&o.hit&&(r=h.length());const l=Eh(h),c=Ah(h.y,r),u=n.asArray();return{type:"world",position:u,normal:u,cameraOrbit:[l,c,r]}}const Je={clearColor:[0,0,0,0],autoSuspendRendering:!0,environmentConfig:{intensity:1,blur:.3,rotation:0},environmentLighting:"auto",environmentSkybox:"none",cameraAutoOrbit:{enabled:!1,delay:2e3,speed:.05},animationAutoPlay:!1,animationSpeed:1,shadowConfig:{quality:"none"},postProcessing:{toneMapping:"neutral",contrast:1,exposure:1,ssao:"auto"},useRightHandedSystem:!1},gf={lighting:!0,skybox:!0};class Kn{constructor(){this.screenPosition=[NaN,NaN],this.worldPosition=[NaN,NaN,NaN],this.visibility=NaN}}class Yn{constructor(e,t){this._engine=e,this._options=t,this.showDebugLogs=!1,this.onEnvironmentChanged=new O,this.onEnvironmentConfigurationChanged=new O,this.onEnvironmentError=new O,this.onShadowsConfigurationChanged=new O,this.onPostProcessingChanged=new O,this.onModelChanged=new O,this.onModelError=new O,this.onLoadingProgressChanged=new O,this.onCameraAutoOrbitChanged=new O,this.onSelectedAnimationChanged=new O,this.onAnimationSpeedChanged=new O,this.onIsAnimationPlayingChanged=new O,this.onAnimationProgressChanged=new O,this.onSelectedMaterialVariantChanged=new O,this.onHotSpotsChanged=new O,this.onCamerasAsHotSpotsChanged=new O,this._renderedLastFrame=null,this._sceneOptimizer=null,this._tempVectors=xi(4,_.Zero),this._meshDataCache=new Map,this._renderLoopController=null,this._loadedModelsBacking=[],this._activeModelBacking=null,this._environmentSkyboxMode="none",this._environmentLightingMode="none",this._skybox=null,this._skyboxBlur=this._options?.environmentConfig?.blur??Je.environmentConfig.blur,this._skyboxTexture=null,this._reflectionTexture=null,this._reflectionsIntensity=this._options?.environmentConfig?.intensity??Je.environmentConfig.intensity,this._reflectionsRotation=this._options?.environmentConfig?.rotation??Je.environmentConfig.rotation,this._light=null,this._ssaoOption=this._options?.postProcessing?.ssao??Je.postProcessing.ssao,this._ssaoPipeline=null,this._autoSuspendRendering=this._options?.autoSuspendRendering??Je.autoSuspendRendering,this._sceneMutated=!1,this._suspendRenderCount=0,this._isDisposed=!1,this._loadModelLock=new Rr,this._loadModelAbortController=null,this._loadEnvironmentLock=new Rr,this._loadEnvironmentAbortController=null,this._camerasAsHotSpotsAbortController=null,this._updateShadowsLock=new Rr,this._shadowsAbortController=null,this._loadOperations=new Set,this._activeAnimationObservers=[],this._animationSpeed=this._options?.animationSpeed??Je.animationSpeed,this._camerasAsHotSpots=!1,this._hotSpots=this._options?.hotSpots??{},this._shadowQuality=this._options?.shadowConfig?.quality??Je.shadowConfig.quality,this._shadowState={},this._defaultHardwareScalingLevel=this._lastHardwareScalingLevel=this._engine.getHardwareScalingLevel();{const s=new tt(this._engine);s.useRightHandedSystem=this._options?.useRightHandedSystem??Je.useRightHandedSystem;const r=new j("default Material",s);r.albedoColor=new q(.4,.4,.4),r.metallic=0,r.roughness=1,r.baseDiffuseRoughness=1,r.microSurface=0,s.defaultMaterial=r,this._toneMappingEnabled=s.imageProcessingConfiguration.toneMappingEnabled,this._toneMappingType=s.imageProcessingConfiguration.toneMappingType,this._contrast=s.imageProcessingConfiguration.contrast,this._exposure=s.imageProcessingConfiguration.exposure,this._imageProcessingConfigurationObserver=s.imageProcessingConfiguration.onUpdateParameters.add(()=>{let o=!1;this._toneMappingEnabled!==s.imageProcessingConfiguration.toneMappingEnabled&&(this._toneMappingEnabled=s.imageProcessingConfiguration.toneMappingEnabled,o=!0),this._toneMappingType!==s.imageProcessingConfiguration.toneMappingType&&(this._toneMappingType=s.imageProcessingConfiguration.toneMappingType,o=!0),this._contrast!==s.imageProcessingConfiguration.contrast&&(this._contrast=s.imageProcessingConfiguration.contrast,o=!0),this._exposure!==s.imageProcessingConfiguration.exposure&&(this._exposure=s.imageProcessingConfiguration.exposure,o=!0),o&&this.onPostProcessingChanged.notifyObservers()});const n=new Ie("Viewer Default Camera",0,0,1,_.Zero(),s);n.useInputToRestoreState=!1,n.useAutoRotationBehavior=!0,n.onViewMatrixChangedObservable.add(()=>{this._markSceneMutated()}),s.onClearColorChangedObservable.add(()=>{this._markSceneMutated()}),s.onPointerObservable.add(async o=>{const h=await this._pick(o.event.offsetX,o.event.offsetY);if(h?.pickedPoint){const l=h.pickedPoint.subtract(n.position).dot(n.getForwardRay().direction);n.target=n.position.add(n.getForwardRay().direction.scale(l)),n.radius=l,n.interpolateTo(void 0,void 0,void 0,h.pickedPoint)}else this.resetCamera(!0)},te.POINTERDOUBLETAP),s.onNewCameraAddedObservable.add(o=>{this.camerasAsHotSpots&&$t(this._addCameraHotSpot(o,this._camerasAsHotSpotsAbortController?.signal))}),s.onCameraRemovedObservable.add(o=>{this._removeCameraHotSpot(o)}),this._scene=s,this._camera=n}this._scene.skipFrustumClipping=!0,this._scene.skipPointerDownPicking=!0,this._scene.skipPointerUpPicking=!0,this._scene.skipPointerMovePicking=!0,this._snapshotHelper=new ef(this._scene,{morphTargetsNumMaxInfluences:30}),this._beforeRenderObserver=this._scene.onBeforeRenderObservable.add(()=>{this._snapshotHelper.updateMesh(this._scene.meshes)}),this._camera.attachControl(),this._autoRotationBehavior=this._camera.getBehaviorByName("AutoRotation"),this._reset(!1,"camera"),$t(this.resetEnvironment()),this._beginRendering();const i=this;this._options?.onInitialized?.({scene:i._scene,camera:i._camera,get model(){return i._activeModel??null},suspendRendering:()=>this._suspendRendering(),markSceneMutated:()=>this._markSceneMutated(),pick:async(s,r)=>await this._pick(s,r)}),this._reset(!1,"source","environment","post-processing")}get cameraAutoOrbit(){return{enabled:this._camera.behaviors.includes(this._autoRotationBehavior),speed:this._autoRotationBehavior.idleRotationSpeed,delay:this._autoRotationBehavior.idleRotationWaitTime}}set cameraAutoOrbit(e){e.enabled!==void 0&&e.enabled!==this.cameraAutoOrbit.enabled&&(e.enabled?this._camera.addBehavior(this._autoRotationBehavior):this._camera.removeBehavior(this._autoRotationBehavior)),e.delay!==void 0&&(this._autoRotationBehavior.idleRotationWaitTime=e.delay),e.speed!==void 0&&(this._autoRotationBehavior.idleRotationSpeed=e.speed),this.onCameraAutoOrbitChanged.notifyObservers()}get environmentConfig(){return{intensity:this._reflectionsIntensity,blur:this._skyboxBlur,rotation:this._reflectionsRotation}}set environmentConfig(e){e.blur!==void 0&&this._changeSkyboxBlur(e.blur),e.intensity!==void 0&&(this._changeEnvironmentIntensity(e.intensity),this._changeShadowLightIntensity()),e.rotation!==void 0&&(this._changeEnvironmentRotation(e.rotation),this._rotateShadowLightWithEnvironment()),this.onEnvironmentConfigurationChanged.notifyObservers()}get shadowConfig(){return{quality:this._shadowQuality}}async updateShadows(e){e.quality&&this._shadowQuality!==e.quality&&(this._shadowQuality=e.quality,await this._updateShadows(),this.onShadowsConfigurationChanged.notifyObservers())}_changeSkyboxBlur(e){if(e!==this._skyboxBlur&&(this._skyboxBlur=e,this._skybox)
62){const t=this._skybox.material;t instanceof _e&&(this._snapshotHelper.disableSnapshotRendering(),t.reflectionBlur=this._skyboxBlur,this._snapshotHelper.enableSnapshotRendering(),this._markSceneMutated())}}_changeEnvironmentRotation(e){e!==this._reflectionsRotation&&(this._reflectionsRotation=e,this._snapshotHelper.disableSnapshotRendering(),this._skyboxTexture&&(this._skyboxTexture.rotationY=this._reflectionsRotation),this._reflectionTexture&&(this._reflectionTexture.rotationY=this._reflectionsRotation),this._snapshotHelper.enableSnapshotRendering(),this._markSceneMutated())}_changeEnvironmentIntensity(e){e!==this._reflectionsIntensity&&(this._reflectionsIntensity=e,this._snapshotHelper.disableSnapshotRendering(),this._skyboxTexture&&(this._skyboxTexture.level=this._reflectionsIntensity),this._reflectionTexture&&(this._reflectionTexture.level=this._reflectionsIntensity),this._snapshotHelper.enableSnapshotRendering(),this._markSceneMutated())}_updateAutoClear(){this._scene.autoClear=!0,this._markSceneMutated()}get postProcessing(){let e="none";if(this._toneMappingEnabled)switch(this._toneMappingType){case ue.TONEMAPPING_STANDARD:e="standard";break;case ue.TONEMAPPING_ACES:e="aces";break;case ue.TONEMAPPING_KHR_PBR_NEUTRAL:e="neutral";break}return{toneMapping:e,contrast:this._contrast,exposure:this._exposure,ssao:this._ssaoOption}}set postProcessing(e){if(this._snapshotHelper.disableSnapshotRendering(),e.toneMapping!==void 0)if(e.toneMapping==="none")this._scene.imageProcessingConfiguration.toneMappingEnabled=!1;else{switch(e.toneMapping){case"standard":this._scene.imageProcessingConfiguration.toneMappingType=ue.TONEMAPPING_STANDARD;break;case"aces":this._scene.imageProcessingConfiguration.toneMappingType=ue.TONEMAPPING_ACES;break;case"neutral":this._scene.imageProcessingConfiguration.toneMappingType=ue.TONEMAPPING_KHR_PBR_NEUTRAL;break}this._scene.imageProcessingConfiguration.toneMappingEnabled=!0}e.contrast!==void 0&&(this._scene.imageProcessingConfiguration.contrast=e.contrast),e.exposure!==void 0&&(this._scene.imageProcessingConfiguration.exposure=e.exposure),e.ssao&&this._ssaoOption!==e.ssao&&(this._ssaoOption=e.ssao,this._updateSSAOPipeline()),this._scene.imageProcessingConfiguration.isEnabled=this._toneMappingEnabled||this._contrast!==1||this._exposure!==1||this._ssaoPipeline!==null,this._snapshotHelper.enableSnapshotRendering(),this._markSceneMutated()}get loadingProgress(){if(this._loadOperations.size>0){let e=0;for(const t of this._loadOperations){if(t.progress==null)return!0;e+=t.progress}return e/this._loadOperations.size}return!1}get _loadedModels(){return this._loadedModelsBacking}get _activeModel(){return this._activeModelBacking}_setActiveModel(...e){const[t,i]=e;t!==this._activeModelBacking&&(this._activeModelBacking=t,this._updateLight(),$t(this._updateShadows()),this._updateSSAOPipeline(),this._applyAnimationSpeed(),this._selectAnimation(0,!1),this.onSelectedMaterialVariantChanged.notifyObservers(),this._reframeCamera(!0,t?[t]:void 0),this.onModelChanged.notifyObservers(i?.source??null))}async _enableSSAOPipeline(e){const t=this._loadedModels.length>0,i=this._loadedModels.some(s=>s.assetContainer.materials.length>0);if(e==="enabled"||e==="auto"&&t&&!i){const[{SSAO2RenderingPipeline:s}]=await of.value;this._ssaoPipeline||(this._scene.postProcessRenderPipelineManager.onNewPipelineAddedObservable.add(o=>{o.name==="ssao"&&this.onPostProcessingChanged.notifyObservers()}),this._scene.postProcessRenderPipelineManager.onPipelineRemovedObservable.add(o=>{o.name==="ssao"&&this.onPostProcessingChanged.notifyObservers()}));const r={ssaoRatio:1,blurRatio:1};this._ssaoPipeline=new s("ssao",this._scene,r);const n=this._getWorldBounds(this._loadedModels);if(this._ssaoPipeline&&n){const o=_.FromArray(n.size).length();this._ssaoPipeline.expensiveBlur=!0,this._ssaoPipeline.maxZ=o*2;const h=50;this._ssaoPipeline.radius=be(Ii(1,5,be((o-1)/h,0,1)),1,5),this._ssaoPipeline.totalStrength=be(Ii(.3,1,be((o-1)/h,0,1)),.3,1),this._ssaoPipeline.samples=Math.round(be(Ii(8,32,be((o-1)/h,0,1)),8,32))}this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline("ssao",this._camera)}}_disableSSAOPipeline(){this._ssaoPipeline&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline("ssao",this._camera),this._scene.postProcessRenderPipelineManager.removePipeline("ssao"),this._ssaoPipeline?.dispose(),this._ssaoPipeline=null)}_updateSSAOPipeline(){!this._ssaoPipeline&&(this._ssaoOption==="auto"||this._ssaoOption==="enabled")?$t(this._enableSSAOPipeline(this._ssaoOption)):this._ssaoOption==="disabled"&&this._disableSSAOPipeline()}get animations(){return this._activeModel?.assetContainer.animationGroups.map(e=>e.name)??[]}get selectedAnimation(){return this._activeModel?.selectedAnimation??-1}set selectedAnimation(e){this._selectAnimation(e,this._loadOperations.size===0)}_selectAnimation(e,t=!0){e=Math.round(be(e,-1,this.animations.length-1)),this._activeModel&&e!==this._activeModel.selectedAnimation&&(this._activeAnimationObservers.forEac
62h(i=>i.remove()),this._activeAnimationObservers=[],this._activeModel.selectedAnimation=e,this._activeAnimation&&(this._activeAnimationObservers=[this._activeAnimation.onAnimationGroupPlayObservable.add(()=>{this.onIsAnimationPlayingChanged.notifyObservers()}),this._activeAnimation.onAnimationGroupPauseObservable.add(()=>{this.onIsAnimationPlayingChanged.notifyObservers()}),this._activeAnimation.onAnimationGroupEndObservable.add(()=>{this.onIsAnimationPlayingChanged.notifyObservers(),this.onAnimationProgressChanged.notifyObservers()})],this._reframeCamera(t)),this.onSelectedAnimationChanged.notifyObservers(),this.onAnimationProgressChanged.notifyObservers())}get isAnimationPlaying(){return this._activeModelBacking?._animationPlaying()??!1}get animationSpeed(){return this._animationSpeed}set animationSpeed(e){this._animationSpeed=e,this._applyAnimationSpeed(),this.onAnimationSpeedChanged.notifyObservers()}get animationProgress(){return this._activeAnimation?this._activeAnimation.getCurrentFrame()/(this._activeAnimation.to-this._activeAnimation.from):0}set animationProgress(e){this._activeAnimation&&(this._activeAnimation.goToFrame(e*(this._activeAnimation.to-this._activeAnimation.from)),this.onAnimationProgressChanged.notifyObservers(),this._autoRotationBehavior.resetLastInteractionTime(),this._markSceneMutated())}get _activeAnimation(){return this._activeModel?.assetContainer.animationGroups[this._activeModel?.selectedAnimation]??null}get materialVariants(){return this._activeModel?.materialVariantsController?.variants??[]}get selectedMaterialVariant(){return this._activeModel?.selectedMaterialVariant??null}set selectedMaterialVariant(e){this._activeModel&&e&&(this._activeModel.selectedMaterialVariant=e)}get hotSpots(){return this._hotSpots}set hotSpots(e){this._hotSpots=e,this.onHotSpotsChanged.notifyObservers()}get camerasAsHotSpots(){return this._camerasAsHotSpots}set camerasAsHotSpots(e){this._camerasAsHotSpots!==e&&(this._camerasAsHotSpots=e,this._toggleCamerasAsHotSpots(),this.onCamerasAsHotSpotsChanged.notifyObservers())}_beginLoadOperation(){const e=this;let t=null;const i={get progress(){return t},set progress(s){t=s,e.onLoadingProgressChanged.notifyObservers()},dispose:()=>{e._loadOperations.delete(i),e.onLoadingProgressChanged.notifyObservers()}};return this._loadOperations.add(i),this.onLoadingProgressChanged.notifyObservers(),i}async loadModel(e,t,i){await this._updateModel(e,t,i)}async resetModel(e){await this._updateModel(void 0,void 0,e)}async _loadModel(e,t,i){this._throwIfDisposedOrAborted(i);const s=this._beginLoadOperation(),r=t?.onProgress,n=u=>{r?.(u),s.progress=u.lengthComputable?u.loaded/u.total:null};delete t?.onProgress;let o=null;const h=t?.pluginOptions?.gltf?.extensionOptions?.KHR_materials_variants?.onLoaded,l=u=>{h?.(u),o=u};delete t?.pluginOptions?.gltf?.extensionOptions?.KHR_materials_variants?.onLoaded,t=Kh({onProgress:n,pluginOptions:{gltf:{transparencyAsCoverage:!0,extensionOptions:{KHR_materials_variants:{onLoaded:l}}}}},t??{}),this._snapshotHelper.disableSnapshotRendering();try{const u=await Ku(e,this._scene,t);Xd(u.meshes.filter(m=>m instanceof ne)),u.animationGroups.forEach(m=>{m.start(!0,this.animationSpeed),m.pause()}),u.addAllToScene(),this._snapshotHelper.fixMeshes(u.meshes);let f=-1;const d=[],g=this,p={assetContainer:u,materialVariantsController:o,_animationPlaying:()=>u.animationGroups[f]?.isPlaying??!1,_shouldRender:()=>{const m=p?.assetContainer.animationGroups.some(A=>A.animatables.some(E=>E.animationStarted));return p._animationPlaying()||m},getHotSpotToRef:(m,A)=>this._getHotSpotToRef(u,m,A),dispose:()=>{this._snapshotHelper.disableSnapshotRendering(),u.meshes.forEach(A=>this._meshDataCache.delete(A)),u.dispose();const m=this._loadedModelsBacking.indexOf(p);m!==-1&&(this._loadedModelsBacking.splice(m,1),p===this._activeModel&&this._setActiveModel(null)),this._snapshotHelper.enableSnapshotRendering(),this._markSceneMutated()},getWorldBounds:(m=f)=>{let A=d[m];return A||(A=pr([p]),A&&(d[m]=A)),A},resetWorldBounds:()=>{d.length=0},get selectedAnimation(){return f},set selectedAnimation(m){let A=u.animationGroups[f];const E=A?.isPlaying??!1;A&&(A.pause(),A.goToFrame(0)),f=m,A=u.animationGroups[f],$t(g._updateShadows()),A&&(A.goToFrame(0),A.play(!0),E||A.pause())},makeActive:m=>{this._setActiveModel(p,m)},set selectedMaterialVariant(m){if(o){let A=m;A||(A=o.variants[0]),A!==o.selectedVariant&&o.variants.includes(A)&&(g._snapshotHelper.disableSnapshotRendering(),o.selectedVariant=A,g._snapshotHelper.enableSnapshotRendering(),g._markSceneMutated(),g.onSelectedMaterialVariantChanged.notifyObservers())}},get selectedMaterialVariant(){return o?o.selectedVariant:null}};return this._loadedModelsBacking.push(p),p}catch(u){throw this.onModelError.notifyObservers(u),u}finally{s.dispose(),this._snapshotHelper.enableSnapshotRendering(),this._markSceneMutated()}}async _updateModel(e,t,i){this._throwIfDisposedOrAborted(i),this._loadModelAbortController?.abort(new Ot("New model is being loaded before previous model finished loading."));const s=this._loadModelAbortController=new AbortController;await this._loadModelLock.lockAsync(async()=>{cn(i,s.signal),this._activeModel?.dispose(),this._activeModelBacking=null,this.selectedAnimation=-1,e&&((await this._loadModel(e,t,s.signal)).makeActive(Object.assign({source:e,interpolateCamera:!1},t)),this._reset(!1,"camera","animation","material-variant"))});const r=this._loadedModels.some(o=>o.assetContainer.materials.some(h=>h instanceof j)),n=this._loadedModels.some(o=>o.assetContainer.meshes.some(h=>!h.material));!this._scene.environmentTexture&&(r||n)&&await this.resetEnvironment({lighting:!0},i),this._startSceneOptimizer(!0)}async _updateShadows(){this._shadowsAbortController?.abort(new Ot("Shadows quality is being change before previous shadows finished initializing."));const e=this._shadowsAbortController=new AbortController;await this._updateShadowsLock.lockAsync(async()=>{this._shadowQuality==="none"?this._disposeShadows():(this._reflectionTexture||await this.loadEnvironment("auto",{lighting:!0,skybox:!1}),this._shadowQuality==="normal"?await this._updateShadowMap(e.signal):this._shadowQuality==="high"&&await this._updateEnvShadow(e.signal))})}_changeShadowLightIntensity(){this._shadowState.high&&(this._shadowState.high.pipeline.resetAccumulation(),this._startIblShadowsRenderTime())}_rotateShadowLightWithEnvironment(){this._shadowQuality==="normal"&&this._shadowState.normal?this._shadowState.normal.light&&this._shadowState.normal.refreshLightPositionDirection(this._reflectionsRotation):this._shadowQuality==="high"&&this._shadowState.high&&(this._shadowState.high.pipeline?.resetAccumulation(),this._startIblShadowsRenderTime())}_startIblShadowsRenderTime(){if(this._shadowState.high){this._shadowState.high.renderTimer!=null?clearTimeout(this._shadowState.high.renderTimer):this._snapshotHelper.disableSnapshotRendering(),this._shadowState.high.shouldRender=!0;const e=()=>{this._shadowState.high&&(this._shadowState.high.shouldRender=!1,this._shadowState.high.renderTimer=null),this._snapshotHelper.enableSnapshotRendering()};this._shadowState.high.renderTimer=setTimeout(e,this._shadowState.high.pipeline.shadowRemanence*4e3)}}async _updateEnvShadow(e){const[{ShaderMaterial:t},{ShaderLanguage:i},{CreateDisc:s},{IblShadowsRenderPipeline:r}]=await Promise.all([G(()=>import("./shaderMaterial-CiyA1esq.js"),__vite__mapDeps([170,13,14]),import.meta.url),G(()=>import("./shaderLanguage-BjwqUAVi.js"),[],import.meta.url),G(()=>import("./discBuilder-Cv7cxbOr.js"),__vite__mapDeps([184,13,14]),import.meta.url),G(()=>import("./iblShadowsRenderPipeline-Xi6BDASc.js"),__vite__mapDeps([185,13,14,170,183,115,175,37,93,25,26,88,27,24,28,89,174,186,168,178,187]),import.meta.url),G(()=>Promise.resolve().then(()=>jh),void 0,import.meta.url),G(()=>import("./engine.multiRender-DNsfVgN_.js"),__vite__mapDeps([179,180,5,12,6,3,181,64,2,79,154,13,14]),import.meta.url),G(()=>import("./postProcessRenderPipelineManagerSceneComponent-DmPyG1MD.js"),__vite__mapDeps([176,13,14]),import.meta.url)]);this._throwIfDisposedOrAborted(e,this._loadModelAbortController?.signal,this._loadEnvironmentAbortController?.signal);let n=this._shadowState.high;const o=pr(this._loadedModelsBacking);if(!o){n?.ground.setEnabled(!1),this._log("No models loaded, cannot create shadows.");return}const h=4,l=_.FromArray(o.size).length(),c=h*l,u=()=>{if(this._shadowState.high){this._snapshotHelper.disableSnapshotRendering();const{pipeline:f,groundMaterial:d,ground:g}=this._shadowState.high;d?.setVector2("renderTargetSize",new Q(this._scene.getEngine().getRenderWidth(),this._scene.getEngine().getRenderHeight())),d?.setFloat("shadowOpacity",f.shadowOpacity),d?.setTexture("shadowTexture",f._getAccumulatedTexture());const p=h*f?.voxelGridSize;g?.scaling.set(p,p,p),this._snapshotHelper.enableSnapshotRendering(),this._markSceneMutated()}};if(this._snapshotHelper.disableSnapshotRendering(),!n){const f=new r("ibl shadows",this._scene,{resolutionExp:6,sampleDirections:3,ssShadowsEnabled:!0,shadowRemanence:.7,triPlanarVoxelization:!0},[this._camera]);f.toggleShadow(!1);const g=this._scene.getEngine().isWebGPU?1:0,p={attributes:["position","uv"],uniforms:["world","worldView","worldViewProjection","view","projection","renderTargetSize","shadowOpacity"],samplers:["shadowTexture"],shaderLanguage:g,extraInitializationsAsync:async()=>{g===1?await Promise.all([G(()=>import("./envShadowGround.vertex-oRlsSdho-D_myDRd1.js"),__vite__mapDeps([188,13,14]),import.meta.url),G(()=>import("./envShadowGround.fragment-CB8lNguw-B3SxnLRx.js"),__vite__mapDeps([189,13,14]),import.meta.url)]):await Promise.all([G(()=>import("./envShadowGround.vertex-6NXvyWvr-CrXyv9Pg.js"),__vite__mapDeps([190,13,14]),import.meta.url),G(()=>import("./envShadowGround.fragment-L1sPCORS-UYZU9Ntx.js"),__vite__mapDeps([191,13,14]),import.meta.url)])}},m=new t("envShadowGroundMaterial",this._scene,"envShadowGround",p);
62m.alphaMode=y.ALPHA_MULTIPLY,m.alpha=.99,u(),f.onShadowTextureReadyObservable.addOnce(u);const A=this._engine.onResizeObservable.add(()=>{u(),f?.resetAccumulation(),this._startIblShadowsRenderTime()});this._camera.onViewMatrixChangedObservable.add(()=>{this._startIblShadowsRenderTime()});const E=s("envShadowGround",{radius:c,tessellation:64},this._scene);E.setEnabled(!1),E.rotation.x=Math.PI/2,E.position.y=o.extents.min[1],E.material=m,n={pipeline:f,groundMaterial:m,resizeObserver:A,shouldRender:!0,ground:E}}n.pipeline.clearShadowCastingMeshes(),n.pipeline.clearShadowReceivingMaterials();for(const f of this._loadedModelsBacking){const d=f.assetContainer.meshes;for(const g of d)g instanceof ne&&(n.pipeline.addShadowCastingMesh(g),g.material&&n.pipeline.addShadowReceivingMaterial(g.material))}n.pipeline.onVoxelizationCompleteObservable.addOnce(()=>{this._snapshotHelper.disableSnapshotRendering(),u(),n.pipeline.toggleShadow(!0),n.ground.setEnabled(!0),this._snapshotHelper.enableSnapshotRendering(),this._markSceneMutated()}),n.ground.position.y=o.extents.min[1],n.pipeline.updateSceneBounds(),n.pipeline.updateVoxelization(),n.pipeline.resetAccumulation(),this._shadowState.normal?.ground.setEnabled(!1),this._startIblShadowsRenderTime(),this._shadowState.high=n,this._snapshotHelper.enableSnapshotRendering(),this._markSceneMutated()}async _findIblDominantDirection(e){return this._reflectionTexture&&e.iblSource!==this._reflectionTexture&&(e.iblSource=this._reflectionTexture,await e.renderWhenReady()),await e.findDominantDirection()}async _updateShadowMap(e){const[{CreateDisc:t},{RenderTargetTexture:i},{ShadowGenerator:s},{IblCdfGenerator:r}]=await Promise.all([G(()=>import("./discBuilder-Cv7cxbOr.js"),__vite__mapDeps([184,13,14]),import.meta.url),G(()=>Promise.resolve().then(()=>Ju),void 0,import.meta.url),G(()=>import("./shadowGenerator-BA9sdJSm.js"),__vite__mapDeps([192,13,14]),import.meta.url),G(()=>import("./iblCdfGenerator-BGHulTsz.js").then(m=>m.i),__vite__mapDeps([183,13,14,115]),import.meta.url),G(()=>import("./iblCdfGeneratorSceneComponent-H3D0TFaU.js"),__vite__mapDeps([187,183,13,14,115]),import.meta.url),G(()=>import("./shadowGeneratorSceneComponent-DOs-bgdv.js"),__vite__mapDeps([193,192,13,14,37,106,26,88,28,27,194]),import.meta.url)]);this._throwIfDisposedOrAborted(e,this._loadModelAbortController?.signal,this._loadEnvironmentAbortController?.signal);let n=this._shadowState.normal;const o=pr(this._loadedModelsBacking);if(!o){n?.ground.setEnabled(!1),this._log("No models loaded, cannot create shadows.");return}const h=_.FromArray(o.size).length();if(this._shadowQuality!=="normal")return;const l=n?.iblDirection.iblCdfGenerator?n?.iblDirection.iblCdfGenerator:new r(this._engine),c=await this._findIblDominantDirection(l);this._throwIfDisposedOrAborted(e,this._loadModelAbortController?.signal,this._loadEnvironmentAbortController?.signal),this._snapshotHelper.disableSnapshotRendering();const u=4096,d=h*20,g=h*3,p=c?be(c.length(),0,1):.5;if(!n){const m=new ii("shadowMapDirectionalLight",_.Zero(),this._scene);m.autoUpdateExtends=!1;const A=new s(u,m);A.setDarkness(Ii(.8,.2,p)),A.setTransparencyShadow(!0),A.filteringQuality=s.QUALITY_HIGH,A.useBlurExponentialShadowMap=!0,A.enableSoftTransparentShadow=!0,A.bias=h/1e3,A.useKernelBlur=!0,A.blurKernel=Math.floor(Ii(64,8,p));const E=A.getShadowMap();E&&(E.refreshRate=i.REFRESHRATE_RENDER_ONEVERYFRAME,E.renderList=this._scene.meshes.slice());const I=new _e("shadowMapGroundMaterial",this._scene);I.shadowOnly=!0,I.primaryColor=q.Black();const M=t("shadowMapGround",{radius:d,tessellation:64},this._scene);M.rotation.x=Math.PI/2,M.receiveShadows=!0,M.position.y=o.extents.min[1],M.material=I;const C=n={light:m,generator:A,ground:M,shouldRender:!0,iblDirection:{iblCdfGenerator:l,positionFactor:g,direction:c},refreshLightPositionDirection(x){let S=this.iblDirection.direction.normalizeToNew();this.light.getScene().useRightHandedSystem&&(S.z*=-1);const L=P.RotationY(x*-1);S=_.TransformCoordinates(S,L),this.light.position=S.scale(this.iblDirection.positionFactor),this.light.direction=_f(S.negate())}};await new Promise((x,S)=>{tr(()=>E.isReadyForRendering(),()=>x(void 0),()=>S(new Error("Failed to get shadow map generator ready")))}),A.onAfterShadowMapRenderObservable.addOnce(()=>{C.shouldRender=!1})}n.iblDirection.direction=c,n.iblDirection.positionFactor=g,n.refreshLightPositionDirection(this._reflectionsRotation),n.light.shadowFrustumSize=h*4;
62for(const m of this._loadedModelsBacking)for(const A of m.assetContainer.meshes)n.generator.addShadowCaster(A,!1),A.receiveShadows=!0;n.ground.position.y=o.extents.min[1],n.ground.scaling.set(d,d,d),this._shadowState.high?.ground.setEnabled(!1),this._shadowState.high?.pipeline.toggleShadow(!1),n.ground.setEnabled(!0),this._shadowState.normal=n,this._snapshotHelper.enableSnapshotRendering(),this._markSceneMutated()}_disposeShadows(){if(this._snapshotHelper.disableSnapshotRendering(),!this._shadowState)return;for(const i of this._loadedModelsBacking){const s=i.assetContainer.meshes,r=i.assetContainer.meshes[0];this._shadowState.normal?.generator.removeShadowCaster(r,!0),r.receiveShadows=!1;for(const n of s)n instanceof ne&&(this._shadowState.high?.pipeline.removeShadowCastingMesh(n),n.material&&this._shadowState.high?.pipeline.removeShadowReceivingMaterial(n.material))}const e=this._shadowState.high,t=this._shadowState.normal;t&&(t.generator.dispose(),t.light.dispose(),t.ground.dispose(!0,!0),t.iblDirection.iblCdfGenerator.dispose(),this._scene.removeMesh(t.ground)),e&&(e.resizeObserver.remove(),e.pipeline.dispose(),e.ground.dispose(!0,!0),this._scene.removeMesh(e.ground),e.renderTimer&&clearTimeout(e.renderTimer)),delete this._shadowState.normal,delete this._shadowState.high,this.onShadowsConfigurationChanged.clear(),this._snapshotHelper.enableSnapshotRendering(),this._markSceneMutated()}async loadEnvironment(e,t,i){await this._updateEnvironment(e,t,i)}async resetEnvironment(e,t){const i=[];if(e?.lighting&&this._scene.materials.some(s=>s instanceof j)){const s={...e,skybox:!1};e={...e,lighting:!1},i.push(this._updateEnvironment("auto",s,t))}i.push(this._updateEnvironment(void 0,e,t)),await Promise.all(i)}_setEnvironmentLighting(e){this._reflectionTexture=e,this._scene.environmentTexture=this._reflectionTexture,this._reflectionTexture.level=this.environmentConfig.intensity,this._reflectionTexture.rotationY=this.environmentConfig.rotation}_setEnvironmentSkybox(e){this._skyboxTexture=e,this._skyboxTexture.level=this.environmentConfig.intensity,this._skyboxTexture.rotationY=this.environmentConfig.rotation,this._skybox=uf(this._scene,this._camera,this._skyboxTexture,this.environmentConfig.blur),this._skybox.setEnabled(!0),this._snapshotHelper.fixMeshes([this._skybox]),this._updateAutoClear()}async _updateEnvironment(e,t=gf,i){if(this._throwIfDisposedOrAborted(i),!t.lighting&&!t.skybox)return;e=e?.trim(),e==="auto"&&(t={...t,extension:".env"}),this._loadEnvironmentAbortController?.abort(new Ot("New environment is being loaded before previous environment finished loading."));const s=this._loadEnvironmentAbortController=new AbortController;await this._loadEnvironmentLock.lockAsync(async()=>{cn(i,s.signal);const r=async()=>(await G(async()=>{const{default:c}=await import("./defaultEnvironment-5jBs1zfd-DPUnnTO0.js");return{default:c}},[],import.meta.url)).default,n=async c=>{await new Promise((u,f)=>{const d=c.onLoadObservable.addOnce(()=>{g.remove(),u()}),g=z.OnTextureLoadErrorObservable.add(p=>{p===c&&(d.remove(),g.remove(),f(new Error("Failed to load environment texture.")))})})},o=e?e==="auto"?"auto":"url":"none";this._environmentLightingMode=t.lighting?o:this._environmentLightingMode,this._environmentSkyboxMode=t.skybox?o:this._environmentSkyboxMode;let h=this._reflectionTexture?.url,l=this._skyboxTexture?.url;this._snapshotHelper.disableSnapshotRendering();try{this._environmentLightingMode==="auto"&&this._environmentSkyboxMode==="auto"?h=l=await r():(this._environmentLightingMode!=="auto"&&t.lighting&&(h=e),this._environmentSkyboxMode!=="auto"&&t.skybox&&(l=e),this._environmentLightingMode==="auto"&&(h=l??await r()),this._environmentSkyboxMode==="auto"&&(l=h??await r()));const c=[];if(h!==this._reflectionTexture?.url&&(this._reflectionTexture?.dispose(),this._reflectionTexture=null,this._scene.environmentTexture=null,h))if(h===this._skyboxTexture?.url)this._setEnvironmentLighting(this._skyboxTexture.clone());else{const u=await $a(h,this._scene,t.extension);c.push(n(u)),this._setEnvironmentLighting(u)}if(l!==this._skyboxTexture?.url&&(this._skybox?.dispose(void 0,!0),this._skyboxTexture=null,this._skybox=null,this._updateAutoClear(),l))if(l===this._reflectionTexture?.url)this._setEnvironmentSkybox(this._reflectionTexture.clone());else{const u=await $a(l,this._scene,t.extension);c.push(n(u)),this._setEnvironmentSkybox(u)}await Promise.all(c),this._updateLight(),$t(this._updateShadows()),this.onEnvironmentChanged.notifyObservers()}catch(c){throw this.onEnvironmentError.notifyObservers(c),c}finally{this._snapshotHelper.enableSnapshotRendering(),this._markSceneMutated()}})}toggleAnimation(){this.isAnimationPlaying?this.pauseAnimation():this.playAnimation()}playAnimation(){this._activeAnimation?.play(!0)}async pauseAnimation(){this._activeAnimation?.pause()}resetCamera(e){e==null&&(e=this.selectedAnimation!==(this._options?.selectedAnimation??0)),e?this._reframeCamera(!0):this._reset(!0,"camera")}updateCamera(e){this._reframeCameraFromBounds(!0,this._loadedModels,e.alpha??NaN,e.beta??NaN,e.radius??NaN,e.targetX??NaN,e.targetY??NaN,e.targetZ??NaN)}reset(...e){this._reset(!0,...e)}_reset(e,...t){if((t.length===0||t.includes("source"))&&$t(this._updateModel(this._options?.source)),(t.length===0||t.includes("environment"))&&(this._scene.clearColor=new fe(...this._options?.clearColor??Je.clearColor),this.environmentConfig={intensity:this._options?.environmentConfig?.intensity??Je.environmentConfig.intensity,blur:this._options?.environmentConfig?.blur??Je.environmentConfig.blur,rotation:this._options?.environmentConfig?.rotation??Je.environmentConfig.rotation},this._options?.environmentLighting===this._options?.environmentSkybox?$t(this._updateEnvironment(this._options?.environmentLighting,{lighting:!0,skybox:!0})):($t(this._updateEnvironment(this._options?.environmentLighting,{lighting:!0})),$t(this._updateEnvironment(this._options?.environmentSkybox,{skybox:!0})))),(t.length===0||t.includes("shadow"))&&(this._shadowQuality=this._options?.shadowConfig?.quality??Je.shadowConfig.quality,$t(this.updateShadows({quality:this._shadowQuality}))),(t.length===0||t.includes("animation"))&&(this.animationSpeed=this._options?.animationSpeed??Je.animationSpeed,this.selectedAnimation=this._options?.selectedAnimation??0,this._options?.animationAutoPlay?this.playAnimation():this.pauseAnimation()),t.length===0||t.includes("camera")){const i=Number(this._options?.cameraOrbit?.[0]),s=Number(this._options?.cameraOrbit?.[1]),r=Number(this._options?.cameraOrbit?.[2]),n=Number(this._options?.cameraTarget?.[0]),o=Number(this._options?.cameraTarget?.[1]),h=Number(this._options?.cameraTarget?.[2]);this._reframeCameraFromBounds(e,this._loadedModels,isNaN(i)?void 0:i,isNaN(s)?void 0:s,isNaN(r)?void 0:r,isNaN(n)?void 0:n,isNaN(o)?void 0:o,isNaN(h)?void 0:h),this.cameraAutoOrbit={enabled:this._options?.cameraAutoOrbit?.enabled??Je.cameraAutoOrbit.enabled,speed:this._options?.cameraAutoOrbit?.speed??Je.cameraAutoOrbit.speed,delay:this._options?.cameraAutoOrbit?.delay??Je.cameraAutoOrbit.delay}}(t.length===0||t.includes("post-processing"))&&(this.postProcessing={toneMapping:this._options?.postProcessing?.toneMapping??Je.postProcessing.toneMapping,contrast:this._options?.postProcessing?.contrast??Je.postProcessing.contrast,exposure:this._options?.postProcessing?.exposure??Je.postProcessing.exposure,ssao:this._options?.postProcessing?.ssao??Je.postProcessing.ssao}),(t.length===0||t.includes("material-variant"))&&(this.selectedMaterialVariant=this._options?.selectedMaterialVariant??null)}dispose(){this.selectedAnimation=-1,this.animationProgress=0,this._loadEnvironmentAbortController?.abort(new Ot("Thew viewer is being disposed.")),this._loadModelAbortController?.abort(new Ot("Thew viewer is being disposed.")),this._camerasAsHotSpotsAbortController?.abort(new Ot("Thew viewer is being disposed.")),this._shadowsAbortController?.abort(new Ot("Thew viewer is being disposed.")),this._renderLoopController?.dispose(),this._activeModel?.dispose(),this._loadedModelsBacking.forEach(e
62=>e.dispose()),this._disposeShadows(),this._scene.dispose(),this.onEnvironmentChanged.clear(),this.onEnvironmentError.clear(),this.onEnvironmentConfigurationChanged.clear(),this.onPostProcessingChanged.clear(),this.onModelChanged.clear(),this.onModelError.clear(),this.onCameraAutoOrbitChanged.clear(),this.onSelectedAnimationChanged.clear(),this.onAnimationSpeedChanged.clear(),this.onIsAnimationPlayingChanged.clear(),this.onAnimationProgressChanged.clear(),this.onSelectedMaterialVariantChanged.clear(),this.onHotSpotsChanged.clear(),this.onCamerasAsHotSpotsChanged.clear(),this.onLoadingProgressChanged.clear(),this._imageProcessingConfigurationObserver.remove(),this._beforeRenderObserver.remove(),this._isDisposed=!0}getHotSpotToRef(e,t){return this._getHotSpotToRef(this._loadedModels.flatMap(i=>i.assetContainer.meshes),e,t)}_getHotSpotToRef(...e){const[t,i,s]=e,r=Array.isArray(t)?t:t?.meshes,n=this._tempVectors[2],o=this._tempVectors[1],h=this._tempVectors[0];if(i.type==="surface"){const d=r?.[i.meshIndex];if(!d||!Gd(d,i,o,n))return!1}else o.copyFromFloats(i.position[0],i.position[1],i.position[2]),n.copyFromFloats(i.normal[0],i.normal[1],i.normal[2]);const l=this._camera.viewport.width*this._engine.getRenderWidth()*this._engine.getHardwareScalingLevel(),c=this._camera.viewport.height*this._engine.getRenderHeight()*this._engine.getHardwareScalingLevel(),u=this._scene;_.ProjectToRef(o,P.IdentityReadOnly,u.getTransformMatrix(),new ps(0,0,l,c),h),s.screenPosition[0]=h.x,s.screenPosition[1]=h.y,s.worldPosition[0]=o.x,s.worldPosition[1]=o.y,s.worldPosition[2]=o.z;const f=this._tempVectors[3];return f.copyFrom(this._camera.globalPosition),f.subtractInPlace(o),f.normalize(),s.visibility=_.Dot(f,n),!0}queryHotSpot(e,t){return this._queryHotSpot(e,t)!=null}focusHotSpot(e){const t=new Kn,i=this._queryHotSpot(e,t);if(i){this.pauseAnimation();const s=i.cameraOrbit??[void 0,void 0,void 0];return this._camera.interpolateTo(s[0],s[1],s[2],new _(t.worldPosition[0],t.worldPosition[1],t.worldPosition[2])),!0}return!1}_queryHotSpot(e,t){const i=this.hotSpots?.[e];return i&&this.getHotSpotToRef(i,t)?i:null}async _addCameraHotSpot(e,t){if(e!==this._camera){const i=await this._createHotSpotFromCamera(e);i&&!t?.aborted&&(this.hotSpots={...this.hotSpots,[`camera-${e.name}`]:i})}}_removeCameraHotSpot(e){delete this.hotSpots[`camera-${e.name}`],this.hotSpots={...this.hotSpots}}_toggleCamerasAsHotSpots(){if(!this.camerasAsHotSpots)this._camerasAsHotSpotsAbortController?.abort(),this._camerasAsHotSpotsAbortController=null,this._scene.cameras.forEach(e=>this._removeCameraHotSpot(e));else{const e=this._camerasAsHotSpotsAbortController=new AbortController;this._scene.cameras.forEach(async t=>await this._addCameraHotSpot(t,e.signal))}}async _createHotSpotFromCamera(e){if(e instanceof Ie){const t=e.target.asArray();return{type:"world",position:t,normal:t,cameraOrbit:[e.alpha,e.beta,e.radius]}}return this._activeModel?await tl(this._activeModel,e):null}get _shouldRender(){return!this._autoSuspendRendering||this._sceneMutated||!this._snapshotHelper.isReady||this._shadowState.normal?.shouldRender||this._shadowState.high?.shouldRender||this._loadedModelsBacking.some(e=>e._shouldRender())}_markSceneMutated(){this._sceneMutated=!0}_suspendRendering(){this._renderLoopController?.dispose(),this._suspendRenderCount++;let e=!1;return{dispose:()=>{e||(e=!0,this._suspendRenderCount--,this._suspendRenderCount===0&&this._beginRendering())}}}_beginRendering(){if(!this._renderLoopController){let e=!1;const t=()=>{this._log("Viewer Resumed Rendering"),this._engine.setHardwareScalingLevel(this._lastHardwareScalingLevel),this._engine.performanceMonitor.enable(),this._snapshotHelper.enableSnapshotRendering(),this._startSceneOptimizer()},i=()=>{this._log("Viewer Suspended Rendering"),this._renderedLastFrame=!1,e=!1,this._lastHardwareScalingLevel=this._engine.getHardwareScalingLevel(),this._stopSceneOptimizer(),this._snapshotHelper.disableSnapshotRendering(),this._engine.performanceMonitor.disable(),this._engine.setHardwareScalingLevel(this._defaultHardwareScalingLevel),this._engine.beginFrame(),this._scene.render(),this._engine.endFrame()},s=()=>{let n=this._shouldRender;!n&&this._renderedLastFrame&&!e&&(e=this._scene.isReady(!0),n=!0),n?(this._renderedLastFrame||(this._renderedLastFrame!==null&&t(),this._renderedLastFrame=!0),this._sceneMutated=!1,this._scene.render(),this._camera.panningSensibility=5e3/this._camera.radius,this._camera.speed=this._camera.radius*.2,this._camera.inputs.attached.keyboard.zoomingSensibility=500/this._camera.radius,this.isAnimationPlaying&&(this.onAnimationProgressChanged.notifyObservers(),this._autoRotationBehavior.resetLastInteractionTime())):(this._camera.update(),this._renderedLastFrame&&i())};this._engine.runRenderLoop(s);let r=!1;this._renderLoopController={dispose:()=>{r||(r=!0,this._engine.stopRenderLoop(s),this._renderLoopController=null,this._renderedLastFrame&&i())}}}}_reframeCamera(e=!1,t=this._loadedModelsBacking){this._reframeCameraFromBounds(e,t)}_getWorldBounds(e){return pr(e)}_getCameraConfig(e){let t=1,i=_.Zero();const s=this._getWorldBounds(e);s&&(this._camera.lowerRadiusLimit=null,t=_.FromArray(s.size).length()*1.1,i=_.FromArray(s.center),isFinite(t)||(t=1,i.c
62opyFromFloats(0,0,0)));const r=t*.001,n=t*5,o=t*.001,h=t*1e3;return{radius:t,target:i,lowerRadiusLimit:r,upperRadiusLimit:n,minZ:o,maxZ:h}}_reframeCameraFromBounds(e,t,i,s,r,n,o,h){let l=1;const c=_.Zero();let u=Math.PI/2,f=Math.PI/2.4;const{radius:d,target:g,lowerRadiusLimit:p,upperRadiusLimit:m,minZ:A,maxZ:E}=this._getCameraConfig(t);this._camera.lowerRadiusLimit=p,this._camera.upperRadiusLimit=m,this._camera.minZ=A,this._camera.maxZ=E,u=i??u,f=s??f,l=r??d,c.x=n??g.x,c.y=o??g.y,c.z=h??g.z,e?this._camera.interpolateTo(u,f,l,c,void 0,.1):(this._camera.stopInterpolation(),isNaN(u)||(this._camera.alpha=u),isNaN(f)||(this._camera.beta=f),isNaN(l)||(this._camera.radius=l),this._camera.setTarget(new _(isNaN(c.x)?this._camera.target.x:c.x,isNaN(c.y)?this._camera.target.y:c.y,isNaN(c.z)?this._camera.target.z:c.z),void 0,void 0,!0)),this._camera.wheelDeltaPercentage=.01,this._camera.useNaturalPinchZoom=!0,el(this._skybox,this._camera)}_updateLight(){let e;if(this._loadedModels.length===0)e=!1;else{const t=this._loadedModels.some(r=>r.assetContainer.lights.length>0),i=!!this._reflectionTexture,s=this._loadedModels.some(r=>r.assetContainer.materials.some(n=>!(n instanceof j)));t?e=!1:e=!i||s}e?this._light||(this._light=new Ss("defaultLight",_.Up(),this._scene)):(this._light?.dispose(),this._light=null)}_applyAnimationSpeed(){this._activeModel?.assetContainer.animationGroups.forEach(e=>e.speedRatio=this._animationSpeed)}async _pick(e,t){if(await G(()=>import("./ray-gjj8VnBP.js"),__vite__mapDeps([171,13,14]),import.meta.url),this._loadedModels.length>0){const i=this._loadedModelsBacking.flatMap(r=>r.assetContainer.meshes);i.forEach(r=>{let n=this._meshDataCache.get(r);n||(n={},this._meshDataCache.set(r,n)),r.refreshBoundingInfo({applyMorph:!0,applySkeleton:!0,cache:n})});const s=this._scene.pick(e,t,r=>i.includes(r));if(s.hit)return s}return null}_startSceneOptimizer(e=!1){this._stopSceneOptimizer(),e&&this._engine.setHardwareScalingLevel(this._defaultHardwareScalingLevel);const t=new Ji(60,1e3),i=new Sn(void 0,1);t.addOptimization(i),this._sceneOptimizer=new zn(this._scene,t),this._sceneOptimizer.start()}_stopSceneOptimizer(){this._sceneOptimizer?.dispose(),this._sceneOptimizer=null}_log(e){this.showDebugLogs&&w.Log(e)}_throwIfDisposedOrAborted(...e){if(this._isDisposed)throw new Error("Viewer is disposed.");cn(...e)}}af();const yr=globalThis,qn=yr.ShadowRoot&&(yr.ShadyCSS===void 0||yr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,jn=Symbol(),Ja=new WeakMap;let il=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==jn)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(qn&&e===void 0){const i=t!==void 0&&t.length===1;i&&(e=Ja.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&Ja.set(t,e))}return e}toString(){return this.cssText}};const pf=a=>new il(typeof a=="string"?a:a+"",void 0,jn),sl=(a,...e)=>{const t=a.length===1?a[0]:e.reduce(((i,s,r)=>i+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+a[r+1]),a[0]);return new il(t,a,jn)},mf=(a,e)=>{if(qn)a.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const t of e){const i=document.createElement("style"),s=yr.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=t.cssText,a.appendChild(i)}},eo=qn?a=>a:a=>a instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return pf(t)})(a):a;const{is:Tf,defineProperty:bf,getOwnPropertyDescriptor:Ef,getOwnPropertyNames:Af,getOwnPropertySymbols:Rf,getPrototypeOf:yf}=Object,Kr=globalThis,to=Kr.trustedTypes,xf=to?to.emptyScript:"",Sf=Kr.reactiveElementPolyfillSupport,Ns=(a,e)=>a,wr={toAttribute(a,e){switch(e){case Boolean:a=a?xf:null;break;case Object:case Array:a=a==null?a:JSON.stringify(a)}return a},fromAttribute(a,e){let t=a;switch(e){case Boolean:t=a!==null;break;case Number:t=a===null?null:Number(a);break;case Object:case Array:try{t=JSON.parse(a)}catch{t=null}}return t}},Qn=(a,e)=>!Tf(a,e),io={attribute:!0,type:String,converter:wr,reflect:!1,useDefault:!1,hasChanged:Qn};Symbol.metadata??=Symbol("metadata"),Kr.litPropertyMetadata??=new WeakMap;let os=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}
vendor: 5,694 bytes, lines 62-64
62static createProperty(e,t=io){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(e,i,t);s!==void 0&&bf(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){const{get:s,set:r}=Ef(this.prototype,e)??{get(){return this[t]},set(n){this[t]=n}};return{get:s,set(n){const o=s?.call(this);r?.call(this,n),this.requestUpdate(e,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??io}static _$Ei(){if(this.hasOwnProperty(Ns("elementProperties")))return;const e=yf(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Ns("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ns("properties"))){const t=this.properties,i=[...Af(t),...Rf(t)];for(const s of i)this.createProperty(s,t[s])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[i,s]of t)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[t,i]of this.elementProperties){const s=this._$Eu(t,i);s!==void 0&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const s of i)t.unshift(eo(s))}else e!==void 0&&t.push(eo(e));return t}static _$Eu(e,t){const i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((e=>e(this)))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return mf(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((e=>e.hostConnected?.()))}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach((e=>e.hostDisconnected?.()))}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){const i=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,i);if(s!==void 0&&i.reflect===!0){const r=(i.converter?.toAttribute!==void 0?i.converter:wr).toAttribute(t,i.type);this._$Em=e,r==null?this.removeAttribute(s):this.setAttribute(s,r),this._$Em=null}}_$AK(e,t){const i=this.constructor,s=i._$Eh.get(e);if(s!==void 0&&this._$Em!==s){const r=i.getPropertyOptions(s),n=typeof r.converter=="function"?{fromAttribute:r.converter}:r.converter?.fromAttribute!==void 0?r.converter:wr;this._$Em=s,this[s]=n.fromAttribute(t,r.type)??this._$Ej?.get(s)??null,this._$Em=null}}requestUpdate(e,t,i){if(e!==void 0){const s=this.constructor,r=this[e];if(i??=s.getPropertyOptions(e),!((i.hasChanged??Qn)(r,t)||i.useDefault&&i.reflect&&r===this._$Ej?.get(e)&&!this.hasAttribute(s._$Eu(e,i))))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:s,wrapped:r},n){i&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,n??t??this[e]),r!==!0||n!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),s===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[s,r]of this._$Ep)this[s]=r;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[s,r]of i){const{wrapped:n}=r,o=this[s];n!==!0||this._$AL.has(s)||o===void 0||this.C(s,void 0,r,o)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach((i=>i.hostUpdate?.())),this.update(t)):this._$EM()}catch(i){throw e=!1,this._$EM(),i}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach((t=>this._$ET(t,this[t]))),this._$EM()}updated(e){}firstUpdated(e){}};os.elementStyles=[],os.shadowRootOptions={mode:"open"},os[Ns("elementProperties")]=new Map,os[Ns("finalized")]=new Map,Sf?.({ReactiveElement:os}),(Kr.reactiveElementVersions??=[]).push("2.1.0");const Zn=globalThis,Lr=Zn.trustedTypes,so=Lr?Lr.createPolicy("lit-html",{createHTML:a=>a}):void 0,rl="$lit$",Pi=`lit$${Math.random().toFixed(9).slice(2)}$`,nl="?"+Pi,Mf=`<${nl}>`,is=document,Qs=()=>is.createComment(""),Zs=a=>a===null||typeof a!="object"&&typeof a!="function",$n=Array.isArray,Cf=a=>$n(a)||typeof a?.[Symbol.iterator]=="function",un=`[ 	
63\f\r]`,Os=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ro=/-->/g,no=/>/g,Ki=RegExp(`>|${un}(?:([^\\s"'>=/]+)(${un}*=${un}*(?:[^ 	
64\f\r"'\`<>=]|("|')|))|$)`,"g"),ao=/'/g,oo=/"/g,al=/^(?:script|style|textarea|title)$/i,If=a=>(e,...t)=>({_$litType$:a,strings:e,values:t}
vendor: 29,827 bytes, lines 64-143
64),ot=If(1),Rs=Symbol.for("lit-noChange"),ut=Symbol.for("lit-nothing"),ho=new WeakMap,Qi=is.createTreeWalker(is,129);function ol(a,e){if(!$n(a)||!a.hasOwnProperty("raw"))throw Error("invalid template strings array");return so!==void 0?so.createHTML(e):e}const Pf=(a,e)=>{const t=a.length-1,i=[];let s,r=e===2?"<svg>":e===3?"<math>":"",n=Os;for(let o=0;o<t;o++){const h=a[o];let l,c,u=-1,f=0;for(;f<h.length&&(n.lastIndex=f,c=n.exec(h),c!==null);)f=n.lastIndex,n===Os?c[1]==="!--"?n=ro:c[1]!==void 0?n=no:c[2]!==void 0?(al.test(c[2])&&(s=RegExp("</"+c[2],"g")),n=Ki):c[3]!==void 0&&(n=Ki):n===Ki?c[0]===">"?(n=s??Os,u=-1):c[1]===void 0?u=-2:(u=n.lastIndex-c[2].length,l=c[1],n=c[3]===void 0?Ki:c[3]==='"'?oo:ao):n===oo||n===ao?n=Ki:n===ro||n===no?n=Os:(n=Ki,s=void 0);const d=n===Ki&&a[o+1].startsWith("/>")?" ":"";r+=n===Os?h+Mf:u>=0?(i.push(l),h.slice(0,u)+rl+h.slice(u)+Pi+d):h+Pi+(u===-2?o:d)}return[ol(a,r+(a[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]};class $s{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let r=0,n=0;const o=e.length-1,h=this.parts,[l,c]=Pf(e,t);if(this.el=$s.createElement(l,i),Qi.currentNode=this.el.content,t===2||t===3){const u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(s=Qi.nextNode())!==null&&h.length<o;){if(s.nodeType===1){if(s.hasAttributes())for(const u of s.getAttributeNames())if(u.endsWith(rl)){const f=c[n++],d=s.getAttribute(u).split(Pi),g=/([.?@])?(.*)/.exec(f);h.push({type:1,index:r,name:g[2],strings:d,ctor:g[1]==="."?Df:g[1]==="?"?Of:g[1]==="@"?Ff:Yr}),s.removeAttribute(u)}else u.startsWith(Pi)&&(h.push({type:6,index:r}),s.removeAttribute(u));if(al.test(s.tagName)){const u=s.textContent.split(Pi),f=u.length-1;if(f>0){s.textContent=Lr?Lr.emptyScript:"";for(let d=0;d<f;d++)s.append(u[d],Qs()),Qi.nextNode(),h.push({type:2,index:++r});s.append(u[f],Qs())}}}else if(s.nodeType===8)if(s.data===nl)h.push({type:2,index:r});else{let u=-1;for(;(u=s.data.indexOf(Pi,u+1))!==-1;)h.push({type:7,index:r}),u+=Pi.length-1}r++}}static createElement(e,t){const i=is.createElement("template");return i.innerHTML=e,i}}function ys(a,e,t=a,i){if(e===Rs)return e;let s=i!==void 0?t._$Co?.[i]:t._$Cl;const r=Zs(e)?void 0:e._$litDirective$;return s?.constructor!==r&&(s?._$AO?.(!1),r===void 0?s=void 0:(s=new r(a),s._$AT(a,t,i)),i!==void 0?(t._$Co??=[])[i]=s:t._$Cl=s),s!==void 0&&(e=ys(a,s._$AS(a,e.values),s,i)),e}class vf{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:i}=this._$AD,s=(e?.creationScope??is).importNode(t,!0);Qi.currentNode=s;let r=Qi.nextNode(),n=0,o=0,h=i[0];for(;h!==void 0;){if(n===h.index){let l;h.type===2?l=new hr(r,r.nextSibling,this,e):h.type===1?l=new h.ctor(r,h.name,h.strings,this,e):h.type===6&&(l=new wf(r,this,e)),this._$AV.push(l),h=i[++o]}n!==h?.index&&(r=Qi.nextNode(),n++)}return Qi.currentNode=is,s}p(e){let t=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class hr{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=ut,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=s?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=ys(this,e,t),Zs(e)?e===ut||e==null||e===""?(this._$AH!==ut&&this._$AR(),this._$AH=ut):e!==this._$AH&&e!==Rs&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Cf(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==ut&&Zs(this._$AH)?this._$AA.nextSibling.data=e:this.T(is.createTextNode(e)),this._$AH=e}$(e){const{values:t,_$litType$:i}=e,s=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=$s.createElement(ol(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(t);else{const r=new vf(s,this),n=r.u(this.options);r.p(t),this.T(n),this._$AH=r}}_$AC(e){let t=ho.get(e.strings);return t===void 0&&ho.set(e.strings,t=new $s(e)),t}k(e){$n(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const r of e)s===t.length?t.push(i=new hr(this.O(Qs()),this.O(Qs()),this,this.options)):i=t[s],i._$AI(r),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e&&e!==this._$AB;){const i=e.nextSibling;e.remove(),e=i}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}}class Yr{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,r){this.type=1,this._$AH=ut,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=ut}_$AI(e,t=this,i,s){const r=this.strings;let n=!1;if(r===void 0)e=ys(this,e,t,0),n=!Zs(e)||e!==this._$AH&&e!==Rs,n&&(this._$AH=e);else{const o=e;let h,l;for(e=r[0],h=0;h<r.length-1;h++)l=ys(this,o[i+h],t,h),l===Rs&&(l=this._$AH[h]),n||=!Zs(l)||l!==this._$AH[h],l===ut?e=ut:e!==ut&&(e+=(l??"")+r[h+1]),this._$AH[h]=l}n&&!s&&this.j(e)}j(e){e===ut?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class Df extends Yr{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ut?void 0:e}}class Of extends Yr{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==ut)}}class Ff extends Yr{constructor(e,t,i,s,r){super(e,t,i,s,r),this.type=5}_$AI(e,t=this){if((e=ys(this,e,t,0)??ut)===Rs)return;const i=this._$AH,s=e===ut&&i!==ut||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==ut&&(i===ut||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class wf{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){ys(this,e)}}const Lf=Zn.litHtmlPolyfillSupport;Lf?.($s,hr),(Zn.litHtmlVersions??=[]).push("3.3.0");const Bf=(a,e,t)=>{const i=t?.renderBefore??e;let s=i._$litPart$;if(s===void 0){const r=t?.renderBefore??null;i._$litPart$=s=new hr(e.insertBefore(Qs(),r),r,void 0,t??{})}return s._$AI(a),s};const Jn=globalThis;let _s=class extends os{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Bf(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Rs}};_s._$litElement$=!0,_s.finalized=!0,Jn.litElementHydrateSupport?.({LitElement:_s});const Nf=Jn.litElementPolyfillSupport;Nf?.({LitElement:_s});(Jn.litElementVersions??=[]).push("4.2.0");const hl=a=>(e,t)=>{t!==void 0?t.addInitializer((()=>{customElements.define(a,e)})):customElements.define(a,e)};const Uf={attribute:!0,type:String,converter:wr,reflect:!1,hasChanged:Qn},kf=(a=Uf,e,t)=>{const{kind:i,metadata:s}=t;let r=globalThis.litPropertyMetadata.get(s);if(r===void 0&&globalThis.litPropertyMetadata.set(s,r=new Map),i==="setter"&&((a=Object.create(a)).wrapped=!0),r.set(t.name,a),i==="accessor"){const{name:n}=t;return{set(o){const h=e.get.call(this);e.set.call(this,o),this.requestUpdate(n,h,a)},init(o){return o!==void 0&&this.C(n,void 0,a,o),o}}}if(i==="setter"){const{name:n}=t;return function(o){const h=this[n];e.call(this,o),this.requestUpdate(n,h,a)}}throw Error("Unsupported decorator location: "+i)};function Be(a){return(e,t)=>typeof t=="object"?kf(a,e,t):((i,s,r)=>{const n=s.hasOwnProperty(r);return s.constructor.createProperty(r,i),n?Object.getOwnPropertyDescriptor(s,r):void 0})(a,e,t)}function lr(a){return Be({...a,state:!0,attribute:!1})}const Gf=(a,e,t)=>(t.configurable=!0,t.enumerable=!0,Reflect.decorate&&typeof e!="object"&&Object.defineProperty(a,e,t),t);function ll(a,e){return(t,i,s)=>{const r=n=>n.renderRoot?.querySelector(a)??null;return Gf(t,i,{get(){return r(this)}})}}const Hf=a=>a.strings===void 0;const Vf={CHILD:2},zf=a=>(...e)=>({_$litDirective$:a,values:e});class Wf{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}const Us=(a,e)=>{const t=a._$AN;if(t===void 0)return!1;for(const i of t)i._$AO?.(e,!1),Us(i,e);return!0},Br=a=>{let e,t;do{if((e=a._$AM)===void 0)break;t=e._$AN,t.delete(a),a=e}while(t?.size===0)},cl=a=>{for(let e;e=a._$AM;a=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(a))break;t.add(a),Yf(e)}};function Xf(a){this._$AN!==void 0?(Br(this),this._$AM=a,cl(this)):this._$AM=a}function Kf(a,e=!1,t=0){const i=this._$AH,s=this._$AN;if(s!==void 0&&s.size!==0)if(e)if(Array.isArray(i))for(let r=t;r<i.length;r++)Us(i[r],!1),Br(i[r]);else i!=null&&(Us(i,!1),Br(i));else Us(this,a)}const Yf=a=>{a.type==Vf.CHILD&&(a._$AP??=Kf,a._$AQ??=Xf)};class qf extends Wf{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,i){super._$AT(e,t,i),cl(this),this.isConnected=e._$AU}_$AO(e,t=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),t&&(Us(this,e),Br(this))}setValue(e){if(Hf(this._$Ct))this._$Ct._$AI(e,this);else{const t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}}const dn=new WeakMap,jf=zf(class extends qf{render(a){return ut}update(a,[e]){const t=e!==this.G;return t&&this.G!==void 0&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.G=e,this.ht=a.options?.host,this.rt(this.ct=a.element)),ut}rt(a){if(this.isConnected||(a=void 0),typeof this.G=="function"){const e=this.ht??globalThis;let t=dn.get(e);t===void 0&&(t=new WeakMap,dn.set(e,t)),t.get(this.G)!==void 0&&this.G.call(this.ht,void 0),t.set(this.G,a),a!==void 0&&this.G.call(this.ht,a)}else this.G.value=a}get lt(){return typeof this.G=="function"?dn.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}}),mr={antialias:!0,adaptToDeviceRatio:!0,enableAllFeatures:!0,setMaximumLimits:!0};function Qf(){return"gpu"in navigator&&"chrome"in window?"WebGPU":"WebGL"}async function ul(a,e={}){const t=new Vn;e=new Proxy(e,{get(o,h){switch(h){case"antialias":return o.antialias??mr.antialias;case"adaptToDeviceRatio":return o.adaptToDeviceRatio??mr.adaptToDeviceRatio;case"enableAllFeatures":return o.enableAllFeatures??mr.enableAllFeatures;case"setMaximumLimits":return o.setMaximumLimits??mr.setMaximumLimits;case"onInitialized":return l=>{o.onInitialized?.(l),t.resolve(l)};default:return o[h]}}});const i=[];let s;switch(e.engine??Qf()){case"WebGPU":{const{WebGPUEngine:o}=await G(async()=>{const{WebGPUEngine:l}=await import("./webgpuEngine-e5c9iler.js");return{WebGPUEngine:l}},__vite__mapDeps([180,5,12,6,3,181,64,2,79,154,13,14]),import.meta.url),h=new o(a,e);try{await h.initAsync(),s=h;break}catch{w.Warn("Failed to initialize WebGPU engine. Falling back to WebGL.")}}case"WebGL":{const{Engine:o}=await G(async()=>{const{Engine:h}=await Promise.resolve().then(()=>Ad);return{Engine:h}},void 0,import.meta.url);s=new o(a,void 0,e);break}}if(e.onFaulted){const o=e.onFaulted,h=s.onContextLostObservable.addOnce(()=>{o(new Error("The engine context was lost."))});i.push(()=>h.remove())}const r=e?.viewerClass??Yn,n=new r(s,e);{const o=await t.promise;let h=!1;const l=new ResizeObserver(()=>{h=!0,o.markSceneMutated()});l.observe(a),i.push(()=>l.disconnect());const c=o.scene.onBeforeRenderObservable.add(()=>{h&&(s.resize(),h=!1)});i.push(()=>c.remove());let u=null;const f=new IntersectionObserver(d=>{d.length>0&&(d[d.length-1].isIntersecting?(u?.dispose(),u=null):u=o.suspendRendering())});f.observe(a),i.push(()=>f.disconnect())}return i.push(n.dispose.bind(n)),i.push(()=>s.dispose()),n.dispose=()=>i.forEach(o=>o()),n}const Zf="M5 5.27368C5 3.56682 6.82609 2.48151 8.32538 3.2973L20.687 10.0235C22.2531 10.8756 22.2531 13.124 20.687 13.9762L8.32538 20.7024C6.82609 21.5181 5 20.4328 5 18.726V5.27368Z",$f="M5.74609 3C4.7796 3 3.99609 3.7835 3.99609 4.75V19.25C3.99609 20.2165 4.7796 21 5.74609 21H9.24609C10.2126 21 10.9961 20.2165 10.9961 19.25V4.75C10.9961 3.7835 10.2126 3 9.24609 3H5.74609ZM14.7461 3C13.7796 3 12.9961 3.7835 12.9961 4.75V19.25C12.9961 20.2165 13.7796 21 14.7461 21H18.2461C19.2126 21 19.9961 20.2165 19.9961 19.25V4.75C19.9961 3.7835 19.2126 3 18.2461 3H14.7461Z",Jf="M7.20711 2.54289C7.59763 2.93342 7.59763 3.56658 7.20711 3.95711L5.41421 5.75H13.25C17.6683 5.75 21.25 9.33172 21.25 13.75C21.25 18.1683 17.6683 21.75 13.25 21.75C8.83172 21.75 5.25 18.1683 5.25 13.75C5.25 13.1977 5.69772 12.75 6.25 12.75C6.80228 12.75 7.25 13.1977 7.25 13.75C7.25 17.0637 9.93629 19.75 13.25 19.75C16.5637 19.75 19.25 17.0637 19.25 13.75C19.25 10.4363 16.5637 7.75 13.25 7.75H5.41421L7.20711 9.54289C7.59763 9.93342 7.59763 10.5666 7.20711 10.9571C6.81658 11.3476 6.18342 11.3476 5.79289 10.9571L2.29289 7.45711C1.90237 7.06658 1.90237 6.43342 2.29289 6.04289L5.79289 2.54289C6.18342 2.15237 6.81658 2.15237 7.20711 2.54289Z",e_="M12 14C13.1046 14 14 13.1046 14 12C14 10.8954 13.1046 10 12 10C10.8954 10 10 10.8954 10 12C10 13.1046 10.8954 14 12 14ZM6 12C6 8.68629 8.68629 6 12 6C15.3137 6 18 8.68629 18 12C18 15.3137 15.3137 18 12 18C8.68629 18 6 15.3137 6 12ZM12 8C9.79086 8 8 9.79086 8 12C8 14.2091 9.79086 16 12 16C14.2091 16 16 14.2091 16 12C16 9.79086 14.2091 8 12 8ZM2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12ZM12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4Z",t_="M5 12C5 8.13401 8.13401 5 12 5C13.32 5 14.5542 5.36484 15.608 6H15C14.4477 6 14 6.44772 14 7C14 7.55228 14.4477 8 15 8H18C18.5523 8 19 7.55228 19 7C19 6 19 5 19 4C19 3.44772 18.5523 3 18 3C17.4477 3 17 3.44772 17 4V4.51575C15.5702 3.5588 13.85 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21C16.9706 21 21 16.9706 21 12C21 11.6199 20.9764 11.2448 20.9304 10.8763C20.8621 10.3282 20.3624 9.93935 19.8144 10.0077C19.2663 10.076 18.8775 10.5757 18.9458 11.1237C18.9815 11.4104 19 11.7028 19 12C19 15.866 15.866 19 12 19C8.13401 19 5 15.866 5 12Z",lo=[.5,1,1.5,2];function i_(a){if(!a)return null;const e=document.createElement("canvas");e.width=e.height=1;const t=e.getContext("2d");if(!t)throw new Error("Unable to get 2d context for parseColor");t.clearRect(0,0,1,1),t.fillStyle=a,t.fillRect(0,0,1,1);const i=t.getImageData(0,0,1,1).data;return new fe(i[0]/255,i[1]/255,i[2]/255,i[3]/255)}function s_(a){if(a==="WebGL"||a==="WebGPU")return a}function mi(a){return a==null?null:Number(a)}function Tr(a){if(!a)return null;const e=a.trim().split(/\s+/);if(e.length!==3)throw new Error(`Camera orbit and target should be defined as three space separated numbers, but was specified as "${a}".`);return e.map(t=>Number(t))}function r_(a){return!a||!Jh(a)?null:a}function n_(a){return!a||!cf(a)?null:a}function a_(a){return!a||a==="auto"?"auto":a==="reframe"?"reframe":a.trim().split(/\s+/)}class Se extends _s{constructor(e,t={}){super(),this._viewerClass=e,this._options=t,this._viewerLock=new Rr,this._animationSliderResizeObserver=null,this._propertyBindings=[this._createPropertyBinding("clearColor",i=>i.scene.onClearColorChangedObservable,i=>i.scene.clearColor=this.clearColor??new fe(0,0,0,0),i=>this.clearColor=i.scene.clearColor),this._createPropertyBinding("skyboxBlur",i=>i.viewer.onEnvironmentConfigurationChanged,i=>i.viewer.environmentConfig={blur:this.skyboxBlur??i.viewer.environmentConfig.blur},i=>this.skyboxBlur=i.viewer.environmentConfig.blur),this._createPropertyBinding("environmentIntensity",i=>i.viewer.onEnvironmentConfigurationChanged,i=>i.viewer.environmentConfig={intensity:this.environmentIntensity??i.viewer.environmentConfig.intensity},i=>this.environmentIntensity=i.viewer.environmentConfig.intensity),this._createPropertyBinding("environmentRotation",i=>i.viewer.onEnvironmentConfigurationChanged,i=>i.viewer.environmentConfig={rotation:this.environmentRotation??i.viewer.environmentConfig.rotation},i=>this.environmentRotation=i.viewer.environmentConfig.rotation),this._createPropertyBinding("toneMapping",i=>i.viewer.onPostProcessingChanged,i=>{this.toneMapping&&(i.viewer.postProcessing={toneMapping:this.toneMapping})},i=>this.toneMapping=i.viewer.postProcessing?.toneMapping),this._createPropertyBinding("contrast",i=>i.viewer.onPostProcessingChanged,i=>i.viewer.postProcessing={contrast:this.contrast??void 0},i=>this.contrast=i.viewer.postProcessing.contrast),this._createPropertyBinding("exposure",i=>i.viewer.onPostProcessingChanged,i=>i.viewer.postProcessing={exposure:this.exposure??void 0},i=>this.exposure=i.viewer.postProcessing.exposure),this._createPropertyBinding("ssao",i=>i.viewer.onPostProcessingChanged,i=>i.viewer.postProcessing={ssao:this.ssao??void 0},i=>this.ssao=i.viewer.postProcessing.ssao),this._createPropertyBinding("cameraAutoOrbit",i=>i.viewer.onCameraAutoOrbitChanged,i=>i.viewer.cameraAutoOrbit={enabled:this.cameraAutoOrbit},i=>this.cameraAutoOrbit=i.viewer.cameraAutoOrbit.enabled),this._createPropertyBinding("cameraAutoOrbitSpeed",i=>i.viewer.onCameraAutoOrbitChanged,i=>i.viewer.cameraAutoOrbit={speed:this.cameraAutoOrbitSpeed??void 0},i=>this.cameraAutoOrbitSpeed=i.viewer.cameraAutoOrbit.speed),this._createPropertyBinding("cameraAutoOrbitDelay",i=>i.viewer.onCameraAutoOrbitChanged,i=>i.viewer.cameraAutoOrbit={delay:this.cameraAutoOrbitDelay??void 0},i=>this.cameraAutoOrbitDelay=i.viewer.cameraAutoOrbit.delay),this._createPropertyBinding("animationSpeed",i=>i.viewer.onAnimationSpeedChanged,i=>i.viewer.animationSpeed=this.animationSpeed,i=>{let s=i.viewer.animationSpeed;s=lo.reduce((r,n)=>Math.abs(n-s)<Math.abs(r-s)?n:r),this.animationSpeed=s,this._dispatchCustomEvent("animationspeedchange",r=>new Event(r))}),this._createPropertyBinding("selectedAnimation",i=>i.viewer.onSelectedAnimationChanged,i=>i.viewer.selectedAnimation=this.selectedAnimation??i.viewer.selectedAnimation,i=>this.selectedAnimation=i.viewer.selectedAnimation),this._createPropertyBinding("selectedMaterialVariant",i=>i.viewer.onSelectedMaterialVariantChanged,i=>i.viewer.selectedMaterialVariant=this.selectedMaterialVariant??i.viewer.selectedMaterialVariant??"",i=>this.selectedMaterialVariant=i.viewer.selectedMaterialVariant),this._createPropertyBinding("hotSpots",i=>i.viewer.onHotSpotsChanged,i=>i.viewer.hotSpots=this.hotSpots??i.viewer.hotSpots,i=>this.hotSpots=i.viewer.hotSpots),this._createPropertyBinding("camerasAsHotSpots",i=>i.viewer.onCamerasAsHotSpotsChanged,i=>i.viewer.camerasAsHotSpots=this.camerasAsHotSpots??i.viewer.camerasAsHotSpots,i=>this.camerasAsHotSpots=i.viewer.camerasAsHotSpots)],this._isFaultedBacking=!1,this.engine=this._options.engine,this.renderWhenIdle=this._options.autoSuspendRendering===!1,this.source=this._options.source??null,this.extension=null,this.environmentLighting=this._options.environmentLighting??null,this.environmentSkybox=this._options.environmentSkybox??null,this.environmentIntensity=this._options.environmentConfig?.intensity??null,this.environmentRotation=this._options.environmentConfig?.rotation??null,this.shadowQuality=null,this._loadingProgress=!1,this.skyboxBlur=this._options.environmentConfig?.blur??null,this.toneMapping=this._options.postProcessing?.toneMapping??null,this.contrast=this._options.postProcessing?.contrast??null,this.exposure=this._options.postProcessing?.exposure??null,this.ssao=this._options.postProcessing?.ssao??null,this.clearColor=this._options.clearColor?new fe(this._options.clearColor[0],this._options.clearColor[1],this._options.clearColor[2],this._options.clearColor[3]??1):null,this.cameraAutoOrbit=this._options.cameraAutoOrbit?.enabled??!1,this.cameraAutoOrbitSpeed=this._options.cameraAutoOrbit?.speed??null,this.cameraAutoOrbitDelay=this._options.cameraAutoOrbit?.delay??null,this.hotSpots=this._options.hotSpots??{},this.animationAutoPlay=!!this._options.animationAutoPlay,this.selectedAnimation=this._options.selectedAnimation??null,this.animationSpeed=this._options.animationSpeed??1,this.animationProgress=0,this._animations=[],this._isAnimationPlaying=!1,this._showAnimationSlider=!0,this.selectedMaterialVariant=this._options.selectedMaterialVariant??null,this.camerasAsHotSpots=!1,this.resetMode="auto"}static get observedAttributes(){return[...super.observedAttributes,"camera-orbit","camera-target"]}get viewerDetails(){return this._viewerDetails}queryHotSpot(e,t){return this._viewerDetails?this._viewerDetails.viewer.queryHotSpot(e,t):!1}focusHotSpot(e){return this._viewerDetails?this._viewerDetails.viewer.focusHotSpot(e):!1}get _isFaulted(){return this._isFaultedBacking}get environment(){return{lighting:this.environmentLighting,skybox:this.environmentSkybox}}set environment(e){this.environmentLighting=e||null,this.environmentSkybox=e||null}get loadingProgress(){return this._loadingProgress}get _hasHotSpots(){return Object.keys(this.hotSpots).length>0}get animations(){return this._animations}get _hasAnimations(){return this._animations.length>0}get isAnimationPlaying(){return this._isAnimationPlaying}get materialVariants(){return this._viewerDetails?.viewer.materialVariants??[]}toggleAnimation(){this._viewerDetails?.viewer.toggleAnimation()}reset(){this._reset(this.resetMode)}_reset(e){switch(e){case"auto":this._viewerDetails?.viewer.resetCamera(void 0);break;case"reframe":this._viewerDetails?.viewer.resetCamera(!0);break;default:this._viewerDetails?.viewer.reset(...e);break}}resetCamera(){this._reset("reframe")}reload(){this._tearDownViewer(),this._setupViewer()}connectedCallback(){super.connectedCallback(),this._setupViewer()}disconnectedCallback(){super.disconnectedCallback(),this._tearDownViewer()}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),this.hasUpdated){if(e=="camera-orbit"){const s=Tr(i);s?this._viewerDetails?.viewer.updateCamera({alpha:s[0],beta:s[1],radius:s[2]}):this._viewerDetails?.viewer.resetCamera(!1)}else if(e=="camera-target"){const s=Tr(i);s?this._viewerDetails?.viewer.updateCamera({targetX:s[0],targetY:s[1],targetZ:s[2]}):this._viewerDetails?.viewer.resetCamera(!1)}}}update(e){super.update(e),this._hotSpotSelect&&(this._hotSpotSelect.value="");let t=!1;if(e.get("renderWhenIdle")!=null)t=!0;else if(e.has("engine")){const i=e.get("engine");i&&this.engine!==i&&(t=!0)}t?(this._tearDownViewer(),this._setupViewer()):(this._propertyBindings.filter(i=>e.has(i.property)).forEach(i=>i.updateViewer()),e.has("source")&&this._updateModel(),(e.has("environmentLighting")||e.has("environmentSkybox"))&&this._updateEnv({lighting:e.has("environmentLighting"),skybox:e.has("environmentSkybox")}),e.has("shadowQuality")&&this._updateShadows(this.shadowQuality))}render(){return ot`
65            <div class="full-size">
66                <div id="canvasContainer" class="full-size"></div>
67                ${this._renderOverlay()}
68            </div>
69        `}_renderProgressBar(){const e=this.loadingProgress!==!1,t=typeof this.loadingProgress=="boolean"?0:this.loadingProgress*100,i=this.loadingProgress===!0;return ot`
70            <div part="progress-bar" class="bar loading-progress-outer ${e?"":"loading-progress-outer-inactive"}" aria-label="Loading Progress">
71                <div
72                    class="loading-progress-inner ${i?"loading-progress-inner-indeterminate":""}"
73                    style="${i?"":`width: ${t}%`}"
74                ></div>
75            </div>
76        `}_renderToolbar(){let e=[];if(this._viewerDetails?.model!=null){this._hasAnimations&&e.push(ot`
77                    <div class="animation-timeline">
78                        <button aria-label="${this.isAnimationPlaying?"Pause":"Play"}" @click="${this.toggleAnimation}">
79                            ${this.isAnimationPlaying?ot`
80                                      <svg viewBox="0 0 24 24">
81                                          <path d="${$f}" fill="currentColor"></path>
82                                      </svg>
83                                  `:ot`
84                                      <svg viewBox="0 0 24 24">
85                                          <path d="${Zf}" fill="currentColor"></path>
86                                      </svg>
87                                  `}
88                        </button>
89                        <input
90                            ${jf(this._onAnimationSliderChanged)}
91                            aria-label="Animation Progress"
92                            class="animation-timeline-input"
93                            style="${this._showAnimationSlider?"":"visibility: hidden"}"
94                            type="range"
95                            min="0"
96                            max="1"
97                            step="0.0001"
98                            .value="${this.animationProgress}"
99                            @input="${this._onAnimationTimelineChanged}"
100                            @pointerdown="${this._onAnimationTimelinePointerDown}"
101                        />
102                    </div>
103                    <select aria-label="Select Animation Speed" @change="${this._onAnimationSpeedChanged}">
104                        ${lo.map(s=>ot`<option value="${s}" .selected="${this.animationSpeed===s}">${s}x</option> `)}
105                    </select>
106                    ${this.animations.length>1?ot`<select aria-label="Select Animation" @change="${this._onSelectedAnimationChanged}">
107                              ${this.animations.map((s,r)=>ot`<option value="${r}" .selected="${this.selectedAnimation===r}">${s}</option>`)}
108                          </select>`:""}
109                `),this.materialVariants.length>1&&e.push(ot`
110                    <select aria-label="Select Material Variant" @change="${this._onMaterialVariantChanged}">
111                        ${this.materialVariants.map(s=>ot`<option value="${s}" .selected="${this.selectedMaterialVariant===s}">${s}</option>`)}
112                    </select>
113                `),e.push(ot`
114                <button aria-label="Reset Camera Pose" @click="${this.reset}">
115                    <svg viewBox="0 0 24 24">
116                        <path d="${Jf}" fill="currentColor"></path>
117                    </svg>
118                </button>
119            `),this._hasHotSpots&&e.push(ot`
120                    <div class="select-container">
121                        <select id="hotSpotSelect" aria-label="Select HotSpot" @change="${this._onHotSpotsChanged}">
122                            <!-- When the select is forced to be less wide than the options, padding on the right is lost. Pad with white space. -->
123                            ${Object.keys(this.hotSpots).map(s=>ot`<option value="${s}">${s}&nbsp;&nbsp;</option>`)}
124                        </select>
125                        <!-- This button is not actually interactive, we want input to pass through to the select below. -->
126                        <button style="pointer-events: none">
127                            <svg viewBox="0 0 24 24">
128                                <path d="${e_}" fill="currentColor"></path>
129                            </svg>
130                        </button>
131                    </div>
132                `);const t=e.length,i=ot`<div class="divider"></div>`;e=e.reduce((s,r,n)=>n<t-1?[...s,r,i]:[...s,r],new Array)}return e.length>0?ot` <div part="tool-bar" class="bar ${this._hasAnimations?"":"bar-min"} tool-bar">${e}</div>`:ot``}_renderReloadButton(){return ot`${this._isFaulted?ot`
133                  <button aria-label="Reload" part="reload-button" class="reload-button" @click="${this.reload}">
134                      <svg viewBox="0 0 24 24">
135                          <path d="${t_}" fill="currentColor"></path>
136                      </svg>
137                  </button>
138              `:""}`}_renderOverlay(){return ot`
139            <slot class="full-size children-slot"></slot>
140            <slot name="progress-bar">${this._renderProgressBar()}</slot>
141            <slot name="tool-bar">${this._renderToolbar()}</slot>
142            <slot name="reload-button">${this._renderReloadButton()}</slot>
143        `}_dispatchCustomEvent(e,t){this.dispatchEvent(t(e))}_onSelectedAnimationChanged(e){const t=e.target;this.selectedAnimation=Number(t.value)}_onAnimationSpeedChanged(e){const t=e.target;this.animationSpeed=Number(t.value)}_onAnimationTimelineChanged(e){if(this._viewerDetails){const t=e.target,i=Number(t.value);i!==this.animationProgress&&(this._viewerDetails.viewer.animationProgress=i)}}_onAnimationTimelinePointerDown(e){this._viewerDetails?.viewer.isAnimationPlaying&&(this._viewerDetails.viewer.pauseAnimation(),e.target.addEventListener("pointerup",()=>this._viewerDetails?.viewer.playAnimation(),{once:!0}))}_onMaterialVariantChanged(e){const t=e.target;this.selectedMaterialVariant=t.value}_onHotSpotsChanged(e){const t=e.target,i=t.value;t.value="",this.focusHotSpot(i)}_onAnimationSliderChanged(e){this._animationSliderResizeObserver?.disconnect(),e&&(this._animationSliderResizeObserver=new ResizeObserver(()=>{this._showAnimationSlider=e.clientWidth>=80}),this._animationSliderResizeObserver.observe(e))}_createPropertyBinding(e,t,i,s){return{property:e,onInitialized:r=>{t(r).add(()=>{s(r)}),i(r)},updateViewer:()=>{this._viewerDetails&&i(this._viewerDetails)}}}async _setupViewer(){await this._viewerLock.lockAsync(async()=>
143{if(this._canvasContainer||await this.updateComplete,this._canvasContainer&&!this._viewerDetails){const e=document.createElement("canvas");e.className="full-size canvas",e.setAttribute("touch-action","none"),this._canvasContainer.appendChild(e);{const i=new Vn,s=this,r=await this._createViewer(e,new Proxy(this._options,{get(o,h){switch(h){case"engine":return s.engine??o.engine;case"autoSuspendRendering":return!(s.hasAttribute("render-when-idle")||o.autoSuspendRendering===!1);case"source":return s.getAttribute("source")??o.source;case"environmentLighting":return s.getAttribute("environment-lighting")??s.getAttribute("environment")??o.environmentLighting;case"environmentSkybox":return s.getAttribute("environment-skybox")??s.getAttribute("environment")??o.environmentSkybox;case"environmentConfig":return{intensity:mi(s.getAttribute("environment-intensity"))??o.environmentConfig?.intensity,blur:mi(s.getAttribute("skybox-blur"))??o.environmentConfig?.blur,rotation:mi(s.getAttribute("environment-rotation"))??o.environmentConfig?.rotation};case"shadowConfig":return{quality:n_(s.getAttribute("shadow-quality"))??o.shadowConfig?.quality};case"cameraOrbit":return Tr(s.getAttribute("camera-orbit"))??o.cameraOrbit;case"cameraTarget":return Tr(s.getAttribute("camera-target"))??o.cameraTarget;case"cameraAutoOrbit":return{enabled:s.hasAttribute("camera-auto-orbit")||o.cameraAutoOrbit?.enabled,speed:mi(s.getAttribute("camera-auto-orbit-speed"))??o.cameraAutoOrbit?.speed,delay:mi(s.getAttribute("camera-auto-orbit-delay"))??o.cameraAutoOrbit?.delay};case"animationAutoPlay":return s.hasAttribute("animation-auto-play")||o.animationAutoPlay;case"animationSpeed":return mi(s.getAttribute("animation-speed"))??o.animationSpeed;case"selectedAnimation":return mi(s.getAttribute("selected-animation"))??o.selectedAnimation;case"postProcessing":return{toneMapping:r_(s.getAttribute("tone-mapping"))??o.postProcessing?.toneMapping,contrast:mi(s.getAttribute("contrast"))??o.postProcessing?.contrast,exposure:mi(s.getAttribute("exposure"))??o.postProcessing?.exposure,ssao:s.hasAttribute("ssao")||o.postProcessing?.ssao};case"selectedMaterialVariant":return s.getAttribute("material-variant")??o.selectedMaterialVariant;case"onInitialized":return l=>{o.onInitialized?.(l),i.resolve(l)};case"onFaulted":return l=>{s._isFaultedBacking=!0,o.onFaulted?.(l),s._tearDownViewer()};default:return o[h]}}})),n=await i.promise;this._viewerDetails=Object.assign(n,{viewer:r})}const t=this._viewerDetails;t.viewer.onEnvironmentChanged.add(()=>{this._dispatchCustomEvent("environmentchange",i=>new Event(i))}),t.viewer.onEnvironmentConfigurationChanged.add(()=>{this._dispatchCustomEvent("environmentconfigurationchange",i=>new Event(i))}),t.viewer.onEnvironmentError.add(i=>{this._dispatchCustomEvent("environmenterror",s=>new ErrorEvent(s,{error:i}))}),t.viewer.onShadowsConfigurationChanged.add(()=>{this._dispatchCustomEvent("shadowsconfigurationchange",i=>new Event(i))}),t.viewer.onModelChanged.add(i=>{this._animations=[...t.viewer.animations],this._dispatchCustomEvent("modelchange",s=>new CustomEvent(s,{detail:i}))}),t.viewer.onModelError.add(i=>{this._animations=[...t.viewer.animations],this._dispatchCustomEvent("modelerror",s=>new ErrorEvent(s,{error:i}))}),t.viewer.onLoadingProgressChanged.add(()=>{this._loadingProgress=t.viewer.loadingProgress,this._dispatchCustomEvent("loadingprogresschange",i=>new Event(i))}),t.viewer.onSelectedAnimationChanged.add(()=>{this._dispatchCustomEvent("selectedanimationchange",i=>new Event(i))}),t.viewer.onIsAnimationPlayingChanged.add(()=>{this._isAnimationPlaying=t.viewer.isAnimationPlaying??!1,this._dispatchCustomEvent("animationplayingchange",i=>new Event(i))}),t.viewer.onAnimationProgressChanged.add(()=>{this.animationProgress=t.viewer.animationProgress??0,this._dispatchCustomEvent("animationprogresschange",i=>new Event(i))}),t.viewer.onSelectedMaterialVariantChanged.add(()=>{this._dispatchCustomEvent("selectedmaterialvariantchange",i=>new Event(i))}),t.scene.onAfterRenderCameraObservable.add(()=>{this._dispatchCustomEvent("viewerrender",i=>new Event(i))}
143),this._propertyBindings.forEach(i=>i.onInitialized(t)),this._dispatchCustomEvent("viewerready",i=>new Event(i))}this._isFaultedBacking=!1})}async _createViewer(e,t){return await ul(e,Object.assign(t,{viewerClass:this._viewerClass}))}async _tearDownViewer(){await this._viewerLock.lockAsync(async()=>{this._viewerDetails&&(this._viewerDetails.viewer.dispose(),this._viewerDetails=void 0),this._loadingProgress=!1,this._canvasContainer&&this._canvasContainer.firstElementChild&&this._canvasContainer.removeChild(this._canvasContainer.firstElementChild)})}async _updateModel(){if(this._viewerDetails)try{this.source?await this._viewerDetails.viewer.loadModel(this.source,{pluginExtension:this.extension??void 0}):await this._viewerDetails.viewer.resetModel()}catch(e){e instanceof Ot||w.Error(e)}}async _updateEnv(e){if(this._viewerDetails)try{const t=[];e.lighting&&e.skybox&&this.environmentLighting===this.environmentSkybox?t.push([this.environmentLighting,{lighting:!0,skybox:!0}]):(e.lighting&&t.push([this.environmentLighting,{lighting:!0}]),e.skybox&&t.push([this.environmentSkybox,{skybox:!0}]));const i=t.map(async([s,r])=>{s?await this._viewerDetails?.viewer.loadEnvironment(s,r):await this._viewerDetails?.viewer.resetEnvironment(r)});await Promise.all(i)}catch(t){t instanceof Ot||w.Error(t)}}async _updateShadows(e){if(e)try{const t={quality:e};await this._viewerDetails?.viewer.updateShadows(t)}catch(t){t instanceof Ot||w.Error(t)}}}Se.styles=sl`
144        :host {
145            --ui-foreground-color: white;
146            --ui-background-hue: 233;
147            --ui-background-saturation: 8%;
148            --ui-background-lightness: 39%;
149            --ui-background-opacity: 0.75;
150            --ui-background-color: hsla(var(--ui-background-hue), var(--ui-background-saturation), var(--ui-background-lightness), var(--ui-background-opacity));
151            --ui-background-color-hover: hsla(
152                var(--ui-background-hue),
153                var(--ui-background-saturation),
154                calc(var(--ui-background-lightness) - 10%),
155                calc(var(--ui-background-opacity) - 0.1)
156            );
157            all: inherit;
158            overflow: hidden;
159        }
160
161        .full-size {
162            display: block;
163            position: relative;
164            width: 100%;
165            height: 100%;
166        }
167
168        .canvas {
169            outline: none;
170        }
171
172        .children-slot {
173            position: absolute;
174            top: 0;
175            background: transparent;
176            pointer-events: none;
177        }
178
179        .reload-button {
180            position: absolute;
181            top: 50%;
182            left: 50%;
183            width: 25%;
184            transform: translate(-50%, -50%);
185            color: var(--ui-foreground-color);
186            background-color: var(--ui-background-color);
187            border: 1px solid transparent;
188            border-radius: 24px;
189            padding: 0;
190            cursor: pointer;
191            outline: none;
192        }
193
194        .reload-button:hover {
195            background-color: var(--ui-background-color-hover);
196        }
197
198        .bar {
199            position: absolute;
200            width: calc(100% - 24px);
201            min-width: 370px;
202            max-width: 1280px;
203            left: 50%;
204            transform: translateX(-50%);
205            background-color: var(--ui-background-color);
206        }
207
208        .bar-min {
209            width: unset;
210            min-width: unset;
211            max-width: unset;
212        }
213
214        .loading-progress-outer {
215            height: 4px;
216            border-radius: 4px;
217            border: 1px solid var(--ui-background-color);
218            outline: none;
219            top: 12px;
220            pointer-events: none;
221            transition: opacity 0.5s ease;
222        }
223
224        .loading-progress-outer-inactive {
225            opacity: 0;
226            /* Set the background color to the foreground color while in the inactive state so that the color seen is correct while fading out the opacity. */
227            background-color: var(--ui-foreground-color);
228        }
229
230        .loading-progress-inner {
231            width: 0;
232            height: 100%;
233            border-radius: inherit;
234            background-color: var(--ui-foreground-color);
235            transition: width 0.3s linear;
236        }
237
238        /* The right side of the inner progress bar starts aligned with the left side of the outer progress bar (container).
239           So, if the width is 30%, then the left side of the inner progress bar moves a total of 130% of the width of the container.
240           This is why the first keyframe is at 23% ((100/130)*30).
241         */
242        @keyframes indeterminate {
243            0% {
244                left: 0%;
245                width: 0%;
246            }
247            23% {
248                left: 0%;
249                width: 30%;
250            }
251            77% {
252                left: 70%;
253                width: 30%;
254            }
255            100% {
256                left: 100%;
257                width: 0%;
258            }
259        }
260
261        .loading-progress-inner-indeterminate {
262            position: absolute;
263            animation: indeterminate 1.5s infinite;
264            animation-timing-function: linear;
265        }
266
267        .tool-bar {
268            display: flex;
269            flex-direction: row;
270            align-items: center;
271            border-radius: 12px;
272            border-color: var(--ui-foreground-color);
273            height: 48px;
274            bottom: 12px;
275            color: var(--ui-foreground-color);
276            -webkit-tap-highlight-color: transparent;
277        }
278
279        .tool-bar * {
280            height: 100%;
281            min-width: 48px;
282        }
283
284        .tool-bar .divider {
285            min-width: 1px;
286            margin: 0px 6px;
287            height: 66%;
288            background-color: var(--ui-foreground-color);
289        }
290
291        .tool-bar select {
292            background: none;
293            min-width: 52px;
294            max-width: 128px;
295            border: 1px solid transparent;
296            border-radius: inherit;
297            color: inherit;
298            font-size: 14px;
299            padding: 0px 12px;
300            cursor: pointer;
301            outline: none;
302            appearance: none; /* Remove default styling */
303            -webkit-appearance: none; /* Remove default styling for Safari */
304        }
305
306        .tool-bar .select-container {
307            position: relative;
308            display: flex;
309            border-radius: inherit;
310            border-width: 0;
311            padding: 0;
312        }
313
314        .tool-bar .select-container select {
315            position: absolute;
316            min-width: 0;
317            width: 100%;
318        }
319
320        .tool-bar .select-container button {
321            position: absolute;
322            border-width: 0;
323        }
324
325        .tool-bar select:hover,
326        .tool-bar select:focus {
327            background-color: var(--ui-background-color-hover);
328        }
329
330        .tool-bar select option {
331            background-color: var(--ui-background-color);
332            color: var(--ui-foreground-color);
333        }
334
335        .tool-bar select:focus-visible {
336            border-color: inherit;
337        }
338
339        .tool-bar button {
340            background: none;
341            border: 1px solid transparent;
342            border-radius: inherit;
343            color: inherit;
344            padding: 0;
345            cursor: pointer;
346            outline: none;
347        }
348
349        .tool-bar button:hover {
350            background-color: var(--ui-background-color-hover);
351        }
352
353        .tool-bar button:focus-visible {
354            border-color: inherit;
355        }
356
357        .tool-bar button svg {
358            width: 32px;
359            height: 32px;
360        }
361
362        .animation-timeline {
363            display: flex;
364            flex: 1;
365            position: relative;
366            overflow: hidden;
367            cursor: pointer;
368            align-items: center;
369            border-radius: inherit;
370            border-color: inherit;
371        }
372
373        .animation-timeline-input {
374            -webkit-appearance: none;
375            cursor: pointer;
376            width: 100%;
377            height: 100%;
378            outline: none;
379            border: 1px solid transparent;
380            border-radius: inherit;
381            padding: 0 12px;
382            background-color: transparent;
383        }
384
385        .animation-timeline-input:focus-visible {
386            border-color: inherit;
387        }
388
389        /*Chrome -webkit */
390
391        .animation-timeline-input::-webkit-slider-thumb {
392            -webkit-appearance: none;
393            width: 20px;
394            height: 20px;
395            border: 2px solid;
396            color: var(--ui-foreground-color);
397            border-radius: 50%;
398            background: hsla(var(--ui-background-hue), var(--ui-background-saturation), var(--ui-background-lightness), 1);
399            margin-top: -10px;
400        }
401
402        .animation-timeline-input::-webkit-slider-runnable-track {
403            height: 2px;
404            -webkit-appearance: none;
405            background-color: var(--ui-foreground-color);
406        }
407
408        /** FireFox -moz */
409
410        .animation-timeline-input::-moz-range-progress {
411            height: 2px;
412            background-color: var(--ui-foreground-color);
413        }
414
415        .animation-timeline-input::-moz-range-thumb {
416            width: 16px;
417            height: 16px;
418            border: 2px solid var(--ui-foreground-color);
419            border-radius: 50%;
420            background: hsla(var(--ui-background-hue), var(--ui-background-saturation), var(--ui-background-lightness), 1);
421        }
422
423        .animation-timeline-input::-moz-range-track {
424            height: 2px;
425            background: var(--ui-foreground-color);
426        }
427    `;T([lr()],Se.prototype,"_isFaultedBacking",void 0);T([Be({converter:s_})],Se.prototype,"engine",void 0);T([Be({attribute:"render-when-idle",type:Boolean})],Se.prototype,"renderWhenIdle",void 0);T([Be()],Se.prototype,"source",void 0);T([Be()],Se.prototype,"extension",void 0);T([Be({hasChanged:(a,e)=>a.lighting!==e.lighting||a.skybox!==e.skybox})],Se.prototype,"environment",null);T([Be({attribute:"environment-lighting"})],Se.prototype,"environmentLighting",void 0);T([Be({attribute:"environment-skybox"})],Se.prototype,"environmentSkybox",void 0);T([Be({type:Number,attribute:"environment-intensity"})],Se.prototype,"environmentIntensity",void 0);T([Be({type:Number,attribute:"environment-rotation"})],Se.prototype,"environmentRotation",void 0);T([Be({attribute:"shadow-quality"})],Se.prototype,"shadowQuality",void 0);T([lr()],Se.prototype,"_loadingProgress",void 0);T([Be({attribute:"skybox-blur"})],Se.prototype,"skyboxBlur",void 0);T([Be({attribute:"tone-mapping",converter:a=>!a||!Jh(a)?"neutral":a})],Se.prototype,"toneMapping",void 0);T([Be()],Se.prototype,"contrast",void 0);T([Be()],Se.prototype,"exposure",void 0);T([Be({type:String})],Se.prototype,"ssao",void 0);T([Be({attribute:"clear-color",converter:{fromAttribute:i_,toAttribute:a=>a?a.toHexString():null}})],Se.prototype,"clearColor",void 0);T([Be({attribute:"camera-auto-orbit",type:Boolean})],Se.prototype,"cameraAutoOrbit",void 0);T([Be({attribute:"camera-auto-orbit-speed",type:Number})],Se.prototype,"cameraAutoOrbitSpeed",void 0);T([Be({attribute:"camera-auto-orbit-delay",type:Number})],Se.prototype,"cameraAutoOrbitDelay",void 0);T([Be({attribute:"hotspots",converter:a=>a?JSON.parse(a):{}})],Se.prototype,"hotSpots",void 0);T([Be({attribute:"animation-auto-play",type:Boolean})],Se.prototype,"animationAutoPlay",void 0);T([Be({attribute:"selected-animation",type:Number})],Se.prototype,"selectedAnimation",void 0);T([Be({attribute:"animation-speed"})],Se.prototype,"animationSpeed",void 0);T([Be({attribute:!1})],Se.prototype,"animationProgress",void 0);T([lr()],Se.prototype,"_animations",void 0);T([lr()],Se.prototype,"_isAnimationPlaying",void 0);T([lr()],Se.prototype,"_showAnimationSlider",void 0);T([Be({attribute:"material-variant"})],Se.prototype,"selectedMaterialVariant",void 0);T([Be({attribute:"cameras-as-hotspots",type:Boolean})],Se.prototype,"camerasAsHotSpots",void 0);T([Be({attribute:"reset-mode",converter:a_})],Se.prototype,"resetMode",void 0);T([ll("#canvasContainer")],Se.prototype,"_canvasContainer",void 0);T([ll("#hotSpotSelect")],Se.prototype,"_hotSpotSelect",void 0);let Nr=class extends Se{constructor(e){super(Yn,e)}};Nr=T([hl("babylon-viewer")],Nr);function o_(a,e){customElements.define(a,class extends Nr{constructor(){super(e)}})}let Js=class extends _s{constructor(){super(...arguments),this._internals=this.attachInternals(),this._mutationObserver=new MutationObserver(e=>{e.some(t=>t.type==="childList")&&this._sanitizeInnerHTML()}),this._viewerAttachment=null,this._connectingAbortController=null,this._updateAnnotation=null,this.hotSpot=""}connectedCallback(){super.connectedCallback(),this._internals.states?.add("invalid"),this._connectingAbortController?.abort(),this._connectingAbortController=new AbortController;const e=this._connectingAbortController.signal;(async()=>
vendor: 4,848 bytes, lines 427-467
427{if(this.parentElement?.matches(":not(:defined)")&&(await customElements.whenDefined(this.parentElement?.tagName.toLowerCase()),e.aborted))return;if(!(this.parentElement instanceof Se)){console.warn("The babylon-viewer-annotation element must be a child of a babylon-viewer element.");return}this._mutationObserver.observe(this,{childList:!0,characterData:!0}),this._sanitizeInnerHTML();const t=this.parentElement,i=new Kn,s=this._updateAnnotation=()=>{if(this.hotSpot)if(t.queryHotSpot(this.hotSpot,i)){const[r,n]=i.screenPosition;this.style.transform=`translate(${r}px, ${n}px)`,this._internals.states?.delete("invalid"),i.visibility<=0?this._internals.states?.add("back-facing"):this._internals.states?.delete("back-facing")}else this._internals.states?.add("invalid")};this._updateAnnotation(),t.addEventListener("viewerrender",s),this._viewerAttachment={dispose(){t.removeEventListener("viewerrender",s)}}})()}disconnectedCallback(){super.disconnectedCallback(),this._connectingAbortController?.abort(),this._connectingAbortController=null,this._viewerAttachment?.dispose(),this._viewerAttachment=null,this._internals.states?.add("invalid"),this._updateAnnotation=null}render(){return ot` <slot><div aria-label="${this.hotSpot} annotation" part="annotation" class="annotation">${this.hotSpot}</div></slot> `}update(e){super.update(e),e.has("hotSpot")&&this._updateAnnotation?.()}_sanitizeInnerHTML(){this.innerHTML.trim().length===0&&(this.innerHTML="")}};Js.styles=sl`
428        :host {
429            --annotation-foreground-color: black;
430            --annotation-background-color: white;
431            display: inline-block;
432            position: absolute;
433            transition: opacity 0.25s;
434        }
435
436        :host([hidden]) {
437            display: none;
438        }
439
440        :host(:state(back-facing)) {
441            opacity: 0.2;
442        }
443
444        :host(:state(invalid)) {
445            display: none;
446        }
447
448        .annotation {
449            transform: translate(-50%, -135%);
450            font-size: 14px;
451            padding: 0px 6px;
452            border-radius: 6px;
453            color: var(--annotation-foreground-color);
454            background-color: var(--annotation-background-color);
455        }
456
457        .annotation::after {
458            content: "";
459            position: absolute;
460            left: 50%;
461            height: 60%;
462            aspect-ratio: 1;
463            transform: translate(-50%, 110%) rotate(-45deg);
464            background-color: inherit;
465            clip-path: polygon(0 0, 100% 100%, 0 100%, 0 0);
466        }
467    `;T([Be({attribute:"hotspot"})],Js.prototype,"hotSpot",void 0);Js=T([hl("babylon-viewer-annotation")],Js);const L_=Object.freeze(Object.defineProperty({__proto__:null,ConfigureCustomViewerElement:o_,CreateHotSpotFromCamera:tl,CreateViewerForCanvas:ul,DefaultViewerOptions:Je,get HTML3DAnnotationElement(){return Js},get HTML3DElement(){return Nr},Viewer:Yn,ViewerElement:Se,ViewerHotSpotResult:Kn},Symbol.toStringTag,{value:"Module"}));export{sh as $,H as A,De as B,q as C,ss as D,vh as E,nh as F,Oi as G,oh as H,Et as I,b as J,ah as K,w as L,P as M,Jo as N,O,ka as P,qc as Q,nt as R,We as S,z as T,_h as U,_ as V,ue as W,gh as X,qo as Y,ph as Z,T as _,re as a,ua as a$,Ue as a0,th as a1,jo as a2,rh as a3,$o as a4,eh as a5,Zo as a6,U as a7,Dh as a8,Ih as a9,je as aA,be as aB,Mo as aC,$u as aD,rt as aE,yi as aF,rf as aG,ye as aH,me as aI,j as aJ,y as aK,Bi as aL,Vn as aM,M_ as aN,S_ as aO,Xr as aP,te as aQ,gu as aR,A_ as aS,E_ as aT,b_ as aU,_u as aV,T_ as aW,R_ as aX,xh as aY,ms as aZ,Me as a_,Ph as aa,Bd as ab,Si as ac,Oe as ad,B as ae,At as af,l_ as ag,Q as ah,ge as ai,Gh as aj,C_ as ak,ih as al,u_ as am,qe as an,W as ao,Ai as ap,Te as aq,Hr as ar,k as as,So as at,Dr as au,Lt as av,sf as aw,Ps as ax,js as ay,vl as az,tt as b,zt as b$,yh as b0,J as b1,Kc as b2,m_ as b3,p_ as b4,Yc as b5,gt as b6,hi as b7,co as b8,fe as b9,Ve as bA,Wr as bB,Qt as bC,ve as bD,Rn as bE,g_ as bF,Ks as bG,Xs as bH,sr as bI,Ru as bJ,et as bK,f_ as bL,ja as bM,gr as bN,Ln as bO,Li as bP,xs as bQ,P_ as bR,Kh as bS,Kd as bT,__ as bU,wn as bV,Ir as bW,Dc as bX,ze as bY,d_ as bZ,Eo as b_,ct as ba,kn as bb,Gc as bc,Gr as bd,ie as be,qa as bf,Ct as bg,ae as bh,Ae as bi,qs as bj,nr as bk,ii as bl,Ii as bm,V as bn,tr as bo,Tt as bp,Qa as bq,Rl as br,Au as bs,Eu as bt,bu,Tu as bv,mu as bw,pu as bx,vt as by,Ds as bz,v as c,Cc as c0,Mc as c1,y_ as c2,Un as c3,Za as c4,oi as c5,K as c6,ic as c7,na as c8,sc as c9,ir as ca,Zl as cb,Ac as cc,Ec as cd,Ti as ce,od as cf,sd as cg,bs as ch,gd as ci,nd as cj,Lo as ck,fd as cl,md as cm,pd as cn,Td as co,bd as cp,Uh as cq,Ed as cr,mh as cs,wo as ct,_d as cu,x_ as cv,I_ as cw,L_ as cx,se as d,le as e,qt as f,c_ as g,Bn as h,On as i,tf as j,ud as k,ne as l,$ as m,it as n,F as o,lh as p,fh as q,su as r,R as s,iu as t,It as u,Ne as v,ch as w,hh as x,uh as y,dh as z};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.