PageSourceSearch

https://ml8r-soundvector.hf.space/assets/index-CFHfsWZK.js

js ml8r-soundvector.hf.space collected 2026-10-03 17:09:29 UTC 1,213,466 bytes, 505 lines download raw bytes

vendor: 20,855 bytes, lines 1-2
1const __vite__fileDeps=["./iesTextureLoader-CHFHas9G.js","./index-Do3LSwBC.js","./index-CHc6r96-.css","./ddsTextureLoader-D5lPLKp_.js","./dds-DixzcEvL.js","./abstractEngine.cubeTexture-BASaYweu.js","./basisTextureLoader-DRmsxhaA.js","./envTextureLoader-BrkIj0tP.js","./environmentTextureTools-CKfezl51.js","./dumpTools-FN1JTOHi.js","./hdrTextureLoader-CmaePHS-.js","./hdr-Bq_8utxw.js","./ktxTextureLoader-Cq2m-Sq7.js","./workerPool-CfMXSLnf.js","./tgaTextureLoader-HBuOg8DH.js","./exrTextureLoader-SNuVWNEu.js","./postprocess.vertex-B1o_Xii7.js","./pass.fragment-BmRfDBYP.js","./pass.fragment-DM0HxvmX.js","./passCube.fragment-BrW21GVa.js","./passCube.fragment-B9YksETb.js","./rgbdDecode.fragment-CQWUQfhY.js","./helperFunctions-BuLYHN3w.js","./rgbdDecode.fragment-zQMwkG3_.js","./helperFunctions-DgUIRvI1.js","./rgbdEncode.fragment-JPw6oGdD.js","./rgbdEncode.fragment-DZmmpssc.js","./pbr.vertex-CT0VYelJ.js","./harmonicsFunctions-CCe3Or1_.js","./meshUboDeclaration-Ds-3afV9.js","./vertexColorMixing-CdtX6QRq.js","./mainUVVaryingDeclaration-acJCdZzO.js","./bakedVertexAnimation-BIxy4Lmt.js","./logDepthVertex-89ZeYAjy.js","./logDepthDeclaration-BUCE0Urq.js","./pbr.fragment-BNttJE0O.js","./oitFragment-C_dfDWek.js","./fogFragment-tKd_0w3t.js","./hdrFilteringFunctions-D8yL88CU.js","./decalFragment-CT67sFxC.js","./pbr.vertex-CtEhXYgW.js","./vertexColorMixing-XeZCYuAV.js","./harmonicsFunctions-h9amqH4m.js","./logDepthDeclaration-BenmCZRJ.js","./mainUVVaryingDeclaration-BEIW-N0T.js","./logDepthVertex-DISwdaFB.js","./pbr.fragment-CqKe22ec.js","./oitFragment-C4xISFDN.js","./fogFragment-BeVWNCua.js","./hdrFilteringFunctions-CSjvQxyF.js","./EXT_lights_image_based-BsNp6JUy.js","./cubeTexture-BKRwbDv0.js","./glTFLoader-D1J2X7DA.js","./bone-Bi3K2QD7.js","./rawTexture-Bf8sqxDX.js","./assetContainer-Dx0xYzI5.js","./objectModelMapping-Ci_2_hsw.js","./EXT_mesh_gpu_instancing-CAv0FSQb.js","./thinInstanceMesh-WRPy-_Lq.js","./EXT_meshopt_compression-D4GQHsLC.js","./EXT_texture_avif-CA35hw-I.js","./EXT_texture_webp-Cst_912F.js","./ExtrasAsMetadata-dmBZGe0V.js","./KHR_animation_pointer--sdv68Zi.js","./glTFLoaderAnimation-CiNDLNe9.js","./KHR_draco_mesh_compression-BP13qWlt.js","./KHR_interactivity-BWDmpWVB.js","./declarationMapper-BUZCyDzt.js","./KHR_lights_punctual-CqmCIXmi.js","./EXT_lights_ies-BEE0trGu.js","./KHR_materials_anisotropy-C7sSQ6HJ.js","./KHR_materials_clearcoat-DAzq7TUe.js","./KHR_materials_diffuse_transmission-DtXEk-Nm.js","./KHR_materials_dispersion-C909cV8R.js","./KHR_materials_emissive_strength-CHfA4dui.js","./KHR_materials_ior-D7SBRgdl.js","./KHR_materials_iridescence-qpOPL2zd.js","./KHR_materials_pbrSpecularGlossiness-xOTKMVvb.js","./KHR_materials_sheen-BFWfJKrE.js","./KHR_materials_specular-Dd7hqLZ_.js","./KHR_materials_transmission-CSC_ev2k.js","./KHR_materials_unlit-CAidPUi6.js","./KHR_materials_variants-DfvkIGRS.js","./KHR_materials_volume-ByedIIn-.js","./KHR_mesh_quantization-QxQB2tfe.js","./KHR_texture_basisu-BrUPMRDb.js","./KHR_texture_transform-CL2sV98D.js","./KHR_xmp_json_ld-C5VTzCWd.js","./MSFT_audio_emitter-CH-xxz_s.js","./audioEngine-CL8q_A19.js","./MSFT_lod-xm5NYZKR.js","./MSFT_minecraftMesh-Rbkc50rD.js","./MSFT_sRGBFactors-BVQ-jX9H.js","./KHR_node_visibility-rjN_FMyb.js","./KHR_node_hoverability-XCLcvC4I.js","./KHR_node_selectability-DKourFKO.js","./objFileLoader-D8fTW4lc.js","./standardMaterial-Cjj-zzYY.js","./splatFileLoader-B8s2l1yo.js","./ray-TYnp1nlE.js","./stlFileLoader-BBIVtB-D.js","./hdrCubeTexture-C7L7dB6V.js","./webgpuEngine-DNcJ2-XH.js","./fresnelFunction-BKo1GnkH.js"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]);
2import{_ as j}from"./index-Do3LSwBC.js";function p(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 Ps={},Bs={};function wo(a){const e=a.getClassName();return Bs[e]||(Bs[e]={}),Bs[e]}function vr(a){const e=a.getClassName();if(Ps[e])return Ps[e];Ps[e]={};const t=Ps[e];let i=a,s=e;for(;s;){const r=Bs[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 Ot(a,e){return(t,i)=>{const s=wo(t);s[i]||(s[i]={type:a,sourceName:e})}}function Lo(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 N(a,e=null){return Lo(a,e)}function E(a){return Ot(0,a)}function Ie(a){return Ot(1,a)}function Rt(a){return Ot(2,a)}function Td(a){return Ot(3,a)}function ma(a){return Ot(4,a)}function ri(a){return Ot(5,a)}function Ta(a){return Ot(6,a)}function Bo(a){return Ot(7,a)}function ba(a){return Ot(8,a)}function No(a){return Ot(9,a)}function Uo(a){return Ot(10,a)}function bd(a){return Ot(12,a)}function si(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)}}si.filter=function(a){return(e,t,i)=>si(e,t,i,a)};const ko=typeof WeakRef<"u";class Vo{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 Ho{constructor(e,t,i=null){this.callback=e,this.mask=t,this.scope=i,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1,this._remove=null}remove(){this._remove&&this._remove()}}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 Vo(0),e&&(this._onObserverAdded=e)}add(e,t=-1,i=!1,s=null,r=!1){if(!e)return null;const n=new Ho(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=ko?new WeakRef(this):{deref:()=>this};return n._remove=()=>{const h=o.deref();h&&h._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 Go=1/2.2,Ns=2.2,_e=.001;function ti(a,e){const t=[];for(let i=0;i<a;++i)t.push(e());return t}function ni(a,e){return ti(a,e)}function zo(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}}const Wo=["push","splice","pop","shift","unshift"];function Aa(a,e){const t=Wo.map(i=>zo(a,i,e));return()=>{t.forEach(i=>{i?.()})}}const Ea={};function it(a,e){Ea[a]=e}function fi(a){return Ea[a]}class We{static SetMatrixPrecision(e){if(We.MatrixTrackPrecisionChange=!1,e&&!We.MatrixUse64Bits&&We.MatrixTrackedMatrices)for(let t=0;t<We.MatrixTrackedMatrices.length;++t){const i=We.MatrixTrackedMatrices[t],s=i._m;i._m=new Array(16);for(let r=0;r<16;++r)i._m[r]=s[r]}We.MatrixUse64Bits=e,We.MatrixCurrentType=We.MatrixUse64Bits?Array:Float32Array,We.MatrixTrackedMatrices=null}}We.MatrixUse64Bits=!1;We.MatrixTrackPrecisionChange=!0;We.MatrixCurrentType=Float32Array;We.MatrixTrackedMatrices=[];class de{static get LastCreatedEngine(){return this.Instances.length===0?null:this.Instances[this.Instances.length-1]}static get LastCreatedScene(){return this._LastCreatedScene}}de.Instances=[];de.OnEnginesDisposedObservable=new O;de._LastCreatedScene=null;de.UseFallbackTexture=!0;de.FallbackTexture="";function Xo(a){return parseInt(a.toString().replace(/\W/g,""))}function ye(a,e,t=1401298e-51){return Math.abs(a-e)<=t}function Ko(a,e,t,i=1401298e-51){return a<e-i||a>t+i}function Oe(a,e){return a===e?a:Math.random()*(e-a)+a}function Hr(a,e,t){return a+(e-a)*t}function Yo(a,e,t){let i=Js(e-a,360);return i>180&&(i-=360),a+i*Te(t)}function qo(a,e,t){let i=0;return a!=e?i=Te((t-a)/(e-a)):i=0,i}function Ra(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 Qo(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 Te(a,e=0,t=1){return Math.min(t,Math.max(e,a))}function ya(a){return a-=Math.PI*2*Math.floor((a+Math.PI)/(Math.PI*2)),a}function Bt(a){const e=a.toString(16);return a<=15?("0"+e).toUpperCase():e.toUpperCase()}function jo(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 Js(a,e){return a-Math.floor(a/e)*e}function Zo(a,e,t){return(a-e)/(t-e)}function Jo(a,e,t){return a*(t-e)+e}function xa(a,e){let t=Js(e-a,360);return t>180&&(t-=360),t}function $o(a,e){const t=Js(a,e*2);return e-Math.abs(t-e)}function eh(a,e,t){let i=Te(t);return i=-2*i*i*i+3*i*i,e*i+a*(1-i)}function Sa(a,e,t){let i=0;return Math.abs(e-a)<=t?i=e:i=a+Math.sign(e-a)*t,i}function th(a,e,t){const i=xa(a,e);let s=0;return-t<i&&i<t?s=e:(e=a+i,s=Sa(a,e,t)),s}function ih(a,e,t){return(a-e)/(t-e)}function sh(a,e,t){return(t-e)*a+e}function Ma(a,e){const t=a%e;return t===0?e:Ma(e,t)}const Ad=Object.freeze(Object.defineProperty({__proto__:null,Clamp:Te,DeltaAngle:xa,Denormalize:Jo,ExtractAsInt:Xo,Hermite:Ra,Hermite1stDerivative:Qo,HighestCommonFactor:Ma,ILog2:jo,InverseLerp:qo,Lerp:Hr,LerpAngle:Yo,MoveTowards:Sa,MoveTowardsAngle:th,Normalize:Zo,NormalizeRadians:ya,OutsideRange:Ko,PercentToRange:sh,PingPong:$o,RandomRange:Oe,RangeToPercent:ih,Repeat:Js,SmoothStep:eh,ToHex:Bt,WithinEpsilon:ye},Symbol.toStringTag,{value:"Module"})),_t=a=>parseInt(a.toString().replace(/\W/g,""));class Z{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=_t(this.x),t=_t(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 Z.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 Z(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 Z(this.x+e.x,this.y+e.y)}subtract(e){return new Z(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 Z(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 Z(this.x*e,this.y*t)}divide(e){return new Z(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 Z(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 Z(-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 Z(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=_e){return e&&ye(this.x,e.x,t)&&ye(this.y,e.y,t)}equalsToFloats(e,t){return this.x===e&&this.y===t}floor(){return new Z(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 Z(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}rotateToRef(e,t){const i=Math.cos(e),s=Math.sin(e),r=i*this.x-s*this.y,n=s*this.x+i*this.y;return t.x=r,t.y=n,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 Z;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 Z(this.x,this.y)}dot(e){return this.x*e.x+this.y*e.y}static Zero(){return new Z(0,0)}static One(){return new Z(1,1)}static Random(e=0,t=1){return new Z(Oe(e,t),Oe(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(Oe(e,t),Oe(e,t))}static get ZeroReadOnly(){return Z._ZeroReadOnly}static FromArray(e,t=0){return new Z(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 Z(h,l)}static ClampToRef(e,t,i,s){return s.x=Te(e.x,t.x,i.x),s.y=Te(e.y,t.y,i.y),s}static Clamp(e,t,i){const s=Te(e.x,t.x,i.x),r=Te(e.y,t.y,i.y);return new Z(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 Z(f,d)}static Hermite1stDerivative(e,t,i,s,r){return this.Hermite1stDerivativeToRef(e,t,i,s,r,new Z)}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 Z.LerpToRef(e,t,i,new Z)}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 Z.NormalizeToRef(e,new Z)}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 Z(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 Z(i,s)}static Transform(e,t){return Z.TransformToRef(e,t,new Z)}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(Z.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 Z.CenterToRef(e,t,new Z)}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=Z.DistanceSquared(t,i);if(s===0)return Z.Distance(e,t);const r=i.subtract(t),n=Math.max(0,Math.min(1,Z.Dot(e.subtract(t),r)/s)),o=t.add(r.multiplyByFloats(n,n));return Z.Distance(e,o)}}Z._V8PerformanceHack=new Z(.5,.5);Z._ZeroReadOnly=Z.Zero();Object.defineProperties(Z.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=_t(this._x),t=_t(this._y),i=_t(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 U.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=z.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=_
vendor: 3,741 bytes, line 2
2e){return e&&ye(this._x,e._x,t)&&ye(this._y,e._y,t)&&ye(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(!ye(t,i,e))return!0;const s=Math.abs(this._z);return!ye(t,s,e)||!ye(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=z.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(z.Matrix[0]),_.TransformCoordinatesToRef(this,z.Matrix[0],t),t}rotateByQuaternionAroundPointToRef(e,t,i){return this.subtractToRef(t,z.Vector3[0]),z.Vector3[0].rotateByQuaternionToRef(e,z.Vector3[0]),t.addToRef(z.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(z.Vector3[1]),r=t.normalizeToRef(z.Vector3[2]);let n=_.Dot(s,r);n=Te(n,-1,1);const o=Math.acos(n),h=z.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){z.Vector3[0].copyFrom(e);const s=z.Vector3[0];z.Vector3[1].copyFrom(t);const r=z.Vector3[1];z.Vector3[2].copyFrom(i);const n=z.Vector3[2],o=z.Vector3[3],h=z.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 
vendor: 24,114 bytes, line 2
2ya(l)}static PitchYawRollToMoveBetweenPointsToRef(e,t,i){const s=C.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=Te(i,0,1);const r=z.Vector3[0],n=z.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-_e){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(Hr(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 _(Oe(e,t),Oe(e,t),Oe(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(Oe(e,t),Oe(e,t),Oe(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=z.Matrix[1],u=de.LastCreatedEngine?.isNDCHalfZRange,f=u?1:.5,d=u?0:.5;M.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=z.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=C.Vector3[0];return s.copyFrom(t).scaleInPlace(2*_.Dot(e,t)),i.copyFrom(e).subtractInPlace(s)}static _UnprojectFromInvertedMatrixToRef(e,t,i){_.TransformCoordinatesToRef(e,t,i);const s=t.m,r=e._x*s[3]+e._y*s[7]+e._z*s[11]+s[15];return ye(r,1)&&i.scaleInPlace(1/r),i}static UnprojectFromTransform(e,t,i,s,r){return this.Unproject(e,t,i,s,r,M.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=z.Matrix[0];n.multiplyToRef(o,c),c.multiplyToRef(h,c),c.invert();const u=z.Vector3[0];return u.x=e/s*2-1,u.y=-(t/r*2-1),de.LastCreatedEngine?.isNDCHalfZRange?u.z=i:u.z=2*i-1,_._UnprojectFromInvertedMatrixToRef(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=z.Vector3[0],o=z.Vector3[1],h=z.Vector3[2],l=z.Vector3[3],c=z.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<_e||f<_e||d<_e)return r.copyFrom(t),_.Distance(e,t);e.subtractToRef(t,c),_.CrossToRef(n,o,l);const g=l.length();if(g<_e)return r.copyFrom(t),_.Distance(e,t);l.normalizeFromLength(g);let m=c.length();if(m<_e)return r.copyFrom(t),0;c.normalizeFromLength(m);const b=_.Dot(l,c),y=z.Vector3[5],A=z.Vector3[6];y.copyFrom(l).scaleInPlace(-m*b),A.copyFrom(e).addInPlace(y);const P=z.Vector3[4],I=z.Vector3[5],x=z.Vector3[7],R=z.Vector3[8];P.copyFrom(n).scaleInPlace(1/u),R.copyFrom(o).scaleInPlace(1/f),P.addInPlace(R).scaleInPlace(-1),I.copyFrom(n).scaleInPlace(-1/u),R.copyFrom(h).scaleInPlace(1/d),I.addInPlace(R).scaleInPlace(-1),x.copyFrom(h).scaleInPlace(-1/d),R.copyFrom(o).scaleInPlace(-1/f),x.addInPlace(R).scaleInPlace(-1);const S=z.Vector3[9];let D;S.copyFrom(A).subtractInPlace(t),_.CrossToRef(P,S,R),D=_.Dot(R,l);const G=D;S.copyFrom(A).subtractInPlace(i),_.CrossToRef(I,S,R),D=_.Dot(R,l);const X=D;S.copyFrom(A).subtractInPlace(s),_.CrossToRef(x,S,R),D=_.Dot(R,l);const Re=D,fe=z.Vector3[10];let ge,ue;G>0&&X<0?(fe.copyFrom(n),ge=t,ue=i):X>0&&Re<0?(fe.copyFrom(h),ge=i,ue=s):(fe.copyFrom(o).scaleInPlace(-1),ge=s,ue=t);const ze=z.Vector3[9],$e=z.Vector3[4];if(ge.subtractToRef(A,R),ue.subtractToRef(A,ze),_.CrossToRef(R,ze,$e),!(_.Dot($e,l)<0))return r.copyFrom(A),Math.abs(m*b);const Ke=z.Vector3[5];_.CrossToRef(fe,$e,Ke),Ke.normalize();const Ye=z.Vector3[9];Ye.copyFrom(ge).subtractInPlace(A);const ct=Ye.length();if(ct<_e)return r.copyFrom(ge),_.Distance(e,ge);Ye.normalizeFromLength(ct);const Tt=_.Dot(Ke,Ye),kt=z.Vector3[7];kt.copyFrom(A).addInPlace(Ke.scaleInPlace(ct*Tt)),R.copyFrom(kt).subtractInPlace(ge),m=fe.length(),fe.normalizeFromLength(m);let hi=_.Dot(R,fe)/Math.max(m,_e);return hi=Te(hi,0,1),kt.copyFrom(ge).addInPlace(fe.scaleInPlace(hi*m)),r.copyFrom(kt),_.Distance(e,kt)}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=z.Quaternion[0];return U.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 he{constructor(e=0,t=0,i=0,s=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=_t(this.x),t=_t(this.y),i=_t(this.z),s=_t(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 he.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 he(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 he(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 he(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 he(-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 he(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=_e){return e&&ye(this.x,e.x,t)&&ye(this.y,e.y,t)&&ye(this.z,e.z,t)&&ye(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 he(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 he(this.x*e,this.y*t,this.z*i,this.w*s)}divide(e){return new he(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 he(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 he(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 he)}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 he(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 he(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 he.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 he(0,0,0,0)}static One(){return new he(1,1,1,1)}static Random(e=0,t=1){return new he(Oe(e,t),Oe(e,t),Oe(e,t),Oe(e,t))}static RandomToRef(e=0,t=1,i){return i.x=Oe(e,t),i.y=Oe(e,t),i.z=Oe(e,t),i.w=Oe(e,t),i}static Clamp(e,t,i){return he.ClampToRef(e,t,i,new he)}static ClampToRef(e,t,i,s){return s.x=Te(e.x,t.x,i.x),s.y=Te(e.y,t.y,i.y),s.z=Te(e.z,t.z,i.z),s.w=Te(e.w,t.w,i.w),s}static CheckExtends(e,t,i){t.minimizeInPlace(e),i.maximizeInPlace(e)}static get ZeroReadOnly(){return he._ZeroReadOnly}static Normalize(e){return he.NormalizeToRef(e,new he)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){const i=new he;return i.copyFrom(e),i.minimizeInPlace(t),i}static Maximize(e,t){const i=new he;return i.copyFrom(e),i.maximizeInPlace(t),i}static Distance(e,t){return Math.sqrt(he.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 he.CenterToRef(e,t,new he)}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 he.TransformCoordinatesToRef(e,t,new he)}static TransformCoordinatesToRef(e,t,i){return he.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 he.TransformNormalToRef(e,t,new he)}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 he(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}}he._V8PerformanceHack=new he(.5,.5,.5,.5);he._ZeroReadOnly=he.Zero();Object.defineProperties(he.prototype,{dimension:{value:[4]},rank:{value:1}});class U{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=_t(this._x),t=_t(this._y),i=_t(this._z),s=_t(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 U.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=_e){return e&&ye(this._x,e._x,t)&&ye(this._y,e._y,t)&&ye(this._z,e._z,t)&&ye(this._w,e._w,t)}isApprox(e,t=_e){return e&&(ye(this._x,e._x,t)&&ye(this._y,e._y,t)&&ye(this._z,e._z,t)&&ye(this._w,e._w,t)||ye(this._x,-e._x,t)&&ye(this._y,-e._y,t)&&ye(this._z,-e._z,t)&&ye(this._w,-e._w,t))}clone(){return new U(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 U(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 U)}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 U(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 U(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 U(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 U)}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 U(-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 U(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 M.FromQuaternionToRef(this,e),e}fromRotationMatrix(e){return U.FromRotationMatrixToRef(e,this),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}static FromRotationMatrix(e){const t=new U;return U.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=U.Dot(e,t);return 1-s*s<=i}static SmoothToRef(e,t,i,s,r){let n=s===0?1:i/s;return n=Te(n,0,1),U.SlerpToRef(e,t,n,r),r}static Zero(){return new U(0,0,0,0)}static Inverse(e){return new U(-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 U(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 U.RotationAxisToRef(e,t,new U)}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 U(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 U;return U.RotationYawPitchRollToRef(t,e,i,s),s}static FromEulerAnglesToRef(e,t,i,s){return U.RotationYawPitchRollToRef(t,e,i,s),s}static FromEulerVector(e){const t=new U;return U.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromEulerVectorToRef(e,t){return U.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromUnitVectorsToRef(e,t,i,s=_
vendor: 7,764 bytes, lines 2-5
2e){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,C.Vector3[0]),i.set(C.Vector3[0].x,C.Vector3[0].y,C.Vector3[0].z,r)),i.normalize()}static RotationYawPitchRoll(e,t,i){const s=new U;return U.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 U;return U.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 U(0,0,0,0);return U.RotationQuaternionFromAxisToRef(e,t,i,s),s}static RotationQuaternionFromAxisToRef(e,t,i,s){const r=z.Matrix[0];return e=e.normalizeToRef(z.Vector3[0]),t=t.normalizeToRef(z.Vector3[1]),i=i.normalizeToRef(z.Vector3[2]),M.FromXYZAxesToRef(e,t,i,r),U.FromRotationMatrixToRef(r,s),s}static FromLookDirectionLH(e,t){const i=new U;return U.FromLookDirectionLHToRef(e,t,i),i}static FromLookDirectionLHToRef(e,t,i){const s=z.Matrix[0];return M.LookDirectionLHToRef(e,t,s),U.FromRotationMatrixToRef(s,i),i}static FromLookDirectionRH(e,t){const i=new U;return U.FromLookDirectionRHToRef(e,t,i),i}static FromLookDirectionRHToRef(e,t,i){const s=z.Matrix[0];return M.LookDirectionRHToRef(e,t,s),U.FromRotationMatrixToRef(s,i)}static Slerp(e,t,i){const s=U.Identity();return U.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,m=e._w*h+i._w*l+t._w*c+s._w*u;return new U(f,d,g,m)}static Hermite1stDerivative(e,t,i,s,r){const n=new U;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=U.Zero();return U.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Clamp(e,t,i){const s=new U;return U.ClampToRef(e,t,i,s),s}static ClampToRef(e,t,i,s){return s.copyFromFloats(Te(e.x,t.x,i.x),Te(e.y,t.y,i.y),Te(e.z,t.z,i.z),Te(e.w,t.w,i.w))}static Random(e=0,t=1){return new U(Oe(e,t),Oe(e,t),Oe(e,t),Oe(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(Oe(e,t),Oe(e,t),Oe(e,t),Oe(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(U.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 U.CenterToRef(e,t,U.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)}}U._V8PerformanceHack=new U(.5,.5,.5,.5);Object.defineProperties(U.prototype,{dimension:{value:[4]},rank:{value:1}});class M{static get Use64Bits(){return We.MatrixUse64Bits}get m(){return this._m}markAsUpdated(){this.updateFlag=M._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,We.MatrixTrackPrecisionChange&&We.MatrixTrackedMatrices.push(this),this._m=new We.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],m=e[13],b=e[14],y=e[15],A=f*y-b*d,P=u*y-m*d,I=u*b-m*f,x=c*y-g*d,R=c*b-f*g,S=c*m-g*u,D=+(o*A-h*P+l*I),G=-(n*A-h*x+l*R),X=+(n*P-o*x+l*S),Re=-(n*I-o*R+h*S);return t*D+i*G+s*X+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 M.FromArrayToRef(e,t,this)}copyFromFloats(...e){return M.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 M.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 M;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 M)}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){if(this._isIdentity===!0)return M.IdentityToRef(e),e;const t=this._m,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],m=t[12],b=t[13],y=t[14],A=t[15],P=d*A-y*g,I=f*A-b*g,x=f*y-b*d,R=u*A-m*g,S=u*y-d*m,D=u*b-m*f,G=+(h*P-l*I+c*x),X=-(o*P-l*R+c*S),Re=+(o*I-h*R+c*D),fe=-(o*x-h*S+l*D),
vendor: 10,722 bytes, line 5
5ge=i*G+s*X+r*Re+n*fe;if(ge===0)return e.copyFrom(this),e;const ue=1/ge,ze=l*A-y*c,$e=h*A-b*c,nt=h*y-b*l,Ke=o*A-m*c,Ye=o*y-m*l,ct=o*b-m*h,Tt=l*g-d*c,kt=h*g-f*c,hi=h*d-f*l,Ms=o*g-u*c,Is=o*d-u*l,Cs=o*f-u*h,ar=-(s*P-r*I+n*x),or=+(i*P-r*R+n*S),hr=-(i*I-s*R+n*D),lr=+(i*x-s*S+r*D),cr=+(s*ze-r*$e+n*nt),ur=-(i*ze-r*Ke+n*Ye),Wt=+(i*$e-s*Ke+n*ct),Xt=-(i*nt-s*Ye+r*ct),Kt=-(s*Tt-r*kt+n*hi),Yt=+(i*Tt-r*Ms+n*Is),Oo=-(i*kt-s*Ms+n*Cs),Fo=+(i*hi-s*Is+r*Cs);return M.FromValuesToRef(G*ue,ar*ue,cr*ue,Kt*ue,X*ue,or*ue,ur*ue,Yt*ue,Re*ue,hr*ue,Wt*ue,Oo*ue,fe*ue,lr*ue,Xt*ue,Fo*ue,e),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 M.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){const i=this._m;return 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],this}multiply(e){const t=new M;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){const s=this._m,r=e.m,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],m=s[9],b=s[10],y=s[11],A=s[12],P=s[13],I=s[14],x=s[15],R=r[0],S=r[1],D=r[2],G=r[3],X=r[4],Re=r[5],fe=r[6],ge=r[7],ue=r[8],ze=r[9],$e=r[10],nt=r[11],Ke=r[12],Ye=r[13],ct=r[14],Tt=r[15];return t[i]=n*R+o*X+h*ue+l*Ke,t[i+1]=n*S+o*Re+h*ze+l*Ye,t[i+2]=n*D+o*fe+h*$e+l*ct,t[i+3]=n*G+o*ge+h*nt+l*Tt,t[i+4]=c*R+u*X+f*ue+d*Ke,t[i+5]=c*S+u*Re+f*ze+d*Ye,t[i+6]=c*D+u*fe+f*$e+d*ct,t[i+7]=c*G+u*ge+f*nt+d*Tt,t[i+8]=g*R+m*X+b*ue+y*Ke,t[i+9]=g*S+m*Re+b*ze+y*Ye,t[i+10]=g*D+m*fe+b*$e+y*ct,t[i+11]=g*G+m*ge+b*nt+y*Tt,t[i+12]=A*R+P*X+I*ue+x*Ke,t[i+13]=A*S+P*Re+I*ze+x*Ye,t[i+14]=A*D+P*fe+I*$e+x*ct,t[i+15]=A*G+P*ge+I*nt+x*Tt,this}divide(e){return this.divideToRef(e,new M)}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 M)}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(!ye(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 M)}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 M)}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 M;return e.copyFrom(this),e}getClassName(){return"Matrix"}getHashCode(){let e=_t(this._m[0]);for(let t=1;t<16;t++)e=e*397^_t(this._m[t]);return e}decomposeToTransformNode(e){return e.rotationQuaternion=e.rotationQuaternion||new U,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||z.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;M.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,z.Matrix[0]),U.FromRotationMatrixToRef(z.Matrix[0],t)}return!0}getRow(e){if(e<0||e>3)return null;const t=e*4;return new he(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 M;return M.TransposeToRef(this,e),e}transposeToRef(e){return M.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 M;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=z.Matrix[0];this.invertToRef(t),t.transposeToRef(e);const i=e._m;return M.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 M;return this.getRotationMatrixToRef(e),e}getRotationMatrixToRef(e){const t=z.Vector3[0];if(!this.decompose(t))return M.IdentityToRef(e),e;const i=this._m,s=1/t._x,r=1/t._y,n=1/t._z;return M.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 M;return M.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 M._IdentityReadOnly}static FromValuesToRef(e,t,i,s,r,n,o,h,l,c,u,f,d,g,m,b,y){const A=y._m;A[0]=e,A[1]=t,A[2]=i,A[3]=s,A[4]=r,A[5]=n,A[6]=o,A[7]=h,A[8]=l,A[9]=c,A[10]=u,A[11]=f,A[12]=d,A[13]=g,A[14]=m,A[15]=b,y.markAsUpdated()}static FromValues(e,t,i,s,r,n,o,h,l,c,u,f,d,g,m,b){const y=new M,A=y._m;return A[0]=e,A[1]=t,A[2]=i,A[3]=s,A[4]=r,A[5]=n,A[6]=o,A[7]=h,A[8]=l,A[9]=c,A[10]=u,A[11]=f,A[12]=d,A[13]=g,A[14]=m,A[15]=b,y.markAsUpdated(),y}static Compose(e,t,i){const s=new M;return M.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,m=n*f,b=o*u,y=o*f,A=h*f,P=l*c,I=l*u,x=l*f,R=e._x,S=e._y,D=e._z;return r[0]=(1-(b+A))*R,r[1]=(g+x)*R,r[2]=(m-I)*R,r[3]=0,r[4]=(g-x)*S,r[5]=(1-(d+A))*S,r[6]=(y+P)*S,r[7]=0,r[8]=(m+I)*D,r[9]=(y-P)*D,r[10]=(1-(d+b))*D,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=M.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 M.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=M.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 M;return M.RotationXToRef(e,t),t}static Invert(e){const t=new M;return e.invertToRef(t),t}static RotationXToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return M.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 M;return M.RotationYToRef(e,t),t}static RotationYToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return M.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 M;return M.RotationZToRef(e,t),t}static RotationZToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return M.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 M;return M.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(z.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+_
vendor: 10,924 bytes, line 5
5e)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 M;return M.RotationYawPitchRollToRef(e,t,i,s),s}static RotationYawPitchRollToRef(e,t,i,s){return U.RotationYawPitchRollToRef(e,t,i,z.Quaternion[0]),z.Quaternion[0].toRotationMatrix(s),s}static Scaling(e,t,i){const s=new M;return M.ScalingToRef(e,t,i,s),s}static ScalingToRef(e,t,i,s){return M.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 M;return M.TranslationToRef(e,t,i,s),s}static TranslationToRef(e,t,i,s){return M.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 M;return M.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 M;return M.DecomposeLerpToRef(e,t,i,s),s}static DecomposeLerpToRef(e,t,i,s){const r=z.Vector3[0],n=z.Quaternion[0],o=z.Vector3[1];e.decompose(r,n,o);const h=z.Vector3[2],l=z.Quaternion[1],c=z.Vector3[3];t.decompose(h,l,c);const u=z.Vector3[4];_.LerpToRef(r,h,i,u);const f=z.Quaternion[2];U.SlerpToRef(n,l,i,f);const d=z.Vector3[5];return _.LerpToRef(o,c,i,d),M.ComposeToRef(u,f,d,s),s}static LookAtLH(e,t,i){const s=new M;return M.LookAtLHToRef(e,t,i,s),s}static LookAtLHToRef(e,t,i,s){const r=z.Vector3[0],n=z.Vector3[1],o=z.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 M.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 M;return M.LookAtRHToRef(e,t,i,s),s}static LookAtRHToRef(e,t,i,s){const r=z.Vector3[0],n=z.Vector3[1],o=z.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 M.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 M;return M.LookDirectionLHToRef(e,t,i),i}static LookDirectionLHToRef(e,t,i){const s=z.Vector3[0];s.copyFrom(e),s.scaleInPlace(-1);const r=z.Vector3[1];return _.CrossToRef(t,s,r),M.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 M;return M.LookDirectionRHToRef(e,t,i),i}static LookDirectionRHToRef(e,t,i){const s=z.Vector3[2];return _.CrossToRef(t,e,s),M.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 M;return M.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 M.FromValuesToRef(l,0,0,0,0,c,0,0,0,0,u,0,0,0,f,1,r),n&&r.multiplyToRef(mi,r),r._updateIdentityStatus(l===1&&c===1&&u===1&&f===0),r}static OrthoOffCenterLH(e,t,i,s,r,n,o){const h=new M;return M.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),m=(e+t)/(e-t),b=(s+i)/(i-s);return M.FromValuesToRef(u,0,0,0,0,f,0,0,0,0,d,0,m,b,g,1,o),h&&o.multiplyToRef(mi,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 M.TranslationToRef(0,0,-l,z.Matrix[1]),M.FromValuesToRef(1,0,0,0,0,1,0,0,f,d,1,0,0,0,0,1,z.Matrix[0]),z.Matrix[1].multiplyToRef(z.Matrix[0],z.Matrix[0]),M.TranslationToRef(0,0,l,z.Matrix[1]),z.Matrix[0].multiplyToRef(z.Matrix[1],z.Matrix[0]),M.OrthoOffCenterLHToRef(e,t,i,s,r,n,c,u),z.Matrix[0].multiplyToRef(c,c),c}static OrthoOffCenterRH(e,t,i,s,r,n,o){const h=new M;return M.OrthoOffCenterRHToRef(e,t,i,s,r,n,h,o),h}static OrthoOffCenterRHToRef(e,t,i,s,r,n,o,h){return M.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 M.TranslationToRef(0,0,l,z.Matrix[1]),M.FromValuesToRef(1,0,0,0,0,1,0,0,f,d,1,0,0,0,0,1,z.Matrix[0]),z.Matrix[1].multiplyToRef(z.Matrix[0],z.Matrix[0]),M.TranslationToRef(0,0,-l,z.Matrix[1]),z.Matrix[0].multiplyToRef(z.Matrix[1],z.Matrix[0]),M.OrthoOffCenterRHToRef(e,t,i,s,r,n,c,u),z.Matrix[0].multiplyToRef(c,c),c}static PerspectiveLH(e,t,i,s,r,n=0){const o=new M,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 M.FromValuesToRef(c,0,0,0,0,u,0,g,0,0,f,1,0,0,d,0,o),r&&o.multiplyToRef(mi,o),o._updateIdentityStatus(!1),o}static PerspectiveFovLH(e,t,i,s,r,n=0,o=!1){const h=new M;return M.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,m=l&&c===0?-1:u!==0?(u+c)/(u-c):1,b=l&&c===0?2*u:u!==0?-2*u*c/(u-c):-2*c,y=Math.tan(h);return M.FromValuesToRef(d,0,0,0,0,g,0,y,0,0,m,1,0,0,b,0,r),o&&r.multiplyToRef(mi,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 M.FromValuesToRef(c,0,0,0,0,u,0,f,0,0,-i,1,0,0,1,0,r),o&&r.multiplyToRef(mi,r),r._updateIdentityStatus(!1),r}static PerspectiveFovRH(e,t,i,s,r,n=0,o=!1){const h=new M;return M.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,m=l&&c===0?1:u!==0?-(u+c)/(u-c):-1,b=l&&c===0?2*u:u!==0?-2*u*c/(u-c):-2*c,y=Math.tan(h);return M.FromValuesToRef(d,0,0,0,0,g,0,y,0,0,m,-1,0,0,b,0,r),o&&r.multiplyToRef(mi,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 M.FromValuesToRef(c,0,0,0,0,u,0,f,0,0,-i,-1,0,0,-1,0,r),o&&r.multiplyToRef(mi,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=M.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 M;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 We.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 We.MatrixUse64Bits?i:new Float32Array(i)}static Transpose(e){const t=new M;return M.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],m=i[14],b=i[3],y=i[7],A=i[11],P=i[15],I=t._m;return I[0]=s,I[1]=r,I[2]=n,I[3]=o,I[4]=h,I[5]=l,I[6]=c,I[7]=u,I[8]=f,I[9]=d,I[10]=g,I[11]=m,I[12]=b,I[13]=y,I[14]=A,I[15]=P,t.markAsUpdated(),t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty),t}static Reflection(e){const t=new M;return M.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 M.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 M.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}}M._UpdateFlagSeed=0;M._IdentityReadOnly=M.Identity();Object.defineProperties(M.prototype,{dimension:{value:[4,4]},rank:{value:2}});class z{}z.Vector3=ni(11,_.Zero);z.Matrix=ni(2,M.Identity);z.Quaternion=ni(3,U.Zero);class C{}C.Vector2=ni(3,Z.Zero);C.Vector3=ni(13,_.Zero);C.Vector4=ni(3,he.Zero);C.Quaternion=ni(3,U.Zero);C.Matrix=ni(8,M.Identity);it("BABYLON.Vector2",Z);it("BABYLON.Vector3",_);it("BABYLON.Vector4",he);it("BABYLON.Matrix",M);const mi=M.FromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1),fn={};function ee(a,e=!1){if(!(e&&fn[a]))return fn[a]=!0,`${a} needs to be imported before as it contains a side-effect required by your code.`}class Ei{static Eval(e,t){return e.match(/\([^()]*\)/g)?e=e.replace(/\([^()]*\)/g,i=>(i=i.slice(1,i.length-1),Ei._HandleParenthesisContent(i,t))):e=Ei._HandleParenthesisContent(e,t),e==="true"?!0:e==="false"?!1:Ei.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=Ei._SimplifyNegation(s[r].trim());const o=n.split("&&");if(o.length>1)for(let h=0;h<o.length;++h){const l=Ei._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 pe{static EnableFor(e){e._tags=e._tags||{},e.hasTags=()=>pe.HasTags(e),e.addTags=t=>pe.AddTagsTo(e,t),e.removeTags=t=>pe.RemoveTagsFrom(e,t),e.matchesTagsQuery=t=>pe.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;t.split(" ").forEach(function(s){pe._AddTagTo(e,s)})}static _AddTagTo(e,t){t=t.trim(),!(t===""||t==="true"||t==="false")&&(t.match(/[\s]/)||t.match(/^([!]|([|]|[&]){2})/)||(pe.EnableFor(e),e._tags[t]=!0))}static RemoveTagsFrom(e,t){if(!pe.HasTags(e))return;const i=t.split(" ");for(const s in i)pe._RemoveTagFrom(e,i[s])}static _RemoveTagFrom(e,t){delete e._tags[t]}static MatchesQuery(e,t){return t===void 0?!0:t===""?pe.HasTags(e):Ei.Eval(t,i=>pe.HasTags(e)&&e._tags[i])}}function wi(a){return Math.pow(a,Ns)}function Li(a){return a<=.04045?.0773993808*a:Math.pow(.947867299*(a+.055),2.4)}function Bi(a){return Math.pow(a,
vendor: 97,763 bytes, lines 5-23
5Go)}function Ni(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 le(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=_e){return ye(this.r,e.r,t)&&ye(this.g,e.g,t)&&ye(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=Te(this.r,e,t),i.g=Te(this.g,e,t),i.b=Te(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"#"+Bt(e)+Bt(t)+Bt(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=Li(this.r),e.g=Li(this.g),e.b=Li(this.b)):(e.r=wi(this.r),e.g=wi(this.g),e.b=wi(this.b)),this}toGammaSpace(e=!1){const t=new q;return this.toGammaSpaceToRef(t,e),t}toGammaSpaceToRef(e,t=!1){return t?(e.r=Ni(this.r),e.g=Ni(this.g),e.b=Ni(this.b)):(e.r=Bi(this.r),e.g=Bi(this.g),e.b=Bi(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 le{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 le(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 le(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 le(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 le(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=Te(this.r,e,t),i.g=Te(this.g,e,t),i.b=Te(this.b,e,t),i.a=Te(this.a,e,t),i}multiply(e){return new le(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 le(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=_e){return ye(this.r,e.r,t)&&ye(this.g,e.g,t)&&ye(this.b,e.b,t)&&ye(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 le().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"#"+Bt(t)+Bt(i)+Bt(s);const r=Math.round(this.a*255);return"#"+Bt(t)+Bt(i)+Bt(s)+Bt(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 le;return this.toLinearSpaceToRef(t,e),t}toLinearSpaceToRef(e,t=!1){return t?(e.r=Li(this.r),e.g=Li(this.g),e.b=Li(this.b)):(e.r=wi(this.r),e.g=wi(this.g),e.b=wi(this.b)),e.a=this.a,this}toGammaSpace(e=!1){const t=new le;return this.toGammaSpaceToRef(t,e),t}toGammaSpaceToRef(e,t=!1){return t?(e.r=Ni(this.r),e.g=Ni(this.g),e.b=Ni(this.b)):(e.r=Bi(this.r),e.g=Bi(this.g),e.b=Bi(this.b)),e.a=this.a,this}static FromHexString(e){return e.substring(0,1)!=="#"||e.length!==9&&e.length!==7?new le(0,0,0,0):new le(0,0,0,1).fromHexString(e)}static Lerp(e,t,i){return le.LerpToRef(e,t,i,new le)}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,m=e.a*h+i.a*l+t.a*c+s.a*u;return new le(f,d,g,m)}static Hermite1stDerivative(e,t,i,s,r){const n=new le;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 le(e.r,e.g,e.b,t)}static FromArray(e,t=0){return new le(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 le(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}}le._V8PerformanceHack=new le(.5,.5,.5,.5);Object.defineProperties(le.prototype,{dimension:{value:[4]},rank:{value:1}});class Ct{}Ct.Color3=ti(3,q.Black);Ct.Color4=ti(3,()=>new le(0,0,0,0));it("BABYLON.Color3",q);it("BABYLON.Color4",le);const _n=function(a,e,t,i={}){const s=a();pe&&pe.HasTags(e)&&pe.AddTagsTo(s,pe.GetTags(e,!0));const r=vr(s),n={};for(const o in r){const h=r[o],l=e[o],c=h.type;if(l!=null&&(o!=="uniqueId"||re.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 re{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={}),pe&&(t.tags=pe.GetTags(e));const i=vr(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"||re.AllowLoadingUniqueId))switch(o){case 0: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=vr(t);for(const n in r){const o=r[n],h=e[o.sourceName||n],l=o.type;if(h!=null&&(n!=="uniqueId"||re.AllowLoadingUniqueId)){const c=t;switch(l){case 0:c[n]=h;break;case 1:i&&(c[n]=re._TextureParser(h,i,s));break;case 2:c[n]=q.FromArray(h);break;case 3:c[n]=re._FresnelParametersParser(h);break;case 4:c[n]=Z.FromArray(h);break;case 5:c[n]=_.FromArray(h);break;case 6:i&&(c[n]=i.getLastMeshById(h));break;case 7:c[n]=re._ColorCurvesParser(h);break;case 8:c[n]=le.FromArray(h);break;case 9:c[n]=re._ImageProcessingConfigurationParser(h);break;case 10:c[n]=U.FromArray(h);break;case 11:i&&(c[n]=i.getCameraById(h));break;case 12:c[n]=M.FromArray(h);break}}}}static Parse(e,t,i,s=null){const r=e();return pe&&pe.AddTagsTo(r,t.tags),re.ParseProperties(t,r,i,s),r}static Clone(e,t,i={}){return _n(e,t,!1,i)}static Instanciate(e,t){return _n(e,t,!0)}}re.AllowLoadingUniqueId=!1;re._ImageProcessingConfigurationParser=a=>{throw ee("ImageProcessingConfiguration")};re._FresnelParametersParser=a=>{throw ee("FresnelParameters")};re._ColorCurvesParser=a=>{throw ee("ColorCurves")};re._TextureParser=(a,e,t)=>{throw ee("Texture")};class rh{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}}class Ve{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}_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 rh,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=M.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||de.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(()=>{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(){this._nodeDataStorage._isParentEnabled=this._parentNode?this._parentNode.isEnabled():!0,this._children&&this._children.forEach(e=>{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]=Ve._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=re.Clone(()=>new Ve(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=M.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}}}Ve._AnimationRangeFactory=(a,e,t)=>{throw ee("AnimationRange")};Ve._NodeConstructors={};p([E()],Ve.prototype,"name",void 0);p([E()],Ve.prototype,"id",void 0);p([E()],Ve.prototype,"uniqueId",void 0);p([E()],Ve.prototype,"state",void 0);p([E()],Ve.prototype,"metadata",void 0);function et(){return typeof window<"u"}function Fi(){return typeof navigator<"u"}function Zi(){return typeof document<"u"}function Ia(a){let e="",t=a.firstChild;for(;t;)t.nodeType===3&&(e+=t.textContent),t=t.nextSibling;return e}class F{static _CheckLimit(e,t){let i=F._LogLimitOutputs[e];return i?i.current++:(i={limit:t,current:1},F._LogLimitOutputs[e]=i),i.current<=i.limit}static _GenerateLimitMessage(e,t=1){const i=F._LogLimitOutputs[e];if(!i||!F.MessageLimitReached)return;const s=this._Levels[t];i.current===i.limit&&F[s.name](F.MessageLimitReached.replace(/%LIMIT%/g,""+i.limit).replace(/%TYPE%/g,s.name??""))}static _AddLogEntry(e){F._LogCache=e+F._LogCache,F.OnNewCacheEntry&&F.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&&!F._CheckLimit(s,i))return;const r=F._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>`;F._AddLogEntry(h),F._GenerateLimitMessage(s,e)}static get LogCache(){return F._LogCache}static ClearLogCache(){F._LogCache="",F._LogLimitOutputs={},F.errorsCount=0}static set LogLevels(e){F.Log=F._LogDisabled,F.Warn=F._LogDisabled,F.Error=F._LogDisabled,[F.MessageLogLevel,F.WarningLogLevel,F.ErrorLogLevel].forEach(t=>{if((e&t)===t){const i=this._Levels[t];F[i.name]=F._LogEnabled.bind(F,t)}})}}F.NoneLogLevel=0;F.MessageLogLevel=1;F.WarningLogLevel=2;F.ErrorLogLevel=4;F.AllLogLevel=7;F.MessageLimitReached="Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.";F._LogCache="";F._LogLimitOutputs={};F._Levels=[{},{color:"white",logFunc:console.log,name:"Log"},{color:"orange",logFunc:console.warn,name:"Warn"},{},{color:"red",logFunc:console.error,name:"Error"}];F.errorsCount=0;F.Log=F._LogEnabled.bind(F,F.MessageLogLevel);F.Warn=F._LogEnabled.bind(F,F.WarningLogLevel);F.Error=F._LogEnabled.bind(F,F.ErrorLogLevel);const gn=(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 nh(a){const e=[];do Object.getOwnPropertyNames(a).forEach(function(t){e.indexOf(t)===-1&&e.push(t)});while(a=Object.getPrototypeOf(a));return e}class Ca{static DeepCopy(e,t,i,s,r=!1){const n=nh(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=gn(h[c],t,r);t[o].indexOf(u)===-1&&t[o].push(u)}else t[o]=h.slice(0)}else t[o]=gn(h,t,r);else t[o]=h}catch(c){F.Warn(c.message)}}}}class Dt{static get Now(){return et()&&window.performance&&window.performance.now?window.performance.now():Date.now()}}function ah(){return typeof _native<"u"&&_native.XMLHttpRequest?new _native.XMLHttpRequest:new XMLHttpRequest}class tt{constructor(){this._xhr=ah(),this._requestURL=""}static get IsCustomRequestAvailable(){return Object.keys(tt.CustomRequestHeaders).length>0||tt.CustomRequestModifiers.length>0}get requestURL(){return this._requestURL}_injectCustomRequestHeaders(){if(!this._shouldSkipRequestModifications(this._requestURL))for(const e in tt.CustomRequestHeaders){const t=tt.CustomRequestHeaders[e];t&&this._xhr.setRequestHeader(e,t)}}_shouldSkipRequestModifications(e){return tt.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){tt.CustomRequestHeaders&&this._injectCustomRequestHeaders(),this._xhr.send(e)}open(e,t){for(const i of tt.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)}}tt.CustomRequestHeaders={};tt.CustomRequestModifiers=new Array;tt.SkipRequestModificationForBabylonCDN=!0;class Ji{}Ji.FilesToLoad={};class oh{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 _i extends Error{}_i._setPrototypeOf=Object.setPrototypeOf||((a,e)=>(a.__proto__=e,a));const ms={MeshInvalidPositionsError:0,UnsupportedTextureError:1e3,GLTFLoaderUnexpectedMagicError:2e3,SceneLoaderError:3e3,LoadFileError:4e3,RequestFileError:4001,ReadFileError:4002};class Ii extends _i{constructor(e,t,i){super(e),this.errorCode=t,this.innerError=i,this.name="RuntimeError",_i._setPrototypeOf(this,Ii.prototype)}}class Mt extends _i{constructor(e="Operation aborted"){super(e),this.name="AbortError",_i._setPrototypeOf(this,Mt.prototype)}}const Ed=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},Pa=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},va=a=>atob(a),hh=a=>{const e=va(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},lh="attribute",ch="varying";class Ts{constructor(){this.children=[]}isValid(e){return!0}process(e,t){let i="";if(this.line){let s=this.line;const r=t.processor;if(r){r.lineProcessor&&(s=r.lineProcessor(s,t.isFragment,t.processingContext));const n=t.processor?.attributeKeywordName??lh,o=t.isFragment&&t.processor?.varyingFragmentKeywordName?t.processor?.varyingFragmentKeywordName:!t.isFragment&&t.processor?.varyingVertexKeywordName?t.processor?.varyingVertexKeywordName:ch;!t.isFragment&&r.attributeProcessor&&this.line.startsWith(n)?s=r.attributeProcessor(this.line,e,t.processingContext):r.varyingProcessor&&(r.varyingCheck?.(this.line,t.isFragment)||!r.varyingCheck&&this.line.startsWith(o))?s=r.varyingProcessor(this.line,t.isFragment,e,t.processingContext):r.uniformProcessor&&r.uniformRegexp&&r.uniformRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(s=r.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):r.uniformBufferProcessor&&r.uniformBufferRegexp&&r.uniformBufferRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(s=r.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0):r.textureProcessor&&r.textureRegexp&&r.textureRegexp.test(this.line)?s=r.textureProcessor(this.line,t.isFragment,e,t.processingContext):(r.uniformProcessor||r.uniformBufferProcessor)&&this.line.startsWith("uniform")&&!t.lookForClosingBracketForUniformBuffer&&(/uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/.test(this.line)?r.uniformProcessor&&(s=r.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):r.uniformBufferProcessor&&(s=r.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0)),t.lookForClosingBracketForUniformBuffer&&this.line.indexOf("}")!==-1&&(t.lookForClosingBracketForUniformBuffer=!1,r.endOfUniformBufferProcessor&&(s=r.endOfUniformBufferProcessor(this.line,t.isFragment,t.processingContext)))}i+=s+`
6`}return this.children.forEach(s=>{i+=s.process(e,t)}),this.additionalDefineKey&&(e[this.additionalDefineKey]=this.additionalDefineValue||"true"),i}}class uh{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 dr extends Ts{process(e,t){for(let i=0;i<this.children.length;i++){const s=this.children[i];if(s.isValid(e))return s.process(e,t)}return""}}class dh extends Ts{isValid(e){return this.testExpression.isTrue(e)}}class ve{isTrue(e){return!0}static postfixToInfix(e){const t=[];for(const i of e)if(ve._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=ve._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<ve._Stack.length-1&&(ve._Stack[++s]=u)},o=()=>ve._Stack[s],h=()=>s===-1?"!!INVALID EXPRESSION!!":ve._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(ve._OperatorPriority[f]>1){for(r();s!==-1&&ve._OperatorPriority[o()]>=ve._OperatorPriority[f];)i.push(h());n(f),l++}else c+=u;l++}for(r();s!==-1;)o()==="("?h():i.push(h());return ve._InfixToPostfixCache.size>=ve.InfixToPostfixCacheLimitSize&&ve.ClearCache(),ve._InfixToPostfixCache.set(e,{result:i,accessTime:Date.now()}),i}static ClearCache(){const e=Array.from(ve._InfixToPostfixCache.entries()).sort((t,i)=>t[1].accessTime-i[1].accessTime);for(let t=0;t<ve.InfixToPostfixCacheCleanupSize;t++)ve._InfixToPostfixCache.delete(e[t][0])}}ve.InfixToPostfixCacheLimitSize=5e4;ve.InfixToPostfixCacheCleanupSize=25e3;ve._InfixToPostfixCache=new Map;ve._OperatorPriority={")":0,"(":1,"||":2,"&&":3};ve._Stack=["","","","","","","","","","","","","","","","","","","",""];class Vs extends ve{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 fh extends ve{isTrue(e){return this.leftOperand.isTrue(e)||this.rightOperand.isTrue(e)}}class _h extends ve{isTrue(e){return this.leftOperand.isTrue(e)&&this.rightOperand.isTrue(e)}}class gh extends ve{constructor(e,t,i){super(),this.define=e,this.operand=t,this.testValue=i}isTrue(e){let t=e[this.define];t===void 0&&(t=this.define);let i=!1;const s=parseInt(t),r=parseInt(this.testValue);switch(this.operand){case">":i=s>r;break;case"<":i=s<r;break;case"<=":i=s<=r;break;case">=":i=s>=r;break;case"==":i=s===r;break;case"!=":i=s!==r;break}return i}}const Hs={};function Da(a,e,t=""){return t+(e?e+`
7`:"")+a}function Oa(a,e,t,i,s,r,n){const o=n||Hs.loadFile;if(o)return o(a,e,t,i,s,r);throw ee("FileTools")}function Fa(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 ph(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 mh=/defined\s*?\((.+?)\)/g,fr=/defined\s*?\[(.+?)\]/g,Th=/#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g,bh=/__decl__/,pn=/light\{X\}.(\w*)/g,mn=/\{X\}/g,vs=[],Ah=/(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/;function Eh(a){a.processor&&a.processor.initializeShaders&&a.processor.initializeShaders(a.processingContext)}function Tn(a,e,t,i){e.processor?.preProcessShaderCode&&(a=e.processor.preProcessShaderCode(a,e.isFragment)),Gs(a,e,s=>{e.processCodeAfterIncludes&&(s=e.processCodeAfterIncludes(e.isFragment?"fragment":"vertex",s,e.defines));const r=Ih(s,e,i);t(r,s)})}function Rh(a,e,t){return!t.processor||!t.processor.finalizeShaders?{vertexCode:a,fragmentCode:e}:t.processor.finalizeShaders(a,e,t.processingContext)}function yh(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 _r(a){const t=/defined\((.+)\)/.exec(a);if(t&&t.length)return new Vs(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 Vs(a);const n=a.substring(0,r).trim(),o=a.substring(r+s.length).trim();return new gh(n,s,o)}function xh(a){a=a.replace(mh,"defined[$1]");const e=ve.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 _h:new fh;typeof r=="string"&&(r=r.replace(fr,"defined($1)")),typeof n=="string"&&(n=n.replace(fr,"defined($1)")),o.leftOperand=typeof n=="string"?_r(n):n,o.rightOperand=typeof r=="string"?_r(r):r,t.push(o)}let i=t[t.length-1];return typeof i=="string"&&(i=i.replace(fr,"defined($1)")),typeof i=="string"?_r(i):i}function Us(a,e){const t=new dh,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 Vs(s):i==="#ifndef"?t.testExpression=new Vs(s,!0):t.testExpression=xh(s),t}function gr(a,e,t){let i=a.currentLine;for(;Dr(a,t);){i=a.currentLine;const s=i.substring(0,5).toLowerCase();if(s==="#else"){const r=new Ts;e.children.push(r),Dr(a,r);return}else if(s==="#elif"){const r=Us(i,5);e.children.push(r),t=r}}}function Dr(a,e){for(;a.canRead;){a.lineIndex++;const t=a.currentLine;if(t.indexOf("#")>=0){const s=Ah.exec(t);if(s&&s.length){switch(s[0]){case"#ifdef":{const n=new dr;e.children.push(n);const o=Us(t,6);n.children.push(o),gr(a,n,o);break}case"#else":case"#elif":return!0;case"#endif":return!1;case"#ifndef":{const n=new dr;e.children.push(n);const o=Us(t,7);n.children.push(o),gr(a,n,o);break}case"#if":{const n=new dr,o=Us(t,3);e.children.push(n),n.children.push(o),gr(a,n,o);break}}continue}}const i=new Ts;if(i.line=t,e.children.push(i),t[0]==="#"&&t[1]==="d"){const s=t.replace(";","").split(" ");i.additionalDefineKey=s[1],s.length===3&&(i.additionalDefineValue=s[2])}}return!1}function Sh(a,e,t){const i=new Ts,s=new uh;return s.lineIndex=-1,s.lines=a.split(`
12`),Dr(s,i),i.process(e,t)}function Mh(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",Fa(i,e?.isNDCHalfZRange,e?.useReverseDepthBuffer,e?.useExactSrgbConversions),i}function Ih(a,e,t){let i=yh(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=Mh(e,t);return e.processor.preProcessor&&(i=e.processor.preProcessor(i,s,r,e.isFragment,e.processingContext)),i=Sh(i,r,e),e.processor.postProcessor&&(i=e.processor.postProcessor(i,s,e.isFragment,e.processingContext,t?{drawBuffersExtensionDisabled:!t.getCaps().drawBuffersExtension}:{})),t?._features.needShaderCodeInlining&&(i=t.inlineShaderCode(i)),i}function Gs(a,e,t){vs.length=0;let i;for(;(i=Th.exec(a))!==null;)vs.push(i);let s=String(a),r=[a],n=!1;for(const o of vs){let h=o[1];if(h.indexOf("__decl__")!==-1&&(h=h.replace(bh,""),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]),m=l.slice(0);l="",isNaN(g)&&(g=e.indexParameters[f[1]]);for(let b=d;b<g;b++)e.supportsUniformBuffers||(m=m.replace(pn,(y,A)=>A+"{X}")),l+=m.replace(mn,b.toString())+`
13`}else e.supportsUniformBuffers||(l=l.replace(pn,(f,d)=>d+"{X}")),l=l.replace(mn,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";wa.loadFile(l,c=>{e.includesShadersStore[h]=c,Gs(r.join(""),e,t)});return}}vs.length=0,s=r.join(""),n?Gs(s.toString(),e,t):t(s)}const wa={loadFile:(a,e,t,i,s,r)=>{throw ee("FileTools")}};let Ds=[];class is{static SetImmediate(e){Ds.length===0&&setTimeout(()=>{const t=Ds;Ds=[];for(const i of t)i()},1),Ds.push(e)}}function bn(a,e,t){try{if(a())return e(),!0}catch(i){return t?.(i),!0}return!1}const La=(a,e,t,i=16,s=3e4,r=!0,n)=>{if(r&&bn(a,e,t))return null;const o=setInterval(()=>{bn(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 Fe{static GetShadersRepository(e=0){return e===0?Fe.ShadersRepository:Fe.ShadersRepositoryWGSL}static GetShadersStore(e=0){return e===0?Fe.ShadersStore:Fe.ShadersStoreWGSL}static GetIncludesShadersStore(e=0){return e===0?Fe.IncludesShadersStore:Fe.IncludesShadersStoreWGSL}}Fe.ShadersRepository="src/Shaders/";Fe.ShadersStore={};Fe.IncludesShadersStore={};Fe.ShadersRepositoryWGSL="src/ShadersWGSL/";Fe.ShadersStoreWGSL={};Fe.IncludesShadersStoreWGSL={};class Ch{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 Or=new WeakMap,Ph={_webGLVersion:2,cachedPipelines:{}};function At(a){let e=Or.get(a);if(!e){if(!a)return Ph;e={_webGLVersion:a.TEXTURE_BINDING_3D?2:1,_context:a,parallelShaderCompile:a.getExtension("KHR_parallel_shader_compile")||void 0,cachedPipelines:{}},Or.set(a,e)}return e}function pr(a){Or.delete(a)}function Ba(a,e,t,i,s,r){const n=At(i);r||(r=n._createShaderProgramInjection??Gr);const o=Fr(e,"vertex",i,n._contextWasLost),h=Fr(t,"fragment",i,n._contextWasLost);return r(a,o,h,i,s,n.validateShaderPrograms)}function Na(a,e,t,i,s,r=null,n){const o=At(s);n||(n=o._createShaderProgramInjection??Gr);const h=o._webGLVersion>1?`#version 300 es
14#define WEBGL2 
15`:"",l=An(e,"vertex",i,h,s,o._contextWasLost),c=An(t,"fragment",i,h,s,o._contextWasLost);return n(a,l,c,s,r,o.validateShaderPrograms)}function vh(a,e){const t=new Ch,i=At(a);return i.parallelShaderCompile&&!i.disableParallelShaderCompile&&(t.isParallelCompiled=!0),t.context=i._context,t}function Gr(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||zr(a,i,r),n}function Dh(a,e,t){const i=a;if(i._isDisposed)return!1;const s=At(e);return s&&s.parallelShaderCompile&&s.parallelShaderCompile.COMPLETION_STATUS_KHR&&i.program&&e.getProgramParameter(i.program,s.parallelShaderCompile.COMPLETION_STATUS_KHR)?(zr(i,e,t),!0):!1}function zr(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 Oh(a,e,t,i,s,r,n,o,h,l="",c,u,f){const d=At(a.context);u||(u=d.createRawShaderProgramInjection??Ba),f||(f=d.createShaderProgramInjection??Na);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 An(a,e,t,i,s,r){return Fr(Da(a,t,i),e,s,r)}function Fr(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 Fh(a,e){e.useProgram(a)}function wh(a,e){const t=a;if(!t.isParallelCompiled){e(a);return}const i=t.onCompiled;t.onCompiled=()=>{i?.(),e(a)}}function Lh(a,e){return At(e).cachedPipelines[a]}function Ua(a){const e=a._name,t=a.context;if(e&&t){const i=At(t);i.cachedPipelines[e]?.dispose(),delete i.cachedPipelines[e]}}function Bh(a,e,t,i,s,r,n){let o,h;const l=et()?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;Tn(d,a,(g,m)=>{n&&(n._fragmentSourceCodeBeforeMigration=m),t&&(g=t("fragment",g));const b=Rh(f,g,a);a=null;const y=Nh(b.vertexCode,b.fragmentCode,e,s);i?.(y.vertexSourceCode,y.fragmentSourceCode)},r)}};En(o,"Vertex","",f=>{Eh(a),Tn(f,a,(d,g)=>{n&&(n._rawVertexSourceCode=f,n._vertexSourceCodeBeforeMigration=g),t&&(d=t("vertex",d)),c[0]=d,u()},r)},s),En(h,"Fragment","Pixel",f=>{n&&(n._rawFragmentSourceCode=f),c[1]=f,u()},s)}function En(a,e,t,i,s,r){if(typeof HTMLElement<"u"&&a instanceof HTMLElement){const h=Ia(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=Fe.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=Fe.GetShadersRepository(s)+a,r=r||Oa,!r)throw new Error("loadFileInjection is not defined");r(o+"."+e.toLowerCase()+".fx",i)}function Nh(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 Uh=(a,e,t,i)=>{try{const s=a.context?At(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 F.Error("Error compiling effect"),s}};class ke{static get ShadersRepository(){return Fe.ShadersRepository}static set ShadersRepository(e){Fe.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.name=e,this._key=u;const g=this._key.replace(/\r/g,"").replace(/\n/g,"|");let m;if(t.attributes){const b=t;if(this._engine=i,this._attributesNames=b.attributes,this._uniformsNames=b.uniformsNames.concat(b.samplers),this._samplerList=b.samplers.slice(),this.defines=b.defines,this.onError=b.onError,this.onCompiled=b.onCompiled,this._fallbacks=b.fallbacks,this._indexParameters=b.indexParameters,this._transformFeedbackVaryings=b.transformFeedbackVaryings||null,this._multiTarget=!!b.multiTarget,this._shaderLanguage=b.shaderLanguage??0,this._disableParallelShaderCompilation=!!b.disableParallelShaderCompilation,b.uniformBuffersNames){this._uniformBuffersNamesList=b.uniformBuffersNames.slice();for(let y=0;y<b.uniformBuffersNames.length;y++)this._uniformBuffersNames[b.uniformBuffersNames[y]]=y}this._processFinalCode=b.processFinalCode??null,this._processCodeAfterIncludes=b.processCodeAfterIncludes??void 0,d=b.extraInitializationsAsync,m=b.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"&&(m=Lh(g,this._engine._gl)??m),this._attributeLocationByName={},this.uniqueId=ke._UniqueIdSeed++,m?(this._pipelineContext=m,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._engine.onReleaseEffectsObservable.addOnce(()=>{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:Fe.GetShadersRepository(this._shaderLanguage),includesShadersStore:Fe.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};Bh(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}whenCompiledAsync(){return 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){La(()=>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(),ke.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=Uh({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._preparePipelineContext.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(F.Error("Unable to compile effect:"),F.Error("Uniforms: "+this._uniformsNames.map(function(n){return" "+n})),F.Error("Attributes: "+i.map(function(n){return" "+n})),F.Error(`Defines:
21`+this.defines),ke.LogShaderCodeOnCompilationError){let n=null,o=null,h=null;this._pipelineContext?._getVertexShaderCode()&&([h,n]=this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(),this._compilationError,!1),h&&(F.Error("Vertex code:"),F.Error(h))),this._pipelineContext?._getFragmentShaderCode()&&([h,o]=this._getShaderCodeAndErrorLine(this._pipelineContext?._getFragmentShaderCode(),this._compilationError,!0),h&&(F.Error("Fragment code:"),F.Error(h))),n&&F.Error(n),o&&F.Error(o)}F.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,F.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||ke._BaseCache[i]===e&&this._engine._features.useUBOBindingCache||(ke._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(ke.PersistentMode)return;this._refCount--}this._refCount>0||this._isDisposed||(this._pipelineContext&&Ua(this._pipelineContext),this._engine._releaseEffect(this),this.clearCodeCache(),this._isDisposed=!0)}static RegisterShader(e,t,i,s=0){t&&(Fe.GetShadersStore(s)[`${e}PixelShader`]=t),i&&(Fe.GetShadersStore(s)[`${e}VertexShader`]=i)}static ResetCache(){ke._BaseCache={}}}ke.LogShaderCodeOnCompilationError=!0;ke.PersistentMode=!1;ke.AutomaticallyClearCodeCache=!1;ke._UniqueIdSeed=0;ke._BaseCache={};ke.ShadersStore=Fe.ShadersStore;ke.IncludesShadersStore=Fe.IncludesShadersStore;class kh{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 Vh{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 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 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.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.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.stencilFunc(this.func,this.funcRef,this.funcMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOp(this.opStencilFail,this.opDepthFail,this.opStencilDepthPass),this._isStencilOpDirty=!1))}}class ei{constructor(){this.reset()}reset(){this.enabled=!1,this.mask=255,this.func=ei.ALWAYS,this.funcRef=1,this.funcMask=255,this.opStencilFail=ei.KEEP,this.opDepthFail=ei.KEEP,this.opStencilDepthPass=ei.REPLACE}get stencilFunc(){return this.func}set stencilFunc(e){this.func=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 stencilMask(){return this.mask}set stencilMask(e){this.mask=e}get stencilTest(){return this.enabled}set stencilTest(e){this.enabled=e}}ei.ALWAYS=519;ei.KEEP=7680;ei.REPLACE=7681;class Hh{constructor(){this._blendFunctionParameters=new Array(4),this._blendEquationParameters=new Array(2),this._blendConstants=new Array(4),this._isBlendConstantsDirty=!1,this._alphaBlend=!1,this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this.reset()}get isDirty(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty||this._isBlendEquationParametersDirty}get alphaBlend(){return this._alphaBlend}set alphaBlend(e){this._alphaBlend!==e&&(this._alphaBlend=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){this._blendFunctionParameters[0]===e&&this._blendFunctionParameters[1]===t&&this._blendFunctionParameters[2]===i&&this._blendFunctionParameters[3]===s||(this._blendFunctionParameters[0]=e,this._blendFunctionParameters[1]=t,this._blendFunctionParameters[2]=i,this._blendFunctionParameters[3]=s,this._isBlendFunctionParametersDirty=!0)}setAlphaEquationParameters(e,t){this._blendEquationParameters[0]===e&&this._blendEquationParameters[1]===t||(this._blendEquationParameters[0]=e,this._blendEquationParameters[1]=t,this._isBlendEquationParametersDirty=!0)}reset(){this._alphaBlend=!1,this._blendFunctionParameters[0]=null,this._blendFunctionParameters[1]=null,this._blendFunctionParameters[2]=null,this._blendFunctionParameters[3]=null,this._blendEquationParameters[0]=null,this._blendEquationParameters[1]=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){this.isDirty&&(this._isAlphaBlendDirty&&(this._alphaBlend?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),this._isBlendConstantsDirty&&(e.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1))}}class Gh{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 Rn;(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"})(Rn||(Rn={}));class Et extends Gh{get useMipMaps(){return this.generateMipMaps}set useMipMaps(e){this.generateMipMaps=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.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._premulAlpha=!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;const zs=new Map;function qt(a,e){zh(a)&&F.Warn(`Extension with the name '${name}' already exists`),zs.set(a,e)}function zh(a){return zs.delete(a)}function Wh(a,e){(e==="image/ktx"||e==="image/ktx2")&&(a=".ktx"),zs.has(a)||(a.endsWith(".ies")&&qt(".ies",()=>j(()=>import("./iesTextureLoader-CHFHas9G.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(i=>new i._IESTextureLoader)),a.endsWith(".dds")&&qt(".dds",()=>j(()=>import("./ddsTextureLoader-D5lPLKp_.js"),__vite__mapDeps([3,4,5,1,2]),import.meta.url).then(i=>new i._DDSTextureLoader)),a.endsWith(".basis")&&qt(".basis",()=>j(()=>import("./basisTextureLoader-DRmsxhaA.js"),__vite__mapDeps([6,1,2]),import.meta.url).then(i=>new i._BasisTextureLoader)),a.endsWith(".env")&&qt(".env",()=>j(()=>import("./envTextureLoader-BrkIj0tP.js"),__vite__mapDeps([7,8,1,2,9]),import.meta.url).then(i=>new i._ENVTextureLoader)),a.endsWith(".hdr")&&qt(".hdr",()=>j(()=>import("./hdrTextureLoader-CmaePHS-.js"),__vite__mapDeps([10,11,1,2]),import.meta.url).then(i=>new i._HDRTextureLoader)),(a.endsWith(".ktx")||a.endsWith(".ktx2"))&&(qt(".ktx",()=>j(()=>import("./ktxTextureLoader-Cq2m-Sq7.js"),__vite__mapDeps([12,13,1,2]),import.meta.url).then(i=>new i._KTXTextureLoader)),qt(".ktx2",()=>j(()=>import("./ktxTextureLoader-Cq2m-Sq7.js"),__vite__mapDeps([12,13,1,2]),import.meta.url).then(i=>new i._KTXTextureLoader))),a.endsWith(".tga")&&qt(".tga",()=>j(()=>import("./tgaTextureLoader-HBuOg8DH.js"),__vite__mapDeps([14,1,2]),import.meta.url).then(i=>new i._TGATextureLoader)),a.endsWith(".exr")&&qt(".exr",()=>j(()=>import("./exrTextureLoader-SNuVWNEu.js"),__vite__mapDeps([15,1,2]),import.meta.url).then(i=>new i._ExrTextureLoader)));const t=zs.get(a);return t?Promise.resolve(t(e)):null}function ka(a,e){if(et()){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}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)}getColorWrite(){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()}ke.ResetCache()}_rebuildGraphicsResources(){this.wipeCaches(!0),this._rebuildEffects(),this._rebuildComputeEffects?.(),this._rebuildBuffers(),this._rebuildInternalTextures(),this._rebuildTextures(),this._rebuildRenderTargetWrappers(),this.wipeCaches(!0)}_flagContextRestored(){F.Warn(this.name+" context successfully restored."),this.onContextRestoredObservable.notifyObservers(this),this._contextWasLost=!1}_restoreEngineAfterContextLost(e){setTimeout(async()=>{this._clearEmptyResources();const t=this._depthCullingState.depthTest,i=this._depthCullingState.depthFunc,s=this._depthCullingState.depthMask,r=this._stencilState.stencilTest;await 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,et()){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+1)}}_isOverFrameTime(e){if(!e)return!1;const t=e-this._lastFrameTime;return this._maxFPS===void 0||t>=this._minFrameTime?(this._lastFrameTime=e,!1):!0}_processFrame(e){if(this._frameHandler=0,!this._contextWasLost&&!this._isOverFrameTime(e)){let t=!0;(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 ka(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 et()?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,m,b){e=e||"";const y=e.substr(0,5)==="data:",A=e.substr(0,5)==="blob:",P=y&&e.indexOf(";base64,")!==-1,I=u||new Et(this,1);I!==u&&(I.label=e.substring(0,60));const x=e;this._transformTextureUrl&&!P&&!u&&!c&&(e=this._transformTextureUrl(e)),x!==e&&(I._originalUrl=x);const R=e.lastIndexOf(".");let S=d||(R>-1?e.substring(R).toLowerCase():"");S.indexOf("?")>-1&&(S=S.split("?")[0]);const G=Wh(S,g);s&&s.addPendingData(I),I.url=e,I.generateMipMaps=!t,I.samplingMode=r,I.invertY=i,I._useSRGBBuffer=this._getUseSRGBBuffer(!!b,t),this._doNotHandleContextLost||(I._buffer=c);let X=null;n&&!u&&(X=I.onLoadedObservable.add(n)),u||this._internalTexturesCache.push(I);const Re=(fe,ge)=>{s&&s.removePendingData(I),e===x?(X&&I.onLoadedObservable.remove(X),de.UseFallbackTexture&&e!==de.FallbackTexture&&this._createTextureBase(de.FallbackTexture,t,I.invertY,s,r,null,o,h,l,c,I),fe=(fe||"Unknown error")+(de.UseFallbackTexture?" - Fallback texture was used":""),I.onErrorObservable.notifyObservers({message:fe,exception:ge}),o&&o(fe,ge)):(F.Warn(`Failed to load ${e}, falling back to ${x}`),this._createTextureBase(x,t,I.invertY,s,r,n,o,h,l,c,I,f,d,g,m,b))};if(G){const fe=async ge=>{(await G).loadData(ge,I,(ze,$e,nt,Ke,Ye,ct)=>{ct?Re("TextureLoader failed to load data"):h(I,S,s,{width:ze,height:$e},I.invertY,!nt,Ke,()=>(Ye(),!1),r)},m)};c?c instanceof ArrayBuffer?fe(new Uint8Array(c)):ArrayBuffer.isView(c)?fe(c):o&&o("Unable to load: only ArrayBuffer or ArrayBufferView is supported",null):this._loadFile(e,ge=>fe(new Uint8Array(ge)),void 0,s?s.offlineProvider:void 0,!0,(ge,ue)=>{Re("Unable to load "+(ge&&ge.responseURL,ue))})}else{const fe=ge=>{A&&!this._doNotHandleContextLost&&(I._buffer=ge),h(I,S,s,ge,I.invertY,t,!1,l,r)};!y||P?c&&(typeof c.decoding=="string"||c.close)?fe(c):H._FileToolsLoadImage(e||"",fe,Re,s?s.offlineProvider:null,g,I.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0,this):typeof c=="string"||c instanceof ArrayBuffer||ArrayBuffer.isView(c)||c instanceof Blob?H._FileToolsLoadImage(c,fe,Re,s?s.offlineProvider:null,g,I.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0,this):c&&fe(c)}return I}_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:Zi()?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.2.0"}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 kh,this._stencilStateComposer=new Vh,this._stencilState=new ei,this._alphaState=new H
vendor: 5,933 bytes, line 23
23h,this._alphaMode=1,this._alphaEquation=0,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.onCanvasBlurObservable=new O,this.onCanvasFocusObservable=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.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,de.Instances.push(this),this.startTime=Dt.Now,this._stencilStateComposer.stencilGlobal=this._stencilState,We.SetMatrixPrecision(!!t.useHighPrecisionMatrix),Fi()&&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=et()&&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=et()&&window.devicePixelRatio||1,r=this._lastDevicePixelRatio/s;this._lastDevicePixelRatio=s,this._hardwareScalingLevel*=r}if(et()&&Zi())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 ee("engine.rawTexture")}createRawCubeTexture(e,t,i,s,r,n,o,h){throw ee("engine.rawTexture")}createRawTexture3D(e,t,i,s,r,n,o,h,l,c,u){throw ee("engine.rawTexture")}createRawTexture2DArray(e,t,i,s,r,n,o,h,l,c,u){throw ee("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&&Zi()&&"ontouchend"in document},this._checkForMobile(),et()&&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 ee("FileTools")}_loadFile(e,t,i,s,r,n){const o=
vendor: 13,692 bytes, line 23
23Oa(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(Hs.loadFile)return Hs.loadFile(e,t,i,s,r,n);throw ee("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?.(),ke.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(),et()&&window.removeEventListener("resize",this._checkForMobile);const e=de.Instances.indexOf(this);e>=0&&de.Instances.splice(e,1),de.Instances.length||(de.OnEnginesDisposedObservable.notifyObservers(this),de.OnEnginesDisposedObservable.clear()),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear()}static DefaultLoadingScreenFactory(e){throw ee("LoadingScreen")}static MarkAllMaterialsAsDirty(e,t){for(let i=0;i<de.Instances.length;i++){const s=de.Instances[i];for(let r=0;r<s.scenes.length;r++)s.scenes[r].markAllMaterialsAsDirty(e,t)}}}H._RenderPassIdCounter=0;H._RescalePostProcessFactory=null;H.CollisionsEpsilon=.001;H.QueueNewFrame=ka;const Va=new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i);class Ws extends Ii{constructor(e,t){super(e,ms.LoadFileError),this.name="LoadFileError",_i._setPrototypeOf(this,Ws.prototype),t instanceof tt?this.request=t:this.file=t}}class Xs extends Ii{constructor(e,t){super(e,ms.RequestFileError),this.request=t,this.name="RequestFileError",_i._setPrototypeOf(this,Xs.prototype)}}class Wr extends Ii{constructor(e,t){super(e,ms.ReadFileError),this.file=t,this.name="ReadFileError",_i._setPrototypeOf(this,Wr.prototype)}}const Xh=a=>(a=a.replace(/#/gm,"%23"),a),De={DefaultRetryStrategy:oh.ExponentialBackoff(),BaseUrl:"",CorsBehavior:"anonymous",PreprocessUrl:a=>a,ScriptBaseUrl:"",ScriptPreprocessUrl:a=>a,CleanUrl:Xh},Xr=(a,e)=>{if(!(a&&a.indexOf("data:")===0)&&De.CorsBehavior)if(typeof De.CorsBehavior=="string"||De.CorsBehavior instanceof String)e.crossOrigin=De.CorsBehavior;else{const t=De.CorsBehavior(a);t&&(e.crossOrigin=t)}},Kr=(a,e,t,i,s="",r,n=de.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,`+Pa(a):a instanceof Blob?(o=URL.createObjectURL(a),h=!0):(o=De.CleanUrl(a),o=De.PreprocessUrl(o));const l=x=>{if(t){const R=o||a.toString();t(`Error while trying to load image: ${R.indexOf("http")===0||R.length<=128?R:R.slice(0,128)+"..."}`,x)}};if(n?._features.forceBitmapOverHTMLImageElement)return gi(o,x=>{n.createImageBitmap(new Blob([x],{type:s}),{premultiplyAlpha:"none",...r}).then(R=>{e(R),h&&URL.revokeObjectURL(o)}).catch(R=>{t&&t("Error while trying to load image: "+a,R)})},void 0,i||void 0,!0,(x,R)=>{l(R)}),null;const c=new Image;Xr(o,c);const u=[],f=()=>{u.forEach(x=>{x.target.addEventListener(x.name,x.handler)})},d=()=>{u.forEach(x=>{x.target.removeEventListener(x.name,x.handler)}),u.length=0},g=()=>{d(),e(c),h&&c.src&&URL.revokeObjectURL(c.src)},m=x=>{d(),l(x),h&&c.src&&URL.revokeObjectURL(c.src)},b=x=>{if(x.blockedURI!==c.src||x.disposition==="report")return;d();const R=new Error(`CSP violation of policy ${x.effectiveDirective} ${x.blockedURI}. Current policy is ${x.originalPolicy}`);de.UseFallbackTexture=!1,l(R),h&&c.src&&URL.revokeObjectURL(c.src),c.src=""};u.push({target:c,name:"load",handler:g}),u.push({target:c,name:"error",handler:m}),u.push({target:document,name:"securitypolicyviolation",handler:b}),f();const y=o.substring(0,5)==="blob:",A=o.substring(0,5)==="data:",P=()=>{y||A||!tt.IsCustomRequestAvailable?c.src=o:gi(o,(x,R,S)=>{const D=!s&&S?S:s,G=new Blob([x],{type:D}),X=URL.createObjectURL(G);h=!0,c.src=X},void 0,i||void 0,!0,(x,R)=>{l(R)})},I=()=>{i&&i.loadImage(o,c)};if(!y&&!A&&i&&i.enableTexturesOffline)i.open(I,P);else{if(o.indexOf("file:")!==-1){const x=decodeURIComponent(o.substring(5).toLowerCase());if(Ji.FilesToLoad[x]&&typeof URL<"u"){try{let R;try{R=URL.createObjectURL(Ji.FilesToLoad[x])}catch{R=URL.createObjectURL(Ji.FilesToLoad[x])}c.src=R,h=!0}catch{c.src=""}return c}}P()}return c},ss=(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 Wr(`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},gi=(a,e,t,i,s,r,n)=>{if(a.name)return ss(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=Ji.FilesToLoad[c];if(u)return ss(u,e,t,s,r?f=>r(void 0,new Ws(f.message,f.file)):void 0)}const{match:h,type:l}=Ga(o);if(h){const c={onCompleteObservable:new O,abort:()=>()=>{}};try{const u=s?Qr(o):za(o);e(u,void 0,l)}catch(u){r?r(void 0,u):F.Error(u.message||"Failed to parse the Data URL")}return is.SetImmediate(()=>{c.onCompleteObservable.notifyObservers(c)}),c}return Yr(o,(c,u)=>{e(c,u?.responseURL,u?.getResponseHeader("content-type"))},t,i,s,r?c=>{r(c.request,new Ws(c.message,c.request))}:void 0,n)},Yr=(a,e,t,i,s,r,n)=>{a=De.CleanUrl(a),a=De.PreprocessUrl(a);const o=De.BaseUrl+a;let h=!1;const l={onCompleteObservable:new O,abort:()=>h=!0},c=()=>{let u=new tt,f=null,d;const g=()=>{u&&(t&&u.removeEventListener("progress",t),d&&u.removeEventListener("readystatechange",d),u.removeEventListener("loadend",m))};let m=()=>{g(),l.onCompleteObservable.notifyObservers(l),l.onCompleteObservable.clear(),t=void 0,d=null,m=null,r=void 0,n=void 0,e=void 0};l.abort=()=>{h=!0,m&&m(),u&&u.readyState!==(XMLHttpRequest.DONE||4)&&u.abort(),f!==null&&(clearTimeout(f),f=null),u=null};const b=A=>{const P=A.message||"Unknown error";r&&u?r(new Xs(P,u)):F.Error(P)},y=A=>{if(u){if(u.open("GET",o),n)try{n(u)}catch(P){b(P);return}s&&(u.responseType="arraybuffer"),t&&u.addEventListener("progress",t),m&&u.addEventListener("loadend",m),d=()=>{if(!(h||!u)&&u.readyState===(XMLHttpRequest.DONE||4)){if(d&&u.removeEventListener("readystatechange",d),u.status>=200&&u.status<300||u.status===0&&(!et()||Ha())){const x=s?u.response:u.responseText;if(x!==null){try{e&&e(x,u)}catch(R){b(R)}return}}const P=De.DefaultRetryStrategy;if(P){const x=P(o,u,A);if(x!==-1){g(),u=new tt,f=setTimeout(()=>y(A+1),x);return}}const I=new Xs("Error status: "+u.status+" "+u.statusText+" - Unable to load "+o,u);r&&r(I)}},u.addEventListener("readystatechange",d),u.send()}};y(0)};if(i&&i.enableSceneOffline){const u=d=>{d&&d.status>400?r&&r(d):c()},f=()=>{i&&i.loadFile(De.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},Rd=a=>{const{match:e,type:t}=Ga(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";default:return}},Ha=()=>typeof location<"u"&&location.protocol==="file:",qr=a=>Va.test(a),Ga=a=>{const e=Va.exec(a);return e===null||e.length===0?{match:!1,type:""}:{match:!0,type:e[0].replace("data:","").replace("base64,","")}};function Qr(a){return hh(a.split(",")[1])}const za=a=>va(a.split(",")[1]),Kh=()=>{H._FileToolsLoadImage=Kr,Hs.loadFile=gi,wa.loadFile=gi};Kh();let Yi;const Yh=(a,e,t,i,s,r,n,o,h,l)=>{Yi={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(Yi,"DefaultRetryStrategy",{get:function(){return t.DefaultRetryStrategy},set:function(c){t.DefaultRetryStrategy=c}}),Object.defineProperty(Yi,"BaseUrl",{get:function(){return t.BaseUrl},set:function(c){t.BaseUrl=c}}),Object.defineProperty(Yi,"PreprocessUrl",{get:function(){return t.PreprocessUrl},set:function(c){t.PreprocessUrl=c}}),Object.defineProperty(Yi,"CorsBehavior",{get:function(){return t.CorsBehavior},set:function(c){t.CorsBehavior=c}})};Yh(Qr,za,De,qr,Ha,gi,Kr,ss,Yr,Xr);class $i{static Instantiate(e){if(this.RegisteredExternalClasses&&this.RegisteredExternalClasses[e])return this.RegisteredExternalClasses[e];const t=fi(e);if(t)return t;F.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}}$i.RegisteredExternalClasses={};function jr(){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 rs(a){let e=1;do e*=2;while(e<a);return e===a}function wr(a,e,t){return a*(1-t)+e*t}function Wa(a){const e=Xa(a),t=Zr(a);return e-a>a-t?t:e}function Xa(a){return a--,a|=a>>1,a|=a>>2,a|=a>>4,a|=a>>8,a|=a>>16,a++,a}function Zr(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 ns(a,e,t=2){let i;switch(t){case 1:i=Zr(a);break;case 2:i=Wa(a);break;case 3:default:i=Xa(a);break}return Math.min(i,e)}class B{static get BaseUrl(){return De.BaseUrl}static set BaseUrl(e){De.BaseUrl=e}static get CleanUrl(){return De.CleanUrl}static set CleanUrl(e){De.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){De.ScriptBaseUrl=e}static get ScriptBaseUrl(){return De.ScriptBaseUrl}static set CDNBaseUrl(e){B.ScriptBaseUrl=e,B.AssetBaseUrl=e}static set ScriptPreprocessUrl(e){De.ScriptPreprocessUrl=e}static get ScriptPreprocessUrl(){return De.ScriptPreprocessUrl}static get DefaultRetryStrategy(){return De.DefaultRetryStrategy}static set DefaultRetryStrategy(e){De.DefaultRetryStrategy=e}static get CorsBehavior(){return De.CorsBehavior}static set CorsBehavior(e){De.CorsBehavior=e}static get UseFallbackTexture(){return de.UseFallbackTexture}static set UseFallbackTexture(e){de.UseFallbackTexture=e}static get RegisteredExternalClasses(){return $i.RegisteredExternalClasses}static set RegisteredExternalClasses(e){$i.RegisteredExternalClasses=e}static get fallbackTexture(){return de.FallbackTexture}static set fallbackTexture(e){de.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 $i.Instantiate(e)}static SetImmediate(e){is.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 et()&&!window.PointerEvent?"mouse":"pointer"}static SetCorsBehavior(e,t){Xr(e,t)}static SetReferrerPolicyBehavior(e,t){t.referrerPolicy=e}static get PreprocessUrl(){return De.PreprocessUrl}static set PreprocessUrl(e){De.PreprocessUrl=e}static LoadImage(e,t,i,s,r,n){return Kr(e,t,i,s,r,n)}static LoadFile(e,t,i,s,r,n){return gi(e,t,i,s,r,n)}static LoadFileAsync(e,t=!0){return new Promise((i,s)=>{gi(e,r=>{i(r)},void 0,void 0,t,(r,n)=>{s(n)})})}static GetAssetUrl(e){if(!e)return"";if(B.AssetBaseUrl&&e.startsWith(B._DefaultAssetsUrl)){const t=B.AssetBaseUrl[B.AssetBaseUrl.length-1]==="/"?B.AssetBaseUrl.substring(0,B.AssetBaseUrl.length-1):B.AssetBaseUrl;return e.replace(B._DefaultAssetsUrl,t)}return e}static GetBabylonScriptURL(e,t){if(!e)return"";if(B.ScriptBaseUrl&&e.startsWith(B._DefaultCdnUrl)){const i=B.ScriptBaseUrl[B.ScriptBaseUrl.length-1]==="/"?B.ScriptBaseUrl.substring(0,B.ScriptBaseUrl.length-1):B.ScriptBaseUrl;e=e.replace(B._DefaultCdnUrl,i)}return e=B.ScriptPreprocessUrl(e),t&&(e=B.GetAbsoluteUrl(e)),e}static LoadBabylonScript(e,t,i,s){e=B.GetBabylonScriptURL(e),B.LoadScript(e,t,i)}static LoadBabylonScriptAsync(e){return e=B.GetBabylonScriptURL(e),B.LoadScriptAsync(e)}static LoadScript(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(!et()){i?.(`Cannot load script '${e}
23' 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 LoadScriptAsync(e,t){return 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 ss(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){Ca.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 ee("DumpTools")}static DumpData(e,t,i,s,r="image/png",n,o=!1,h=!1,l){throw ee("DumpTools")}static DumpDataAsync(e,t,i,s="image/png",r,n=!1,o=!1,h){throw ee("DumpTools")}static _IsOffScreenCanvas(e){return e.convertToBlob!==void 0}static ToBlob(e,t,i="image/png",s){!B._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;u++)c[u]=h.charCodeAt(u);r(new Blob([c]))})}),B._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"}B.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&&B.DownloadBlob(n,s),t&&t("")},i,r);else if(t){if(B._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 ee("ScreenshotTools")}static CreateScreenshotAsync(e,t,i,s="image/png",r){throw ee("ScreenshotTools")}static CreateScreenshotUsingRenderTarget(e,t,i,s,r="image/png",n=1,o=!1,h,l=!1,c=!1,u=!0,f,d){throw ee("ScreenshotTools")}static CreateScreenshotUsingRenderTargetAsync(e,t,i,s="image/png",r=1,n=!1,o,h=!1,l=!1,c=!0,u,f){throw ee("ScreenshotTools")}static RandomId(){return jr()}static IsBase64(e){return qr(e)}static DecodeBase64(e){return Qr(e)}static get errorsCount(){return F.errorsCount}static Log(e){F.Log(e)}static Warn(e){F.Warn(e)}static Error(e){F.Error(e)}static get LogCache(){return F.LogCache}static ClearLogCache(){F.ClearLogCache()}static set LogLevels(e){F.LogLevels=e}static set PerformanceLogLevel(e){if((e&B.PerformanceUserMarkLogLevel)===B.PerformanceUserMarkLogLevel){B.StartPerformanceCounter=B._StartUserMark,B.EndPerformanceCounter=B._EndUserMark;return}if((e&B.PerformanceConsoleLogLevel)===B.PerformanceConsoleLogLevel){B.StartPerformanceCounter=B._StartPerformanceConsole,B.EndPerformanceCounter=B._EndPerformanceConsole;return}B.StartPerformanceCounter=B._StartPerformanceCounterDisabled,B.EndPerformanceCounter=B._EndPerformanceCounterDisabled}static _StartPerformanceCounterDisabled(e,t){}static _EndPerformanceCounterDisabled(e,t){}static _StartUserMark(e,t=!0){if(!B._Performance){if(!et())return;B._Performance=window.performance}!t||!B._Performance.mark||B._Performance.mark(e+"-Begin")}
vendor: 6,935 bytes, line 23
23static _EndUserMark(e,t=!0){!t||!B._Performance.mark||(B._Performance.mark(e+"-End"),B._Performance.measure(e,e+"-Begin",e+"-End"))}static _StartPerformanceConsole(e,t=!0){t&&(B._StartUserMark(e,t),console.time&&console.time(e))}static _EndPerformanceConsole(e,t=!0){t&&(B._EndUserMark(e,t),console.timeEnd(e))}static get Now(){return Dt.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 DelayAsync(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}static IsSafari(){return Fi()?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}}B.AssetBaseUrl="";B.UseCustomRequestHeaders=!1;B.CustomRequestHeaders=tt.CustomRequestHeaders;B.GetDOMTextContent=Ia;B._DefaultCdnUrl="https://cdn.babylonjs.com";B._DefaultAssetsUrl="https://assets.babylonjs.com/core";B.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.")};B.NoneLogLevel=F.NoneLogLevel;B.MessageLogLevel=F.MessageLogLevel;B.WarningLogLevel=F.WarningLogLevel;B.ErrorLogLevel=F.ErrorLogLevel;B.AllLogLevel=F.AllLogLevel;B.IsWindowObjectExist=et;B.PerformanceNoneLogLevel=0;B.PerformanceUserMarkLogLevel=1;B.PerformanceConsoleLogLevel=2;B.StartPerformanceCounter=B._StartPerformanceCounterDisabled;B.EndPerformanceCounter=B._EndPerformanceCounterDisabled;class Ks{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 Ks(e,t,i,s);return r.executeNext(),r}static SyncAsyncForLoop(e,t,i,s,r,n=0){return Ks.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)}}B.Mix=wr;B.IsExponentOfTwo=rs;de.FallbackTexture="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/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 Lr(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 qh(a=25){let e;return(t,i,s)=>{const r=performance.now();e===void 0||r-e>a?(e=r,setTimeout(()=>{Lr(t,i,s)},0)):Lr(t,i,s)}}function Ka(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 Jr(a,e){let t;return Ka(a,Lr,i=>t=i,i=>{throw i}),t}function Qh(a,e,t){return new Promise((i,s)=>{Ka(a,e,i,s)})}function j
vendor: 22,301 bytes, line 23
23h(a,e){return(...t)=>Jr(a(...t))}class rt{constructor(e){this.length=0,this.data=new Array(e),this._id=rt._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}}rt._GlobalId=0;class bi extends rt{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];this.pushNoDuplicate(i)}}}}class ki{constructor(e,t,i,s){this.x=e,this.y=t,this.width=i,this.height=s}toGlobal(e,t){return new ki(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 ki(this.x,this.y,this.width,this.height)}}class Pt{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 Pt(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=Pt._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 Pt(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 Pt(e[0],e[1],e[2],e[3])}static FromPoints(e,t,i){const s=new Pt(0,0,0,0);return s.copyFromPoints(e,t,i),s}static FromPositionAndNormal(e,t){const i=new Pt(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}}Pt._TmpMatrix=M.Identity();class It{static GetPlanes(e){const t=[];for(let i=0;i<6;i++)t.push(new Pt(0,0,0,0));return It.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){It.GetNearPlaneToRef(e,t[0]),It.GetFarPlaneToRef(e,t[1]),It.GetLeftPlaneToRef(e,t[2]),It.GetRightPlaneToRef(e,t[3]),It.GetTopPlaneToRef(e,t[4]),It.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 Ve{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}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 ki(0,0,1,1),this.layerMask=268435455,this.fovMode=J.FOVMODE_VERTICAL_FIXED,this.cameraRigMode=J.RIG_MODE_NONE,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 M,this._postProcesses=new Array,this._activeMeshes=new rt(256),this._globalPosition=_.Zero(),this._computedViewMatrix=M.Identity(),this._doNotComputeProjectionMatrix=!1,this._transformMatrix=M.Zero(),this._refreshFrustumPlanes=!0,this._absoluteRotation=U.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(){let e=this._cache.mode===this.mode&&this._cache.minZ===this.minZ&&this._cache.maxZ===this.maxZ;if(!e)return!1;const t=this.getEngine();return this.mode===J.PERSPECTIVE_CAMERA?e=this._cache.fov===this.fov&&this._cache.fovMode===this.fovMode&&this._cache.aspectRatio===t.getAspectRatio(this)&&this._cache.projectionPlaneTilt===this.projectionPlaneTilt:(e=this._cache.orthoLeft===this.orthoLeft&&this._cache.orthoRight===this.orthoRight&&this._cache.orthoBottom===this.orthoBottom&&this._cache.orthoTop===this.orthoTop&&this._cache.renderWidth===t.getRenderWidth()&&this._cache.renderHeight===t.getRenderHeight(),this.oblique&&(e=e&&this._cache.obliqueAngle===this.oblique.angle&&this._cache.obliqueLength===this.oblique.length&&this._cache.obliqueOffset===this.oblique.offset)),e}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?(F.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 M.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._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;this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ,this._refreshFrustumPlanes=!0;const t=this.getEngine(),i=this.getScene(),s=t.useReverseDepthBuffer;if(this.mode===J.PERSPECTIVE_CAMERA){this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=t.getAspectRatio(this),this._cache.projectionPlaneTilt=this.projectionPlaneTilt,this.minZ<=0&&(this.minZ=.1);let r;i.useRightHandedSystem?r=M.PerspectiveFovRHToRef:r=M.PerspectiveFovLHToRef,r(this.fov,t.getAspectRatio(this),s?this.maxZ:this.minZ,s?this.minZ:this.maxZ,this._projectionMatrix,this.fovMode===J.FOVMODE_VERTICAL_FIXED,t.isNDCHalfZRange,this.projectionPlaneTilt,s)}else{const r=t.getRenderWidth()/2,n=t.getRenderHeight()/2;i.useRightHandedSystem?this.oblique?M.ObliqueOffCenterRHToRef(this.orthoLeft??-r,this.orthoRight??r,this.orthoBottom??-n,this.orthoTop??n,s?this.maxZ:this.minZ,s?this.minZ:this.maxZ,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,t.isNDCHalfZRange):M.OrthoOffCenterRHToRef(this.orthoLeft??-r,this.orthoRight??r,this.orthoBottom??-n,this.orthoTop??n,s?this.maxZ:this.minZ,s?this.minZ:this.maxZ,this._projectionMatrix,t.isNDCHalfZRange):this.oblique?M.ObliqueOffCenterLHToRef(this.orthoLeft??-r,this.orthoRight??r,this.orthoBottom??-n,this.orthoTop??n,s?this.maxZ:this.minZ,s?this.minZ:this.maxZ,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,t.isNDCHalfZRange):M.OrthoOffCenterLHToRef(this.orthoLeft??-r,this.orthoRight??r,this.orthoBottom??-n,this.orthoTop??n,s?this.maxZ:this.minZ,s?this.minZ:this.maxZ,this._projectionMatrix,t.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=t.getRenderWidth(),this._cache.renderHeight=t.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?It.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=It.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)}isInFrustum(e,t=!1){if(this._updateFrustumPlanes(),t&&this.rigCameras.length>0){let i=!1;return this.rigCameras.forEach(s=>{s._updateFrustumPlanes(),i=i||e.isInFrustum(s._frustumPlanes)}),i}else return e.isInFrustum(this._frustumPlanes)}isCompletelyInFrustum(e){return this._updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)}getForwardRay(e=100,t,i){throw ee("Ray")}getForwardRayToRef(e,t=100,i,s){throw ee("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=B.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 M.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,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=B.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.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=re.Serialize(this);return e.uniqueId=this.uniqueId,e.type=this.getClassName(),this.parent&&this.parent._serializeAsParent(e),this.inputs&&this.inputs.serialize(e),re.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.isEnabled=this.isEnabled(),e}clone(e,t=null){const i=re.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=Ve.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=re.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=fi("BABYLON.Animation");h&&r.animations.push(h.Parse(o))}Ve.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 ee("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;p([ri("position")],J.prototype,"_position",void 0);p([ri("upVector")],J.prototype,"_upVector",void 0);p([E()],J.prototype,"orthoLeft",null);p([E()],J.prototype,"orthoRight",null);p([E()],J.prototype,"orthoBottom",null);p([E()],J.prototype,"orthoTop",null);p([E()],J.prototype,"fov",void 0);p([E()],J.prototype,"projectionPlaneTilt",void 0);p([E()],J.prototype,"minZ",void 0);p([E()],J.prototype,"maxZ",void 0);p([E()],J.prototype,"inertia",void 0);p([E()],J.prototype,"mode",null);p([E()],J.prototype,"layerMask",void 0);p([E()],J.prototype,"fovMode",void 0);p([E()],J.prototype,"cameraRigMode",void 0);p([E()],J.prototype,"interaxialDistance",void 0);p([E()],J.prototype,"isStereoscopicSideBySide",void 0);class bs{get underlyingResource(){return null}constructor(){this.references=0,this.capacity=0,this.is32Bits=!1,this.uniqueId=bs._Counter++}}bs._Counter=0;function 
vendor: 26,372 bytes, line 23
23Zh(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 Jh(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 li(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 yd(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 Ys(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;d++)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=li(s);for(let f=0;f<r;f+=i){for(let d=0,g=e;d<i;d++,g+=u)h[d]=l[d]=Zh(c,s,g,n);o(l,f);for(let d=0,g=e;d<i;d++,g+=u)h[d]!==l[d]&&Jh(c,s,g,n,l[d]);e+=t}}}function yn(a,e,t,i,s,r,n,o){const h=e*li(t),l=n*e;if(t!==5126||s!==h){const c=new Float32Array(l);return Ys(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&&(F.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 $h(a,e,t,i,s,r,n,o){const h=e*li(t),l=n*e;if(o.length!==l)throw new Error("Output length is not valid");if(t!==5126||s!==h){Ys(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){F.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 qs{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 bs?(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 T(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}F.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 T{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 m=!1;if(this.engine=e,typeof s=="object"&&s!==null?(m=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):m=!!s,t instanceof qs?(this._buffer=t,this._ownsBuffer=g):(this._buffer=new qs(e,t,m,n,r,o,f,d,this._label),this._ownsBuffer=!0),this.uniqueId=T._Counter++,this._kind=i,c===void 0){const y=this.getData();this.type=y?T.GetDataType(y):T.FLOAT}else this.type=c;const b=li(this.type);f?(this._size=l||(n?n/b:T.DeduceStride(i)),this.byteStride=n||this._buffer.byteStride||this._size*b,this.byteOffset=h||0):(this._size=l||n||T.DeduceStride(i),this.byteStride=n?n*b:this._buffer.byteStride||this._size*b,this.byteOffset=(h||0)*b),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}isUpdatable(){return this._buffer.isUpdatable()}getData(){return this._buffer.getData()}getFloatData(e,t){const i=this.getData();return i?yn(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/li(this.type)}getOffset(){return this.byteOffset/li(this.type)}getSize(e=!1){return e?this._size*li(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){Ys(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 T.UVKind:case T.UV2Kind:case T.UV3Kind:case T.UV4Kind:case T.UV5Kind:case T.UV6Kind:return 2;case T.NormalKind:case T.PositionKind:return 3;case T.ColorKind:case T.ColorInstanceKind:case T.MatricesIndicesKind:case T.MatricesIndicesExtraKind:case T.MatricesWeightsKind:case T.MatricesWeightsExtraKind:case T.TangentKind:return 4;default:throw new Error("Invalid kind '"+e+"'")}}static GetDataType(e){return e instanceof Int8Array?T.BYTE:e instanceof Uint8Array?T.UNSIGNED_BYTE:e instanceof Int16Array?T.SHORT:e instanceof Uint16Array?T.UNSIGNED_SHORT:e instanceof Int32Array?T.INT:e instanceof Uint32Array?T.UNSIGNED_INT:T.FLOAT}static GetTypeByteLength(e){return li(e)}static ForEach(e,t,i,s,r,n,o,h){Ys(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 yn(e,t,i,s,r,n,o,h)}}T._Counter=0;T.BYTE=5120;T.UNSIGNED_BYTE=5121;T.SHORT=5122;T.UNSIGNED_SHORT=5123;T.INT=5124;T.UNSIGNED_INT=5125;T.FLOAT=5126;T.PositionKind="position";T.NormalKind="normal";T.TangentKind="tangent";T.UVKind="uv";T.UV2Kind="uv2";T.UV3Kind="uv3";T.UV4Kind="uv4";T.UV5Kind="uv5";T.UV6Kind="uv6";T.ColorKind="color";T.ColorInstanceKind="instanceColor";T.MatricesIndicesKind="matricesIndices";T.MatricesWeightsKind="matricesWeights";T.MatricesIndicesExtraKind="matricesIndicesExtra";T.MatricesWeightsExtraKind="matricesWeightsExtra";class xn{constructor(e,t,i){this.bu=e,this.bv=t,this.distance=i,this.faceId=0,this.subMeshId=0}}class $t{constructor(e,t,i){this.vectors=ti(8,_.Zero),this.center=_.Zero(),this.centerWorld=_.Zero(),this.extendSize=_.Zero(),this.extendSizeWorld=_.Zero(),this.directions=ti(3,_.Zero),this.vectorsWorld=ti(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||M.IdentityReadOnly,this._update(this._worldMatrix)}scale(e){const t=$t._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 $t.IsInFrustum(this.vectorsWorld,e)}isCompletelyInFrustum(e){return $t.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=-_e;return!(o-c<d||d>c-s||h-u<d||d>u-r||l-f<d||d>f-n)}intersectsSphere(e){return $t.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,m=t.y,b=t.z;return!(h<u||r>g||l<f||n>m||c<d||o>b)}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=$t._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}}$t._TmpVector3=ti(3,_.Zero);class yi{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||M.IdentityReadOnly)}scale(e){const t=this.radius*e,i=yi._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=yi._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 yi(this._TmpVector3[0],this._TmpVector3[2]);return i?s._worldMatrix=i:s._worldMatrix=M.Identity(),s}}yi._TmpVector3=ti(3,_.Zero);const mr={min:0,max:0},Tr={min:0,max:0},Sn=(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},ut=(a,e,t)=>(Sn(a,e,mr),Sn(a,t,Tr),!(mr.min>Tr.max||Tr.min>mr.max));class St{constructor(e,t,i){this._isLocked=!1,this.boundingBox=new $t(e,t,i),this.boundingSphere=new yi(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=St._TmpVector3[0].copyFrom(e).subtractInPlace(t),s=St._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=C.Matrix[0];this.boundingBox.getWorldMatrix().invertToRef(t);const i=C.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,St._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(!yi.Intersects(this.boundingSphere,e.boundingSphere)||!$t.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;const i=this.boundingBox,s=e.boundingBox;return!(!ut(i.directions[0],i,s)||!ut(i.directions[1],i,s)||!ut(i.directions[2],i,s)||!ut(s.directions[0],i,s)||!ut(s.directions[1],i,s)||!ut(s.directions[2],i,s)||!ut(_.Cross(i.directions[0],s.directions[0]),i,s)||!ut(_.Cross(i.directions[0],s.directions[1]),i,s)||!ut(_.Cross(i.directions[0],s.directions[2]),i,s)||!ut(_.Cross(i.directions[1],s.directions[0]),i,s)||!ut(_.Cross(i.directions[1],s.directions[1]),i,s)||!ut(_.Cross(i.directions[1],s.directions[2]),i,s)||!ut(_.Cross(i.directions[2],s.directions[0]),i,s)||!ut(_.Cross(i.directions[2],s.directions[1]),i,s)||!ut(_.Cross(i.directions[2],s.directions[2]),i,s))}}St._TmpVector3=ti(2,_.Zero);class $s{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)}}}p([si.filter((...[a,e])=>!Array.isArray(a)&&!Array.isArray(e))],$s,"extractMinAndMaxIndexed",null);p([si.filter((...[a])=>!Array.isArray(a))],$s,"extractMinAndMax",null);function el(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 $s.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 Ya(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),$s.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 $r{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():is.SetImmediate(()=>{t.getEngine().onEndFrameObservable.addOnce(()=>{t.dispose()})}),this.effect=null}this.drawContext?.dispose()}}class vt{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 $r(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 vt(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(T.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=el(e,t,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new St(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 xn(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 xn(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],m=t[f],b=t[d];if(!g||!m||!b||o&&!o(g,m,b,e,u,f,d))continue;const y=e.intersectsTriangle(g,m,b);if(y){if(y.distance<0)continue;if((n||!h||y.distance<h.distance)&&(h=y,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 vt(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 St(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 vt(e,o,h-o+1,t,i,s,r,n)}}class br{}class Q{constructor(){this.uniqueId=0,this.metadata={},this._applyTo=j
vendor: 19,435 bytes, line 23
23h(this._applyToCoroutine.bind(this)),this.uniqueId=Q._UniqueIDGenerator,Q._UniqueIDGenerator++}set(e,t){switch(e.length||F.Warn(`Setting vertex data kind '${t}' with an empty array`),t){case T.PositionKind:this.positions=e;break;case T.NormalKind:this.normals=e;break;case T.TangentKind:this.tangents=e;break;case T.UVKind:this.uvs=e;break;case T.UV2Kind:this.uvs2=e;break;case T.UV3Kind:this.uvs3=e;break;case T.UV4Kind:this.uvs4=e;break;case T.UV5Kind:this.uvs5=e;break;case T.UV6Kind:this.uvs6=e;break;case T.ColorKind:this.colors=e;break;case T.MatricesIndicesKind:this.matricesIndices=e;break;case T.MatricesWeightsKind:this.matricesWeights=e;break;case T.MatricesIndicesExtraKind:this.matricesIndicesExtra=e;break;case T.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(T.PositionKind,this.positions,t),i&&(yield)),this.normals&&(e.setVerticesData(T.NormalKind,this.normals,t),i&&(yield)),this.tangents&&(e.setVerticesData(T.TangentKind,this.tangents,t),i&&(yield)),this.uvs&&(e.setVerticesData(T.UVKind,this.uvs,t),i&&(yield)),this.uvs2&&(e.setVerticesData(T.UV2Kind,this.uvs2,t),i&&(yield)),this.uvs3&&(e.setVerticesData(T.UV3Kind,this.uvs3,t),i&&(yield)),this.uvs4&&(e.setVerticesData(T.UV4Kind,this.uvs4,t),i&&(yield)),this.uvs5&&(e.setVerticesData(T.UV5Kind,this.uvs5,t),i&&(yield)),this.uvs6&&(e.setVerticesData(T.UV6Kind,this.uvs6,t),i&&(yield)),this.colors){const s=this.positions&&this.colors.length===this.positions.length?3:4;e.setVerticesData(T.ColorKind,this.colors,t,s),this.hasVertexAlpha&&e.hasVertexAlpha!==void 0&&(e.hasVertexAlpha=!0),i&&(yield)}if(this.matricesIndices&&(e.setVerticesData(T.MatricesIndicesKind,this.matricesIndices,t),i&&(yield)),this.matricesWeights&&(e.setVerticesData(T.MatricesWeightsKind,this.matricesWeights,t),i&&(yield)),this.matricesIndicesExtra&&(e.setVerticesData(T.MatricesIndicesExtraKind,this.matricesIndicesExtra,t),i&&(yield)),this.matricesWeightsExtra&&(e.setVerticesData(T.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 vt(r.materialIndex,r.verticesStart,r.verticesCount,r.indexStart,r.indexCount,s)}return this}_update(e,t,i){return this.positions&&e.updateVerticesData(T.PositionKind,this.positions,t,i),this.normals&&e.updateVerticesData(T.NormalKind,this.normals,t,i),this.tangents&&e.updateVerticesData(T.TangentKind,this.tangents,t,i),this.uvs&&e.updateVerticesData(T.UVKind,this.uvs,t,i),this.uvs2&&e.updateVerticesData(T.UV2Kind,this.uvs2,t,i),this.uvs3&&e.updateVerticesData(T.UV3Kind,this.uvs3,t,i),this.uvs4&&e.updateVerticesData(T.UV4Kind,this.uvs4,t,i),this.uvs5&&e.updateVerticesData(T.UV5Kind,this.uvs5,t,i),this.uvs6&&e.updateVerticesData(T.UV6Kind,this.uvs6,t,i),this.colors&&e.updateVerticesData(T.ColorKind,this.colors,t,i),this.matricesIndices&&e.updateVerticesData(T.MatricesIndicesKind,this.matricesIndices,t,i),this.matricesWeights&&e.updateVerticesData(T.MatricesWeightsKind,this.matricesWeights,t,i),this.matricesIndicesExtra&&e.updateVerticesData(T.MatricesIndicesExtraKind,this.matricesIndicesExtra,t,i),this.matricesWeightsExtra&&e.updateVerticesData(T.MatricesWeightsExtraKind,this.matricesWeightsExtra,t,i),this.indices&&e.setIndices(this.indices,null),this}static _TransformVector3Coordinates(e,t,i=0,s=e.length){const r=C.Vector3[0],n=C.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=C.Vector3[0],n=C.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=C.Vector4[0],n=C.Vector4[1];for(let o=i;o<i+s;o+=4)he.FromArrayToRef(e,o,r),he.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&&Q._TransformVector3Coordinates(this.positions,e),this.normals&&Q._TransformVector3Normals(this.normals,e),this.tangents&&Q._TransformVector4Normals(this.tangents,e),t&&this.indices&&Q._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 Q;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 br;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 Jr(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,m=0;const b=[];let y=null;const A=[];for(const I of this.splitBasedOnMaterialID())A.push({vertexData:I,transform:e});for(const I of t)if(I.vertexData)for(const x of I.vertexData.splitBasedOnMaterialID())A.push({vertexData:x,transform:I.transform});A.sort((I,x)=>{const R=I.vertexData.materialInfos?I.vertexData.materialInfos[0].materialIndex:0,S=x.vertexData.materialInfos?x.vertexData.materialInfos[0].materialIndex:0;return R>S?1:R===S?0:-1});for(const I of A){const x=I.vertexData;if(x.materialInfos?d=x.materialInfos[0].materialIndex:d=0,y&&y.materialIndex===d)y.indexCount+=x.indices.length,y.verticesCount+=x.positions.length/3;else{const R=new br;R.materialIndex=d,R.indexStart=g,R.indexCount=x.indices.length,R.verticesStart=m,R.verticesCount=x.positions.length/3,b.push(R),y=R}g+=x.indices.length,m+=x.positions.length/3}const P=A.splice(0,1)[0];l=P.vertexData,e=P.transform,h=A.map(I=>I.vertexData),t=A,this.materialInfos=b}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 m=i||f instanceof Uint32Array?new Uint32Array(c):new Uint16Array(c);m.set(f),f=m}e&&e.determinant()<0&&Q._FlipFaces(f,0,d)}let g=l.positions?l.positions.length/3:0;for(const{vertexData:m,transform:b}of t)if(m.indices){for(let y=0;y<m.indices.length;y++)f[d+y]=m.indices[y]+g;b&&b.determinant()<0&&Q._FlipFaces(f,d,m.indices.length),g+=m.positions.length/3,d+=m.indices.length,s&&(yield)}}return this.indices=f,this.positions=Q._MergeElement(T.PositionKind,l.positions,e,t.map(d=>[d.vertexData.positions,d.transform])),s&&(yield),l.normals&&(this.normals=Q._MergeElement(T.NormalKind,l.normals,e,t.map(d=>[d.vertexData.normals,d.transform])),s&&(yield)),l.tangents&&(this.tangents=Q._MergeElement(T.TangentKind,l.tangents,e,t.map(d=>[d.vertexData.tangents,d.transform])),s&&(yield)),l.uvs&&(this.uvs=Q._MergeElement(T.UVKind,l.uvs,e,t.map(d=>[d.vertexData.uvs,d.transform])),s&&(yield)),l.uvs2&&(this.uvs2=Q._MergeElement(T.UV2Kind,l.uvs2,e,t.map(d=>[d.vertexData.uvs2,d.transform])),s&&(yield)),l.uvs3&&(this.uvs3=Q._MergeElement(T.UV3Kind,l.uvs3,e,t.map(d=>[d.vertexData.uvs3,d.transform])),s&&(yield)),l.uvs4&&(this.uvs4=Q._MergeElement(T.UV4Kind,l.uvs4,e,t.map(d=>[d.vertexData.uvs4,d.transform])),s&&(yield)),l.uvs5&&(this.uvs5=Q._MergeElement(T.UV5Kind,l.uvs5,e,t.map(d=>[d.vertexData.uvs5,d.transform])),s&&(yield)),l.uvs6&&(this.uvs6=Q._MergeElement(T.UV6Kind,l.uvs6,e,t.map(d=>[d.vertexData.uvs6,d.transform])),s&&(yield)),l.colors&&(this.colors=Q._MergeElement(T.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=Q._MergeElement(T.MatricesIndicesKind,l.matricesIndices,e,t.map(d=>[d.vertexData.matricesIndices,d.transform])),s&&(yield)),l.matricesWeights&&(this.matricesWeights=Q._MergeElement(T.MatricesWeightsKind,l.matricesWeights,e,t.map(d=>[d.vertexData.matricesWeights,d.transform])),s&&(yield)),l.matricesIndicesExtra&&(this.matricesIndicesExtra=Q._MergeElement(T.MatricesIndicesExtraKind,l.matricesIndicesExtra,e,t.map(d=>[d.vertexData.matricesIndicesExtra,d.transform])),s&&(yield)),l.matricesWeightsExtra&&(this.matricesWeightsExtra=Q._MergeElement(T.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===T.PositionKind?Q._TransformVector3Coordinates:e===T.NormalKind?Q._TransformVector3Normals:e===T.TangentKind?Q._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 Ii("Positions are required",ms.MeshInvalidPositionsError);const e=(s,r)=>{const n=T.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(T.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(T.NormalKind,this.normals),this.tangents&&i(T.TangentKind,this.tangents),this.uvs&&i(T.UVKind,this.uvs),this.uvs2&&i(T.UV2Kind,this.uvs2),this.uvs3&&i(T.UV3Kind,this.uvs3),this.uvs4&&i(T.UV4Kind,this.uvs4),this.uvs5&&i(T.UV5Kind,this.uvs5),this.uvs6&&i(T.UV6Kind,this.uvs6),this.colors&&i(T.ColorKind,this.colors),this.matricesIndices&&i(T.MatricesIndicesKind,this.matricesIndices),this.matricesWeights&&i(T.MatricesWeightsKind,this.matricesWeights),this.matricesIndicesExtra&&i(T.MatricesIndicesExtraKind,this.matricesIndicesExtra),this.matricesWeightsExtra&&i(T.MatricesWeightsExtraKind,this.matricesWeightsExtra)}clone(){const e=this.serialize();return Q.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.matricesIndices._isExpanded=!0),this.matricesWeights&&(e.matricesWeights=Array.from(this.matricesWeights)),this.matricesIndicesExtra&&(e.matricesIndicesExtra=Array.from(this.matricesIndicesExtra),e.matricesIndicesExtra._isExpanded=!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 Q._ExtractFrom(e,t,i)}static ExtractFromGeometry(e,t,i){return Q._ExtractFrom(e,t,i)}static _ExtractFrom(e,t,i){const s=new Q;if(e.isVerticesDataPresent(T.PositionKind)&&(s.positions=e.getVerticesData(T.PositionKind,t,i)),e.isVerticesDataPresent(T.NormalKind)&&(s.normals=e.getVerticesData(T.NormalKind,t,i)),e.isVerticesDataPresent(T.TangentKind)&&(s.tangents=e.getVerticesData(T.TangentKind,t,i)),e.isVerticesDataPresent(T.UVKind)&&(s.uvs=e.getVerticesData(T.UVKind,t,i)),e.isVerticesDataPresent(T.UV2Kind)&&(s.uvs2=e.getVerticesData(T.UV2Kind,t,i)),e.isVerticesDataPresent(T.UV3Kind)&&(s.uvs3=e.getVerticesData(T.UV3Kind,t,i)),e.isVerticesDataPresent(T.UV4Kind)&&(s.uvs4=e.getVerticesData(T.UV4Kind,t,i)),e.isVerticesDataPresent(T.UV5Kind)&&(s.uvs5=e.getVerticesData(T.UV5Kind,t,i)),e.isVerticesDataPresent(T.UV6Kind)&&(s.uvs6=e.getVerticesData(T.UV6Kind,t,i)),e.isVerticesDataPresent(T.ColorKind)){const r=e.geometry||e,n=r.getVertexBuffer(T.ColorKind),o=r.getVerticesData(T.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(T.MatricesIndicesKind)&&(s.matricesIndices=e.getVerticesData(T.MatricesIndicesKind,t,i)),e.isVerticesDataPresent(T.MatricesWeightsKind)&&(s.matricesWeights=e.getVerticesData(T.MatricesWeightsKind,t,i)),e.isVerticesDataPresent(T.MatricesIndicesExtraKind)&&(s.matricesIndicesExtra=e.getVerticesData(T.MatricesIndicesExtraKind,t,i)),e.isVerticesDataPresent(T.MatricesWeightsExtraKind)&&(s.matricesWeightsExtra=e.getVerticesData(T.MatricesWeightsExtraKind,t,i)),s.indices=e.getIndices(t,i),s}static CreateRibbon(e){throw ee("ribbonBuilder")}static CreateBox(e){throw ee("boxBuilder")}static CreateTiledBox(e){throw ee("tiledBoxBuilder")}static CreateTiledPlane(e){throw ee("tiledPlaneBuilder")}static CreateSphere(e){throw ee("sphereBuilder")}static CreateCylinder(e){throw ee("cylinderBuilder")}static CreateTorus(e){throw ee("torusBuilder")}static CreateLineSystem(e){throw ee("linesBuilder")}static CreateDashedLines(e){throw ee("linesBuilder")}static CreateGround(e){throw ee("groundBuilder")}static CreateTiledGround(e){throw ee("groundBuilder")}static CreateGroundFromHeightMap(e){throw ee("groundBuilder")}static CreatePlane(e){throw ee("planeBuilder")}static CreateDisc(e){throw ee("discBuilder")}static CreatePolygon(e,t,i,s,r,n,o){throw ee("polygonBuilder")}static CreateIcoSphere(e){throw ee("icoSphereBuilder")}static CreatePolyhedron(e){throw ee("polyhedronBuilder")}static CreateCapsule(e={orientation:_.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6}){throw ee("capsuleBuilder")}static CreateTorusKnot(e){throw ee("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,m=0,b=0,y=0,A=0,P=0,I=0,x=0,R=0,S=0,D=0,G=!1,X=!1,Re=!1,fe=!1,
vendor: 12,360 bytes, line 23
23ge=1,ue=0,ze=null;s&&(G=!!s.facetNormals,X=!!s.facetPositions,Re=!!s.facetPartitioning,ge=s.useRightHandedSystem===!0?-1:1,ue=s.ratio||0,fe=!!s.depthSort,ze=s.distanceTo,fe&&ze===void 0&&(ze=_.Zero()));let $e=0,nt=0,Ke=0,Ye=0;for(Re&&s&&s.bbSize&&($e=s.subDiv.X*ue/s.bbSize.x,nt=s.subDiv.Y*ue/s.bbSize.y,Ke=s.subDiv.Z*ue/s.bbSize.z,Ye=s.subDiv.max*s.subDiv.max,s.facetPartitioning.length=0),r=0;r<e.length;r++)i[r]=0;const ct=t.length/3|0;for(r=0;r<ct;r++){if(b=t[r*3]*3,y=b+1,A=b+2,P=t[r*3+1]*3,I=P+1,x=P+2,R=t[r*3+2]*3,S=R+1,D=R+2,n=e[b]-e[P],o=e[y]-e[I],h=e[A]-e[x],l=e[R]-e[P],c=e[S]-e[I],u=e[D]-e[x],f=ge*(o*u-h*c),d=ge*(h*l-n*u),g=ge*(n*c-o*l),m=Math.sqrt(f*f+d*d+g*g),m=m===0?1:m,f/=m,d/=m,g/=m,G&&s&&(s.facetNormals[r].x=f,s.facetNormals[r].y=d,s.facetNormals[r].z=g),X&&s&&(s.facetPositions[r].x=(e[b]+e[P]+e[R])/3,s.facetPositions[r].y=(e[y]+e[I]+e[S])/3,s.facetPositions[r].z=(e[A]+e[x]+e[D])/3),Re&&s){const Tt=Math.floor((s.facetPositions[r].x-s.bInfo.minimum.x*ue)*$e),kt=Math.floor((s.facetPositions[r].y-s.bInfo.minimum.y*ue)*nt),hi=Math.floor((s.facetPositions[r].z-s.bInfo.minimum.z*ue)*Ke),Ms=Math.floor((e[b]-s.bInfo.minimum.x*ue)*$e),Is=Math.floor((e[y]-s.bInfo.minimum.y*ue)*nt),Cs=Math.floor((e[A]-s.bInfo.minimum.z*ue)*Ke),ar=Math.floor((e[P]-s.bInfo.minimum.x*ue)*$e),or=Math.floor((e[I]-s.bInfo.minimum.y*ue)*nt),hr=Math.floor((e[x]-s.bInfo.minimum.z*ue)*Ke),lr=Math.floor((e[R]-s.bInfo.minimum.x*ue)*$e),cr=Math.floor((e[S]-s.bInfo.minimum.y*ue)*nt),ur=Math.floor((e[D]-s.bInfo.minimum.z*ue)*Ke),Wt=Ms+s.subDiv.max*Is+Ye*Cs,Xt=ar+s.subDiv.max*or+Ye*hr,Kt=lr+s.subDiv.max*cr+Ye*ur,Yt=Tt+s.subDiv.max*kt+Ye*hi;s.facetPartitioning[Yt]=s.facetPartitioning[Yt]?s.facetPartitioning[Yt]:new Array,s.facetPartitioning[Wt]=s.facetPartitioning[Wt]?s.facetPartitioning[Wt]:new Array,s.facetPartitioning[Xt]=s.facetPartitioning[Xt]?s.facetPartitioning[Xt]:new Array,s.facetPartitioning[Kt]=s.facetPartitioning[Kt]?s.facetPartitioning[Kt]:new Array,s.facetPartitioning[Wt].push(r),Xt!=Wt&&s.facetPartitioning[Xt].push(r),Kt==Xt||Kt==Wt||s.facetPartitioning[Kt].push(r),Yt==Wt||Yt==Xt||Yt==Kt||s.facetPartitioning[Yt].push(r)}if(fe&&s&&s.facetPositions){const Tt=s.depthSortedFacets[r];Tt.ind=r*3,Tt.sqDistance=_.DistanceSquared(s.facetPositions[r],ze)}i[b]+=f,i[y]+=d,i[A]+=g,i[P]+=f,i[I]+=d,i[x]+=g,i[R]+=f,i[S]+=d,i[D]+=g}for(r=0;r<i.length/3;r++)f=i[r*3],d=i[r*3+1],g=i[r*3+2],m=Math.sqrt(f*f+d*d+g*g),m=m===0?1:m,f/=m,d/=m,g/=m,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||Q.DEFAULTSIDE,e){case Q.FRONTSIDE:break;case Q.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 Q.DOUBLESIDE:{const f=t.length,d=f/3;for(let b=0;b<f;b++)t[f+b]=t[b];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 m=0;for(m=0;m<g;m++)r[m+g]=r[m];for(n=n||new he(0,0,1,1),o=o||new he(0,0,1,1),m=0,c=0;c<g/2;c++)r[m]=n.x+(n.z-n.x)*r[m],r[m+1]=n.y+(n.w-n.y)*r[m+1],r[m+g]=o.x+(o.z-o.x)*r[m+g],r[m+g+1]=o.y+(o.w-o.y)*r[m+g+1],m+=2;break}}}static Parse(e){const t=new Q,i=e.positions;i&&t.set(i,T.PositionKind);const s=e.normals;s&&t.set(s,T.NormalKind);const r=e.tangents;r&&t.set(r,T.TangentKind);const n=e.uvs;n&&t.set(n,T.UVKind);const o=e.uvs2;o&&t.set(o,T.UV2Kind);const h=e.uvs3;h&&t.set(h,T.UV3Kind);const l=e.uvs4;l&&t.set(l,T.UV4Kind);const c=e.uvs5;c&&t.set(c,T.UV5Kind);const u=e.uvs6;u&&t.set(u,T.UV6Kind);const f=e.colors;f&&(t.set(le.CheckColors4(f,i.length/3),T.ColorKind),e.hasVertexAlpha!==void 0&&(t.hasVertexAlpha=e.hasVertexAlpha));const d=e.matricesIndices;d&&t.set(d,T.MatricesIndicesKind);const g=e.matricesWeights;g&&t.set(g,T.MatricesWeightsKind);const m=e.indices;m&&(t.indices=m);const b=e.materialInfos;if(b){t.materialInfos=[];for(const y of b){const A=new br;A.indexCount=y.indexCount,A.indexStart=y.indexStart,A.verticesCount=y.verticesCount,A.verticesStart=y.verticesStart,A.materialIndex=y.materialIndex,t.materialInfos.push(A)}}return t}static ImportVertexData(e,t){const i=Q.Parse(e);t.setAllVerticesData(i,e.updatable)}}Q.FRONTSIDE=0;Q.BACKSIDE=1;Q.DOUBLESIDE=2;Q.DEFAULTSIDE=0;Q._UniqueIDGenerator=0;p([si.filter((...[a])=>!Array.isArray(a))],Q,"_TransformVector3Coordinates",null);p([si.filter((...[a])=>!Array.isArray(a))],Q,"_TransformVector3Normals",null);p([si.filter((...[a])=>!Array.isArray(a))],Q,"_TransformVector4Normals",null);p([si.filter((...[a])=>!Array.isArray(a))],Q,"_FlipFaces",null);class ft{static get ForceFullSceneLoadingForIncremental(){return ft._ForceFullSceneLoadingForIncremental}static set ForceFullSceneLoadingForIncremental(e){ft._ForceFullSceneLoadingForIncremental=e}static get ShowLoadingScreen(){return ft._ShowLoadingScreen}static set ShowLoadingScreen(e){ft._ShowLoadingScreen=e}static get loggingLevel(){return ft._LoggingLevel}static set loggingLevel(e){ft._LoggingLevel=e}static get CleanBoneMatrixWeights(){return ft._CleanBoneMatrixWeights}static set CleanBoneMatrixWeights(e){ft._CleanBoneMatrixWeights=e}}ft._ForceFullSceneLoadingForIncremental=!1;ft._ShowLoadingScreen=!0;ft._CleanBoneMatrixWeights=!1;ft._LoggingLevel=0;let Mn=!1;class ot{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 ot(ot.RandomId(),e.getScene());return t.applyToMesh(e),t}get meshes(){return this._meshes}constructor(e,t,i,s=!1,r=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||de.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,i?this.setAllVerticesData(i,s):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 T(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._buffer._increaseReferences(),this._vertexBuffers[s]=e;const r=this._meshes,n=r.length;if(s===T.PositionKind){this._totalVertices=t??e._maxVerticesCount,this._updateExtend(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===T.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&&$h(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(T.PositionKind),!e))return;this._extend=Y
vendor: 13,838 bytes, line 23
23a(e,0,this._totalVertices,this.boundingBias,3)}}_applyToMesh(e){const t=this._meshes.length;for(const i in this._vertexBuffers)t===1&&this._vertexBuffers[i].create(),i===T.PositionKind&&(this._extend||this._updateExtend(),e.buildBoundingInfo(this._extend.minimum,this._extend.maximum),e._createGlobalSubMesh(e.isUnIndexed),e._updateBoundingInfo());t===1&&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(T.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(T.PositionKind,t,!1)}const i=this.getVerticesData(T.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(T.NormalKind,i,!1)}}_resetPointsArrayCache(){this._positions=null}_generatePointsArray(){if(this._positions)return!0;const e=this.getVerticesData(T.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 Q;t.indices=[];const i=this.getIndices();if(i)for(let h=0;h<i.length;h++)t.indices.push(i[h]);let s=!1,r=!1,n;for(n in this._vertexBuffers){const h=this.getVerticesData(n);if(h&&(h instanceof Float32Array?t.set(new Float32Array(h),n):t.set(h.slice(0),n),!r)){const l=this.getVertexBuffer(n);l&&(s=l.isUpdatable(),r=!s)}}const o=new ot(e,this._scene,t,s);o.delayLoadState=this.delayLoadState,o.delayLoadingFile=this.delayLoadingFile,o._delayLoadingFunction=this._delayLoadingFunction;for(n in this._delayInfo)o._delayInfo=o._delayInfo||[],o._delayInfo.push(n);return o._boundingInfo=new St(this._extend.minimum,this._extend.maximum),o}serialize(){const e={};return e.id=this.id,e.uniqueId=this.uniqueId,e.updatable=this._updatable,pe&&pe.HasTags(this)&&(e.tags=pe.GetTags(this)),e}_toNumberArray(e){return Array.isArray(e)?e:Array.prototype.slice.call(e)}clearCachedData(){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(T.PositionKind)&&(e.positions=this._toNumberArray(this.getVerticesData(T.PositionKind)),this.isVertexBufferUpdatable(T.PositionKind)&&(e.positions._updatable=!0)),this.isVerticesDataPresent(T.NormalKind)&&(e.normals=this._toNumberArray(this.getVerticesData(T.NormalKind)),this.isVertexBufferUpdatable(T.NormalKind)&&(e.normals._updatable=!0)),this.isVerticesDataPresent(T.TangentKind)&&(e.tangents=this._toNumberArray(this.getVerticesData(T.TangentKind)),this.isVertexBufferUpdatable(T.TangentKind)&&(e.tangents._updatable=!0)),this.isVerticesDataPresent(T.UVKind)&&(e.uvs=this._toNumberArray(this.getVerticesData(T.UVKind)),this.isVertexBufferUpdatable(T.UVKind)&&(e.uvs._updatable=!0)),this.isVerticesDataPresent(T.UV2Kind)&&(e.uvs2=this._toNumberArray(this.getVerticesData(T.UV2Kind)),this.isVertexBufferUpdatable(T.UV2Kind)&&(e.uvs2._updatable=!0)),this.isVerticesDataPresent(T.UV3Kind)&&(e.uvs3=this._toNumberArray(this.getVerticesData(T.UV3Kind)),this.isVertexBufferUpdatable(T.UV3Kind)&&(e.uvs3._updatable=!0)),this.isVerticesDataPresent(T.UV4Kind)&&(e.uvs4=this._toNumberArray(this.getVerticesData(T.UV4Kind)),this.isVertexBufferUpdatable(T.UV4Kind)&&(e.uvs4._updatable=!0)),this.isVerticesDataPresent(T.UV5Kind)&&(e.uvs5=this._toNumberArray(this.getVerticesData(T.UV5Kind)),this.isVertexBufferUpdatable(T.UV5Kind)&&(e.uvs5._updatable=!0)),this.isVerticesDataPresent(T.UV6Kind)&&(e.uvs6=this._toNumberArray(this.getVerticesData(T.UV6Kind)),this.isVertexBufferUpdatable(T.UV6Kind)&&(e.uvs6._updatable=!0)),this.isVerticesDataPresent(T.ColorKind)&&(e.colors=this._toNumberArray(this.getVerticesData(T.ColorKind)),this.isVertexBufferUpdatable(T.ColorKind)&&(e.colors._updatable=!0)),this.isVerticesDataPresent(T.MatricesIndicesKind)&&(e.matricesIndices=this._toNumberArray(this.getVerticesData(T.MatricesIndicesKind)),e.matricesIndices._isExpanded=!0,this.isVertexBufferUpdatable(T.MatricesIndicesKind)&&(e.matricesIndices._updatable=!0)),this.isVerticesDataPresent(T.MatricesWeightsKind)&&(e.matricesWeights=this._toNumberArray(this.getVerticesData(T.MatricesWeightsKind)),this.isVertexBufferUpdatable(T.MatricesWeightsKind)&&(e.matricesWeights._updatable=!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 B.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(T.PositionKind,o,!1)}if(n.normalsAttrDesc&&n.normalsAttrDesc.count>0){const o=new Float32Array(e,n.normalsAttrDesc.offset,n.normalsAttrDesc.count);t.setVerticesData(T.NormalKind,o,!1)}if(n.tangetsAttrDesc&&n.tangetsAttrDesc.count>0){const o=new Float32Array(e,n.tangetsAttrDesc.offset,n.tangetsAttrDesc.count);t.setVerticesData(T.TangentKind,o,!1)}if(n.uvsAttrDesc&&n.uvsAttrDesc.count>0){const o=new Float32Array(e,n.uvsAttrDesc.offset,n.uvsAttrDesc.count);t.setVerticesData(T.UVKind,o,!1)}if(n.uvs2AttrDesc&&n.uvs2AttrDesc.count>0){const o=new Float32Array(e,n.uvs2AttrDesc.offset,n.uvs2AttrDesc.count);t.setVerticesData(T.UV2Kind,o,!1)}if(n.uvs3AttrDesc&&n.uvs3AttrDesc.count>0){const o=new Float32Array(e,n.uvs3AttrDesc.offset,n.uvs3AttrDesc.count);t.setVerticesData(T.UV3Kind,o,!1)}if(n.uvs4AttrDesc&&n.uvs4AttrDesc.count>0){const o=new Float32Array(e,n.uvs4AttrDesc.offset,n.uvs4AttrDesc.count);t.setVerticesData(T.UV4Kind,o,!1)}if(n.uvs5AttrDesc&&n.uvs5AttrDesc.count>0){const o=new Float32Array(e,n.uvs5AttrDesc.offset,n.uvs5AttrDesc.count);t.setVerticesData(T.UV5Kind,o,!1)}if(n.uvs6AttrDesc&&n.uvs6AttrDesc.count>0){const o=new Float32Array(e,n.uvs6AttrDesc.offset,n.uvs6AttrDesc.count);t.setVerticesData(T.UV6Kind,o,!1)}if(n.colorsAttrDesc&&n.colorsAttrDesc.count>0){const o=new Float32Array(e,n.colorsAttrDesc.offset,n.colorsAttrDesc.count);t.setVerticesData(T.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(T.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(T.MatricesIndicesExtraKind,h,!1)}if(n.matricesWeightsAttrDesc&&n.matricesWeightsAttrDesc.count>0){const o=new Float32Array(e,n.matricesWeightsAttrDesc.offset,n.matricesWeightsAttrDesc.count);t.setVerticesData(T.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];vt.AddToMesh(l,c,u,f,d,t)}}}else if(e.positions&&e.normals&&e.indices){if(t.setVerticesData(T.PositionKind,e.positions,e.positions._updatable),t.setVerticesData(T.NormalKind,e.normals,e.normals._updatable),e.tangents&&t.setVerticesData(T.TangentKind,e.tangents,e.tangents._updatable),e.uvs&&t.setVerticesData(T.UVKind,e.uvs,e.uvs._updatable),e.uvs2&&t.setVerticesData(T.UV2Kind,e.uvs2,e.uvs2._updatable),e.uvs3&&t.setVerticesData(T.UV3Kind,e.uvs3,e.uvs3._updatable),e.uvs4&&t.setVerticesData(T.UV4Kind,e.uvs4,e.uvs4._updatable),e.uvs5&&t.setVerticesData(T.UV5Kind,e.uvs5,e.uvs5._updatable),e.uvs6&&t.setVerticesData(T.UV6Kind,e.uvs6,e.uvs6._updatable),e.colors&&t.setVerticesData(T.ColorKind,le.CheckColors4(e.colors,e.positions.length/3),e.colors._updatable),e.matricesIndices)if(e.matricesIndices._isExpanded)delete e.matricesIndices._isExpanded,t.setVerticesData(T.MatricesIndicesKind,e.matricesIndices,e.matricesIndices._updatable);else{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(T.MatricesIndicesKind,n,e.matricesIndices._updatable)}if(e.matricesIndicesExtra)if(e.matricesIndicesExtra._isExpanded)delete e.matricesIndices._isExpanded,t.setVerticesData(T.MatricesIndicesExtraKind,e.matricesIndicesExtra,e.matricesIndicesExtra._updatable);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(T.MatricesIndicesExtraKind,n,e.matricesIndicesExtra._updatable)}e.matricesWeights&&(ot._CleanMatricesWeights(e,t),t.setVerticesData(T.MatricesWeightsKind,e.matricesWeights,e.matricesWeights._updatable)),e.matricesWeightsExtra&&t.setVerticesData(T.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];vt.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(!ft.CleanBoneMatrixWeights)return;let s=0;if(e.skeletonId>-1){const u=t.getScene().getLastSkeletonById(e.skeletonId);if(!u)return;s=u.bones.length}else return;const r=t.getVerticesData(T.MatricesIndicesKind),n=t.getVerticesData(T.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 m=o[u+g];f+=m,m<.001&&d<0&&(d=g)}if(h)for(let g=0;g<4;g++){const m=h[u+g];f+=m,m<.001&&d<0&&(d=g+4)}if((d<0||d>l-1)&&(d=l-1),f>.001){const g=1/f;for(let m=0;m<4;m++)o[u+m]*=g;if(h)for(let m=0;m<4;m++)h[u+m]*=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(T.MatricesIndicesKind,r),e.matricesWeightsExtra&&t.setVerticesData(T.MatricesIndicesExtraKind,n)}static Parse(e,t,i){const s=new ot(e.id,t,void 0,e.updatable);return s._loadedUniqueId=e.uniqueId,pe&&pe.AddTagsTo(s,e.tags),e.delayLoadingFile?(s.delayLoadState=4,s.delayLoadingFile=i+e.delayLoadingFile,s._boundingInfo=new St(_.FromArray(e.boundingBoxMinimum),_.FromArray(e.boundingBoxMaximum)),s._delayInfo=[],e.hasUVs&&s._delayInfo.push(T.UVKind),e.hasUVs2&&s._delayInfo.push(T.UV2Kind),e.hasUVs3&&s._delayInfo.push(T.UV3Kind),e.hasUVs4&&s._delayInfo.push(T.UV4Kind),e.hasUVs5&&s._delayInfo.push(T.UV5Kind),e.hasUVs6&&s._delayInfo.push(T.UV6Kind),e.hasColors&&s._delayInfo.push(T.ColorKind),e.hasMatricesIndices&&s._delayInfo.push(T.MatricesIndicesKind),e.hasMatricesWeights&&s._delayInfo.push(T.MatricesWeightsKind),s._delayLoadingFunction=Q.ImportVertexData):Q.ImportVertexData(e,s),t.pushGeometry(s,!0),s}}const 
23t
vendor: 14,573 bytes, line 23
23l=M.Compose(_.One(),U.FromEulerAngles(0,Math.PI,0),_.Zero());class ie extends Ve{get billboardMode(){return this._billboardMode}set billboardMode(e){this._billboardMode!==e&&(this._billboardMode=e,this._cache.useBillboardPosition=(this._billboardMode&ie.BILLBOARDMODE_USE_POSITION)!==0,this._computeUseBillboardPath())}get preserveParentRotationForBillboard(){return this._preserveParentRotationForBillboard}set preserveParentRotationForBillboard(e){e!==this._preserveParentRotationForBillboard&&(this._preserveParentRotationForBillboard=e,this._computeUseBillboardPath())}_computeUseBillboardPath(){this._cache.useBillboardPath=this._billboardMode!==ie.BILLBOARDMODE_NONE&&!this.preserveParentRotationForBillboard}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=ie.BILLBOARDMODE_NONE,this._preserveParentRotationForBillboard=!1,this.scalingDeterminant=1,this._infiniteDistance=!1,this.ignoreNonUniformScaling=!1,this.reIntegrateRotationIntoRotationQuaternion=!1,this._poseMatrix=null,this._localMatrix=M.Zero(),this._usePivotMatrix=!1,this._absolutePosition=_.Zero(),this._absoluteScaling=_.Zero(),this._absoluteRotationQuaternion=U.Identity(),this._pivotMatrix=M.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=M.Identity()),this._poseMatrix}_isSynchronized(){const e=this._cache;return!(this._billboardMode!==e.billboardMode||this._billboardMode!==ie.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,e.useBillboardPath=!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=M.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||U.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=C.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=C.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=ie._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=C.Matrix[0];this.rotationQuaternion.toRotationMatrix(h);const l=C.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(l),l.invert(),h.multiplyToRef(l,h),this.rotationQuaternion.fromRotationMatrix(h)}else{const h=C.Quaternion[0];U.FromEulerVectorToRef(this.rotation,h);const l=C.Matrix[0];h.toRotationMatrix(l);const c=C.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?U.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=C.Matrix[0];i.invertToRef(s),e=_.TransformCoordinates(e,s)}return this.setPivotMatrix(M.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=C.Quaternion[0],r=C.Vector3[0],n=C.Vector3[1],o=C.Matrix[1];M.IdentityToRef(o);const h=C.Matrix[0];this.computeWorldMatrix(!0);let l=this.rotationQuaternion;return l||(l=ie._TmpRotation,U.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,l)),M.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(M.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=U.RotationAxisToRef(e,t,ie._RotationAxisCache),this.rotationQuaternion.multiplyToRef(s,this.rotationQuaternion);else{if(this.parent){const r=this.parent.getWorldMatrix(),n=C.Matrix[0];r.invertToRef(n),e=_.TransformNormal(e,n),r.determinant()<0&&(t*=-1)}s=U.RotationAxisToRef(e,t,ie._RotationAxisCache),s.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}return this}rotateAround(e,t,i){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=U.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.setAll(0));const s=C.Vector3[0],r=C.Vector3[1],n=C.Vector3[2],o=C.Quaternion[0],h=C.Matrix[0],l=C.Matrix[1],c=C.Matrix[2],u=C.Matrix[3];return e.subtractToRef(this.position,s),M.TranslationToRef(s.x,s.y,s.z,h),M.TranslationToRef(-s.x,-s.y,-s.z,l),M.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=C.Quaternion[1],U.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,s));const r=C.Quaternion[0];return U.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!==ie.BILLBOARDMODE_NONE&&!this.preserveParentRotationForBillboard}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=ie._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=ie._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(U.RotationYawPitchRoll(this._rotation.y,this._rotation.x,this._rotation.z)),this._rotation.copyFromFloats(0,0,0))):(h=ie._TmpRotation,U.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,h)),this._usePivotMatrix){const l=C.Matrix[1];M.ScalingToRef(n.x,n.y,n.z,l);const c=C.Matrix[0];h.toRotationMatrix(c),this._pivotMatrix.multiplyToRef(l,C.Matrix[4]),C.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 M.ComposeToRef(n,h,o,this._localMatrix);if(r&&r.getWorldMatrix){if(e&&r.computeWorldMatrix(e),s.useBillboardPath){if(this._transformToBoneReferal){const f=this.parent;f.getSkeleton().prepare(),f.getFinalMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),C.Matrix[7])}else C.Matrix[7].copyFrom(r.getWorldMatrix());const l=C.Vector3[5],c=C.Vector3[6],u=C.Quaternion[0];C.Matrix[7].decompose(c,u,l),M.ScalingToRef(c.x,c.y,c.z,C.Matrix[7]),C.Matrix[7].setTranslation(l),ie.BillboardUseParentOrientation&&(this._position.applyRotationQuaternionToRef(u,l),this._localMatrix.setTranslation(l)),this._localMatrix.multiplyToRef(C.Matrix[7],this._worldMatrix)}else if(this._transformToBoneReferal){const l=this.parent;l.getSkeleton().prepare(),this._localMatrix.multiplyToRef(l.getFinalMatrix(),C.Matrix[6]),C.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(s.useBillboardPath&&t&&this.billboardMode&&!s.useBillboardPosition){const l=C.Vector3[0];if(this._worldMatrix.getTranslationToRef(l),C.Matrix[1].copyFrom(t.getViewMatrix()),this._scene.useRightHandedSystem&&C.Matrix[1].multiplyToRef(
vendor: 6,282 bytes, line 23
23tl,C.Matrix[1]),C.Matrix[1].setTranslationFromFloats(0,0,0),C.Matrix[1].invertToRef(C.Matrix[0]),(this.billboardMode&ie.BILLBOARDMODE_ALL)!==ie.BILLBOARDMODE_ALL){C.Matrix[0].decompose(void 0,C.Quaternion[0],void 0);const c=C.Vector3[1];C.Quaternion[0].toEulerAnglesToRef(c),(this.billboardMode&ie.BILLBOARDMODE_X)!==ie.BILLBOARDMODE_X&&(c.x=0),(this.billboardMode&ie.BILLBOARDMODE_Y)!==ie.BILLBOARDMODE_Y&&(c.y=0),(this.billboardMode&ie.BILLBOARDMODE_Z)!==ie.BILLBOARDMODE_Z&&(c.z=0),M.RotationYawPitchRollToRef(c.y,c.x,c.z,C.Matrix[0])}this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(C.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(C.Vector3[0])}else if(s.useBillboardPath&&t&&s.useBillboardPosition){const l=C.Vector3[0];this._worldMatrix.getTranslationToRef(l);const c=t.globalPosition;this._worldMatrix.invertToRef(C.Matrix[1]);const u=C.Vector3[1];_.TransformCoordinatesToRef(c,C.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(U.RotationYawPitchRollToRef(f,g,0,C.Quaternion[0]),(this.billboardMode&ie.BILLBOARDMODE_ALL)!==ie.BILLBOARDMODE_ALL){const m=C.Vector3[1];C.Quaternion[0].toEulerAnglesToRef(m),(this.billboardMode&ie.BILLBOARDMODE_X)!==ie.BILLBOARDMODE_X&&(m.x=0),(this.billboardMode&ie.BILLBOARDMODE_Y)!==ie.BILLBOARDMODE_Y&&(m.y=0),(this.billboardMode&ie.BILLBOARDMODE_Z)!==ie.BILLBOARDMODE_Z&&(m.z=0),M.RotationYawPitchRollToRef(m.y,m.x,m.z,C.Matrix[0])}else M.FromQuaternionToRef(C.Quaternion[0],C.Matrix[0]);this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(C.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(C.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=M.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=C.Matrix[0];s._localMatrix.multiplyToRef(this._localMatrix,r);const n=C.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=U.Identity()),this._worldMatrix=M.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=re.Clone(()=>new ie(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=re.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(),re.AppendSerializedAnimations(this,t),t.ranges=this.serializeAnimationRanges(),t}static Parse(e,t,i){const s=re.Parse(()=>new ie(e.name,t),e,t,i);if(e.localMatrix?s.setPreTransformMatrix(M.FromArray(e.localMatrix)):e.pivotMatrix&&s.setPivotMatrix(M.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=fi("BABYLON.Animation");o&&s.animations.push(o.Parse(n))}Ve.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 ie),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)}}ie.BILLBOARDMODE_NONE=0;ie.BILLBOARDMODE_X=1;ie.BILLBOARDMODE_Y=2;ie.BILLBOARDMODE_Z=4;ie.BILLBOARDMODE_ALL=7;ie.BILLBOARDMODE_USE_POSITION=128;ie.BillboardUseParentOrientation=!1;ie._TmpRotation=U.Zero();ie._TmpScaling=_.Zero();ie._TmpTranslation=_.Zero();ie._LookAtVectorCache=new _(0,0,0);ie._RotationAxisCache=new U;p([ri("position")],ie.prototype,"_position",void 0);p([ri("rotation")],ie.prototype,"_rotation",void 0);p([U
vendor: 17,658 bytes, line 23
23o("rotationQuaternion")],ie.prototype,"_rotationQuaternion",void 0);p([ri("scaling")],ie.prototype,"_scaling",void 0);p([E("billboardMode")],ie.prototype,"_billboardMode",void 0);p([E()],ie.prototype,"scalingDeterminant",void 0);p([E("infiniteDistance")],ie.prototype,"_infiniteDistance",void 0);p([E()],ie.prototype,"ignoreNonUniformScaling",void 0);p([E()],ie.prototype,"reIntegrateRotationIntoRotationQuaternion",void 0);class as{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(T.NormalKind))return null;let i=this.pickedMesh.getIndices();i?.length===0&&(i=null);let s;const r=C.Vector3[0],n=C.Vector3[1],o=C.Vector3[2];if(t){const l=this.pickedMesh.getVerticesData(T.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(T.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();l.nonUniformScaling&&(C.Matrix[0].copyFrom(u),u=C.Matrix[0],u.setTranslationFromFloats(0,0,0),u.invert(),u.transposeToRef(C.Matrix[1]),u=C.Matrix[1]),_.TransformNormalToRef(c,u,c)};if(e&&h(this.pickedMesh,s),this.ray){const l=C.Vector3[0].copyFrom(s);e||h(this.pickedMesh,l),_.Dot(l,this.ray.direction)>0&&s.negateInPlace()}return s.normalize(),s}getTextureCoordinates(e=T.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=Z.FromArray(i,t[this.faceId*3]*2),r=Z.FromArray(i,t[this.faceId*3+1]*2),n=Z.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 Z(s.x+r.x+n.x,s.y+r.y+n.y)}}class W{constructor(e,t,i,s,r=!1){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._engine._features.trackUbosInFrame&&(this._buffers=[],this._bufferIndex=-1,this._createBufferOnWrite=!1,this._currentFrameId=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!==void 0}getData(){return this._bufferData}getBuffer(){return this._buffer}_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)}}addUniform(e,t,i=0){if(this._noUBO||this._uniformLocations[e]!==void 0)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),this._uniformArraySizes[e]={strideSize:t,arraySize:i},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{t=t,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)}_getNames(){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._getNames()):this._buffer=this._engine.createUniformBuffer(this._bufferData,this._name+"_UniformList:"+this._getNames()),this._engine._features.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._engine._features.trackUbosInFrame&&(this._buffers=[],this._currentFrameId=0),this._rebuild()}get _numBuffers(){return this._buffers.length}get _indexBuffer(){return this._bufferIndex}get name(){return this._name}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._engine._features.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._engine._features.trackUbosInFrame;return}else this._copyBuffer(this._bufferData,this._buffers[this._bufferIndex][1]);this._engine.updateUniformBuffer(this._buffer,this._bufferData),this._engine._features._collectUbosUpdatedInFrame&&(W._UpdatedUbosInFrame[this._name]||(W._UpdatedUbosInFrame[this._name]=0),W._UpdatedUbosInFrame[this._name]++),this._needSync=!1,this._createBufferOnWrite=this._engine._features.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._engine._features.trackUbosInFrame&&this._currentFrameId!==this._engine.frameId&&(this._currentFrameId=this._engine.frameId,this._createBufferOnWrite=!1,this._buffers&&this._buffers.length>0?(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){F.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){F.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;l++)if(this._bufferData[s+h*4+o]!==B.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++)W._TempBuffer[i*4]=t[i*3],W._TempBuffer[i*4+1]=t[i*3+1],W._TempBuffer[i*4+2]=t[i*3+2],W._TempBuffer[i*4+3]=0;this.updateUniform(e,W._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++)W._TempBuffer[i*4]=t[i*2],W._TempBuffer[i*4+1]=t[i*2+1],W._TempBuffer[i*4+2]=0,W._TempBuffer[i*4+3]=0;this.updateUniform(e,W._TempBuffer,8)}_updateFloatForEffect(e,t){this._currentEffect.setFloat(e,t)}_updateFloatForUniform(e,t){W._TempBuffer[0]=t,this.updateUniform(e,W._TempBuffer,1)}_updateFloat2ForEffect(e,t,i,s=""){this._currentEffect.setFloat2(e+s,t,i)}_updateFloat2ForUniform(e,t,i){W._TempBuffer[0]=t,W._TempBuffer[1]=i,this.updateUniform(e,W._TempBuffer,2)}_updateFloat3ForEffect(e,t,i,s,r=""){this._currentEffect.setFloat3(e+r,t,i,s)}_updateFloat3ForUniform(e,t,i,s){W._TempBuffer[0]=t,W._TempBuffer[1]=i,W._TempBuffer[2]=s,this.updateUniform(e,W._TempBuffer,3)}_updateFloat4ForEffect(e,t,i,s,r,n=""){this._currentEffect.setFloat4(e+n,t,i,s,r)}_updateFloat4ForUniform(e,t,i,s,r){W._TempBuffer[0]=t,W._TempBuffer[1]=i,W._TempBuffer[2]=s,W._TempBuffer[3]=r,this.updateUniform(e,W._TempBuffer,4)}_updateFloatArrayForEffect(e,t){this._currentEffect.setFloatArray(e,t)}_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){W._TempBufferInt32View.set(t),this.updateUniformArray(e,W._TempBuffer,t.length)}_updateUIntArrayForEffect(e,t){this._currentEffect.setUIntArray(e,t)}_updateUIntArrayForUniform(e,t){W._TempBufferUInt32View.set(t),this.updateUniformArray(e,W._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){W._TempBuffer[0]=t.x,W._TempBuffer[1]=t.y,W._TempBuffer[2]=t.z,this.updateUniform(e,W._TempBuffer,3)}_updateVector4ForEffect(e,t){this._currentEffect.setVector4(e,t)}_updateVector4ForUniform(e,t){W._TempBuffer[0]=t.x,W._TempBuffer[1]=t.y,W._TempBuffer[2]=t.z,W._TempBuffer[3]=t.w,this.updateUniform(e,W._TempBuffer,4)}_updateColor3ForEffect(e,t,i=""){this._currentEffect.setColor3(e+i,t)}_updateColor3ForUniform(e,t){W._TempBuffer[0]=t.r,W._TempBuffer[1]=t.g,W._TempBuffer[2]=t.b,this.updateUniform(e,W._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){W._TempBuffer[0]=t.r,W._TempBuffer[1]=t.g,W._TempBuffer[2]=t.b,W._TempBuffer[3]=i,this.updateUniform(e,W._TempBuffer,4)}_updateDirectColor4ForUniform(e,t){W._TempBuffer[0]=t.r,W._TempBuffer[1]=t.g,W._TempBuffer[2]=t.b,W._TempBuffer[3]=t.a,this.updateUniform(e,W._TempBuffer,4)}_updateIntForEffect(e,t,i=""){this._currentEffect.setInt(e+i,t)}_updateIntForUniform(e,t){W._TempBufferInt32View[0]=t,this.updateUniform(e,W._TempBuffer,1)}_updateInt2ForEffect(e,t,i,s=""){this._currentEffect.setInt2(e+s,t,i)}_updateInt2ForUniform(e,t,i){W._TempBufferInt32View[0]=t,W._TempBufferInt32View[1]=i,this.updateUniform(e,W._TempBuffer,2)}_updateInt3ForEffect(e,t,i,s,r=""){this._currentEffect.setInt3(e+r,t,i,s)}_updateInt3ForUniform(e,t,i,s){W._TempBufferInt32View[0]=t,W._TempBufferInt32View[1]=i,W._TempBufferInt32View[2]=s,this.updateUniform(e,W._TempBuffer,3)}_updateInt4ForEffect(e,t,i,s,r,n=""){this._currentEffect.setInt4(e+n,t,i,s,r)}_updateInt4ForUniform(e,t,i,s,r){W._TempBufferInt32View[0]=t,W._TempBufferInt32View[1]=i,W._TempBufferInt32View[2]=s,W._TempBufferInt32View[3]=r,this.updateUniform(e,W._TempBuffer,4)}_updateUIntForEffect(e,t,i=""){this._currentEffect.setUInt(e+i,t)}_updateUIntForUniform(e,t){W._TempBufferUInt32View[0]=t,this.updateUniform(e,W._TempBuffer,1)}_updateUInt2ForEffect(e,t,i,s=""){this._currentEffect.setUInt2(e+s,t,i)}_updateUInt2ForUniform(e,t,i){W._TempBufferUInt32View[0]=t,W._TempBufferUInt32View[1]=i,this.updateUniform(e,W._TempBuffer,2)}_updateUInt3ForEffect(e,t,i,s,r=""){this._currentEffect.setUInt3(e+r,t,i,s)}_updateUInt3ForUniform(e,t,i,s){W._TempBufferUInt32View[0]=t,W._TempBufferUInt32View[1]=i,W._TempBufferUInt32View[2]=s,this.updateUniform(e,W._TempBuffer,3)}_updateUInt4ForEffect(e,t,i,s,r,n=""){this._currentEffect.setUInt4(e+n,t,i,s,r)}_updateUInt4ForUniform(e,t,i,s,r){W._TempBufferUInt32View[0]=t,W._TempBufferUInt32View[1]=i,W._TempBufferUInt32View[2]=s,W._TempBufferUInt32View[3]=r,this.updateUniform(e,W._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._currentFrameId=this._engine.frameId,!0;return!1}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._engine._features.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)}}W._UpdatedUbosInFrame={};W._MAX_UNIFORM_SIZE=256;W._TempBuffer=new Float32Array(W._MAX_UNIFORM_SIZE);W._TempBufferInt32View=new Int32Array(W._TempBuffer.buffer);W._TempBufferUInt32View=new Uint32Array(W._TempBuffer.buffer);class 
vendor: 2,360 bytes, line 23
23il{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 In;(function(a){a[a.LOCAL=0]="LOCAL",a[a.WORLD=1]="WORLD",a[a.BONE=2]="BONE"})(In||(In={}));class Vi{}Vi.X=new _(1,0,0);Vi.Y=new _(0,1,0);Vi.Z=new _(0,0,1);var Cn;(function(a){a[a.X=0]="X",a[a.Y=1]="Y",a[a.Z=2]="Z"})(Cn||(Cn={}));function sl(a,e,t){let i=null;switch(e){case T.PositionKind:i=s=>s.getPositions();break;case T.NormalKind:i=s=>s.getNormals();break;case T.TangentKind:i=s=>s.getTangents();break;case T.UVKind:i=s=>s.getUVs();break;case T.UV2Kind:i=s=>s.getUV2s();break;case T.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 rl(a,e,t,i,s,r,n){const o=C.Vector3[0],h=C.Matrix[0],l=C.Matrix[1],c=e===T.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&&(M.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&&(M.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 nl{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 al{constructor(){this._hasVertexAlpha=!1,this._useVertexColors=!0,this._numBoneInfluencers=4,this._applyFog=!0,this._receiveShadows=!1,this._facetData=new nl,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 i
vendor: 8,885 bytes, line 23
23l,this._enableDistantPicking=!1,this._rawBoundingInfo=null,this._sideOrientationHint=!1,this._inheritVisibility=!1}}class pt extends ie{static get BILLBOARDMODE_NONE(){return ie.BILLBOARDMODE_NONE}static get BILLBOARDMODE_X(){return ie.BILLBOARDMODE_X}static get BILLBOARDMODE_Y(){return ie.BILLBOARDMODE_Y}static get BILLBOARDMODE_Z(){return ie.BILLBOARDMODE_Z}static get BILLBOARDMODE_ALL(){return ie.BILLBOARDMODE_ALL}static get BILLBOARDMODE_USE_POSITION(){return ie.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 inheritVisibility(){return this._internalAbstractMeshDataInfo._inheritVisibility}set inheritVisibility(e){this._internalAbstractMeshDataInfo._inheritVisibility=e}get isVisible(){if(!this._isVisible||!this.inheritVisibility||!this._parentNode)return this._isVisible;if(this._isVisible){let e=this._parentNode;for(;e;){const t=e.isVisible;if(typeof t<"u")return t;e=e.parent}}return this._isVisible}set isVisible(e){this._isVisible=e}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 
vendor: 8,021 bytes, line 23
23al,this._waitingMaterialId=null,this._waitingMorphTargetManagerId=null,this.cullingStrategy=pt.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._isVisible=!0,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 le(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 W(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!==ie.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 St(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(T.MatricesIndicesKind)&&this.isVerticesDataPresent(T.MatricesWeightsKind)}_preActivate(){}_preActivateForIntermediateRendering(e){}_activate(e,t){return this._renderId=e,!0}_postActivate(){}_freeze(){}_unFreeze(){}getWorldMatrix(){return this._masterMesh&&this.billboardMode===ie.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 M;(this.rotationQuaternion?this.rotationQuaternion:U.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=Ya(e,0,this.getTotalVertices(),t);this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new St(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 St(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){rl(e,t,i,s,r,n,o)}_getData(e,t,i=T.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&&s
vendor: 9,515 bytes, line 23
23l(t,i,this.morphTargetManager),e.applySkeleton&&this.skeleton){const n=r(T.MatricesIndicesKind),o=r(T.MatricesWeightsKind);if(o&&n){const h=this.numBoneInfluencers>4,l=h?r(T.MatricesIndicesExtraKind):null,c=h?r(T.MatricesWeightsExtraKind):null,u=this.skeleton.getTransformMatrices(this);pt._ApplySkeleton(t,i,u,n,o,l,c)}}if(e.updatePositionsArray!==!1&&i===T.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,T.NormalKind)}getPositionData(e=!1,t=!1,i=null){return this._getData({applySkeleton:e,applyMorph:t,updatePositionsArray:!1},i,T.PositionKind)}_updateBoundingInfo(){return this._boundingInfo?this._boundingInfo.update(this.worldMatrixFromCache):this._boundingInfo=new St(_.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){this.getAbsolutePosition().addToRef(this.ellipsoidOffset,this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions);const i=this.getScene().collisionCoordinator;return this._internalAbstractMeshDataInfo._meshCollisionData._collider||(this._internalAbstractMeshDataInfo._meshCollisionData._collider=i.createCollider()),this._internalAbstractMeshDataInfo._meshCollisionData._collider._radius=this.ellipsoid,i.getNewPosition(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,e,this._internalAbstractMeshDataInfo._meshCollisionData._collider,this.collisionRetryCount,this,this._onCollisionPositionChange,this.uniqueId),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=C.Matrix[0],i=C.Matrix[1];return M.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 as,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 m=0;m<d;m++){const y=f.data[m].getMaterial();if(y&&(y.fillMode==7||y.fillMode==0||y.fillMode==1||y.fillMode==2||y.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 m=0;m<d;m++){const b=f.data[m];if(d>1&&!n&&!b.canIntersects(e))continue;const y=b.intersects(e,this._positions,this.getIndices(),t,i);if(y&&(t||!u||y.distance<u.distance)&&(u=y,u.subMeshId=m,t))break}if(u){const m=r??this.getWorldMatrix(),b=C.Vector3[0],y=C.Vector3[1];_.TransformCoordinatesToRef(e.origin,m,b),e.direction.scaleToRef(u.distance,y);const P=_.TransformNormal(y,m).addInPlace(b);return o.hit=!0,o.distance=_.Distance(b,P),o.pickedPoint=P,o.pickedMesh=this,o.bu=u.bu||0,o.bv=u.bv||0,o.subMeshFaceId=u.faceId,o.faceId=u.faceId+f.data[u.subMeshId].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,s.lights.forEach(o=>{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(T.PositionKind),i=this.getIndices(),s=this.getVerticesData(T.NormalKind),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=M.Identity(),e.facetDepthSortOrigin=_.Zero()}e.bbSize.x=r.maximum.x-r.minimum.x>
vendor: 21,031 bytes, line 23
23_e?r.maximum.x-r.minimum.x:_e,e.bbSize.y=r.maximum.y-r.minimum.y>_e?r.maximum.y-r.minimum.y:_e,e.bbSize.z=r.maximum.z-r.minimum.z>_e?r.maximum.z-r.minimum.z:_e;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&&Q.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=C.Matrix[5];o.invertToRef(h);const l=C.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,m=0;const b=this.getFacetLocalPositions(),y=this.getFacetLocalNormals(),A=this.getFacetsAtLocalCoordinates(e,t,i);if(!A)return null;let P=Number.MAX_VALUE,I=P,x,R,S;for(let D=0;D<A.length;D++)x=A[D],R=y[x],S=b[x],u=(e-S.x)*R.x+(t-S.y)*R.y+(i-S.z)*R.z,(!r||r&&n&&u>=0||r&&!n&&u<=0)&&(u=R.x*S.x+R.y*S.y+R.z*S.z,f=-(R.x*e+R.y*t+R.z*i-u)/(R.x*R.x+R.y*R.y+R.z*R.z),d=e+R.x*f,g=t+R.y*f,m=i+R.z*f,h=d-e,l=g-t,c=m-i,I=h*h+l*l+c*c,I<P&&(P=I,o=x,s&&(s.x=d,s.y=g,s.z=m)));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(T.PositionKind),i=this.getIndices();let s;return this.isVerticesDataPresent(T.NormalKind)?s=this.getVerticesData(T.NormalKind):s=[],Q.ComputeNormals(t,i,s,{useRightHandedSystem:this.getScene().useRightHandedSystem}),this.setVerticesData(T.NormalKind,s,e),this}async optimizeIndicesAsync(){const e=this.getIndices();if(!e)return this;const{OptimizeIndices:t}=await j(()=>import("./mesh.vertexData.functions-BYooUupK.js"),[],import.meta.url);return t(e),this.setIndices(e,this.getTotalVertices()),this}alignWithNormal(e,t){t||(t=Vi.Y);const i=C.Vector3[0],s=C.Vector3[1];return _.CrossToRef(t,e,s),_.CrossToRef(e,s,i),this.rotationQuaternion?U.RotationQuaternionFromAxisToRef(i,e,s,this.rotationQuaternion):_.RotationFromAxisToRef(i,e,s,this.rotation),this}_checkOcclusionQuery(){return!1}disableEdgesRendering(){throw ee("EdgesRenderer")}enableEdgesRendering(e,t,i){throw ee("EdgesRenderer")}getConnectedParticleSystems(){return this._scene.particleSystems.filter(e=>e.emitter===this)}}pt.OCCLUSION_TYPE_NONE=0;pt.OCCLUSION_TYPE_OPTIMISTIC=1;pt.OCCLUSION_TYPE_STRICT=2;pt.OCCLUSION_ALGORITHM_TYPE_ACCURATE=0;pt.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE=1;pt.CULLINGSTRATEGY_STANDARD=0;pt.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1;pt.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2;pt.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3;p([si.filter((...[a,e,t,i,s])=>!Array.isArray(a)&&!Array.isArray(e)&&!Array.isArray(t)&&!Array.isArray(i)&&!Array.isArray(s))],pt,"_ApplySkeleton",null);it("BABYLON.AbstractMesh",pt);class ai{constructor(){this.reset()}reset(){this.enabled=!1,this.mask=255,this.func=519,this.funcRef=1,this.funcMask=255,this.opStencilFail=7680,this.opDepthFail=7680,this.opStencilDepthPass=7681}get func(){return this._func}set func(e){this._func=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 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){re.Clone(()=>e,this)}serialize(){return re.Serialize(this)}parse(e,t,i){re.Parse(()=>this,e,t,i)}}p([E()],ai.prototype,"func",null);p([E()],ai.prototype,"funcRef",null);p([E()],ai.prototype,"funcMask",null);p([E()],ai.prototype,"opStencilFail",null);p([E()],ai.prototype,"opDepthFail",null);p([E()],ai.prototype,"opStencilDepthPass",null);p([E()],ai.prototype,"mask",null);p([E()],ai.prototype,"enabled",null);class me{static CompareLightsPriority(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority}}me.FALLOFF_DEFAULT=0;me.FALLOFF_PHYSICAL=1;me.FALLOFF_GLTF=2;me.FALLOFF_STANDARD=3;me.LIGHTMAP_DEFAULT=0;me.LIGHTMAP_SPECULAR=1;me.LIGHTMAP_SHADOWSONLY=2;me.INTENSITYMODE_AUTOMATIC=0;me.INTENSITYMODE_LUMINOUSPOWER=1;me.INTENSITYMODE_LUMINOUSINTENSITY=2;me.INTENSITYMODE_ILLUMINANCE=3;me.INTENSITYMODE_LUMINANCE=4;me.LIGHTTYPEID_POINTLIGHT=0;me.LIGHTTYPEID_DIRECTIONALLIGHT=1;me.LIGHTTYPEID_SPOTLIGHT=2;me.LIGHTTYPEID_HEMISPHERICLIGHT=3;me.LIGHTTYPEID_RECT_AREALIGHT=4;function ol(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 hl(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 ll(a,e,t){let i=e.clipPlane??t.clipPlane;Pi(a,"vClipPlane",i),i=e.clipPlane2??t.clipPlane2,Pi(a,"vClipPlane2",i),i=e.clipPlane3??t.clipPlane3,Pi(a,"vClipPlane3",i),i=e.clipPlane4??t.clipPlane4,Pi(a,"vClipPlane4",i),i=e.clipPlane5??t.clipPlane5,Pi(a,"vClipPlane5",i),i=e.clipPlane6??t.clipPlane6,Pi(a,"vClipPlane6",i)}function Pi(a,e,t){t&&a.setFloat4(e,t.normal.x,t.normal.y,t.normal.z,t.d)}const Pn=q.Black();function cl(a,e,t){if(!a||a.LOGARITHMICDEPTH||a.indexOf&&a.indexOf("LOGARITHMICDEPTH")>=0){const i=t.activeCamera;i.mode===1&&F.Error("Logarithmic depth is not compatible with orthographic cameras!",20),e.setFloat("logarithmicDepthConstant",2/(Math.log(i.maxZ+1)/Math.LN2))}}function ul(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(Pn,a.getEngine().useExactSrgbConversions),t.setColor3("vFogColor",Pn)):t.setColor3("vFogColor",a.fogColor))}function dl(a,e,t,i=!0){const s=t.NUM_MORPH_INFLUENCERS;if(s>0&&de.LastCreatedEngine){const r=de.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.COLOR;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&&F.Error("Cannot add more vertex attributes for mesh "+e.name)}}function fl(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 qa(a,e){const t=a.morphTargetManager;!a||!t||e.setFloatArray("morphTargetInfluences",t.influences)}function _l(a,e){e.bindToEffect(a,"Scene")}function Le(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 Be(a,e,t){const i=a.getTextureMatrix();e.updateMatrix(t+"Matrix",i)}function gl(a,e,t){t.BAKED_VERTEX_ANIMATION_TEXTURE&&t.INSTANCES&&a.push("bakedVertexAnimationSettingsInstanced")}function pl(a,e){return e.set(a),e}function ml(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]),pl(s,t.previousBones[a.uniqueId])))}}}function Tl(a,e,t,i,s,r=!0){a._bindLight(e,t,i,s,r)}function bl(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];Tl(o,n,a,t,typeof i=="boolean"?i:i.SPECULARTERM,e.receiveShadows)}}function Al(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 El(a,e){(e.INSTANCES||e.THIN_INSTANCES)&&fl(a,!!e.PREPASS_VELOCITY),e.INSTANCESCOLOR&&a.push("instanceColor")}function Rl(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 yl(a,e){return e.fogEnabled&&a.applyFog&&e.fogMode!==0}function xl(a,e,t,i,s,r,n,o=!1){n._areMiscDirty&&(n.LOGARITHMICDEPTH=t,n.POINTSIZE=i,n.FOG=s&&yl(a,e),n.NONUNIFORMSCALING=a.nonUniformScaling,n.ALPHATEST=r,n.DECAL_AFTER_DETAIL=o)}function Sl(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 l of e.lightSources)if(Ml(a,e,l,n,t,i,o),n++,n===s)break}t.SPECULARTERM=o.specularEnabled,t.SHADOWS=o.shadowEnabled;for(let l=n;l<s;l++)t["LIGHT"+l]!==void 0&&(t["LIGHT"+l]=!1,t["HEMILIGHT"+l]=!1,t["POINTLIGHT"+l]=!1,t["DIRLIGHT"+l]=!1,t["SPOTLIGHT"+l]=!1,t["AREALIGHT"+l]=!1,t["SHADOW"+l]=!1,t["SHADOWCSM"+l]=!1,t["SHADOWCSMDEBUG"+l]=!1,t["SHADOWCSMNUM_CASCADES"+l]=!1,t["SHADOWCSMUSESHADOWMAXZ"+l]=!1,t["SHADOWCSMNOBLEND"+l]=!1,t["SHADOWCSM_RIGHTHANDED"+l]=!1,t["SHADOWPCF"+l]=!1,t["SHADOWPCSS"+l]=!1,t["SHADOWPOISSON"+l]=!1,t["SHADOWESM"+l]=!1,t["SHADOWCLOSEESM"+l]=!1,t["SHADOWCUBE"+l]=!1,t["SHADOWLOWQUALITY"+l]=!1,t["SHADOWMEDIUMQUALITY"+l]=!1);const h=a.getEngine().getCaps();return t.SHADOWFLOAT===void 0&&(o.needRebuild=!0),t.SHADOWFLOAT=o.shadowEnabled&&(h.textureFloatRender&&h.textureFloatLinearFiltering||h.textureHalfFloatRender&&h.textureHalfFloatLinearFiltering),t.LIGHTMAPEXCLUDED=o.lightmapMode,o.needRebuild&&t.rebuild(),o.needNormals}function Ml(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,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 me.FALLOFF_GLTF:s["LIGHT_FALLOFF_GLTF"+i]=!0;break;case me.FALLOFF_PHYSICAL:s["LIGHT_FALLOFF_PHYSICAL"+i]=!0;break;case me.FALLOFF_STANDARD:s["LIGHT_FALLOFF_STANDARD"+i]=!0;break}if(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!=me.LIGHTMAP_DEFAULT?(n.lightmapMode=!0,s["LIGHTMAPEXCLUDED"+i]=!0,s["LIGHTMAPNOSPECULAR"+i]=t.lightmapMode==me.LIGHTMAP_SHADOWSONLY):(s["LIGHTMAPEXCLUDED"+i]=!1,s["LIGHTMAPNOSPECULAR"+i]=!1)}function Il(a,e,t,i,s,r=null,n=!1){let o=Ll(a,i);r!==!1&&(o=hl(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 Cl(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 Pl(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 vl(a,e){const t=a.bakedVertexAnimationManager;e.BAKED_VERTEX_ANIMATION_TEXTURE=!!(t&&t.isEnabled)}function Dl(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&&Cl(a,e),s&&Pl(a,e),n&&vl(a,e),!0}function Ol(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 Fl(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 wl(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 Ll(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 Bl(a,e,t,i,s=null,r=!1,n=!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,"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))}function Nl(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];
23n++)B
vendor: 10,044 bytes, line 23
23l(n,s,e,t["PROJECTEDLIGHTTEXTURE"+n],r,!1,t["IESLIGHTTEXTURE"+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"))}class v{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(v.MiscDirtyFlag+v.PrePassDirtyFlag)}get alpha(){return this._alpha}set backFaceCulling(e){this._backFaceCulling!==e&&(this._backFaceCulling=e,this.markAsDirty(v.TextureDirtyFlag))}get backFaceCulling(){return this._backFaceCulling}set cullBackFaces(e){this._cullBackFaces!==e&&(this._cullBackFaces=e,this.markAsDirty(v.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!==e&&(this._alphaMode=e,this.markAsDirty(v.TextureDirtyFlag))}get alphaMode(){return this._alphaMode}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(v.MiscDirtyFlag))}get fogEnabled(){return this._fogEnabled}get wireframe(){switch(this._fillMode){case v.WireFrameFillMode:case v.LineListDrawMode:case v.LineLoopDrawMode:case v.LineStripDrawMode:return!0}return this._scene.forceWireframe}set wireframe(e){this.fillMode=e?v.WireFrameFillMode:v.TriangleFillMode}get pointsCloud(){switch(this._fillMode){case v.PointFillMode:case v.PointListDrawMode:return!0}return this._scene.forcePointsCloud}set pointsCloud(e){this.fillMode=e?v.PointFillMode:v.TriangleFillMode}get fillMode(){return this._fillMode}set fillMode(e){this._fillMode!==e&&(this._fillMode=e,this.markAsDirty(v.MiscDirtyFlag))}get useLogarithmicDepth(){return this._useLogarithmicDepth}set useLogarithmicDepth(e){const t=this.getScene().getEngine().getCaps().fragmentDepthSupported;e&&!t&&F.Warn("Logarithmic depth has been requested for a material on a device that doesn't support it."),this._useLogarithmicDepth=e&&t,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.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 ai,this._useUBO=!1,this._fillMode=v.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=()=>{},this._callbackPluginEventFillRenderTargetTextures=()=>{},this._transparencyMode=null,this.name=e;const r=t||de.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||B.RandomId(),this.uniqueId=this._scene.getUniqueId(),this._materialContext=this._scene.getEngine().createMaterialContext(),this._drawWrapper=new $r(this._scene.getEngine(),!1),this._drawWrapper.materialContext=this._materialContext,this._uniformBuffer=new W(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={}),v.OnEventObservable.notifyObservers(this,1))}_createUniformBuffer(){const e=this.getScene().getEngine();this._uniformBuffer?.dispose(),e.isWebGPU&&!this._forceGLSL?(this._uniformBuffer=new W(e,void 0,void 0,this.name,!0),this._shaderLanguage=1):this._uniformBuffer=new W(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===v.MATERIAL_ALPHABLEND||this._transparencyMode===v.MATERIAL_ALPHATESTANDBLEND}get _transparencyModeIsTest(){return this._transparencyMode===v.MATERIAL_ALPHATEST||this._transparencyMode===v.MATERIAL_ALPHATESTANDBLEND}get _disableAlphaBlending(){return this._transparencyMode===v.MATERIAL_OPAQUE||this._transparencyMode===v.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(v.AllDirtyFlag)}_preBind(e,t=null){const i=this._scene.getEngine(),r=(t??this.sideOrientation)===v.ClockWiseSideOrientation;return i.enableEffect(e||this._getDrawWrapper()),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,
23_
vendor: 15,557 bytes, line 23
23l(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),v._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 Pt(0,0,0,1)),this._storeEffectOnSubMeshes){let c=!0,u=null;if(e.subMeshes){const f=new vt(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()}forceCompilationAsync(e,t){return new Promise((i,s)=>{this.forceCompilation(e,()=>{i()},t,r=>{s(r)})})}markAsDirty(e){this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism||(v._DirtyCallbackArray.length=0,e&v.ImageProcessingDirtyFlag&&v._DirtyCallbackArray.push(v._ImageProcessingDirtyCallBack),e&v.TextureDirtyFlag&&v._DirtyCallbackArray.push(v._TextureDirtyCallBack),e&v.LightDirtyFlag&&v._DirtyCallbackArray.push(v._LightsDirtyCallBack),e&v.FresnelDirtyFlag&&v._DirtyCallbackArray.push(v._FresnelDirtyCallBack),e&v.AttributesDirtyFlag&&v._DirtyCallbackArray.push(v._AttributeDirtyCallBack),e&v.MiscDirtyFlag&&v._DirtyCallbackArray.push(v._MiscDirtyCallBack),e&v.PrePassDirtyFlag&&v._DirtyCallbackArray.push(v._PrePassDirtyCallBack),v._DirtyCallbackArray.length&&this._markAllSubMeshesAsDirty(v._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(v._AllDirtyCallBack)}_markAllSubMeshesAsImageProcessingDirty(){this._markAllSubMeshesAsDirty(v._ImageProcessingDirtyCallBack)}_markAllSubMeshesAsTexturesDirty(){this._markAllSubMeshesAsDirty(v._TextureDirtyCallBack)}_markAllSubMeshesAsFresnelDirty(){this._markAllSubMeshesAsDirty(v._FresnelDirtyCallBack)}_markAllSubMeshesAsFresnelAndMiscDirty(){this._markAllSubMeshesAsDirty(v._FresnelAndMiscDirtyCallBack)}_markAllSubMeshesAsLightsDirty(){this._markAllSubMeshesAsDirty(v._LightsDirtyCallBack)}_markAllSubMeshesAsAttributesDirty(){this._markAllSubMeshesAsDirty(v._AttributeDirtyCallBack)}_markAllSubMeshesAsMiscDirty(){this._markAllSubMeshesAsDirty(v._MiscDirtyCallBack)}_markAllSubMeshesAsPrePassDirty(){this._markAllSubMeshesAsDirty(v._PrePassDirtyCallBack)}_markAllSubMeshesAsTexturesAndMiscDirty(){this._markAllSubMeshesAsDirty(v._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=re.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 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 F.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."),null;const r=B.Instantiate(e.customType).Parse(e,t,i);return r._loadedUniqueId=e.uniqueId,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=B.Instantiate("BABYLON."+r);h&&(o=new h(t))}o?.parse(n,i,s)}}}v.TriangleFillMode=0;v.WireFrameFillMode=1;v.PointFillMode=2;v.PointListDrawMode=3;v.LineListDrawMode=4;v.LineLoopDrawMode=5;v.LineStripDrawMode=6;v.TriangleStripDrawMode=7;v.TriangleFanDrawMode=8;v.ClockWiseSideOrientation=0;v.CounterClockWiseSideOrientation=1;v.ImageProcessingDirtyFlag=64;v.TextureDirtyFlag=1;v.LightDirtyFlag=2;v.FresnelDirtyFlag=4;v.AttributesDirtyFlag=8;v.MiscDirtyFlag=16;v.PrePassDirtyFlag=32;v.AllDirtyFlag=127;v.MATERIAL_OPAQUE=0;v.MATERIAL_ALPHATEST=1;v.MATERIAL_ALPHABLEND=2;v.MATERIAL_ALPHATESTANDBLEND=3;v.MATERIAL_NORMALBLENDMETHOD_WHITEOUT=0;v.MATERIAL_NORMALBLENDMETHOD_RNM=1;v.OnEventObservable=new O;v._AllDirtyCallBack=a=>a.markAllAsDirty();v._ImageProcessingDirtyCallBack=a=>a.markAsImageProcessingDirty();v._TextureDirtyCallBack=a=>a.markAsTexturesDirty();v._FresnelDirtyCallBack=a=>a.markAsFresnelDirty();v._MiscDirtyCallBack=a=>a.markAsMiscDirty();v._PrePassDirtyCallBack=a=>a.markAsPrePassDirty();v._LightsDirtyCallBack=a=>a.markAsLightDirty();v._AttributeDirtyCallBack=a=>a.markAsAttributesDirty();v._FresnelAndMiscDirtyCallBack=a=>{v._FresnelDirtyCallBack(a),v._MiscDirtyCallBack(a)};v._TextureAndMiscDirtyCallBack=a=>{v._TextureDirtyCallBack(a),v._MiscDirtyCallBack(a)};v._DirtyCallbackArray=[];v._RunDirtyCallBacks=a=>{for(const e of v._DirtyCallbackArray)e(a)};p([E()],v.prototype,"id",void 0);p([E()],v.prototype,"uniqueId",void 0);p([E()],v.prototype,"name",void 0);p([E()],v.prototype,"metadata",void 0);p([E()],v.prototype,"checkReadyOnEveryCall",void 0);p([E()],v.prototype,"checkReadyOnlyOnce",void 0);p([E()],v.prototype,"state",void 0);p([E("alpha")],v.prototype,"_alpha",void 0);p([E("backFaceCulling")],v.prototype,"_backFaceCulling",void 0);p([E("cullBackFaces")],v.prototype,"_cullBackFaces",void 0);p([E()],v.prototype,"sideOrientation",void 0);p([E("alphaMode")],v.prototype,"_alphaMode",void 0);p([E()],v.prototype,"_needDepthPrePass",void 0);p([E()],v.prototype,"disableDepthWrite",void 0);p([E()],v.prototype,"disableColorWrite",void 0);p([E()],v.prototype,"forceDepthWrite",void 0);p([E()],v.prototype,"depthFunction",void 0);p([E()],v.prototype,"separateCullingPass",void 0);p([E("fogEnabled")],v.prototype,"_fogEnabled",void 0);p([E()],v.prototype,"pointSize",void 0);p([E()],v.prototype,"zOffset",void 0);p([E()],v.prototype,"zOffsetUnits",void 0);p([E()],v.prototype,"pointsCloud",null);p([E()],v.prototype,"fillMode",null);p([E()],v.prototype,"useLogarithmicDepth",null);p([E()],v.prototype,"transparencyMode",null);class Hi extends v{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 Hi(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,pe&&(e.tags=pe.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 Hi(e.name,t);return i.id=e.id,i._loadedUniqueId=e.uniqueId,pe&&pe.AddTagsTo(i,e.tags),e.materialsUniqueIds?i._waitingSubMaterialsUniqueIds=e.materialsUniqueIds:e.materials.forEach(s=>i.subMaterials.push(t.getLastMaterialById(s))),i}}it("BABYLON.MultiMaterial",Hi);class te{}te.NAME_EFFECTLAYER="EffectLayer";te.NAME_LAYER="Layer";te.NAME_LENSFLARESYSTEM="LensFlareSystem";te.NAME_BOUNDINGBOXRENDERER="BoundingBoxRenderer";te.NAME_PARTICLESYSTEM="ParticleSystem";te.NAME_GAMEPAD="Gamepad";te.NAME_SIMPLIFICATIONQUEUE="SimplificationQueue";te.NAME_GEOMETRYBUFFERRENDERER="GeometryBufferRenderer";te.NAME_PREPASSRENDERER="PrePassRenderer";te.NAME_DEPTHRENDERER="DepthRenderer";te.NAME_DEPTHPEELINGRENDERER="DepthPeelingRenderer";te.NAME_POSTPROCESSRENDERPIPELINEMANAGER="PostProcessRenderPipelineManager";te.NAME_SPRITE="Sprite";te.NAME_SUBSURFACE="SubSurface";te.NAME_OUTLINERENDERER="Outline";te.NAME_PROCEDURALTEXTURE="ProceduralTexture";te.NAME_SHADOWGENERATOR="ShadowGenerator";te.NAME_OCTREE="Octree";te.NAME_PHYSICSENGINE="PhysicsEngine";te.NAME_AUDIO="Audio";te.NAME_FLUIDRENDERER="FluidRenderer";te.NAME_IBLCDFGENERATOR="iblCDFGenerator";te.STEP_ISREADYFORMESH_EFFECTLAYER=0;te.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER=0;te.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER=0;te.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER=0;te.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER=1;te.STEP_BEFORECAMERADRAW_PREPASS=0;te.STEP_BEFORECAMERADRAW_EFFECTLAYER=1;te.STEP_BEFORECAMERADRAW_LAYER=2;te.STEP_BEFORERENDERTARGETDRAW_PREPASS=0;te.STEP_BEFORERENDERTARGETDRAW_LAYER=1;te.STEP_BEFORERENDERINGMESH_PREPASS=0;te.STEP_BEFORERENDERINGMESH_OUTLINE=1;te.STEP_AFTERRENDERINGMESH_PREPASS=0;te.STEP_AFTERRENDERINGMESH_OUTLINE=1;te.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW=0;te.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER=1;te.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE=0;te.STEP_BEFORECLEAR_PROCEDURALTEXTURE=0;te.STEP_BEFORECLEAR_PREPASS=1;te.STEP_BEFORERENDERTARGETCLEAR_PREPASS=0;te.STEP_AFTERRENDERTARGETDRAW_PREPASS=0;te.STEP_AFTERRENDERTARGETDRAW_LAYER=1;te.STEP_AFTERCAMERADRAW_PREPASS=0;te.STEP_AFTERCAMERADRAW_EFFECTLAYER=1;te.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM=2;te.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW=3;te.STEP_AFTERCAMERADRAW_LAYER=4;te.STEP_AFTERCAMERADRAW_FLUIDRENDERER=5;te.STEP_AFTERCAMERAPOSTPROCESS_LAYER=0;te.STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER=0;te.STEP_AFTERRENDER_AUDIO=0;te.STEP_GATHERRENDERTARGETS_DEPTHRENDERER=0;te.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER=1;te.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR=2;te.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER=3;te.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER=0;te.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER=1;te.STEP_POINTERMOVE_SPRITE=0;te.STEP_POINTERDOWN_SPRITE=0;te.STEP_POINTERUP_SPRITE=0;class we extends Array{constructor(e){super(...e)}static Create(){return Object.create(we.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 
vendor: 11,659 bytes, line 23
23Ul{constructor(e,t){this.distanceOrScreenCoverage=e,this.mesh=t}}class kl{constructor(){this.visibleInstances={},this.batchCache=new vn,this.batchCacheReplacementModeInFrozenMode=new vn,this.instancesBufferSize=32*16*4}}class vn{constructor(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=[],this.hardwareInstancedRendering=[]}}class Vl{constructor(){this.instancesCount=0,this.matrixBuffer=null,this.previousMatrixBuffer=null,this.matrixBufferSize=32*16,this.matrixData=null,this.boundingVectors=[],this.worldMatrices=null}}class Hl{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 Vt={source:null,parent:null,doNotCloneChildren:!1,clonePhysicsImpostor:!0,cloneThinInstances:!1};class se extends pt{static _GetDefaultSideOrientation(e){return e||se.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(T.PositionKind,this._internalMeshDataInfo._sourcePositions,!0),this._internalMeshDataInfo._sourceNormals&&this.setVerticesData(T.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 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(){return this._instanceDataStorage.instancesData}get previousWorldMatrixInstancedBuffer(){return this._instanceDataStorage.instancesPreviousData}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),Ca.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,pe&&pe.HasTags(e)&&pe.AddTagsTo(this,pe.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?(Vt.parent=this,Vt.doNotCloneChildren=t,Vt.clonePhysicsImpostor=i,Vt.cloneThinInstances=s,h.clone(this.name+"."+h.name,Vt)):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 Hl,this.delayLoadState=0,this.instances=[],this._creationDataStorage=null,this._geometry=null,this._instanceDataStorage=new kl,this._thinInstanceDataStorage=new Vl,this._shouldGenerateFlatShading=!1,this._originalBuilderSideOrientation=se.DEFAULTSIDE,this.ignoreCameraMaxZ=!1,t=this.getScene(),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(T.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 F.Warn("You cannot use a mesh as LOD level twice"),this;const i=new U
vendor: 52,095 bytes, lines 23-30
23l(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=[];return this._delayInfo&&this._delayInfo.forEach(function(s){i.push(s)}),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 m=0;m<g.length;++m){i.currentRenderPassId=g[m];for(const b of this.subMeshes)if(!f.isReady(b,r,b.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}_preActivate(){const e=this._internalMeshDataInfo,t=this.getScene().getRenderId();return e._preActivateId===t?this:(e._preActivateId=t,this._instanceDataStorage.visibleInstances=null,this)}_preActivateForIntermediateRendering(e){return this._instanceDataStorage.visibleInstances&&(this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId=e),this}_registerInstanceForRenderId(e,t){return this._instanceDataStorage.visibleInstances||(this._instanceDataStorage.visibleInstances={defaultRenderId:t,selfDefaultRenderId:this._renderId}),this._instanceDataStorage.visibleInstances[t]||(this._instanceDataStorage.previousRenderId!==void 0&&this._instanceDataStorage.isFrozen&&(this._instanceDataStorage.visibleInstances[this._instanceDataStorage.previousRenderId]=null),this._instanceDataStorage.previousRenderId=t,this._instanceDataStorage.visibleInstances[t]=new Array),this._instanceDataStorage.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,T.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 vt(0,0,t,0,this.getTotalIndices()||t,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++)vt.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 Q;r.set(t,e);const n=this.getScene();new ot(ot.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){return this._geometry||(this._geometry=ot.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e,null,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(T.PositionKind);if(!i)return this;if(e(i),this.updateVerticesData(T.PositionKind,i,!1,!1),t){const s=this.getIndices(),r=this.getVerticesData(T.NormalKind);if(!r)return this;Q.ComputeNormals(i,s,r),this.updateVerticesData(T.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(ot.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this}setIndexBuffer(e,t,i,s=null){let r=this._geometry;r||(r=new ot(ot.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 Q;r.indices=e;const n=this.getScene();new ot(ot.RandomId(),n,r,i,this)}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)switch(this._getRenderingFillMode(i)){case v.WireFrameFillMode:n=e._getLinesIndexBuffer(this.getIndices(),r);break;default:n=null;break}else switch(this._getRenderingFillMode(i)){case v.PointFillMode:n=null;break;case v.WireFrameFillMode:n=e._getLinesIndexBuffer(this.getIndices(),r);break;default:case v.TriangleFillMode:n=this._geometry.getIndexBuffer();break}return this._bindDirect(t,n,s)}_bindDirect(e,t,i=!0){return this._geometry?(this.morphTargetManager&&this.morphTargetManager.isUsingTextureForTargets&&this.morphTargetManager._bind(e),!i||!this._userInstancedBuffersStorage||this.hasThinInstances?this._geometry._bind(e,t):this._geometry._bind(e,t,this._userInstancedBuffersStorage.vertexBuffers,this._userInstancedBuffersStorage.vertexArrayObjects),this):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();return this._unIndexed&&t!==v.WireFrameFillMode||t==v.PointFillMode?r.drawArraysType(t,e.verticesStart,e.verticesCount,this.forcedInstanceCount||i):t==v.WireFrameFillMode?r.drawElementsType(t,0,e._linesIndexCount,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){if(this._instanceDataStorage.isFrozen){if(t)return this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.hardwareInstancedRendering[e]=!1,this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.renderSelf[e]=!0,this._instanceDataStorage.batchCacheReplacementModeInFrozenMode;if(this._instanceDataStorage.previousBatch)return this._instanceDataStorage.previousBatch}const i=this.getScene(),s=i._isInIntermediateRendering(),r=s?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,n=this._instanceDataStorage.batchCache;if(n.mustReturn=!1,n.renderSelf[e]=t||!r&&this.isEnabled()&&this.isVisible,n.visibleInstances[e]=null,this._instanceDataStorage.visibleInstances&&!t){const o=this._instanceDataStorage.visibleInstances,h=i.getRenderId(),l=s?o.intermediateDefaultRenderId:o.defaultRenderId;n.visibleInstances[e]=o[h],!n.visibleInstances[e]&&l&&(n.visibleInstances[e]=o[l])}return n.hardwareInstancedRendering[e]=!t&&this._instanceDataStorage.hardwareInstancedRendering&&n.visibleInstances[e]!==null&&n.visibleInstances[e]!==void 0,this._instanceDataStorage.previousBatch=n,n}_updateInstancedBuffers(e,t,i,s,r,n){const o=t.visibleInstances[e._id],h=o?o.length:0,l=this._instanceDataStorage;let c=l.instancesBuffer,u=l.instancesPreviousBuffer,f=0,d=0;const g=t.renderSelf[e._id],m=!c||i!==l.instancesBufferSize||this._scene.needsPreviousWorldMatrices&&!l.instancesPreviousBuffer;if(!this._instanceDataStorage.manualUpdate&&(!l.isFrozen||m)){const b=this.getWorldMatrix();if(g&&(this._scene.needsPreviousWorldMatrices&&(l.masterMeshPreviousWorldMatrix?(l.masterMeshPreviousWorldMatrix.copyToArray(l.instancesPreviousData,f),l.masterMeshPreviousWorldMatrix.copyFrom(b)):(l.masterMeshPreviousWorldMatrix=b.clone(),l.masterMeshPreviousWorldMatrix.copyToArray(l.instancesPreviousData,f))),b.copyToArray(l.instancesData,f),f+=16,d++),o){if(se.INSTANCEDMESH_SORT_TRANSPARENT&&this._scene.activeCamera&&e.getMaterial()?.needAlphaBlendingForMesh(e.getRenderingMesh())){const y=this._scene.activeCamera.globalPosition;for(let A=0;A<o.length;A++){const P=o[A];P._distanceToCamera=_.Distance(P.getBoundingInfo().boundingSphere.centerWorld,y)}o.sort((A,P)=>A._distanceToCamera>P._distanceToCamera?-1:A._distanceToCamera<P._distanceToCamera?1:0)}for(let y=0;y<o.length;y++){const A=o[y],P=A.getWorldMatrix();P.copyToArray(l.instancesData,f),this._scene.needsPreviousWorldMatrices&&(A._previousWorldMatrix?(A._previousWorldMatrix.copyToArray(l.instancesPreviousData,f),A._previousWorldMatrix.copyFrom(P)):(A._previousWorldMatrix=P.clone(),A._previousWorldMatrix.copyToArray(l.instancesPreviousData,f))),f+=16,d++}}}else d=(g?1:0)+h;m?(c&&c.dispose(),u&&u.dispose(),c=new qs(s,l.instancesData,!0,16,!1,!0),l.instancesBuffer=c,this._userInstancedBuffersStorage||(this._userInstancedBuffersStorage={data:{},vertexBuffers:{},strides:{},sizes:{},vertexArrayObjects:this.getEngine().getCaps().vertexArrayObject?{}:void 0}),this._userInstancedBuffersStorage.vertexBuffers.world0=c.createVertexBuffer("world0",0,4),this._userInstancedBuffersStorage.vertexBuffers.world1=c.createVertexBuffer("world1",4,4),this._userInstancedBuffersStorage.vertexBuffers.world2=c.createVertexBuffer("world2",8,4),this._userInstancedBuffersStorage.vertexBuffers.world3=c.createVertexBuffer("world3",12,4),this._scene.needsPreviousWorldMatrices&&(u=new qs(s,l.instancesPreviousData,!0,16,!1,!0),l.instancesPreviousBuffer=u,this._userInstancedBuffersStorage.vertexBuffers.previousWorld0=u.createVertexBuffer("previousWorld0",0,4),this._userInstancedBuffersStorage.vertexBuffers.previousWorld1=u.createVertexBuffer("previousWorld1",4,4),this._userInstancedBuffersStorage.vertexBuffers.previousWorld2=u.createVertexBuffer("previousWorld2",8,4),this._userInstancedBuffersStorage.vertexBuffers.previousWorld3=u.createVertexBuffer("previousWorld3",12,4)),this._invalidateInstanceVertexArrayObject()):(!this._instanceDataStorage.isFrozen||this._instanceDataStorage.forceMatrixUpdates)&&(c.updateDirectly(l.instancesData,0,d),this._scene.needsPreviousWorldMatrices&&(!this._instanceDataStorage.manualUpdate||this._instanceDataStorage.previousManualUpdate)&&u.updateDirectly(l.instancesPreviousData,0,d)),this._processInstancedBuffers(o,g),n&&r!==void 0&&(this.getScene()._activeIndices.addCount(e.indexCount*d,!1),s._currentDrawContext&&(s._currentDrawContext.useInstancing=!0),this._bind(e,n,r),this._draw(e,r,d)),this._scene.needsPreviousWorldMatrices&&!m&&this._instanceDataStorage.manualUpdate&&(!this._instanceDataStorage.isFrozen||this._instanceDataStorage.forceMatrixUpdates)&&!this._instanceDataStorage.previousManualUpdate&&u.updateDirectly(l.instancesData,0,d)}_renderWithInstances(e,t,i,s,r){const n=i.visibleInstances[e._id],o=n?n.length:0,h=this._instanceDataStorage,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 b=f[g].getWorldMatrix();o&&o(!0,b,h),this._draw(t,s)}}l._activeIndices.addCount(t.indexCount*u,!1)}return this}_rebuild(e=!1){if(this._instanceDataStorage.instancesBuffer&&(e&&this._instanceDataStorage.instancesBuffer.dispose(),this._instanceDataStorage.instancesBuffer=null),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,this._instanceDataStorage.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;t&&h.setAlphaMode(this._internalMeshDataInfo._effectiveMaterial.alphaMode);let m;this._internalMeshDataInfo._effectiveMaterial._storeEffectOnSubMeshes?m=e._drawWrapper:m=this._internalMeshDataInfo._effectiveMaterial._getDrawWrapper();const b=m?.effect??null;for(const S of s._beforeRenderingMeshStage)S.action(this,e,o,b);if(!m||!b)return c&&(c.maxZ=l,s.updateTransformMatrix(!0)),this;const y=i||this;let A;if(!d.isFrozen&&(this._internalMeshDataInfo._effectiveMaterial.backFaceCulling||this._internalMeshDataInfo._effectiveMaterial.sideOrientation!==null||this._internalMeshDataInfo._effectiveMaterial.twoSidedLighting)){const S=y._getWorldMatrixDeterminant();A=this._internalMeshDataInfo._effectiveMaterial._getEffectiveOrientation(this),S<0&&(A=A===v.ClockWiseSideOrientation?v.CounterClockWiseSideOrientation:v.ClockWiseSideOrientation),d.sideOrientation=A}else A=d.sideOrientation;const P=this._internalMeshDataInfo._effectiveMaterial._preBind(m,A);this._internalMeshDataInfo._effectiveMaterial.forceDepthWrite&&h.setDepthWrite(!0);const I=this._internalMeshDataInfo._effectiveMaterial,x=I.fillMode;this._internalMeshDataInfo._onBeforeBindObservable&&this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this),f||this._bind(e,b,x,!1);const R=y.getWorldMatrix();I._storeEffectOnSubMeshes?I.bindForSubMesh(R,this,e):I.bind(R,this),!I.backFaceCulling&&I.separateCullingPass&&(h.setState(!0,I.zOffset,!1,!P,I.cullBackFaces,I.stencil,I.zOffsetUnits),this._processRendering(this,e,b,x,o,f,this._onBeforeDraw,this._internalMeshDataInfo._effectiveMaterial),h.setState(!0,I.zOffset,!1,P,I.cullBackFaces,I.stencil,I.zOffsetUnits),this._internalMeshDataInfo._onBetweenPassObservable&&this._internalMeshDataInfo._onBetweenPassObservable.notifyObservers(e)),this._processRendering(this,e,b,x,o,f,this._onBeforeDraw,this._internalMeshDataInfo._effectiveMaterial),this._internalMeshDataInfo._effectiveMaterial.unbind();for(const S of s._afterRenderingMeshStage)S.action(this,e,o,b);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(T.MatricesWeightsKind)&&(this.isVerticesDataPresent(T.MatricesWeightsExtraKind)?this._normalizeSkinWeightsAndExtra():this._normalizeSkinFourWeights())}_normalizeSkinFourWeights(){const e=this.getVerticesData(T.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(T.MatricesWeightsKind,e)}_normalizeSkinWeightsAndExtra(){const e=this.getVerticesData(T.MatricesWeightsExtraKind),t=this.getVerticesData(T.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(T.MatricesWeightsKind,t),this.setVerticesData(T.MatricesWeightsKind,e)}validateSkinning(){const e=this.getVerticesData(T.MatricesWeightsExtraKind),t=this.getVerticesData(T.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 b=0;b<=h;b++)l[b]=0;const c=.001;for(let b=0;b<i;b+=4){let y=t[b],A=y,P=A===0?0:1;for(let I=1;I<h;I++){const x=I<4?t[b+I]:e[b+I-4];x>y&&s++,x!==0&&P++,A+=x,y=x}if(l[P]++,P>n&&(n=P),A===0)r++;else{const I=1/A;let x=0;for(let R=0;R<h;R++)R<4?x+=Math.abs(t[b+R]-t[b+R]*I):x+=Math.abs(e[b+R-4]-e[b+R-4]*I);x>c&&o++}}const u=this.skeleton.bones.length,f=this.getVerticesData(T.MatricesIndicesKind),d=this.getVerticesData(T.MatricesIndicesExtraKind);let g=0;for(let b=0;b<i;b+=4)for(let y=0;y<h;y++){const A=y<4?f[b+y]:d[b+y-4];(A>=u||A<0)&&g++}const m="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:m}}_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 B.LoadFile(this.delayLoadingFile,i=>{i instanceof ArrayBuffer?this._delayLoadingFunction(i,this):this._delayLoadingFunction(JSON.parse(i),this),this.instances.forEach(s=>{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(T.PositionKind))return this;const t=this.subMeshes.splice(0);this._resetPointsArrayCache();let i=this.getVerticesData(T.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(T.PositionKind,i,this.getVertexBuffer(T.PositionKind).isUpdatable()),this.isVerticesDataPresent(T.NormalKind)){for(i=this.getVerticesData(T.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(T.NormalKind,i,this.getVertexBuffer(T.NormalKind).isUpdatable())}if(this.isVerticesDataPresent(T.TangentKind)){for(i=this.getVerticesData(T.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(T.TangentKind,i,this.getVertexBuffer(T.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 Vt.source=this,Vt.doNotCloneChildren=r.doNotCloneChildren,Vt.clonePhysicsImpostor=r.clonePhysicsImpostor,Vt.cloneThinInstances=r.cloneThinInstances,new se(e,this.getScene(),Vt)}return new se(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._instanceDataStorage.visibleInstances={},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,m=this.getEngine().createCanvas(f,d).getContext("2d");m.drawImage(u,0,0);const b=m.getImageData(0,0,f,d).data;this.applyDisplacementMapFromBuffer(b,f,d,t,i,r,n,o),s&&s(this)};return B.LoadImage(e,c,h||(()=>{}),l.offlineProvider),this}applyDisplacementMapFromBuffer(e,t,i,s,r,n,o,h=!1){if(!this.isVerticesDataPresent(T.PositionKind)||!this.isVerticesDataPresent(T.NormalKind)||!this.isVerticesDataPresent(T.UVKind))return F.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),this;const l=this.getVerticesData(T.PositionKind,!0,!0),c=this.getVerticesData(T.NormalKind),u=this.getVerticesData(T.UVKind);let f=_.Zero();const d=_.Zero(),g=Z.Zero();n=n||Z.Zero(),o=o||new Z(1,1);for(let m=0;m<l.length;m+=3){_.FromArrayToRef(l,m,f),_.FromArrayToRef(c,m,d),Z.FromArrayToRef(u,m/3*2,g);const b=Math.abs(g.x*o.x+n.x%1)*(t-1)%t|0,y=Math.abs(g.y*o.y+n.y%1)*(i-1)%i|0,A=(b+y*t)*4,P=e[A]/255,I=e[A+1]/255,x=e[A+2]/255,R=P*.3+I*.59+x*.11;d.normalize(),d.scaleInPlace(s+(r-s)*R),f=f.add(d),f.toArray(l,m)}return Q.ComputeNormals(l,this.getIndices(),c),h?(this.setVerticesData(T.PositionKind,l),this.setVerticesData(T.NormalKind,c),this.setVerticesData(T.UVKind,u)):(this.updateVerticesData(T.PositionKind,l),this.updateVerticesData(T.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(),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===T.NormalKind){const u=this._getFlattenedNormals(i,s[T.PositionKind]);this.setVerticesData(T.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();vt.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=Q.ExtractFromMesh(this);let i;if(e&&this.isVerticesDataPresent(T.NormalKind)&&t.normals){for(i=0;i<t.normals.length;i++)t.normals[i]*=-1;this.setVerticesData(T.NormalKind,t.normals,this.isVertexBufferUpdatable(T.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(T.PositionKind),!0)}return this}increaseVertices(e=1){const t=Q.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)F.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=new Array;for(let x=0;x<o+1;x++)h[x]=new Array;let l,c;const u=new _(0,0,0),f=new _(0,0,0),d=new Z(0,0),g=new Array,m=new Array,b=new Array;let y,A=s.length,P;r&&(P=r.length);let I;n&&(I=n.length);for(let x=0;x<i.length;x+=3){m[0]=i[x],m[1]=i[x+1],m[2]=i[x+2];for(let R=0;R<3;R++)if(l=m[R],c=m[(R+1)%3],b[l]===void 0&&b[c]===void 0?(b[l]=new Array,b[c]=new Array):(b[l]===void 0&&(b[l]=new Array),b[c]===void 0&&(b[c]=new Array)),b[l][c]===void 0&&b[c][l]===void 0){b[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),b[l][c].push(l);for(let S=1;S<o;S++)b[l][c].push(s.length/3),s[A++]=s[3*l]+S*u.x,s[A++]=s[3*l+1]+S*u.y,s[A++]=s[3*l+2]+S*u.z,n&&(n[I++]=n[3*l]+S*f.x,n[I++]=n[3*l+1]+S*f.y,n[I++]=n[3*l+2]+S*f.z),r&&(r[P++]=r[2*l]+S*d.x,r[P++]=r[2*l+1]+S*d.y);b[l][c].push(c),b[c][l]=new Array,y=b[l][c].length;for(let S=0;S<y;S++)b[c][l][S]=b[l][c][y-1-S]}h[0][0]=i[x],h[1][0]=b[i[x]][i[x+1]][1],h[1][1]=b[i[x]][i[x+2]][1];for(let R=2;R<o;R++){h[R][0]=b[i[x]][i[x+1]][R],h[R][R]=b[i[x]][i[x+2]][R],u.x=(s[3*h[R][R]]-s[3*h[R][0]])/R,u.y=(s[3*h[R][R]+1]-s[3*h[R][0]+1])/R,u.z=(s[3*h[R][R]+2]-s[3*h[R][0]+2])/R,n&&(f.x=(n[3*h[R][R]]-n[3*h[R][0]])/R,f.y=(n[3*h[R][R]+1]-n[3*h[R][0]+1])/R,f.z=(n[3*h[R][R]+2]-n[3*h[R][0]+2])/R),r&&(d.x=(r[2*h[R][R]]-r[2*h[R][0]])/R,d.y=(r[2*h[R][R]+1]-r[2*h[R][0]+1])/R);for(let S=1;S<R;S++)h[R][S]=s.length/3,s[A++]=s[3*h[R][0]]+S*u.x,s[A++]=s[3*h[R][0]+1]+S*u.y,s[A++]=s[3*h[R][0]+2]+S*u.z,n&&(n[I++]=n[3*h[R][0]]+S*f.x,n[I++]=n[3*h[R][0]+1]+S*f.y,n[I++]=n[3*h[R][0]+2]+S*f.z),r&&(r[P++]=r[2*h[R][0]]+S*d.x,r[P++]=r[2*h[R][0]+1]+S*d.y)}h[o]=b[i[x+1]][i[x+2]],g.push(h[0][0],h[1][0],h[1][1]);for(let R=1;R<o;R++){let S;for(S=0;S<R;S++)g.push(h[R][S],h[R+1][S],h[R+1][S+1]),g.push(h[R][S],h[R+1][S+1],h[R][S+1]);g.push(h[R][S],h[R+1][S],h[R+1][S+1])}}t.indices=g,t.applyToMesh(this,this.isVertexBufferUpdatable(T.PositionKind))}}forceSharedVertices(){const e=Q.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)F.Warn("VertexData contains empty entries");else{const c=new Array,u=new Array,f=new Array,d=new Array,g=new Array,m=new Array,b=new Array,y=new Array;let A=new Array,P=0;const I={};let x,R;for(let D=0;D<i.length;D+=3){R=[i[D],i[D+1],i[D+2]],A=[];for(let G=0;G<3;G++){A[G]="";for(let X=0;X<3;X++)Math.abs(s[3*R[G]+X])<1e-8&&(s[3*R[G]+X]=0),A[G]+=s[3*R[G]+X]+"|"}if(!(A[0]==A[1]||A[0]==A[2]||A[1]==A[2]))for(let G=0;G<3;G++){if(x=I[A[G]],x===void 0){I[A[G]]=P,x=P++;for(let X=0;X<3;X++)c.push(s[3*R[G]+X]);if(r!=null)for(let X=0;X<4;X++)d.push(r[4*R[G]+X]);if(t!=null)for(let X=0;X<2;X++)f.push(t[2*R[G]+X]);if(n!=null)for(let X=0;X<4;X++)g.push(n[4*R[G]+X]);if(o!=null)for(let X=0;X<4;X++)m.push(o[4*R[G]+X]);if(h!=null)for(let X=0;X<4;X++)b.push(h[4*R[G]+X]);if(l!=null)for(let X=0;X<4;X++)y.push(l[4*R[G]+X])}u.push(x)}}const S=new Array;Q.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=m),h!=null&&(e.matricesIndicesExtra=b),o!=null&&(e.matricesWeightsExtra=y),e.applyToMesh(this,this.isVertexBufferUpdatable(T.PositionKind))}}static _instancedMeshFactory(e,t){throw ee("InstancedMesh")}static _PhysicsImpostorParser(e,t,i){throw ee("PhysicsImpostor")}createInstance(e){const t=se._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(T.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 Ks.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(),pe&&pe.HasTags(this)&&(e.tags=pe.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(te.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(te.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),re.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 re.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()){F.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){F.Error("Invalid morph target. Target must have positions.");return}this.geometry.setVerticesData(T.PositionKind+t,s,!1,3);const r=i.getNormals();r&&this.geometry.setVerticesData(T.NormalKind+t,r,!1,3);const n=i.getTangents();n&&this.geometry.setVerticesData(T.TangentKind+t,n,!1,3);const o=i.getUVs();o&&this.geometry.setVerticesData(T.UVKind+"_"+t,o,!1,2);const h=i.getUV2s();h&&this.geometry.setVerticesData(T.UV2Kind+"_"+t,h,!1,2);const l=i.getColors();l&&this.geometry.setVerticesData(T.ColorKind+t,l,!1,4)}}else{let t=0;for(;this.geometry.isVerticesDataPresent(T.PositionKind+t);)this.geometry.removeVerticesData(T.PositionKind+t),this.geometry.isVerticesDataPresent(T.NormalKind+t)&&this.geometry.removeVerticesData(T.NormalKind+t),this.geometry.isVerticesDataPresent(T.TangentKind+t)&&this.geometry.removeVerticesData(T.TangentKind+t),this.geometry.isVerticesDataPresent(T.UVKind+t)&&this.geometry.removeVerticesData(T.UVKind+"_"+t),this.geometry.isVerticesDataPresent(T.UV2Kind+t)&&this.geometry.removeVerticesData(T.UV2Kind+"_"+t),this.geometry.isVerticesDataPresent(T.ColorKind+t)&&this.geometry.removeVerticesData(T.ColorKind+t),t++}}static Parse(e,t,i){let s;if(e.type&&e.type==="LinesMesh"?s=se._LinesMeshParser(e,t):e.type&&e.type==="GroundMesh"?s=se._GroundMeshParser(e,t):e.type&&e.type==="GoldbergMesh"?s=se._GoldbergMeshParser(e,t):e.type&&e.type==="GreasedLineMesh"?s=se._GreasedLineMeshParser(e,t):e.type&&e.type==="TrailMesh"?s=se._TrailMeshParser(e,t):s=new se(e.name,t),s.id=e.id,s._waitingParsedUniqueId=e.uniqueId,pe&&pe.AddTagsTo(s,e.tags),s.position=_.FromArray(e.position),e.metadata!==void 0&&(s.metadata=e.metadata),e.rotationQuaternion?s.rotationQuaternion=U.FromArray(e.rotationQuaternion):e.rotation&&(s.rotation=_.FromArray(e.rotation)),s.scaling=_.FromArray(e.scaling),e.localMatrix?s.setPreTransformMatrix(M.FromArray(e.localMatrix)):e.pivotMatrix&&s.setPivotMatrix(M.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(T.UVKind),e.hasUVs2&&s._delayInfo.push(T.UV2Kind),e.hasUVs3&&s._delayInfo.push(T.UV3Kind),e.hasUVs4&&s._delayInfo.push(T.UV4Kind),e.hasUVs5&&s._delayInfo.push(T.UV5Kind),e.hasUVs6&&s._delayInfo.push(T.UV6Kind),e.hasColors&&s._delayInfo.push(T.ColorKind),e.hasMatricesIndices&&s._delayInfo.push(T.MatricesIndicesKind),e.hasMatricesWeights&&s._delayInfo.push(T.MatricesWeightsKind),s._delayLoadingFunction=ot._ImportGeometry,ft.ForceFullSceneLoadingForIncremental&&s._checkDelayState()):ot._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=fi("BABYLON.Animation");o&&s.animations.push(o.Parse(n))}Ve.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=se._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),pe&&(n.tags?pe.AddTagsTo(o,n.tags):pe.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=U.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=se._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=fi("BABYLON.Animation");c&&o.animations.push(c.Parse(l))}Ve.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.instancesCount=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(T.PositionKind);if(!t)return e._sourcePositions;e._sourcePositions=new Float32Array(t),this.isVertexBufferUpdatable(T.PositionKind)||this.setVerticesData(T.PositionKind,t,!0)}return e._sourcePositions}setNormalsForCPUSkinning(){const e=this._internalMeshDataInfo;if(!e._sourceNormals){const t=this.getVerticesData(T.NormalKind);if(!t)return e._sourceNormals;e._sourceNormals=new Float32Array(t),this.isVertexBufferUpdatable(T.NormalKind)||this.setVerticesData(T.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(T.PositionKind))return this;if(!this.isVerticesDataPresent(T.MatricesIndicesKind))return this;if(!this.isVerticesDataPresent(T.MatricesWeightsKind))return this;const t=this.isVerticesDataPresent(T.NormalKind),i=this._internalMeshDataInfo;if(!i._sourcePositions){const y=this.subMeshes.slice();this.setPositionsForCPUSkinning(),this.subMeshes=y}t&&!i._sourceNormals&&this.setNormalsForCPUSkinning();let s=this.getVerticesData(T.PositionKind);if(!s)return this;s instanceof Float32Array||(s=new Float32Array(s));let r=this.getVerticesData(T.NormalKind);if(t){if(!r)return this;r instanceof Float32Array||(r=new Float32Array(r))}const n=this.getVerticesData(T.MatricesIndicesKind),o=this.getVerticesData(T.MatricesWeightsKind);if(!o||!n)return this;const h=this.numBoneInfluencers>4,l=h?this.getVerticesData(T.MatricesIndicesExtraKind):null,c=h?this.getVerticesData(T.MatricesWeightsExtraKind):null,u=e.getTransformMatrices(this),f=_.Zero(),d=new M,g=new M;let m=0,b;for(let y=0;y<s.length;y+=3,m+=4){let A;for(b=0;b<4;b++)A=o[m+b],A>0&&(M.FromFloat32ArrayToRefScaled(u,Math.floor(n[m+b]*16),A,g),d.addToSelf(g));if(h)for(b=0;b<4;b++)A=c[m+b],A>0&&(M.FromFloat32ArrayToRefScaled(u,Math.floor(l[m+b]*16),A,g),d.addToSelf(g));_.TransformCoordinatesFromFloatsToRef(i._sourcePositions[y],i._sourcePositions[y+1],i._sourcePositions[y+2],d,f),f.toArray(s,y),t&&(_.TransformNormalFromFloatsToRef(i._sourceNormals[y],i._sourceNormals[y+1],i._sourceNormals[y+2],d,f),f.toArray(r,y)),d.reset()}return this.updateVerticesData(T.PositionKind,s),t&&this.updateVerticesData(T.NormalKind,r),this}static MinMax(e){let t=null,i=null;return e.forEach(function(s){const n=s.getBoundingInfo().boundingBox;!t||!i?(t=n.minimumWorld,i=n.maximumWorld):(t.minimizeInPlace(n.minimumWorld),i.maximizeInPlace(n.maximumWorld))}),!t||!i?{min:_.Zero(),max:_.Zero()}:{min:t,max:i}}static Center(e){const t=e instanceof Array?se.MinMax(e):e;return _.Center(t.min,t.max)}static MergeMeshes(e,t=!0,i,s,r,n){return Jr(se._MergeMeshesCoroutine(e,t,i,s,r,n,!1))}static MergeMeshesAsync(e,t=!0,i,s,r,n){return 
30Qh(se._MergeMeshesCoroutine(e,t,i,s,r,n,!0),q
vendor: 6,216 bytes, line 30
30h())}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 F.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 F.Warn("Cannot merge instance meshes."),null;if(f!==S.sideOrientation)return F.Warn("Cannot merge meshes with different sideOrientation values."),null;if(r&&u.push(S.getTotalIndices()),n)if(S.material){const D=S.material;if(D instanceof Hi){for(let G=0;G<D.subMaterials.length;G++)l.indexOf(D.subMaterials[G])<0&&l.push(D.subMaterials[G]);for(let G=0;G<S.subMeshes.length;G++)c.push(l.indexOf(D.subMaterials[S.subMeshes[G].materialIndex])),u.push(S.subMeshes[G].indexCount)}else{l.indexOf(D)<0&&l.push(D);for(let G=0;G<S.subMeshes.length;G++)c.push(l.indexOf(D)),u.push(S.subMeshes[G].indexCount)}}else for(let D=0;D<S.subMeshes.length;D++)c.push(0),u.push(S.subMeshes[D].indexCount)}const d=e[0],g=S=>{const D=S.computeWorldMatrix(!0);return{vertexData:Q.ExtractFromMesh(S,!1,!1),transform:D}},{vertexData:m,transform:b}=g(d);o&&(yield);const y=new Array(e.length-1);for(let S=1;S<e.length;S++)y[S-1]=g(e[S]),o&&(yield);const A=m._mergeCoroutine(b,y,i,o,!t);let P=A.next();for(;!P.done;)o&&(yield),P=A.next();const I=P.value;s||(s=new se(d.name+"_merged",d.getScene()));const x=I._applyToCoroutine(s,void 0,o);let R=x.next();for(;!R.done;)o&&(yield),R=x.next();if(s.checkCollisions=d.checkCollisions,s.sideOrientation=d.sideOrientation,t)for(h=0;h<e.length;h++)e[h].dispose();if(r||n){s.releaseSubMeshes(),h=0;let S=0;for(;h<u.length;)vt.CreateFromIndices(0,S,u[h],s,void 0,!1),S+=u[h],h++;for(const D of s.subMeshes)D.refreshBoundingInfo();s.computeWorldMatrix(!0)}if(n){const S=new Hi(d.name+"_merged",d.getScene());S.subMaterials=l;for(let D=0;D<s.subMeshes.length;D++)s.subMeshes[D].materialIndex=c[D];s.material=S}else s.material=d.material;return s}addInstance(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===v.CounterClockWiseSideOrientation}_getRenderingFillMode(e){const t=this.getScene();return t.forcePointsCloud?v.PointFillMode:t.forceWireframe?v.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")}}se.FRONTSIDE=Q.FRONTSIDE;se.BACKSIDE=Q.BACKSIDE;se.DOUBLESIDE=Q.DOUBLESIDE;se.DEFAULTSIDE=Q.DEFAULTSIDE;se.NO_CAP=0;se.CAP_START=1;se.CAP_END=2;se.CAP_ALL=3;se.NO_FLIP=0;se.FLIP_TILE=1;se.ROTATE_TILE=2;se.FLIP_ROW=3;se.ROTATE_ROW=4;se.FLIP_N_ROTATE_TILE=5;se.FLIP_N_ROTATE_ROW=6;se.CENTER=0;se.LEFT=1;se.RIGHT=2;se.TOP=3;se.BOTTOM=4;se.INSTANCEDMESH_SORT_TRANSPARENT=!1;se._GroundMeshParser=(a,e)=>{throw ee("GroundMesh")};se._GoldbergMeshParser=(a,e)=>{throw ee("GoldbergMesh")};se._LinesMeshParser=(a,e)=>{throw ee("LinesMesh")};se._GreasedLineMeshParser=(a,e)=>{throw ee("GreasedLineMesh")};se._GreasedLineRibbonMeshParser=(a,e)=>{throw ee("GreasedLineRibbonMesh")};se._TrailMeshParser=(a,e)=>{throw ee("TrailMesh")};it("BABYLON.Mesh",se);class ne{}ne.POINTERDOWN=1;ne.POINTERUP=2;ne.POINTERMOVE=4;ne.POINTERWHEEL=8;ne.POINTERPICK=16;ne.POINTERTAP=32;ne.POINTERDOUBLETAP=64;class 
vendor: 12,903 bytes, line 30
30Qa{constructor(e,t){this.type=e,this.event=t}}class Gl extends Qa{constructor(e,t,i,s){super(e,t),this.ray=null,this.originalPickingInfo=null,this.skipOnPointerObservable=!1,this.localPosition=new Z(i,s)}}class Qt extends Qa{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 zl{constructor(){this._zoomStopsAnimation=!1,this._idleRotationSpeed=.05,this._idleRotationWaitTime=2e3,this._idleRotationSpinupTime=2e3,this.targetAlpha=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}init(){}attach(e){this._attachedCamera=e;const t=this._attachedCamera.getScene();this._onPrePointerObservableObserver=t.onPrePointerObservable.add(i=>{if(i.type===ne.POINTERDOWN){this._isPointerDown=!0;return}i.type===ne.POINTERUP&&(this._isPointerDown=!1)}),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add(()=>{if(this._reachTargetAlpha())return;const i=Dt.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??Dt.Now}_reachTargetAlpha(){return this._attachedCamera&&this.targetAlpha?Math.abs(this._attachedCamera.alpha-this.targetAlpha)<_e:!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=Dt.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 Dn;(function(a){a[a.CW=0]="CW",a[a.CCW=1]="CCW"})(Dn||(Dn={}));class Wl{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 lt{constructor(){this._easingMode=lt.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 lt.EASINGMODE_EASEIN:return this.easeInCore(e);case lt.EASINGMODE_EASEOUT:return 1-this.easeInCore(1-e)}return e>=.5?(1-this.easeInCore((1-e)*2))*.5+.5:this.easeInCore(e*2)*.5}}lt.EASINGMODE_EASEIN=0;lt.EASINGMODE_EASEOUT=1;lt.EASINGMODE_EASEINOUT=2;class xd extends lt{easeInCore(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)}}class Xl extends lt{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 Sd extends lt{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,m=d-u;return-Math.pow(1/i,t-l)/(m*m)*(g-m)*(g+m)}}class Md extends lt{easeInCore(e){return e*e*e}}class Id extends lt{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 Kl extends lt{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 Cd extends lt{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 Wl.Interpolate(e,this.x1,this.y1,this.x2,this.y2)}}class er{constructor(e,t,i){this.name=e,this.from=t,this.to=i}clone(){return new er(this.name,this.from,this.to)}}class yt{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}copyFrom(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 yt(this.width*e,this.height*t)}clone(){return new yt(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 yt(0,0)}add(e){return new yt(this.width+e.width,this.height+e.height)}subtract(e){return new yt(this.width-e.width,this.height-e.height)}scale(e){return new yt(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 yt(s,r)}}const Yl=Object.freeze(new U(0,0,0,0)),ql=Object.freeze(_.Zero()),Ql=Object.freeze(Z.Zero()),jl=Object.freeze(yt.Zero()),Zl=Object.freeze(q.Black()),Jl=Object.freeze(new le(0,0,0,0)),wt={key:0,repeatCount:0,loopMode:2};class w{static _PrepareAnimation(e,t,i,s,r,n,o,h){let l;if(!isNaN(parseFloat(r))&&isFinite(r)?l=w.ANIMATIONTYPE_FLOAT:r instanceof U?l=w.ANIMATIONTYPE_QUATERNION:r instanceof _?l=w.ANIMATIONTYPE_VECTOR3:r instanceof Z?l=w.ANIMATIONTYPE_VECTOR2:r instanceof q?l=w.ANIMATIONTYPE_COLOR3:r instanceof le?l=w.ANIMATIONTYPE_COLOR4:r instanceof yt&&(l=w.ANIMATIONTYPE_SIZE),l==null)return null;const c=new w(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 w(e+"Animation",e,i,t,w.ANIMATIONLOOPMODE_CONSTANT);return r.setEasingFunction(s),r}static CreateAndStartAnimation(e,t,i,s,r,n,o,h,l,c,u){const f=w._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!==w.ANIMATIONLOOPMODE_CONSTANT,1,c)}static CreateAndStartHierarchyAnimation(e,t,i,s,r,n,o,h,l,c,u){const f=w._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=w._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:C.Vector3[0],referenceQuaternion:C.Quaternion[0],referenceScaling:C.Vector3[1],keyPosition:C.Vector3[2],keyQuaternion:C.Quaternion[1],keyScaling:C.Vector3[3]};let g=c.frame,m=f.frame;if(n.range){const A=o.getRange(n.range);A&&(g=A.from,m=A.to)}else g=n.fromFrame??g,m=n.toFrame??m;if(g!==c.frame&&(l=o.createKeyForFrame(g)),m!==f.frame&&(u=o.createKeyForFrame(m)),o._keys.length===1){const A=o._getKeyValue(o._keys[0]);d.referenceValue=A.clone?A.clone():A}else if(h<=c.frame){const A=o._getKeyValue(c.value);d.referenceValue=A.clone?A.clone():A}else if(h>=f.frame){const A=o._getKeyValue(f.value);d.referenceValue=A.clone?A.clone():A}else{wt.key=0;const A=o._interpolate(h,wt);d.referenceValue=A.clone?A.clone():A}o.dataType===w.ANIMATIONTYPE_QUATERNION?d.referenceValue.normalize().conjugateInPlace():o.dataType===w.ANIMATIONTYPE_MATRIX&&(d.referenceValue.decompose(d.referenceScaling,d.referenceQuaternion,d.referencePosition),d.referenceQuaternion.normalize().conjugateInPlace());let b=Number.MAX_VALUE;const y=n.clipKeys?[]:null;for(let A=l;A<=u;A++){let P=o._keys[A];if((y||n.cloneOriginalAnimation)&&(P={frame:P.frame,value:P.value.clone?P.value.clone():P.value,inTangent:P.inTangent,outTangent:P.outTangent,interpolation:P.interpolation,lockedTangent:P.lockedTangent},y&&(b===Number.MAX_VALUE&&(b=P.frame),P.frame-=b,y.push(P))),!(A&&o.dataType!==w.ANIMATIONTYPE_FLOAT&&P.value===c.value))switch(o.dataType){case w.ANIMATIONTYPE_MATRIX:P.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),M.ComposeToRef(d.keyScaling,d.keyQuaternion,d.keyPosition,P.value);break;case w.ANIMATIONTYPE_QUATERNION:d.referenceValue.multiplyToRef(P.value,P.value);break;case w.ANIMATIONTYPE_VECTOR2:case w.ANIMATIONTYPE_VECTOR3:case w.ANIMATIONTYPE_COLOR3:case w.ANIMATIONTYPE_COLOR4:P.value.subtractToRef(d.referenceValue,P.value);break;case w.ANIMATIONTYPE_SIZE:P.value.width-=d.referenceValue.width,P.value.height-=d.referenceValue.height;break;default:P.value-=d.referenceValue}}return y&&o.setKeys(y,!0),o}static TransitionTo(e,t,i,s,r,n,o,h=null){if(o<=0)return i[e]=t,h&&h(),null;const l=r*(o/1e3);n.setKeys([{frame:0,value:i[e].clone?i[e].clone():i[e]},{frame:l,value:t}]),i.animations||(i.animations=[]),i.animations.push(n);const c=s.beginAnimation(i,0,l,!1);return c.onAnimationEnd=h,c}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.targetPropertyPath=t.split("."),this.dataType=s,this.loopMode=r===void 0?w.ANIMATIONLOOPMODE_CYCLE:r,this.uniqueId=w._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 er(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 Hr(e,t,i)}floatInterpolateFunctionWithTangents(e,t,i,s,r){return R
vendor: 2,410 bytes, line 30
30a(e,t,i,s,r)}quaternionInterpolateFunction(e,t,i){return U.Slerp(e,t,i)}quaternionInterpolateFunctionWithTangents(e,t,i,s,r){return U.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 Z.Lerp(e,t,i)}vector2InterpolateFunctionWithTangents(e,t,i,s,r){return Z.Hermite(e,t,i,s,r)}sizeInterpolateFunction(e,t,i){return yt.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 le.Lerp(e,t,i)}color4InterpolateFunctionWithTangents(e,t,i,s,r){return le.Hermite(e,t,i,s,r)}_getKeyValue(e){return typeof e=="function"?e():e}evaluate(e){return wt.key=0,this._interpolate(e,wt)}_interpolate(e,t,i=!1){if(t.loopMode===w.ANIMATIONLOOPMODE_CONSTANT&&t.repeatCount>0)return t.highLimitValue.clone?t.highLimitValue.clone():t.highLimitValue;const s=this._keys,r=s.length;let n=t.key;for(;n>=0&&e<s[n].frame;)--n;for(;n+1<=r-1&&e>=s[n+1].frame;)++n;if(t.key=n,n<0)return i?void 0:this._getKeyValue(s[0].value);if(n+1>r-1)return i?void 0:this._getKeyValue(s[r-1].value);const o=s[n],h=s[n+1];if(i&&(e===o.frame||e===h.frame))return;const l=this._getKeyValue(o.value),c=this._getKeyValue(h.value);if(o.interpolation===1)return h.frame>e?l:c;const u=o.outTangent!==void 0&&h.inTangent!==void 0,f=h.frame-o.frame;let d=(e-o.frame)/f;const g=o.easingFunction||this.getEasingFunction();switch(g&&(d=g.ease(d)),this.dataType){case w.ANIMATIONTYPE_FLOAT:{const m=u?this.floatInterpolateFunctionWithTangents(l,o.outTangent*f,c,h.inTangent*f,d):this.floatInterpolateFunction(l,c,d);switch(t.loopMode){case w.ANIMATIONLOOPMODE_CYCLE:case w.ANIMATIONLOOPMODE_CONSTANT:case w.ANIMATIONLOOPMODE_YOYO:return m;case w.ANIMATIONLOOPMODE_RELATIVE:case w.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return(t.offsetValue??0)*t.repeatCount+m}break}case w.ANIMATIONTYPE_QUATERNION:{const m=u?this.quaternionInterpolateFunctionWithTangents(l,o.outTangent.scale(f),c,h.inTangent.scale(f),d):this.quaternionInterpolateFunction(l,c,d);switch(t.loopMode){case w.ANIMATIONLOOPMODE_CYCLE:case w.ANIMATIONLOOPMODE_CONSTANT:case w.ANIMATIONLOOPMODE_YOYO:return m;case w.ANIMATIONLOOPMODE_RELATIVE:case w.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return m.addInPlace((t.offsetValue||
vendor: 64,785 bytes, line 30
30Yl).scale(t.repeatCount))}return m}case w.ANIMATIONTYPE_VECTOR3:{const m=u?this.vector3InterpolateFunctionWithTangents(l,o.outTangent.scale(f),c,h.inTangent.scale(f),d):this.vector3InterpolateFunction(l,c,d);switch(t.loopMode){case w.ANIMATIONLOOPMODE_CYCLE:case w.ANIMATIONLOOPMODE_CONSTANT:case w.ANIMATIONLOOPMODE_YOYO:return m;case w.ANIMATIONLOOPMODE_RELATIVE:case w.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return m.add((t.offsetValue||ql).scale(t.repeatCount))}break}case w.ANIMATIONTYPE_VECTOR2:{const m=u?this.vector2InterpolateFunctionWithTangents(l,o.outTangent.scale(f),c,h.inTangent.scale(f),d):this.vector2InterpolateFunction(l,c,d);switch(t.loopMode){case w.ANIMATIONLOOPMODE_CYCLE:case w.ANIMATIONLOOPMODE_CONSTANT:case w.ANIMATIONLOOPMODE_YOYO:return m;case w.ANIMATIONLOOPMODE_RELATIVE:case w.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return m.add((t.offsetValue||Ql).scale(t.repeatCount))}break}case w.ANIMATIONTYPE_SIZE:{switch(t.loopMode){case w.ANIMATIONLOOPMODE_CYCLE:case w.ANIMATIONLOOPMODE_CONSTANT:case w.ANIMATIONLOOPMODE_YOYO:return this.sizeInterpolateFunction(l,c,d);case w.ANIMATIONLOOPMODE_RELATIVE:case w.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return this.sizeInterpolateFunction(l,c,d).add((t.offsetValue||jl).scale(t.repeatCount))}break}case w.ANIMATIONTYPE_COLOR3:{const m=u?this.color3InterpolateFunctionWithTangents(l,o.outTangent.scale(f),c,h.inTangent.scale(f),d):this.color3InterpolateFunction(l,c,d);switch(t.loopMode){case w.ANIMATIONLOOPMODE_CYCLE:case w.ANIMATIONLOOPMODE_CONSTANT:case w.ANIMATIONLOOPMODE_YOYO:return m;case w.ANIMATIONLOOPMODE_RELATIVE:case w.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return m.add((t.offsetValue||Zl).scale(t.repeatCount))}break}case w.ANIMATIONTYPE_COLOR4:{const m=u?this.color4InterpolateFunctionWithTangents(l,o.outTangent.scale(f),c,h.inTangent.scale(f),d):this.color4InterpolateFunction(l,c,d);switch(t.loopMode){case w.ANIMATIONLOOPMODE_CYCLE:case w.ANIMATIONLOOPMODE_CONSTANT:case w.ANIMATIONLOOPMODE_YOYO:return m;case w.ANIMATIONLOOPMODE_RELATIVE:case w.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return m.add((t.offsetValue||Jl).scale(t.repeatCount))}break}case w.ANIMATIONTYPE_MATRIX:{switch(t.loopMode){case w.ANIMATIONLOOPMODE_CYCLE:case w.ANIMATIONLOOPMODE_CONSTANT:case w.ANIMATIONLOOPMODE_YOYO:return w.AllowMatricesInterpolation?this.matrixInterpolateFunction(l,c,d,t.workValue):l;case w.ANIMATIONLOOPMODE_RELATIVE:case w.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return l}break}}return 0}matrixInterpolateFunction(e,t,i,s){return w.AllowMatrixDecomposeForInterpolation?s?(M.DecomposeLerpToRef(e,t,i,s),s):M.DecomposeLerp(e,t,i):s?(M.LerpToRef(e,t,i,s),s):M.Lerp(e,t,i)}clone(){const e=new w(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){wt.key=0;const t=this._interpolate(e,wt,!0);if(!t)return this._keys[wt.key].frame===e?wt.key:wt.key+1;const i={frame:e,value:t.clone?t.clone():t};return this._keys.splice(wt.key+1,0,i),wt.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 w.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 w.ANIMATIONTYPE_QUATERNION:case w.ANIMATIONTYPE_MATRIX:case w.ANIMATIONTYPE_VECTOR3:case w.ANIMATIONTYPE_COLOR3:case w.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 w(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 w.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 w.ANIMATIONTYPE_QUATERNION:if(r=U.FromArray(o.values),o.values.length>=8){const f=U.FromArray(o.values.slice(4,8));f.equals(U.Zero())||(h=f)}if(o.values.length>=12){const f=U.FromArray(o.values.slice(8,12));f.equals(U.Zero())||(l=f)}o.values.length>=13&&(c=o.values[12]);break;case w.ANIMATIONTYPE_MATRIX:r=M.FromArray(o.values),o.values.length>=17&&(c=o.values[16]);break;case w.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 w.ANIMATIONTYPE_COLOR4:r=le.FromArray(o.values),o.values[4]&&(h=le.FromArray(o.values[4])),o.values[5]&&(l=le.FromArray(o.values[5])),o.values[6]&&(c=le.FromArray(o.values[6]));break;case w.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){re.AppendSerializedAnimations(e,t)}static ParseFromFileAsync(e,t){return new Promise((i,s)=>{const r=new tt;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 ParseFromSnippetAsync(e){return new Promise((t,i)=>{const s=new tt;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()})}}w._UniqueIdGenerator=0;w.AllowMatricesInterpolation=!1;w.AllowMatrixDecomposeForInterpolation=!0;w.SnippetUrl="https://snippet.babylonjs.com";w.ANIMATIONTYPE_FLOAT=0;w.ANIMATIONTYPE_VECTOR3=1;w.ANIMATIONTYPE_QUATERNION=2;w.ANIMATIONTYPE_MATRIX=3;w.ANIMATIONTYPE_COLOR3=4;w.ANIMATIONTYPE_COLOR4=7;w.ANIMATIONTYPE_VECTOR2=5;w.ANIMATIONTYPE_SIZE=6;w.ANIMATIONLOOPMODE_RELATIVE=0;w.ANIMATIONLOOPMODE_CYCLE=1;w.ANIMATIONLOOPMODE_CONSTANT=2;w.ANIMATIONLOOPMODE_YOYO=4;w.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT=5;w.CreateFromSnippetAsync=w.ParseFromSnippetAsync;it("BABYLON.Animation",w);Ve._AnimationRangeFactory=(a,e,t)=>new er(a,e,t);class xi{constructor(){this.transitionDuration=450,this.lowerRadiusTransitionRange=2,this.upperRadiusTransitionRange=-2,this._autoTransitionRange=!1,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))}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||(xi.EasingFunction.setEasingMode(xi.EasingMode),this._radiusBounceTransition=w.CreateAnimation("radius",w.ANIMATIONTYPE_FLOAT,60,xi.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;const t=w.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()}}xi.EasingFunction=new Xl(.3);xi.EasingMode=lt.EASINGMODE_EASEOUT;class dt{constructor(){this.onTargetFramingAnimationEndObservable=new O,this._mode=dt.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._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}init(){}attach(e){this._attachedCamera=e;const t=this._attachedCamera.getScene();dt.EasingFunction.setEasingMode(dt.EasingMode),this._onPrePointerObservableObserver=t.onPrePointerObservable.add(i=>{if(i.type===ne.POINTERDOWN){this._isPointerDown=!0;return}i.type===ne.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=w.CreateAnimation("target",w.ANIMATIONTYPE_VECTOR3,60,dt.EasingFunction)),this._betaIsAnimating=!0;let c=w.TransitionTo("target",r,this._attachedCamera,this._attachedCamera.getScene(),60,this._vectorTransition,this._framingTime);c&&this._animatables.push(c);let u=0;if(this._mode===dt.FitFrustumSidesMode){const f=this._calculateLowerRadiusFromModelBoundingSphere(e,t);this.autoCorrectCameraLimitsAndSensibility&&(this._attachedCamera.lowerRadiusLimit=l.length()+this._attachedCamera.minZ),u=f}else this._mode===dt.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=w.CreateAnimation("radius",w.ANIMATIONTYPE_FLOAT,60,dt.EasingFunction)),c=w.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===dt.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=Dt.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=w.CreateAnimation("beta",w.ANIMATIONTYPE_FLOAT,60,dt.EasingFunction));const s=w.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=Dt.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}}dt.EasingFunction=new Kl;dt.EasingMode=lt.EASINGMODE_EASEINOUT;dt.IgnoreBoundsSizeMode=0;dt.FitFrustumSidesMode=1;Ve.AddNodeConstructor("TargetCamera",(a,e)=>()=>new He(a,_.Zero(),e));class He extends J{constructor(e,t,i,s=!0){super(e,t,i,s),this._tmpUpVector=_.Zero(),this._tmpTargetVector=_.Zero(),this.cameraDirection=new _(0,0,0),this.cameraRotation=new Z(0,0),this.ignoreParentScaling=!1,this.updateUpVectorFromRotation=!1,this._tmpQuaternion=new U,this.rotation=new _(0,0,0),this.speed=2,this.noRotationConstraint=!1,this.invertRotation=!1,this.inverseRotationSpeed=.2,this.lockedTarget=null,this._currentTarget=_.Zero(),this._initialFocalDistance=1,this._viewMatrix=M.Zero(),this._camMatrix=M.Zero(),this._cameraTransformMatrix=M.Zero(),this._cameraRotationMatrix=M.Zero(),this._referencePoint=new _(0,0,1),this._transformedReferencePoint=_.Zero(),this._deferredPositionUpdate=new _,this._deferredRotationQuaternionUpdate=new U,this._deferredRotationUpdate=new _,this._deferredUpdated=!1,this._deferOnly=!1,this._defaultUp=_.Up(),this._cachedRotationZ=0,this._cachedQuaternionRotationZ=0}getFrontPosition(e){this.getWorldMatrix();const t=C.Vector3[0],i=C.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.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 U(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+=_e),this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),M.LookAtLHToRef(this.position,e,this._defaultUp,this._camMatrix),this._camMatrix.invert(),this.rotation.x=Math.atan(this._camMatrix.m[6]/this._camMatrix.m[10]);const t=e.subtract(this.position);t.x>=0?this.rotation.y=-Math.atan(t.z/t.x)+Math.PI/2:this.rotation.y=-Math.atan(t.z/t.x)-Math.PI/2,this.rotation.z=0,isNaN(this.rotation.x)&&(this.rotation.x=0),isNaN(this.rotation.y)&&(this.rotation.y=0),isNaN(this.rotation.z)&&(this.rotation.z=0),this.rotationQuaternion&&U.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)}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(C.Matrix[0]),_.TransformNormalToRef(this.cameraDirection,C.Matrix[0],C.Vector3[0]),this._deferredPositionUpdate.addInPlace(C.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()&&(U.RotationYawPitchRollToRef(this._deferredRotationUpdate.y,this._deferredRotationUpdate.x,this._deferredRotationUpdate.z,this._deferredRotationQuaternionUpdate),this._deferOnly?this._deferredUpdated=!0:this.rotationQuaternion.copyFrom(this._deferredRotationQuaternionUpdate))),t&&(Math.abs(this.cameraDirection.x)<this.speed*_e&&(this.cameraDirection.x=0),Math.abs(this.cameraDirection.y)<this.speed*_e&&(this.cameraDirection.y=0),Math.abs(this.cameraDirection.z)<this.speed*_e&&(this.cameraDirection.z=0),this.cameraDirection.scaleInPlace(this.inertia)),i&&(Math.abs(this.cameraRotation.x)<this.speed*_e&&(this.cameraRotation.x=0),Math.abs(this.cameraRotation.y)<this.speed*_e&&(this.cameraRotation.y=0),this.cameraRotation.scaleInPlace(this.inertia)),super._checkInputs()}_updateCameraRotationMatrix(){this.rotationQuaternion?this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix):M.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix)}_rotateUpVectorWithCameraRotationMatrix(){return _.TransformNormalToRef(this._defaultUp,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?Vi.Y.rotateByQuaternionToRef(this.rotationQuaternion,this.upVector):(U.FromEulerVectorToRef(this.rotation,this._tmpQuaternion),Vi.Y.rotateByQuaternionToRef(this._tmpQuaternion,this.upVector))),this._computeViewMatrix(this.position,this._currentTarget,this.upVector),this._viewMatrix}_computeViewMatrix(e,t,i){if(this.ignoreParentScaling){if(this.parent){const s=this.parent.getWorldMatrix();_.TransformCoordinatesToRef(e,s,this._globalPosition),_.TransformCoordinatesToRef(t,s,this._tmpTargetVector),_.TransformNormalToRef(i,s,this._tmpUpVector),this._markSyncedWithParent()}else this._globalPosition.copyFrom(e),this._tmpTargetVector.copyFrom(t),this._tmpUpVector.copyFrom(i);this.getScene().useRightHandedSystem?M.LookAtRHToRef(this._globalPosition,this._tmpTargetVector,this._tmpUpVector,this._viewMatrix):M.LookAtLHToRef(this._globalPosition,this._tmpTargetVector,this._tmpUpVector,this._viewMatrix);return}if(this.getScene().useRightHandedSystem?M.LookAtRHToRef(e,t,i,this._viewMatrix):M.LookAtLHToRef(e,t,i,this._viewMatrix),this.parent){const s=this.parent.getWorldMatrix();this._viewMatrix.invert(),this._viewMatrix.multiplyToRef(s,this._viewMatrix),this._viewMatrix.getTranslationToRef(this._globalPosition),this._viewMatrix.invert(),this._markSyncedWithParent()}else this._globalPosition.copyFrom(e)}createRigCamera(e,t){if(this.cameraRigMode!==J.RIG_MODE_NONE){const i=new He(e,this.position.clone(),this.getScene());return i.isRigCamera=!0,i.rigParent=this,this.cameraRigMode===J.RIG_MODE_VR&&(this.rotationQuaternion||(this.rotationQuaternion=new U),i._cameraRigParams={},i.rotationQuaternion=new U),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?(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,He._TargetFocalPoint),He._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);const s=He._TargetFocalPoint.addInPlace(this.position);M.TranslationToRef(-s.x,-s.y,-s.z,He._TargetTransformMatrix),He._TargetTransformMatrix.multiplyToRef(M.RotationAxis(t.upVector,e),He._RigCamTransformMatrix),M.TranslationToRef(s.x,s.y,s.z,He._TargetTransformMatrix),He._RigCamTransformMatrix.multiplyToRef(He._TargetTransformMatrix,He._RigCamTransformMatrix),_.TransformCoordinatesToRef(this.position,He._RigCamTransformMatrix,t.position),t.setTarget(s)}getClassName(){return"TargetCamera"}}He._RigCamTransformMatrix=new M;He._TargetTransformMatrix=new M;He._TargetFocalPoint=new _;p([E()],He.prototype,"ignoreParentScaling",void 0);p([E()],He.prototype,"updateUpVectorFromRotation",void 0);p([ri()],He.prototype,"rotation",void 0);p([E()],He.prototype,"speed",void 0);p([Ta("lockedTargetId")],He.prototype,"lockedTarget",void 0);var os={};class $l{constructor(e){this.attachedToElement=!1,this.attached={},this.camera=e,this.checkInputs=()=>{}}add(e){const t=e.getSimpleName();if(this.attached[t]){F.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=re.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=os[i];if(s){const r=t[i],n=re.Parse(()=>new s,r,null);this.add(n)}}}else for(const i in this.attached){const s=os[this.attached[i].getClassName()];if(s){const r=re.Parse(()=>new s,e,null);this.remove(this.attached[i]),this.add(r)}}}}class ja{constructor(){this._currentMousePointerIdDown=-1,this.buttons=[0,1,2]}attachControl(e){e=B.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!==ne.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!==ne.POINTERDOWN&&o.type!==ne.POINTERDOUBLETAP&&l&&this._pointA?.pointerId!==h.pointerId&&this._pointB?.pointerId!==h.pointerId)return;if(o.type===ne.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};else if(this._pointB===null)this._pointB={x:h.clientX,y:h.clientY,pointerId:h.pointerId,type:h.pointerType};else return;this._currentMousePointerIdDown===-1&&!l&&(this._currentMousePointerIdDown=h.pointerId),this.onButtonDown(h),e||(h.preventDefault(),i&&i.focus())}else if(o.type===ne.POINTERDOUBLETAP)this.onDoubleTap(h.pointerType);else if(o.type===ne.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===ne.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,m={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,m),r=m,s=g}}}},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,ne.POINTERDOWN|ne.POINTERUP|ne.POINTERMOVE|ne.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&&B.RegisterTopRootEvents(n,[{name:"blur",handler:this._onLostFocus}])}detachControl(){if(this._onLostFocus){const e=this.camera.getScene().getEngine().getHostWindow();e&&B.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(){}}p([E()],ja.prototype,"buttons",void 0);class mt extends ja{constructor(){super(...arguments),this.buttons=[0,1,2],this.angularSensibilityX=1e3,this.angularSensibilityY=1e3,this.pinchPrecision=12,this.pinchDeltaPercentage=0,this.useNaturalPinchZoom=!1,this.pinchZoom=!0,this.panningSensibility=1e3,this.multiTouchPanning=!0,this.multiTouchPanAndZoom=!0,this.pinchInwards=!0,this._isPanClick=!1,this._twoFingerActivityCount=0,this._isPinching=!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||mt.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){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._twoFingerActivityCount<20&&Math.abs(Math.sqrt(s)-Math.sqrt(i))>this.camera.pinchToPanMaxDistance?(this._computePinchZoom(i,s),this._isPinching=!0):this._computeMultiTouchPanning(r,n)):this.multiTouchPanning?this._computeMultiTouchPanning(r,n):this.pinchZoom&&this._computePinchZoom(i,s))}onButtonDown(e){this._isPanClick=e.button===this.camera._panningMouseButton}onButtonUp(e){this._twoFingerActivityCount=0,this._isPinching=!1}onLostFocus(){this._isPanClick=!1,this._twoFingerActivityCount=0,this._isPinching=!1}}mt.MinimumRadiusForPinch=.001;p([E()],mt.prototype,"buttons",void 0);p([E()],mt.prototype,"angularSensibilityX",void 0);p([E()],mt.prototype,"angularSensibilityY",void 0);p([E()],mt.prototype,"pinchPrecision",void 0);p([E()],mt.prototype,"pinchDeltaPercentage",void 0);p([E()],mt.prototype,"useNaturalPinchZoom",void 0);p([E()],mt.prototype,"pinchZoom",void 0);p([E()],mt.prototype,"panningSensibility",void 0);p([E()],mt.prototype,"multiTouchPanning",void 0);p([E()],mt.prototype,"multiTouchPanAndZoom",void 0);os.ArcRotateCameraPointersInput=mt;class hs{}hs.KEYDOWN=1;hs.KEYUP=2;class Br{constructor(e,t){this.type=e,this.event=t}}class On extends Br{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 Ut{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=B.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===hs.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"}}p([E()],Ut.prototype,"keysUp",void 0);p([E()],Ut.prototype,"keysDown",void 0);p([E()],Ut.prototype,"keysLeft",void 0);p([E()],Ut.prototype,"keysRight",void 0);p([E()],Ut.prototype,"keysReset",void 0);p([E()],Ut.prototype,"panningSensibility",void 0);p([E()],Ut.prototype,"zoomingSensibility",void 0);p([E()],Ut.prototype,"useAltToZoom",void 0);p([E()],Ut.prototype,"angularSpeed",void 0);os.ArcRotateCameraKeyboardMoveInput=Ut;var Fn;(function(a){a[a.PointerMove=0]="PointerMove",a[a.PointerDown=1]="PointerDown",a[a.PointerUp=2]="PointerUp"})(Fn||(Fn={}));class As{}As.DOM_DELTA_PIXEL=0;As.DOM_DELTA_LINE=1;As.DOM_DELTA_PAGE=2;const ec=40;class Es{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=B.BackCompatCameraNoPreventDefault(arguments),this._wheel=t=>{if(t.type!==ne.POINTERWHEEL)return;const i=t.event;let s=0;const r=i.deltaMode===As.DOM_DELTA_LINE?ec: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;const h=this.camera.inertialRadiusOffset+s;o-=h,o=Te(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,ne.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=Pt.FromPositionAndNormal(e.target,t)}_getPosition(){const e=this.camera,t=e.getScene(),i=t.createPickingRay(t.pointerX,t.pointerY,M.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=C.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)<_e&&(e.x=0),Math.abs(e.y)<_e&&(e.y=0),Math.abs(e.z)<_e&&(e.z=0)}}p([E()],Es.prototype,"wheelPrecision",void 0);p([E()],Es.prototype,"zoomToMouseLocation",void 0);p([E()],Es.prototype,"wheelDeltaPercentage",void 0);os.ArcRotateCameraMouseWheelInput=Es;class tc extends $l{constructor(e){super(e)}addMouseWheel(){return this.add(new Es),this}addPointers(){return this.add(new mt),this}addKeyboard(){return this.add(new Ut),this}}Ve.AddNodeConstructor("ArcRotateCamera",(a,e)=>()=>new Se(a,0,0,1,_.Zero(),e));function Za(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 Ja(a,e){return Math.acos(a/e)}function at(a,e){return isNaN(a)?e:a}class Se extends He{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 M,this._upToYMatrix=new M,this._upVector=_.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()}get upVector(){return this._upVector}setMatUp(){M.RotationAlignToRef(_.UpReadOnly,this._upVector,this._yToUpMatrix),M.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 xi,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 dt,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 zl,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=Z.Zero(),this.allowUpsideDown=!0,this.useInputToRestoreState=!0,this.restoreStateInterpolationFactor=0,this._currentInterpolationFactor=0,this._viewMatrix=new M,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 Z(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 m=this._getTargetPosition();this._computationVector.copyFromFloats(this.radius*u*g,this.radius*d,this.radius*f*g),m.addToRef(this._computationVector,this._newPosition),this._position.copyFrom(this._newPosition);let b=this.upVector;this.allowUpsideDown&&this.beta<0&&(b=b.clone(),b=b.negate()),this._computeViewMatrix(this._position,m,b),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 tc(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=Z.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>_e&&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=at(e,this._goalAlpha),this._goalBeta=at(t,this._goalBeta),this._goalRadius=at(i,this._goalRadius),this._goalTarget.set(at(s.x,this._goalTarget.x),at(s.y,this._goalTarget.y),at(s.z,this._goalTarget.z)),this._goalTargetScreenOffset.set(at(r.x,this._goalTargetScreenOffset.x),at(r.y,this._goalTargetScreenOffset.y)),this._goalAlpha=Te(this._goalAlpha,this.lowerAlphaLimit??-1/0,this.upperAlphaLimit??1/0),this._goalBeta=Te(this._goalBeta,this.lowerBetaLimit??-1/0,this.upperBetaLimit??1/0),this._goalRadius=Te(this._goalRadius,this.lowerRadiusLimit??-1/0,this.upperRadiusLimit??1/0),this._goalTarget.y=Te(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=B.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)<_e&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<_e&&(this.inertialBetaOffset=0),Math.abs(this.inertialRadiusOffset)<this.speed*_e&&(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 i=this.upVector,s=_.CrossToRef(this._transformedDirection,i,this._transformedDirection);_.CrossToRef(i,s,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 i=C.Matrix[0];this.parent.getWorldMatrix().getRotationMatrixToRef(i),i.transposeToRef(i),_.TransformCoordinatesToRef(this._transformedDirection,i,this._transformedDirection)}this._target.addInPlace(this._transformedDirection)}this.inertialPanningX*=this.panningInertia,this.inertialPanningY*=this.panningInertia,Math.abs(this.inertialPanningX)<this.speed*_e&&(this.inertialPanningX=0),Math.abs(this.inertialPanningY)<this.speed*_e&&(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=at(this._goalRadius,this.radius);if(!isNaN(this._goalTarget.x)||!isNaN(this._goalTarget.y)||!isNaN(this._goalTarget.z)){const n=C.Vector3[0].set(at(this._goalTarget.x,this._target.x),at(this._goalTarget.y,this._target.y),at(this._goalTarget.z,this._target.z));this.setTarget(_.Lerp(this.target,n,s),void 0,void 0,!0),_.Distance(this.target,n)*10/r<_e?(this._goalTarget.set(NaN,NaN,NaN),this.setTarget(n.clone(),void 0,void 0,!0)):t=!0}if(!isNaN(this._goalAlpha)||!isNaN(this._goalBeta)){const n=U.RotationAlphaBetaGammaToRef(at(this._goalAlpha,this.alpha),at(this._goalBeta,this.beta),0,C.Quaternion[0]),o=U.RotationAlphaBetaGammaToRef(this.alpha,this.beta,0,C.Quaternion[1]),h=U.SlerpToRef(o,n,s,C.Quaternion[2]);h.normalize();const l=h.toAlphaBetaGammaToRef(C.Vector3[0]);if(this.alpha=l.x,this.beta=l.y,h.isApprox(n,_e/5)){this._goalAlpha=NaN,this._goalBeta=NaN;const c=n.toAlphaBetaGammaToRef(C.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)<_e?(this._goalRadius=NaN,this.radius=r):t=!0),!isNaN(this._goalTargetScreenOffset.x)||!isNaN(this._goalTargetScreenOffset.y)){const n=C.Vector2[0].set(at(this._goalTargetScreenOffset.x,this.targetScreenOffset.x),at(this._goalTargetScreenOffset.y,this.targetScreenOffset.y));Z.LerpToRef(this.targetScreenOffset,n,s,this.targetScreenOffset),Z.Distance(this.targetScreenOffset,n)<_e?(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=Za(this._computationVector),this.beta=Ja(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=r,this._viewMatrix}zoomOn(e,t=!1){e=e||this.getScene().meshes;const i=se.MinMax(e);let s=this._calculateLowerRadiusFromModelBoundingSphere(i.min,i.max);s=Math.max(Math.min(s,this.upperRadiusLimit||Number.MAX_VALUE),this.lowerRadiusLimit||0),this.radius=s*this.zoomOnFactor,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=se.MinMax(r),s=_.Distance(i.min,i.max)}else{const r=e;i=r,s=r.distance}this._target=se.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 Se(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"}}p([E()],Se.prototype,"alpha",void 0);p([E()],Se.prototype,"beta",void 0);p([E()],Se.prototype,"radius",void 0);p([E()],Se.prototype,"overrideCloneAlphaBetaRadius",void 0);p([ri("target")],Se.prototype,"_target",void 0);p([Ta("targetHost")],Se.prototype,"_targetHost",void 0);p([E()],Se.prototype,"inertialAlphaOffset",void 0);p([E()],Se.prototype,"inertialBetaOffset",void 0);p([E()],Se.prototype,"inertialRadiusOffset",void 0);p([E()],Se.prototype,"lowerAlphaLimit",void 0);p([E()],Se.prototype,"upperAlphaLimit",void 0);p([E()],Se.prototype,"lowerBetaLimit",void 0);p([E()],Se.prototype,"upperBetaLimit",void 0);p([E()],Se.prototype,"lowerRadiusLimit",void 0);p([E()],Se.prototype,"upperRadiusLimit",void 0);p([E()],Se.prototype,"lowerTargetYLimit",void 0);p([E()],Se.prototype,"inertialPanningX",void 0);p([E()],Se.prototype,"inertialPanningY",void 0);p([E()],Se.prototype,"pinchToPanMaxDistance",void 0);p([E()],Se.prototype,"panningDistanceLimit",void 0);p([ri()],Se.prototype,"panningOriginTarget",void 0);p([E()],Se.prototype,"panningInertia",void 0);p([E()],Se.prototype,"zoomToMouseLocation",null);p([E()],Se.prototype,"zoomOnFactor",void 0);p([m
vendor: 10,976 bytes, line 30
30a()],Se.prototype,"targetScreenOffset",void 0);p([E()],Se.prototype,"allowUpsideDown",void 0);p([E()],Se.prototype,"useInputToRestoreState",void 0);p([E()],Se.prototype,"restoreStateInterpolationFactor",void 0);it("BABYLON.ArcRotateCamera",Se);class ce extends Ve{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){super(e,t,!1),this.diffuse=new q(1,1,1),this.specular=new q(1,1,1),this.falloffType=ce.FALLOFF_DEFAULT,this.intensity=1,this._range=Number.MAX_VALUE,this._inverseSquaredRange=0,this._photometricScale=1,this._intensityMode=ce.INTENSITYMODE_AUTOMATIC,this._radius=1e-5,this.renderPriority=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._isLight=!0,this.getScene().addLight(this),this._uniformBuffer=new W(this.getScene().getEngine(),void 0,void 0,e),this._buildUniformLayout(),this.includedOnlyMeshes=[],this.excludedMeshes=[],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,Ct.Color3[0]),this._uniformBuffer.updateColor4("vLightDiffuse",Ct.Color3[0],this.range,n),s&&(this.specular.scaleToRef(h,Ct.Color3[1]),this._uniformBuffer.updateColor4("vLightSpecular",Ct.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"][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)||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=ce.GetConstructorFromName(this.getTypeID(),e,this.getScene());if(!i)return null;const s=re.Clone(i,this);return e&&(s.name=e),t&&(s.parent=t),s.setEnabled(this.isEnabled()),this.onClonedObservable.notifyObservers(s),s}serialize(){const e=re.Serialize(this);return e.uniqueId=this.uniqueId,e.type=this.getTypeID(),this.parent&&this.parent._serializeAsParent(e),this.excludedMeshes.length>0&&(e.excludedMeshesIds=[],this.excludedMeshes.forEach(t=>{e.excludedMeshesIds.push(t.id)})),this.includedOnlyMeshes.length>0&&(e.includedOnlyMeshesIds=[],this.includedOnlyMeshes.forEach(t=>{e.includedOnlyMeshesIds.push(t.id)})),re.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.isEnabled=this.isEnabled(),e}static GetConstructorFromName(e,t,i){const s=Ve.Construct("Light_Type_"+e,t,i);return s||null}static Parse(e,t){const i=ce.GetConstructorFromName(e.type,e.name,t);if(!i)return null;const s=re.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=fi("BABYLON.Animation");o&&s.animations.push(o.Parse(n))}Ve.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===ce.INTENSITYMODE_AUTOMATIC&&(t===ce.LIGHTTYPEID_DIRECTIONALLIGHT?i=ce.INTENSITYMODE_ILLUMINANCE:i=ce.INTENSITYMODE_LUMINOUSINTENSITY),t){case ce.LIGHTTYPEID_POINTLIGHT:case ce.LIGHTTYPEID_SPOTLIGHT:switch(i){case ce.INTENSITYMODE_LUMINOUSPOWER:e=1/(4*Math.PI);break;case ce.INTENSITYMODE_LUMINOUSINTENSITY:e=1;break;case ce.INTENSITYMODE_LUMINANCE:e=this.radius*this.radius;break}break;case ce.LIGHTTYPEID_DIRECTIONALLIGHT:switch(i){case ce.INTENSITYMODE_ILLUMINANCE:e=1;break;case ce.INTENSITYMODE_LUMINANCE:{let s=this.radius;s=Math.max(s,.001),e=2*Math.PI*(1-Math.cos(s));break}}break;case ce.LIGHTTYPEID_HEMISPHERICLIGHT:e=1;break}return e}_reorderLightsInScene(){const e=this.getScene();this._renderPriority!=0&&(e.requireLightSorting=!0),this.getScene().sortLightsByPriority()}_isReady(){return!0}}ce.FALLOFF_DEFAULT=me.FALLOFF_DEFAULT;ce.FALLOFF_PHYSICAL=me.FALLOFF_PHYSICAL;ce.FALLOFF_GLTF=me.FALLOFF_GLTF;ce.FALLOFF_STANDARD=me.FALLOFF_STANDARD;ce.LIGHTMAP_DEFAULT=me.LIGHTMAP_DEFAULT;ce.LIGHTMAP_SPECULAR=me.LIGHTMAP_SPECULAR;ce.LIGHTMAP_SHADOWSONLY=me.LIGHTMAP_SHADOWSONLY;ce.INTENSITYMODE_AUTOMATIC=me.INTENSITYMODE_AUTOMATIC;ce.INTENSITYMODE_LUMINOUSPOWER=me.INTENSITYMODE_LUMINOUSPOWER;ce.INTENSITYMODE_LUMINOUSINTENSITY=me.INTENSITYMODE_LUMINOUSINTENSITY;ce.INTENSITYMODE_ILLUMINANCE=me.INTENSITYMODE_ILLUMINANCE;ce.INTENSITYMODE_LUMINANCE=me.INTENSITYMODE_LUMINANCE;ce.LIGHTTYPEID_POINTLIGHT=me.LIGHTTYPEID_POINTLIGHT;ce.LIGHTTYPEID_DIRECTIONALLIGHT=me.LIGHTTYPEID_DIRECTIONALLIGHT;ce.LIGHTTYPEID_SPOTLIGHT=me.LIGHTTYPEID_SPOTLIGHT;ce.LIGHTTYPEID_HEMISPHERICLIGHT=me.LIGHTTYPEID_HEMISPHERICLIGHT;ce.LIGHTTYPEID_RECT_AREALIGHT=me.LIGHTTYPEID_RECT_AREALIGHT;p([Rt()],ce.prototype,"diffuse",void 0);p([Rt()],ce.prototype,"specular",void 0);p([E()],ce.prototype,"falloffType",void 0);p([E()],ce.prototype,"intensity",void 0);p([E()],ce.prototype,"range",null);p([E()],ce.prototype,"intensityMode",null);p([E()],ce.prototype,"radius",null);p([E()],ce.prototype,"_renderPriority",void 0);p([N("_reorderLightsInScene")],ce.prototype,"renderPriority",void 0);p([E("shadowEnabled")],ce.prototype,"_shadowEnabled",void 0);p([E("excludeWithLayerMask")],ce.prototype,"_excludeWithLayerMask",void 0);p([E("includeOnlyWithLayerMask")],ce.prototype,"_includeOnlyWithLayerMask",void 0);p([E("lightmapMode")],ce.prototype,"_lightmapMode",void 0);Ve.AddNodeConstructor("Light_Type_3",(a,e)=>()=>new Rs(a,_.Zero(),e));class Rs extends ce{constructor(e,t,i){super(e,i),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=M.Identity()),this._worldMatrix}getTypeID(){return ce.LIGHTTYPEID_HEMISPHERICLIGHT}prepareLightSpecificDefines(e,t){e["HEMILIGHT"+t]=!0}}p([Rt()],Rs.prototype,"groundColor",void 0);p([ri()],Rs.prototype,"direction",void 0);it("BABYLON.HemisphericLight",Rs);class 
vendor: 14,087 bytes, line 30
30wn{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}add(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 $a(a){a.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")}class Ce{constructor(){this._dirty=!0,this._tempColor=new le(0,0,0,0),this._globalCurve=new le(0,0,0,0),this._highlightsCurve=new le(0,0,0,0),this._midtonesCurve=new le(0,0,0,0),this._shadowsCurve=new le(0,0,0,0),this._positiveCurve=new le(0,0,0,0),this._negativeCurve=new le(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=Ce._Clamp(e,0,360),t=Ce._Clamp(t,-100,100),i=Ce._Clamp(i,-100,100),s=Ce._Clamp(s,-100,100),t=Ce._ApplyColorGradingSliderNonlinear(t),t*=.5,s=Ce._ApplyColorGradingSliderNonlinear(s),t<0&&(t*=-1,e=(e+180)%360),Ce._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=Ce._Clamp(e,0,360);const n=Ce._Clamp(t/100,0,1),o=Ce._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 re.Clone(()=>new Ce,this)}serialize(){return re.Serialize(this)}static Parse(e){return re.Parse(()=>new Ce,e,null,null)}}Ce.PrepareUniforms=$a;p([E()],Ce.prototype,"_globalHue",void 0);p([E()],Ce.prototype,"_globalDensity",void 0);p([E()],Ce.prototype,"_globalSaturation",void 0);p([E()],Ce.prototype,"_globalExposure",void 0);p([E()],Ce.prototype,"_highlightsHue",void 0);p([E()],Ce.prototype,"_highlightsDensity",void 0);p([E()],Ce.prototype,"_highlightsSaturation",void 0);p([E()],Ce.prototype,"_highlightsExposure",void 0);p([E()],Ce.prototype,"_midtonesHue",void 0);p([E()],Ce.prototype,"_midtonesDensity",void 0);p([E()],Ce.prototype,"_midtonesSaturation",void 0);p([E()],Ce.prototype,"_midtonesExposure",void 0);re._ColorCurvesParser=Ce.Parse;function ic(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&&$a(a),e.DITHER&&a.push("ditherIntensity")}function sc(a,e){e.COLORGRADING&&a.push("txColorTransform")}class ae{constructor(){this.colorCurves=new Ce,this._colorCurvesEnabled=!1,this._colorGradingEnabled=!1,this._colorGradingWithGreenDepth=!0,this._colorGradingBGR=!0,this._exposure=1,this._toneMappingEnabled=!1,this._toneMappingType=ae.TONEMAPPING_STANDARD,this._contrast=1,this.vignetteStretch=0,this.vignetteCenterX=0,this.vignetteCenterY=0,this.vignetteWeight=1.5,this.vignetteColor=new le(0,0,0,0),this.vignetteCameraFov=.5,this._vignetteBlendMode=ae.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===ae._VIGNETTEMODE_MULTIPLY,e.VIGNETTEBLENDMODEOPAQUE=!e.VIGNETTEBLENDMODEMULTIPLY,!this._toneMappingEnabled)e.TONEMAPPING=0;else switch(this._toneMappingType){case ae.TONEMAPPING_KHR_PBR_NEUTRAL:e.TONEMAPPING=3;break;case ae.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&&Ce.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=wr(o,h,this.vignetteStretch),n=wr(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 re.Clone(()=>new ae,this)}serialize(){return re.Serialize(this)}static Parse(e){const t=re.Parse(()=>new ae,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}}ae.TONEMAPPING_STANDARD=0;ae.TONEMAPPING_ACES=1;ae.TONEMAPPING_KHR_PBR_NEUTRAL=2;ae.PrepareUniforms=ic;ae.PrepareSamplers=sc;ae._VIGNETTEMODE_MULTIPLY=0;ae._VIGNETTEMODE_OPAQUE=1;p([Bo()],ae.prototype,"colorCurves",void 0);p([E()],ae.prototype,"_colorCurvesEnabled",void 0);p([Ie("colorGradingTexture")],ae.prototype,"_colorGradingTexture",void 0);p([E()],ae.prototype,"_colorGradingEnabled",void 0);p([E()],ae.prototype,"_colorGradingWithGreenDepth",void 0);p([E()],ae.prototype,"_colorGradingBGR",void 0);p([E()],ae.prototype,"_exposure",void 0);p([E()],ae.prototype,"_toneMappingEnabled",void 0);p([E()],ae.prototype,"_toneMappingType",void 0);p([E()],ae.prototype,"_contrast",void 0);p([E()],ae.prototype,"vignetteStretch",void 0);p([E()],ae.prototype,"vignetteCenterX",void 0);p([E()],ae.prototype,"vignetteCenterY",void 0);p([E()],ae.prototype,"vignetteWeight",void 0);p([b
vendor: 9,223 bytes, line 30
30a()],ae.prototype,"vignetteColor",void 0);p([E()],ae.prototype,"vignetteCameraFov",void 0);p([E()],ae.prototype,"_vignetteBlendMode",void 0);p([E()],ae.prototype,"_vignetteEnabled",void 0);p([E()],ae.prototype,"_ditheringEnabled",void 0);p([E()],ae.prototype,"_ditheringIntensity",void 0);p([E()],ae.prototype,"_skipFinalColorClamp",void 0);p([E()],ae.prototype,"_applyByPostProcess",void 0);p([E()],ae.prototype,"_isEnabled",void 0);p([E()],ae.prototype,"outputTextureWidth",void 0);p([E()],ae.prototype,"outputTextureHeight",void 0);re._ImageProcessingConfigurationParser=ae.Parse;it("BABYLON.ImageProcessingConfiguration",ae);class je{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 je(e,s.pointerX,s.pointerY,s.meshUnderPointer||e,t,i)}static CreateNewFromSprite(e,t,i,s){return new je(e,t.pointerX,t.pointerY,t.meshUnderPointer,i,s)}static CreateNewFromScene(e,t){return new je(null,e.pointerX,e.pointerY,e.meshUnderPointer,t)}static CreateNewFromPrimitive(e,t,i,s){return new je(e,t.x,t.y,null,i,s)}}class Nr{constructor(e){this._vertexBuffers={},this.onBeforeRenderObservable=new O,this._scene=e}_prepareBuffers(){if(this._vertexBuffers[T.PositionKind])return;const e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffers[T.PositionKind]=new T(this._scene.getEngine(),e,T.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[T.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){const o=this._scene.getEngine();for(let h=0;h<e.length;h++){h<e.length-1?e[h+1].activate(this._scene.activeCamera||this._scene,t?.texture):(t?o.bindFramebuffer(t,s,void 0,void 0,i,r):n||o.restoreDefaultFramebuffer(),o._debugInsertMarker?.(`post process ${e[h].name} output`));const l=e[h],c=l.apply();c&&(l.onBeforeRenderObservable.notifyObservers(c),this._prepareBuffers(),o.bindBuffers(this._vertexBuffers,this._indexBuffer,c),o.drawElementsType(0,0,6),l.onAfterRenderObservable.notifyObservers(c))}o.setDepthBuffer(!0),o.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[T.PositionKind];e&&(e.dispose(),this._vertexBuffers[T.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null)}}class Lt{set opaqueSortCompareFn(e){e?this._opaqueSortCompareFn=e:this._opaqueSortCompareFn=Lt.PainterSortCompare,this._renderOpaque=this._renderOpaqueSorted}set alphaTestSortCompareFn(e){e?this._alphaTestSortCompareFn=e:this._alphaTestSortCompareFn=Lt.PainterSortCompare,this._renderAlphaTest=this._renderAlphaTestSorted}set transparentSortCompareFn(e){e?this._transparentSortCompareFn=e:this._transparentSortCompareFn=Lt.defaultTransparentSortCompare,this._renderTransparent=this._renderTransparentSorted}constructor(e,t,i=null,s=null,r=null){this.index=e,this._opaqueSubMeshes=new rt(256),this._transparentSubMeshes=new rt(256),this._alphaTestSubMeshes=new rt(256),this._depthOnlySubMeshes=new rt(256),this._particleSystems=new rt(256),this._spriteManagers=new rt(256),this._empty=!0,this._edgesRenderers=new bi(16),this._scene=t,this.opaqueSortCompareFn=i,this.alphaTestSortCompareFn=s,this.transparentSortCompareFn=r}render(e,t,i,s){if(e){e(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);return}const r=this._scene.getEngine();this._depthOnlySubMeshes.length!==0&&(r.setColorWrite(!1),this._renderAlphaTest(this._depthOnlySubMeshes),r.setColorWrite(!0)),this._opaqueSubMeshes.length!==0&&this._renderOpaque(this._opaqueSubMeshes),this._alphaTestSubMeshes.length!==0&&this._renderAlphaTest(this._alphaTestSubMeshes);const n=r.getStencilBuffer();if(r.setStencilBuffer(!1),t&&this._renderSprites(),i&&this._renderParticles(s),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),this._transparentSubMeshes.length!==0||this._scene.useOrderIndependentTransparency){if(r.setStencilBuffer(n),this._scene.useOrderIndependentTransparency){const o=this._scene.depthPeelingRenderer.render(this._transparentSubMeshes);o.length&&this._renderTransparent(o)}else this._renderTransparent(this._transparentSubMeshes);r.setAlphaMode(0)}if(r.setStencilBuffer(!1),this._edgesRenderers.length){for(let o=0;o<this._edgesRenderers.length;o++)this._edgesRenderers.data[o].render();r.setAlphaMode(0)}r.setStencilBuffer(n)}_renderOpaqueSorted(e){Lt._RenderSorted(e,this._opaqueSortCompareFn,this._scene.activeCamera,!1)}_renderAlphaTestSorted(e){Lt._RenderSorted(e,this._alphaTestSortCompareFn,this._scene.activeCamera,!1)}_renderTransparentSorted(e){Lt._RenderSorted(e,this._transparentSortCompareFn,this._scene.activeCamera,!0)}static _RenderSorted(e,t,i,s){let r=0,n;const o=i?i.globalPosition:Lt._ZeroVector;if(s)for(;r<e.length;r++)n=e.data[r],n._alphaIndex=n.getMesh().alphaIndex,n._distanceToCamera=_.Distance(n.getBoundingInfo().boundingSphere.centerWorld,o);const h=e.length===e.data.length?e.data:e.data.slice(0,e.length);t&&h.sort(t);const l=h[0].getMesh().getScene();for(r=0;r<h.length;r++)if(n=h[r],!(l._activeMeshesFrozenButKeepClipping&&!n.isInFrustum(l._frustumPlanes))){if(s){const c=n.getMaterial();if(c&&c.needDepthPrePass){const u=c.getScene().getEngine();u.setColorWrite(!1),u.setAlphaMode(0),n.render(!1),u.setColorWrite(!0)}}n.render(s)}}static defaultTransparentSortCompare(e,t){return e._alphaIndex>t._alphaIndex?1:e._alphaIndex<t._alphaIndex?-1:Lt.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._depthOnlySubMeshes.push(e),this._alphaTestSubMeshes.push(e)):(i.needDepthPrePass&&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)}}Lt._ZeroVector=_.Zero();class 
vendor: 72,309 bytes, line 30
30rc{}class st{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._renderingGroups=new Array,this._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderingGroupInfo=new rc,this._maintainStateBetweenFrames=!1,this._scene=e;for(let t=st.MIN_RENDERINGGROUPS;t<st.MAX_RENDERINGGROUPS;t++)this._autoClearDepthStencil[t]={autoClear:!0,depth:!0,stencil:!0}}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){const r=this._renderingGroupInfo;if(r.scene=this._scene,r.camera=this._scene.activeCamera,r.renderingManager=this,this._scene.spriteManagers&&s)for(let n=0;n<this._scene.spriteManagers.length;n++){const o=this._scene.spriteManagers[n];this.dispatchSprites(o)}for(let n=st.MIN_RENDERINGGROUPS;n<st.MAX_RENDERINGGROUPS;n++){this._depthStencilBufferAlreadyCleaned=n===st.MIN_RENDERINGGROUPS;const o=this._renderingGroups[n];if(!o||o._empty)continue;const h=1<<n;if(r.renderingGroupId=n,this._scene.onBeforeRenderingGroupObservable.notifyObservers(r,h),st.AUTOCLEAR){const l=this._useSceneAutoClearSetup?this._scene.getAutoClearDepthStencilSetup(n):this._autoClearDepthStencil[n];l&&l.autoClear&&this._clearDepthStencilBuffer(l.depth,l.stencil)}for(const l of this._scene._beforeRenderingGroupDrawStage)l.action(n);o.render(e,s,i,t);for(const l of this._scene._afterRenderingGroupDrawStage)l.action(n);this._scene.onAfterRenderingGroupObservable.notifyObservers(r,h)}}reset(){if(!this.maintainStateBetweenFrames)for(let e=st.MIN_RENDERINGGROUPS;e<st.MAX_RENDERINGGROUPS;e++){const t=this._renderingGroups[e];t&&t.prepare()}}resetSprites(){if(!this.maintainStateBetweenFrames)for(let e=st.MIN_RENDERINGGROUPS;e<st.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=st.MIN_RENDERINGGROUPS;e<st.MAX_RENDERINGGROUPS;e++){const t=this._renderingGroups[e];t&&t.dispose()}}_prepareRenderingGroup(e){this._renderingGroups[e]===void 0&&(this._renderingGroups[e]=new Lt(e,this._scene,this._customOpaqueSortCompareFn[e],this._customAlphaTestSortCompareFn[e],this._customTransparentSortCompareFn[e]))}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]}}st.MAX_RENDERINGGROUPS=4;st.MIN_RENDERINGGROUPS=0;st.AUTOCLEAR=!0;class xt{constructor(){this.hoverCursor="",this.actions=[],this.isRecursive=!1,this.disposeWhenUnowned=!0}static get HasTriggers(){for(const e in xt.Triggers)if(Object.prototype.hasOwnProperty.call(xt.Triggers,e))return!0;return!1}static get HasPickTriggers(){for(const e in xt.Triggers)if(Object.prototype.hasOwnProperty.call(xt.Triggers,e)){const t=parseInt(e);if(t>=1&&t<=7)return!0}return!1}static HasSpecificTrigger(e){for(const t in xt.Triggers)if(Object.prototype.hasOwnProperty.call(xt.Triggers,t)&&parseInt(t)===e)return!0;return!1}}xt.Triggers={};var K;(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"})(K||(K={}));var $;(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"})($||($={}));var Ln;(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"})(Ln||(Ln={}));var Bn;(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"})(Bn||(Bn={}));var Nn;(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"})(Nn||(Nn={}));var Un;(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"})(Un||(Un={}));var kn;(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"})(kn||(kn={}));class Ai{static CreateDeviceEvent(e,t,i,s,r,n,o){switch(e){case K.Keyboard:return this._CreateKeyboardEvent(i,s,r,n);case K.Mouse:if(i===$.MouseWheelX||i===$.MouseWheelY||i===$.MouseWheelZ)return this._CreateWheelEvent(e,t,i,s,r,n);case K.Touch:return this._CreatePointerEvent(e,t,i,s,r,n,o);default:throw`Unable to generate event for device ${K[e]}`}}static _CreatePointerEvent(e,t,i,s,r,n,o){const h=this._CreateMouseEvent(e,t,i,s,r,n);e===K.Mouse?(h.deviceType=K.Mouse,h.pointerId=1,h.pointerType="mouse"):(h.deviceType=K.Touch,h.pointerId=o??t,h.pointerType="touch");let l=0;return l+=r.pollInput(e,t,$.LeftClick),l+=r.pollInput(e,t,$.RightClick)*2,l+=r.pollInput(e,t,$.MiddleClick)*4,h.buttons=l,i===$.Move?h.type="pointermove":i>=$.LeftClick&&i<=$.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=As.DOM_DELTA_PIXEL,o.deltaX=0,o.deltaY=0,o.deltaZ=0,i){case $.MouseWheelX:o.deltaX=s;break;case $.MouseWheelY:o.deltaY=s;break;case $.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,$.Horizontal),l=r.pollInput(e,t,$.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=K.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(K.Keyboard),s=i&&t.pollInput(K.Keyboard,0,18)===1,r=i&&t.pollInput(K.Keyboard,0,17)===1,n=i&&(t.pollInput(K.Keyboard,0,91)===1||t.pollInput(K.Keyboard,0,92)===1||t.pollInput(K.Keyboard,0,93)===1),o=i&&t.pollInput(K.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 nc{constructor(e,t,i){this._nativeInput=_native.DeviceInputSystem?new _native.DeviceInputSystem(e,t,(s,r,n,o)=>{const h=Ai.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===K.Mouse||e===K.Touch}dispose(){this._nativeInput.dispose()}_createDummyNativeInput(){return{pollInput:()=>0,isDeviceAvailable:()=>!1,dispose:()=>{}}}}const Vn=255,Hn=Object.keys($).length/2;class ac{constructor(e,t,i,s){this._inputs=[],this._keyboardActive=!1,this._pointerActive=!1,this._usingSafari=B.IsSafari(),this._usingMacOS=Fi()&&/(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=Fi()&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox")!==-1,this._isUsingChromium=Fi()&&navigator.userAgent&&navigator.userAgent.indexOf("Chrome")!==-1,this._maxTouchPoints=0,this._pointerInputClearObserver=null,this._gamepadConnectedEvent=r=>{},this._gamepadDisconnectedEvent=r=>{},this._eventPrefix=B.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 ${K[e]}`;e>=K.DualShock&&e<=K.DualSense&&this._updateDevice(e,t,i);const r=s[i];if(r===void 0)throw`Unable to find input ${i} for device ${K[e]} in slot ${t}`;return i===$.Move&&B.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(K.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,Hn);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 ${K[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(K.Keyboard,0,Vn));const t=this._inputs[K.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(K.Keyboard,0,i)}},this._keyboardUpEvent=e=>{this._keyboardActive||(this._keyboardActive=!0,this._registerDevice(K.Keyboard,0,Vn));const t=this._inputs[K.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=Ai.CreateDeviceEvent(K.Keyboard,0,s,0,this,this._elementToAttachTo);t[s]=0,this._onInputChanged(K.Keyboard,0,r)}this._metaKeys.splice(0,this._metaKeys.length)}this._onInputChanged(K.Keyboard,0,i)}},this._keyboardBlurEvent=()=>{if(this._keyboardActive){const e=this._inputs[K.Keyboard][0];for(let t=0;t<e.length;t++)if(e[t]!==0){e[t]=0;const i=Ai.CreateDeviceEvent(K.Keyboard,0,t,0,this,this._elementToAttachTo);this._onInputChanged(K.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=Fi()&&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===K.Mouse?0:this._activeTouchIds.indexOf(i.pointerId);if(s===K.Touch&&r===-1){const o=this._activeTouchIds.indexOf(-1);if(o>=0)r=o,this._activeTouchIds[o]=i.pointerId,this._onDeviceConnected(s,r);else{B.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=$.Move,n[$.Horizontal]=i.clientX,n[$.Vertical]=i.clientY,s===K.Touch&&n[$.LeftClick]===0&&(n[$.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===K.Mouse?0:i.pointerId;if(s===K.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{B.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===K.Touch&&this._onDeviceConnected(s,r):this._addPointerDevice(s,r,i.clientX,i.clientY);const n=this._inputs[s][r];if(n){const o=n[$.Horizontal],h=n[$.Vertical];if(s===K.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[$.Horizontal]=i.clientX,n[$.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=$.Move,this._onInputChanged(s,r,l))}},this._pointerUpEvent=i=>{const s=this._getPointerType(i),r=s===K.Mouse?0:this._activeTouchIds.indexOf(i.pointerId);if(s===K.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[$.Horizontal],c=n[$.Vertical];n[$.Horizontal]=i.clientX,n[$.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=$.Move,this._onInputChanged(s,r,u)),u.inputIndex=o+2,s===K.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===K.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[K.Touch][s][$.LeftClick]=0;const r=Ai.CreateDeviceEvent(K.Touch,s,$.LeftClick,0,this,this._elementToAttachTo,i);this._onInputChanged(K.Touch,s,r),this._activeTouchIds[s]=-1,this._onDeviceDisconnected(K.Touch,s)},this._pointerCancelEvent=i=>{if(i.pointerType==="mouse"){const s=this._inputs[K.Mouse][0];this._mouseId>=0&&this._elementToAttachTo.hasPointerCapture?.(this._mouseId)&&this._elementToAttachTo.releasePointerCapture(this._mouseId);for(let r=$.LeftClick;r<=$.BrowserForward;r++)if(s[r]===1){s[r]=0;const n=Ai.CreateDeviceEvent(K.Mouse,0,r,0,this,this._elementToAttachTo);this._onInputChanged(K.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(K.Mouse)){const i=this._inputs[K.Mouse][0];this._mouseId>=0&&this._elementToAttachTo.hasPointerCapture?.(this._mouseId)&&this._elementToAttachTo.releasePointerCapture(this._mouseId);for(let s=$.LeftClick;s<=$.BrowserForward;s++)if(i[s]===1){i[s]=0;const r=Ai.CreateDeviceEvent(K.Mouse,0,s,0,this,this._elementToAttachTo);this._onInputChanged(K.Mouse,0,r)}}if(this.isDeviceAvailable(K.Touch)){const i=this._inputs[K.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]?.[$.LeftClick]===1){i[s][$.LeftClick]=0;const n=Ai.CreateDeviceEvent(K.Touch,s,$.LeftClick,0,this,this._elementToAttachTo,r);this._onInputChanged(K.Touch,s,n),this._activeTouchIds[s]=-1,this._onDeviceDisconnected(K.Touch,s)}}}},this._pointerWheelEvent=i=>{const s=K.Mouse,r=0;this._inputs[s]||(this._inputs[s]=[]),this._inputs[s][r]||(this._pointerActive=!0,this._registerDevice(s,r,Hn));const n=this._inputs[s][r];if(n){n[$.MouseWheelX]=i.deltaX||0,n[$.MouseWheelY]=i.deltaY||i.wheelDelta||0,n[$.MouseWheelZ]=i.deltaZ||0;const o=i;i.pointerId===void 0&&(i.pointerId=this._mouseId),n[$.MouseWheelX]!==0&&(o.inputIndex=$.MouseWheelX,this._onInputChanged(s,r,o)),n[$.MouseWheelY]!==0&&(o.inputIndex=$.MouseWheelY,this._onInputChanged(s,r,o)),n[$.MouseWheelZ]!==0&&(o.inputIndex=$.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(K.Mouse)){const i=this._inputs[K.Mouse][0];i[$.MouseWheelX]=0,i[$.MouseWheelY]=0,i[$.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?K.DualSense:K.DualShock:e.indexOf("Xbox One")!==-1||e.search("Xbox 360")!==-1||e.search("xinput")!==-1?K.Xbox:e.indexOf("057e")!==-1?K.Switch:K.Generic}_getPointerType(e){let t=K.Mouse;return(e.pointerType==="touch"||e.pointerType==="pen"||e.touches)&&(t=K.Touch),t}}class Gn{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 oc{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 Gn(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(K).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 Gn(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 nc(i,s,r):this._deviceInputSystem=new ac(e,i,s,r)}dispose(){this._deviceInputSystem.dispose()}}class hc{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(K).length/2;this._devices=new Array(t),this._firstDevice=new Array(t),this._engine=e,this._engine._deviceSourceManager||(this._engine._deviceSourceManager=new oc(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]=new Array),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 K.Keyboard:case K.Mouse:this._firstDevice[e]=0;break;case K.Touch:case K.DualSense:case K.DualShock:case K.Xbox:case K.Switch:case K.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 eo{}eo._IsPickingAvailable=!1;class zn{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 Ne{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 Z(0,0),this._previousStartingPointerPosition=new Z(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||de.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 Z(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>=$.MouseWheelX&&t.inputIndex<=$.MouseWheelZ?ne.POINTERWHEEL:ne.POINTERMOVE;i.onPointerMove&&(e=e||this._pickMove(t),i.onPointerMove(t,e,n));let o;e?(o=new Qt(n,t,e),this._setRayOnPointerInfo(e,t)):(o=new Qt(n,t,null,this),this._movePointerInfo=o),i.onPointerObservable.hasObservers()&&i.onPointerObservable.notifyObservers(o,n)}_setRayOnPointerInfo(e,t){const i=this._scene;e&&eo._IsPickingAvailable&&(e.ray||(e.ray=i.createPickingRay(t.offsetX,t.offsetY,M.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 Gl(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=$.Move,!this._checkPrePointerObservable(e,i,ne.POINTERMOVE)&&this._processPointerMove(e,i)}simulatePointerDown(e,t){const i=new PointerEvent("pointerdown",t);i.inputIndex=i.button+2,!this._checkPrePointerObservable(e,i,ne.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 je(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e)),t.button){case 0:n.processTrigger(2,new je(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e));break;case 1:n.processTrigger(4,new je(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e));break;case 2:n.processTrigger(3,new je(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>Ne.LongPressDelay&&!this._isPointerSwiping()&&(this._startingPointerTime=0,n.processTrigger(8,je.CreateNew(o.pickedMesh,t)))},Ne.LongPressDelay)}}else for(const n of i._pointerDownStage)e=n.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t,!1);let s;const r=ne.POINTERDOWN;e?(i.onPointerDown&&i.onPointerDown(t,e,r),s=new Qt(r,t,e),this._setRayOnPointerInfo(e,t)):s=new Qt(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=$.Move;const r=new zn;i?r.doubleClick=!0:r.singleClick=!0,!this._checkPrePointerObservable(e,s,ne.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=ne.POINTERPICK,o=new Qt(n,t,e);this._setRayOnPointerInfo(e,t),s.onPointerObservable.notifyObservers(o,n)}const r=e.pickedMesh._getActionManagerForTrigger();if(r&&!i.ignore){r.processTrigger(7,je.CreateNew(e.pickedMesh,t,e)),!i.hasSwiped&&i.singleClick&&r.processTrigger(1,je.CreateNew(e.pickedMesh,t,e));const n=e.pickedMesh._getActionManagerForTrigger(6);i.doubleClick&&n&&n.processTrigger(6,je.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,je.CreateNew(this._pickedDownMesh,t))}if(!i.ignore){const r=new Qt(ne.POINTERUP,t,e);if(this._setRayOnPointerInfo(e,t),s.onPointerObservable.notifyObservers(r,ne.POINTERUP),s.onPointerUp&&s.onPointerUp(t,e,ne.POINTERUP),!i.hasSwiped&&!this._skipPointerTap&&!this._isMultiTouchGesture){let n=0;if(i.singleClick?n=ne.POINTERTAP:i.doubleClick&&(n=ne.POINTERDOUBLETAP),n){const o=new Qt(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 hc(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>Ne.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=ne.POINTERTAP,f=new Qt(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 zn;this._currentPickResult=null;let f=null,d=o.hasSpecificMask(ne.POINTERPICK)||h.hasSpecificMask(ne.POINTERPICK)||o.hasSpecificMask(ne.POINTERTAP)||h.hasSpecificMask(ne.POINTERTAP)||o.hasSpecificMask(ne.POINTERDOUBLETAP)||h.hasSpecificMask(ne.POINTERDOUBLETAP);!d&&xt&&(f=this._initActionManager(f,u),f&&(d=f.hasPickTriggers));let g=!1;if(d=d&&!this._isMultiTouchGesture,d){const m=l.button;if(u.hasSwiped=this._isPointerSwiping(),!u.hasSwiped){let b=!Ne.ExclusiveDoubleClickMode;if(b||(b=!o.hasSpecificMask(ne.POINTERDOUBLETAP)&&!h.hasSpecificMask(ne.POINTERDOUBLETAP),b&&!xt.HasSpecificTrigger(6)&&(f=this._initActionManager(f,u),f&&(b=!f.hasSpecificTrigger(6)))),b)(Date.now()-this._previousStartingPointerTime>Ne.DoubleClickDelay||m!==this._previousButtonPressed)&&(u.singleClick=!0,c(u,this._currentPickResult),g=!0);else{const A={evt:l,clickInfo:u,timeoutId:window.setTimeout(this._delayedSimpleClick.bind(this,m,u,c),Ne.DoubleClickDelay)};this._delayedClicks[m]=A}let y=o.hasSpecificMask(ne.POINTERDOUBLETAP)||h.hasSpecificMask(ne.POINTERDOUBLETAP);!y&&xt.HasSpecificTrigger(6)&&(f=this._initActionManager(f,u),f&&(y=f.hasSpecificTrigger(6))),y&&(m===this._previousButtonPressed&&Date.now()-this._previousStartingPointerTime<Ne.DoubleClickDelay&&!this._doubleClickOccured?(!u.hasSwiped&&!this._isPointerSwiping()?(this._previousStartingPointerTime=0,this._doubleClickOccured=!0,u.doubleClick=!0,u.ignore=!1,Ne.ExclusiveDoubleClickMode&&this._delayedClicks[m]&&(clearTimeout(this._delayedClicks[m]?.timeoutId),this._delayedClicks[m]=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=m,Ne.ExclusiveDoubleClickMode?(this._delayedClicks[m]&&(clearTimeout(this._delayedClicks[m]?.timeoutId),this._delayedClicks[m]=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=m))}}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)>Ne.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>Ne.DragMovementThreshold),n.isPointerLock&&n._verifyPointerLock(),this._checkPrePointerObservable(null,o,o.inputIndex>=$.MouseWheelX&&o.inputIndex<=$.MouseWheelZ?ne.POINTERWHEEL:ne.POINTERMOVE)||!r.cameraToUseForPointers&&!r.activeCamera)return;if(r.skipPointerMovePicking){this._processPointerMove(new as,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,Ne.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=ne.POINTERTAP,g=new Qt(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,ne.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 as: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,ne.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(ne.POINTERTAP)&&this._checkPrePointerObservable(null,o,ne.POINTERTAP)&&(this._skipPointerTap=!0),l.doubleClick&&r.onPrePointerObservable.hasSpecificMask(ne.POINTERDOUBLETAP)&&this._checkPrePointerObservable(null,o,ne.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&&(xt&&xt.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=hs.KEYDOWN;if(r.onPreKeyboardObservable.hasObservers()){const l=new On(h,o);if(r.onPreKeyboardObservable.notifyObservers(l,h),l.skipOnKeyboardObservable)return}if(r.onKeyboardObservable.hasObservers()){const l=new Br(h,o);r.onKeyboardObservable.notifyObservers(l,h)}r.actionManager&&r.actionManager.processTrigger(14,je.CreateNewFromScene(r,o))},this._onKeyUp=o=>{const h=hs.KEYUP;if(r.onPreKeyboardObservable.hasObservers()){const l=new On(h,o);if(r.onPreKeyboardObservable.notifyObservers(l,h),l.skipOnKeyboardObservable)return}if(r.onKeyboardObservable.hasObservers()){const l=new Br(h,o);r.onKeyboardObservable.notifyObservers(l,h)}r.actionManager&&r.actionManager.processTrigger(15,je.CreateNewFromScene(r,o))},this._deviceSourceManager.onDeviceConnectedObservable.add(o=>{o.deviceType===K.Mouse?o.onInputChangedObservable.add(h=>{this._originMouseEvent=h,h.inputIndex===$.LeftClick||h.inputIndex===$.MiddleClick||h.inputIndex===$.RightClick||h.inputIndex===$.BrowserBack||h.inputIndex===$.BrowserForward?t&&o.getInput(h.inputIndex)===1?this._onPointerDown(h):e&&o.getInput(h.inputIndex)===0&&this._onPointerUp(h):i&&(h.inputIndex===$.Move?this._onPointerMove(h):(h.inputIndex===$.MouseWheelX||h.inputIndex===$.MouseWheelY||h.inputIndex===$.MouseWheelZ)&&this._onPointerMove(h))}):o.deviceType===K.Touch?o.onInputChangedObservable.add(h=>{h.inputIndex===$.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===$.Move&&this._onPointerMove(h)}):o.deviceType===K.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 je(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 je(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]}}Ne.DragMovementThreshold=10;Ne.LongPressDelay=500;Ne.DoubleClickDelay=300;Ne.ExclusiveDoubleClickMode=!1;class Gt{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){Gt.Enabled&&(this._current+=e,t&&this._fetchResult())}beginMonitoring(){Gt.Enabled&&(this._startMonitoringTime=Dt.Now)}endMonitoring(e=!0){if(!Gt.Enabled)return;e&&this.fetchNewFrame();const t=Dt.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=Dt.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)}}Gt.Enabled=!0;class to{static get UniqueId(){const e=this._UniqueIdCounter;return this._UniqueIdCounter++,e}}to._UniqueIdCounter=1;class lc{constructor(){this.pointerDownFastCheck=!1,this.pointerUpFastCheck=!1,this.pointerMoveFastCheck=!1,this.skipPointerMovePicking=!1,this.skipPointerDownPicking=!1,this.skipPointerUpPicking=!1}}var Wn;(function(a){a[a.BackwardCompatible=0]="BackwardCompatible",a[a.Intermediate=1]="Intermediate",a[a.Aggressive=2]="Aggressive"})(Wn||(Wn={}));class Xe{static DefaultMaterialFactory(e){throw ee("StandardMaterial")}static CollisionCoordinatorFactory(){throw ee("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=[];return e=e.concat(this.meshes),e=e.concat(this.lights),e=e.concat(this.cameras),e=e.concat(this.transformNodes),this.skeletons.forEach(t=>e=e.concat(t.bones)),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 Ne.DragMovementThreshold}static set DragMovementThreshold(e){Ne.DragMovementThreshold=e}static get LongPressDelay(){return Ne.LongPressDelay}static set LongPressDelay(e){Ne.LongPressDelay=e}static get DoubleClickDelay(){return Ne.DoubleClickDelay}static set DoubleClickDelay(e){Ne.DoubleClickDelay=e}static get ExclusiveDoubleClickMode(){return Ne.ExclusiveDoubleClickMode}static set ExclusiveDoubleClickMode(e){Ne.ExclusiveDoubleClickMode=e}bindEyePosition(e,t="vEyePosition",i=!1){const s=this._forcedViewPosition?this._forcedViewPosition:this._mirroredCameraPosition?this._mirroredCameraPosition:this.activeCamera?.globalPosition??_.ZeroReadOnly,r=this.useRightHandedSystem===(this._mirroredCameraPosition!=null);return C.Vector4[0].set(s.x,s.y,s.z,r?-1:1),e&&(i?e.setFloat3(t,C.Vector4[0].x,C.Vector4[0].y,C.Vector4[0].z):e.setVector4(t,C.Vector4[0])),C.Vector4[0]}finalizeSceneUbo(){const e=this.getSceneUniformBuffer(),t=this.bindEyePosition(null);return e.updateFloat4("vEyePosition",t.x,t.y,t.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=Aa(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 Xe.DefaultMaterialFactory!==Xe._OriginalDefaultMaterialFactory}get defaultMaterial(){return this._defaultMaterial||(this._defaultMaterial=Xe.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)}set skeletonsEnabled(e){this._skeletonsEnabled!==e&&(this._skeletonsEnabled=e,this.markAllMaterialsAsDirty(8))}get skeletonsEnabled(){return this._skeletonsEnabled}get collisionCoordinator(){return this._collisionCoordinator||(this._collisionCoordinator=Xe.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}constructor(e,t){this._inputManager=new Ne(this),this.cameraToUseForPointers=null,this._isScene=!0,this._blockEntityCollection=!1,this.autoClear=!0,this.autoClearDepthAndStencil=!0,this._clearColor=new le(.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.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.hoverCursor="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.onNewMaterialAddedObservable=new O,this.onNewMultiMaterialAddedObservable=new O,this.onMaterialRemovedObservable=new O,this.onMultiMaterialRemovedObservable=new O,this.onNewTextureAddedObservable=new O,this.onTextureRemovedObservable=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 bi(256),this._pointerPickingConfiguration=new lc,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=Xe.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 bi(256),this.proceduralTexturesEnabled=!0,this._totalVertices=new Gt,this._activeIndices=new Gt,this._activeParticles=new Gt,this._activeBones=new Gt,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=new Array,this._isDisposed=!1,this.dispatchAllSubMeshesOfActiveMeshes=!1,this._activeMeshes=new rt(256),this._processedMaterials=new rt(256),this._renderTargets=new bi(256),this._materialsRenderTargets=new bi(256),this._activeParticleSystems=new rt(256),this._activeSkeletons=new bi(32),this._softwareSkinnedMeshes=new bi(32),this._activeAnimatables=new Array,this._transformMatrix=M.Zero(),this.requireLightSorting=!1,this._components=[],this._serializableComponents=[],this._transientComponents=[],this._beforeCameraUpdateStage=we.Create(),this._beforeClearStage=we.Create(),this._beforeRenderTargetClearStage=we.Create(),this._gatherRenderTargetsStage=we.Create(),this._gatherActiveCameraRenderTargetsStage=we.Create(),this._isReadyForMeshStage=we.Create(),this._beforeEvaluateActiveMeshStage=we.Create(),this._evaluateSubMeshStage=we.Create(),this._preActiveMeshStage=we.Create(),this._cameraDrawRenderTargetStage=we.Create(),this._beforeCameraDrawStage=we.Create(),this._beforeRenderTargetDrawStage=we.Create(),this._beforeRenderingGroupDrawStage=we.Create(),this._beforeRenderingMeshStage=we.Create(),this._afterRenderingMeshStage=we.Create(),this._afterRenderingGroupDrawStage=we.Create(),this._afterCameraDrawStage=we.Create(),this._afterCameraPostProcessStage=we.Create(),this._afterRenderTargetDrawStage=we.Create(),this._afterRenderTargetPostProcessStage=we.Create(),this._afterRenderStage=we.Create(),this._pointerMoveStage=we.Create(),this._pointerDownStage=we.Create(),this._pointerUpStage=we.Create(),this._geometriesByUniqueId=null,this._defaultMeshCandidates={data:[],length:0},this._defaultSubMeshCandidates={data:[],length:0},this._preventFreeActiveMeshesAndRenderingGroups=!1,this._activeMeshesFrozen=!1,this._activeMeshesFrozenButKeepClipping=!1,this._skipEvaluateActiveMeshesCompletely=!1,this._useCurrentFrameBuffer=!1,this._allowPostProcessClearColor=!0,this.getDeterministicFrameTime=()=>this._engine.getTimeStep(),this._registeredActions=0,this._blockMaterialDirtyMechanism=!1,this._perfCollector=null,this.activeCameras=[];const i={useGeometryUniqueIdsMap:!0,useMaterialMeshMap:!0,useClonedMeshMap:!0,virtual:!1,...t};e=this._engine=e||de.LastCreatedEngine,i.virtual?e._virtualScenes.push(this):(de._LastCreatedScene=this,e.scenes.push(this)),this._uid=null,this._renderingManager=new st(this),Nr&&(this.postProcessManager=new Nr(this)),et()&&this.attachControl(),this._createUbo(),ae&&(this._imageProcessingConfiguration=new ae),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;for(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)}whenReadyAsync(e=!1){return new Promise(t=>{this.executeWhenReady(()=>{t()},e)})}_checkIsReady(e=!1){if(this._registerTransientComponents(),this.isReady(e)){this.onReadyObservable.notifyObservers(this),this.onReadyObservable.clear(),this._executeWhenReadyTimeoutId=null;return}if(this._isDisposed){this.onReadyObservable.clear(),this._executeWhenReadyTimeoutId=null;return}this._executeWhenReadyTimeoutId=setTimeout(()=>{this.incrementRenderId(),this._checkIsReady(e)},100)}get animatables(){return this._activeAnimatables}resetLastAnimationTimeFrame(){this._animationTimeLast=Dt.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?It.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=It.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){const t=new W(this._engine,void 0,!1,e??"scene");return t.addUniform("viewProjection",16),t.addUniform("view",16),t.addUniform("projection",16),t.addUniform("vEyePosition",4),t}setSceneUniformBuffer(e){this._sceneUbo=e,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1}getUniqueId(){return t
vendor: 12,550 bytes, line 30
30o.UniqueId}addMesh(e,t=!1){this._blockEntityCollection||(this.meshes.push(e),e._resyncLightSources(),e.parent||e._addToSceneRootNodes(),B.SetImmediate(()=>{this.onNewMeshAddedObservable.notifyObservers(e)}),t&&e.getChildMeshes().forEach(i=>{this.addMesh(i)}))}removeMesh(e,t=!1){const i=this.meshes.indexOf(e);return i!==-1&&(this.meshes.splice(i,1),e.parent||e._removeFromSceneRootNodes()),this._inputManager._invalidateMesh(e),this.onMeshRemovedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach(s=>{this.removeMesh(s)}),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()}return this.onLightRemovedObservable.notifyObservers(e),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)),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),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}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());B.SetImmediate(()=>{this.onNewLightAddedObservable.notifyObservers(e)})}}sortLightsByPriority(){this.requireLightSorting&&this.lights.sort(me.CompareLightsPriority)}addCamera(e){this._blockEntityCollection||(this.cameras.push(e),B.SetImmediate(()=>{this.onNewCameraAddedObservable.notifyObservers(e)}),e.parent||e._addToSceneRootNodes())}addSkeleton(e){this._blockEntityCollection||(this.skeletons.push(e),B.SetImmediate(()=>{this.onNewSkeletonAddedObservable.notifyObservers(e)}))}addParticleSystem(e){this._blockEntityCollection||this.particleSystems.push(e)}addAnimation(e){this._blockEntityCollection||this.animations.push(e)}addAnimationGroup(e){this._blockEntityCollection||this.animationGroups.push(e)}addMultiMaterial(e){this._blockEntityCollection||(this.multiMaterials.push(e),B.SetImmediate(()=>{this.onNewMultiMaterialAddedObservable.notifyObservers(e)}))}addMaterial(e){this._blockEntityCollection||e.getScene()===this&&e._indexInSceneMaterialArray!==-1||(e._indexInSceneMaterialArray=this.materials.length,this.materials.push(e),B.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))}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._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),B.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);if(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=B.RandomId()),this._uid}addExternalData(e,t){return this._externalData||(this._externalData=new 
30wn),this._externalData.add(e,t)}getExternalData(e){return this._externalData?this._externalData.get(e):null}getOrAddExternalDataWithFactory(e,t){return this._externalData||(this._externalData=new w
vendor: 28,236 bytes, line 30
30n),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){return this.executeWhenReady(()=>{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)}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&&(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 n=!0;e._renderingMultiview&&e.outputRenderTarget&&(n=e.outputRenderTarget.skipInitialClear,this.autoClear&&(this._defaultFrameBufferCleared=!1,e.outputRenderTarget.skipInitialClear=!1)),this._bindFrameBuffer(this._activeCamera),e._renderingMultiview&&e.outputRenderTarget&&(e.outputRenderTarget.skipInitialClear=n)}this.updateTransformMatrix(),this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),this._evaluateActiveMeshes();for(let n=0;n<this._softwareSkinnedMeshes.length;n++){const o=this._softwareSkinnedMeshes.data[n];o.applySkeleton(o.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 n of this._gatherActiveCameraRenderTargetsStage)n.action(this._renderTargets);let r=!1;if(this.renderTargetsEnabled){if(this._intermediateRendering=!0,this._renderTargets.length>0){B.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(let n=0;n<this._renderTargets.length;n++){const o=this._renderTargets.data[n];if(o._shouldRender()){this._renderId++;const h=o.activeCamera&&o.activeCamera!==this.activeCamera;o.render(h,this.dumpNextRenderTargets),r=!0}}B.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._renderId++}for(const n of this._cameraDrawRenderTargetStage)r=n.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 n of this._beforeCameraDrawStage)n.action(this.activeCamera);this.onBeforeDrawPhaseObservable.notifyObservers(this),s.snapshotRendering&&s.snapshotRenderingMode===1&&this.finalizeSceneUbo(),this._renderingManager.render(null,null,!0,!0),this.onAfterDrawPhaseObservable.notifyObservers(this);for(const n of this._afterCameraDrawStage)n.action(this.activeCamera);if(this.postProcessManager&&!e._multiviewTexture){const n=e.outputRenderTarget?e.outputRenderTarget.renderTarget:void 0;this.postProcessManager._finalizeFrame(e.isIntermediate,n)}for(const n of this._afterCameraPostProcessStage)n.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(je.CreateNew(t,void 0,n)),t._intersectionsInProgress.push(n)):s.trigger===13&&t._intersectionsInProgress.push(n):!o&&h>-1&&(s.trigger===13&&s._executeCurrent(je.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(Xe.MinDeltaTime,Math.min(this._engine.getDeltaTime(),Xe.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(Xe.MinDeltaTime,Math.min(this._engine.getDeltaTime(),Xe.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){if(this.activeCamera=null,this._activeParticleSystems.reset(),this._activeSkeletons.reset(),e){for(const r of this.cameras)if(r.update(),r.cameraRigMode!==0)for(let n=0;n<r._rigCameras.length;n++)r._rigCameras[n].update()}for(const r of this._beforeClearStage)r.action();const i=this.getActiveMeshCandidates(),s=i.length;for(let r=0;r<s;r++){const n=i.data[r];n.isBlocked||(this._totalVertices.addCount(n.getTotalVertices(),!1),!(!n.isReady()||!n.isEnabled()||n.scaling.hasAZeroComponent)&&(n.computeWorldMatrix(),n.actionManager&&n.actionManager.hasSpecificTriggers2(12,13)&&this._meshesForIntersections.pushNoDuplicate(n)))}if(this.particlesEnabled)for(let r=0;r<this.particleSystems.length;r++){const n=this.particleSystems[r];if(!n.isStarted()||!n.emitter)continue;const o=n.emitter;(!o.position||o.isEnabled())&&(this._activeParticleSystems.push(n),n.animate())}this.frameGraph?.execute()}render(e=!0,t=!1){if(!this.isDisposed){this.onReadyObservable.hasObservers()&&this._executeWhenReadyTimeoutId===null&&this._checkIsReady(),this._frameId++,this._defaultFrameBufferCleared=!1,this._checkCameraRenderTarget(this.activeCamera),this.activeCameras?.length&&this.activeCameras.forEach(this._checkCameraRenderTarget),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.onBeforeRenderObservable.notifyObservers(this),this.customRenderFunction)this._renderId++,this._engine.currentRenderPassId=0,this.customRenderFunction(e,t);else{const i=this.getEngine();this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);const s=this.activeCameras?.length?this.activeCameras[0]:this.activeCamera;if(this.renderTargetsEnabled){B.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!0;for(let r=0;r<this.customRenderTargets.length;r++){const n=this.customRenderTargets[r];if(n._shouldRender()){if(this._renderId++,this.activeCamera=n.activeCamera||this.activeCamera,!this.activeCamera)throw new Error("Active camera not set");i.setViewport(this.activeCamera.viewport),this.updateTransformMatrix(),n.render(s!==this.activeCamera,this.dumpNextRenderTargets)}}B.EndPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!1,this._renderId++}this._engine.currentRenderPassId=s?.renderPassId??0,this.activeCamera=s,this._activeCamera&&this._activeCamera.cameraRigMode!==22&&!this.prePass&&this._bindFrameBuffer(this._activeCamera,!1),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(const r of this._beforeClearStage)r.action();this._clearFrameBuffer(this.activeCamera);for(const r of this._gatherRenderTargetsStage)r.action(this._renderTargets);if(this.activeCameras&&this.activeCameras.length>0)for(let r=0;r<this.activeCameras.length;r++)this._processSubCameras(this.activeCameras[r],r>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;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&&(this._activeAnimatables.forEach(r=>{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){F.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._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),de._LastCreatedScene===this){de._LastCreatedScene=null;let r=de.Instances.length-1;for(;r>=0;){const n=de.Instances[r];if(n.scenes.length>0){de._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.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}_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);return e=e||(()=>!0),this.meshes.filter(e).forEach(s=>{if(s.computeWorldMatrix(!0),!s.subMeshes||s.subMeshes.length===0||s.infiniteDistance)return;const r=s.getBoundingInfo(),n=r.boundingBox.minimumWorld,o=r.boundingBox.maximumWorld;_.CheckExtends(n,t,i),_.CheckExtends(o,t,i)}),{min:t,max:i}}createPickingRay(e,t,i,s,r=!1){throw ee("Ray")}createPickingRayToRef(e,t,i,s,r,n=!1,o=!1){throw ee("Ray")}createPickingRayInCameraSpace(e,t,i){throw ee("Ray")}createPickingRayInCameraSpaceToRef(e,t,i,s){throw ee("Ray")}pick(e,t,i,s,r,n){const o=ee("Ray",!0);return o&&F.Warn(o),new as}pickWithBoundingInfo(e,t,i,s,r){const n=ee("Ray",!0);return n&&F.Warn(n),new as}pickWithRay(e,t,i,s){throw ee("Ray")}multiPick(e,t,i,s,r){throw ee("Ray")}multiPickWithRay(e,t,i){throw ee("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];pe&&pe.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=gi(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}_loadFileAsync(e,t,i,s,r){return 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=Yr(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}_requestFileAsync(e,t,i,s,r){return 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=ss(e,t,i,s,r);return this._activeRequests.push(n),n.onCompleteObservable.add(o=>{this._activeRequests.splice(this._activeRequests.indexOf(o),1)}),n}_readFileAsync(e,t,i){return new Promise((s,r)=>{this._readFile(e,n=>{s(n)},t,i,n=>{r(n)})})}getPerfCollector(){throw ee("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)}}Xe.FOGMODE_NONE=0;Xe.FOGMODE_EXP=1;Xe.FOGMODE_EXP2=2;Xe.FOGMODE_LINEAR=3;Xe.MinDeltaTime=1;Xe.MaxDeltaTime=1e3;Xe._OriginalDefaultMaterialFactory=Xe.DefaultMaterialFactory;it("BABYLON.Scene",Xe);function 
vendor: 5,328 bytes, line 30
30cc(a,e){const t=e.method||"GET";return new Promise((i,s)=>{const r=new tt;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 Xn;(function(a){a[a.Clean=0]="Clean",a[a.Stop=1]="Stop",a[a.Sync=2]="Sync",a[a.NoSync=3]="NoSync"})(Xn||(Xn={}));function uc(a){return!!a.createPlugin}function dc(a){return!!a.name}const fc=new O,ii={};function en(){return ii[".babylon"]}function _c(a){for(const e in ii){const t=ii[e];if(t.mimeType===a)return t}}function Kn(a,e){const t=ii[a];return t||(F.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?en():void 0)}function gc(a){for(const e in ii){const t=ii[e].plugin;if(t.canDirectLoad&&t.canDirectLoad(a))return ii[e]}return en()}function pc(a){const e=a.indexOf("?");e!==-1&&(a=a.substring(0,e));const t=a.lastIndexOf(".");return a.substring(t,a.length).toLowerCase()}function mc(a){return a.substring(0,5)==="data:"?a.substring(5):null}function Tc(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 bc(a,e,t,i,s,r,n,o,h){const l=mc(a.url);if(a.rawData&&!n)throw"When using ArrayBufferView to load data the file extension must be provided.";const c=!l&&!n?pc(a.url):"";let u=n?Kn(n,!0):l?gc(a.url):Kn(c,!1);if(!u&&c){if(a.url&&!a.url.startsWith("blob:")){const d=await cc(a.url,{method:"HEAD",responseHeaders:["Content-Type"]}),g=d.headerValues?d.headerValues["Content-Type"]:"";g&&(u=_c(g))}u||(u=en())}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(uc(u.plugin)){const m=u.plugin.createPlugin(h??{});return m instanceof Promise?(m.then(d).catch(b=>{s("Error instantiating plugin.",b)}),null):(d(m),m)}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(fc.notifyObservers(d),l&&(d.canDirectLoad&&d.canDirectLoad(a.url)||!qr(a.url))){if(d.directLoad){const x=d.directLoad(e,l);x instanceof Promise?x.then(R=>{t(d,R)}).catch(R=>{s("Error in directLoad of _loadData: "+R,R)}):t(d,x)}else t(d,l);return}const g=u.isBinary,m=(x,R)=>{if(e.isDisposed){s("Scene has been disposed");return}t(d,x,R)};let b=null,y=!1;d.onDisposeObservable?.add(()=>{y=!0,b&&(b.abort(),b=null),r()});const A=()=>{if(y)return;const x=(R,S)=>{s(R?.statusText,S)};if(!d.loadFile&&a.rawData)throw"Plugin does not support loading ArrayBufferView.";b=d.loadFile?d.loadFile(e,a.rawData||a.file||a.url,a.rootUrl,m,i,g,x,o):e._loadFile(a.file||a.url,m,i,!0,g,x)},P=e.getEngine();let I=P.enableOfflineSupport;if(I){let x=!1;for(const R of e.disableOfflineSupportExceptionRules)if(R.test(a.url)){x=!0;break}I=!x}I&&H.OfflineProviderFactory?e.offlineProvider=H.OfflineProviderFactory(a.url,A,P.disableManifestCheck):A()})}function Ac(a,e){let t,i,s=null,r=null;if(!e)t=a,i=B.GetFilename(a),a=B.GetFolderPath(a);else if(dc(e))t=`file:${e.name}`,i=e.name,s=e;else if(ArrayBuffer.isView(e))t="",i=jr(),r=e;else if(e.startsWith("data:"))t=e,i="";else if(a){const n=e;if(n.substring(0,1)==="/")return B.Error("Wrong sceneFilename parameter"),null;t=a+n,i=n}else t=e,i=B.GetFilename(e),a=B.GetFolderPath(e);return{url:t,rootUrl:a,name:i,file:s,rawData:r}}function Os(a){if(typeof a.extensions=="string"){const e=a.extensions;ii[e.toLowerCase()]={plugin:a,isBinary:!1}}else{const e=a.extensions;Object.keys(e).forEach(t=>{ii[t.toLowerCase()]={plugin:a,isBinary:e[t].isBinary,mimeType:e[t].mimeType}})}}async function Ec(a,e="",t=de.LastCreatedScene,i=null,s=null,r=null,n=null,o="",h={}){if(!t)return F.Error("No scene available to load asset container to"),null;const l=Ac(a,e);if(!l)return null;const c={};t.addPendingData(c);const u=()=>{t.removePendingData(c)},f=(m,b)=>{const y=Tc(l,m,b);r?r(t,y,new Ii(y,ms.SceneLoaderError,b)):F.Error(y),u()},d=s?m=>{try{s(m)}catch(b){f("Error in onProgress callback",b)}}:void 0,g=m=>{if(i)try{i(m)}catch(b){f("Error in onSuccess callback",b)}t.removePendingData(c)};return await bc(l,t,(m,b)=>{if(m.loadAssetContainer){const A=m.loadAssetContainer(t,b,l.rootUrl,f);if(!A)return;A.populateRootNodes(),t.loadingPluginName=m.name,g(A)}else m.loadAssetContainerAsync?m.loadAssetContainerAsync(t,b,l.rootUrl,d,l.name).then(A=>{A.populateRootNodes(),t.loadingPluginName=m.name,g(A)}).catch(A=>{f(A.message,A)}):f("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.")},d,f,u,n,o,h)}function Rc(a,e,t){const{rootUrl:i="",onProgress:s,pluginExtension:r,name:n,pluginOptions:o}=t??{};return yc(i,a,e,s,r,n,o)}function yc(a,e,t,i,s,r,n){return new Promise((o,h)=>{try{E
vendor: 10,343 bytes, line 30
30c(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 tn{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=yt.Zero(),this._cachedBaseSize=yt.Zero(),this._initialSamplingMode=2,this._texture=tn._IsRenderTargetWrapper(e)?e.texture:e,this._texture&&(this._engine=this._texture.getEngine())}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){this._texture&&this._engine&&this._engine.updateTextureSamplingMode(e,this._texture,this._texture.generateMipMaps)}releaseInternalTexture(){this._texture&&(this._texture.dispose(),this._texture=null)}dispose(){this._texture&&(this.releaseInternalTexture(),this._engine=null)}}class Me extends tn{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=jr()),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=Me.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,this._isCube=!1,this._gammaSpace=!0,this.invertZ=!1,this.lodLevelInAlpha=!1,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?Me._IsScene(e)?this._scene=e:this._engine=e:this._scene=de.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 M.IdentityReadOnly}getReflectionTextureMatrix(){return M.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=re.Serialize(this);return re.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"}}Me.DEFAULT_ANISOTROPIC_FILTERING_LEVEL=4;p([E()],Me.prototype,"uniqueId",void 0);p([E()],Me.prototype,"name",void 0);p([E()],Me.prototype,"displayName",void 0);p([E()],Me.prototype,"metadata",void 0);p([E("hasAlpha")],Me.prototype,"_hasAlpha",void 0);p([E("getAlphaFromRGB")],Me.prototype,"_getAlphaFromRGB",void 0);p([E()],Me.prototype,"level",void 0);p([E("coordinatesIndex")],Me.prototype,"_coordinatesIndex",void 0);p([E()],Me.prototype,"optimizeUVAllocation",void 0);p([E("coordinatesMode")],Me.prototype,"_coordinatesMode",void 0);p([E()],Me.prototype,"wrapU",null);p([E()],Me.prototype,"wrapV",null);p([E()],Me.prototype,"wrapR",void 0);p([E()],Me.prototype,"anisotropicFilteringLevel",void 0);p([E()],Me.prototype,"isCube",null);p([E()],Me.prototype,"is3D",null);p([E()],Me.prototype,"is2DArray",null);p([E()],Me.prototype,"gammaSpace",null);p([E()],Me.prototype,"invertZ",void 0);p([E()],Me.prototype,"lodLevelInAlpha",void 0);p([E()],Me.prototype,"lodGenerationOffset",null);p([E()],Me.prototype,"lodGenerationScale",null);p([E()],Me.prototype,"linearSpecularLOD",null);p([Ie()],Me.prototype,"irradianceTexture",null);p([E()],Me.prototype,"isRenderTarget",void 0);function 
vendor: 2,896 bytes, line 30
30io(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 xc(a,e=0,t=0){const i=a.getInternalTexture();if(!i)return null;const s=a._readPixelsSync(e,t);return s?io(s,a.getSize(),i.invertY):null}async function Sc(a,e=0,t=0){const i=a.getInternalTexture();if(!i)return null;const s=await a.readPixels(e,t);return s?io(s,a.getSize(),i.invertY):null}class V extends Me{static _CreateVideoTexture(e,t,i,s=!1,r=!1,n=V.TRILINEAR_SAMPLINGMODE,o={},h,l=5){throw ee("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=V.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 m,b=!1,y=null,A=!0;typeof i=="object"&&i!==null?(m=i.noMipmap??!1,s=i.invertY??!Mn,r=i.samplingMode??V.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,b=i.useSRGBBuffer??!1,y=i.internalTexture??null,A=i.gammaSpace??A,g=i.forcedExtension??g):m=!!i,this._gammaSpace=A,this._noMipmap=m,this._invertY=s===void 0?!Mn
vendor: 8,734 bytes, line 30
30:s,this._initialSamplingMode=r,this._buffer=h,this._deleteBuffer=l,this._mimeType=u,this._loaderOptions=f,this._creationFlags=d,this._useSRGBBuffer=b,this._forcedExtension=g,c&&(this._format=c);const P=this.getScene(),I=this._getEngine();if(!I)return;I.onBeforeTextureInitObservable.notifyObservers(this);const x=()=>{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&&P&&P.resetCachedMaterial()},R=(S,D)=>{this._loadingError=!0,this._errorObject={message:S,exception:D},o&&o(S,D),V.OnTextureLoadErrorObservable.notifyObservers(this)};if(!this.url&&!y){this._delayedOnLoad=x,this._delayedOnError=R;return}if(this._texture=y??this._getFromCache(this.url,m,r,this._invertY,b,this.isCube),this._texture)if(this._texture.isReady)is.SetImmediate(()=>x());else{const S=this._texture.onLoadedObservable.add(x);this._texture.onErrorObservable.add(D=>{R(D.message,D.exception),this._texture?.onLoadedObservable.remove(S)})}else if(!P||!P.useDelayedTextureLoading){try{this._texture=I.createTexture(this.url,m,this._invertY,P,r,x,R,this._buffer,void 0,this._format,this._forcedExtension,u,f,d,b)}catch(S){throw R("error loading",S),S}l&&(this._buffer=null)}else this.delayLoadState=4,this._delayedOnLoad=x,this._delayedOnError=R}updateURL(e,t=null,i,s){this.url&&(this.releaseInternalTexture(),this.getScene().markAllMaterialsAsDirty(1,r=>r.hasTexture(this))),(!this.name||this.name.startsWith("data:"))&&(this.name=e),this.url=e,this._buffer=t,this._forcedExtension=s,this.delayLoadState=4,i&&(this._delayedOnLoad=i),this.delayLoad()}delayLoad(){if(this.delayLoadState!==4)return;const e=this.getScene();e&&(this.delayLoadState=1,this._texture=this._getFromCache(this.url,this._noMipmap,this.samplingMode,this._invertY,this._useSRGBBuffer,this.isCube),this._texture?this._delayedOnLoad&&(this._texture.isReady?is.SetImmediate(this._delayedOnLoad):this._texture.onLoadedObservable.add(this._delayedOnLoad)):(this._texture=e.getEngine().createTexture(this.url,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=M.Zero(),this._rowGenerationMatrix=new M,this._t0=_.Zero(),this._t1=_.Zero(),this._t2=_.Zero()),M.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this.homogeneousRotationInUVTransform?(M.TranslationToRef(-this._cachedURotationCenter,-this._cachedVRotationCenter,-this._cachedWRotationCenter,C.Matrix[0]),M.TranslationToRef(this._cachedURotationCenter,this._cachedVRotationCenter,this._cachedWRotationCenter,C.Matrix[1]),M.ScalingToRef(this._cachedUScale,this._cachedVScale,0,C.Matrix[2]),M.TranslationToRef(this._cachedUOffset,this._cachedVOffset,0,C.Matrix[3]),C.Matrix[0].multiplyToRef(this._rowGenerationMatrix,this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(C.Matrix[1],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(C.Matrix[2],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(C.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),M.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===V.PROJECTION_MODE){if(this._cachedReflectionProjectionMatrixId===e.getProjectionMatrix().updateFlag)return this._cachedReflectionTextureMatrix}else return this._cachedReflectionTextureMatrix;this._cachedReflectionTextureMatrix||(this._cachedReflectionTextureMatrix=M.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=M.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 V.PLANAR_MODE:{M.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 V.PROJECTION_MODE:{M.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:M.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 re.Clone(()=>new V(this._texture?this._texture.url:null,this.getScene(),e),this)}serialize(){const e=this.name;V.SerializeBuffers||this.name.startsWith("data:")&&(this.name=""),this.name.startsWith("data:")&&this.url===this.name&&(this.url="");const t=super.serialize(V._SerializeInternalTextureUniqueId);if(!t)return null;if(V.SerializeBuffers||V.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,${
30Pa(this._buffer)}`}else(V.ForceSerializeBuffers||this.url&&this.url.startsWith("blob:")||this._forceSerialize)&&(t.base64String=!this._engine||this._engine._features.supportSyncTextureRead?xc(this):Sc(this));return t.invertY=this._invertY,t.samplingMode=this.samplingMode,t._creationFlags=this._creationFlags,t._useSRGBBuffer=this._useSRGBBuffer,V._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=$i.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 V._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=fi("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 re.Parse(()=>{let h=!0;if(e.noMipmap&&(h=!1),e.mirrorPlane){const l=V._CreateMirror(e.name,e.renderTargetSize,t,h);return l._waitingRenderList=e.renderList,l.mirrorPlane=Pt.FromArray(e.mirrorPlane),n(l),l}else if(e.isRenderTarget){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=V._CreateRenderTargetTexture(e.name,e.renderTargetSize,t,h,e._creationFlags??0),l._waitingRenderList=e.renderList;return n(l),l}else if(e.isVideo){const l=V._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=V.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:")||V.UseSerializedUrlIfAny)&&(c=e.url);const u={noMipmap:!h,invertY:e.invertY,samplingMode:e.samplingMode,onLoad:()=>{n(l)},internalTexture:r};l=new V(c,t,u)}return l}},e,t)}static CreateFromBase64String(e,t,i,s,r,n=V.TRILINEAR_SAMPLINGMODE,o=null,h=null,l=5,c,u){return new V("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=V.TRILINEAR_SAMPLINGMODE,h=null,l=null,c=5,u,f){return e.substring(0,5)!=="data:"&&(e="data:"+e),new V(e,i,r,n,o,h,l,t,s,c,void 0,void 0,u,f)}}V.SerializeBuffers=!0;V.ForceSerializeBuffers=!1;V.OnTextureLoadErrorObservable=new O;V._SerializeInternalTextureUniqueId=!1;V._CubeTextureParser=(a,e,t)=>{throw ee("CubeTexture")};V._CreateMirror=(a,e,t,i)=>{throw ee("MirrorTexture")};V._CreateRenderTargetTexture=(a,e,t,i,s)=>{throw ee("RenderTargetTexture")};
vendor: 1,861 bytes, lines 30-36
30V.NEAREST_SAMPLINGMODE=1;V.NEAREST_NEAREST_MIPLINEAR=8;V.BILINEAR_SAMPLINGMODE=2;V.LINEAR_LINEAR_MIPNEAREST=11;V.TRILINEAR_SAMPLINGMODE=3;V.LINEAR_LINEAR_MIPLINEAR=3;V.NEAREST_NEAREST_MIPNEAREST=4;V.NEAREST_LINEAR_MIPNEAREST=5;V.NEAREST_LINEAR_MIPLINEAR=6;V.NEAREST_LINEAR=7;V.NEAREST_NEAREST=1;V.LINEAR_NEAREST_MIPNEAREST=9;V.LINEAR_NEAREST_MIPLINEAR=10;V.LINEAR_LINEAR=2;V.LINEAR_NEAREST=12;V.EXPLICIT_MODE=0;V.SPHERICAL_MODE=1;V.PLANAR_MODE=2;V.CUBIC_MODE=3;V.PROJECTION_MODE=4;V.SKYBOX_MODE=5;V.INVCUBIC_MODE=6;V.EQUIRECTANGULAR_MODE=7;V.FIXED_EQUIRECTANGULAR_MODE=8;V.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9;V.CLAMP_ADDRESSMODE=0;V.WRAP_ADDRESSMODE=1;V.MIRROR_ADDRESSMODE=2;V.UseSerializedUrlIfAny=!1;p([E()],V.prototype,"url",void 0);p([E()],V.prototype,"uOffset",void 0);p([E()],V.prototype,"vOffset",void 0);p([E()],V.prototype,"uScale",void 0);p([E()],V.prototype,"vScale",void 0);p([E()],V.prototype,"uAng",void 0);p([E()],V.prototype,"vAng",void 0);p([E()],V.prototype,"wAng",void 0);p([E()],V.prototype,"uRotationCenter",void 0);p([E()],V.prototype,"vRotationCenter",void 0);p([E()],V.prototype,"wRotationCenter",void 0);p([E()],V.prototype,"homogeneousRotationInUVTransform",void 0);p([E()],V.prototype,"isBlocking",null);it("BABYLON.Texture",V);re._TextureParser=V.Parse;const Ur="postprocessVertexShader",so=`attribute vec2 position;uniform vec2 scale;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);
31#define CUSTOM_VERTEX_DEFINITIONS
32void main(void) {
33#define CUSTOM_VERTEX_MAIN_BEGIN
34vUV=(position*madd+madd)*scale;gl_Position=vec4(position,0.0,1.0);
35#define CUSTOM_VERTEX_MAIN_END
36}`;Fe.ShadersStore[Ur]||(Fe.ShadersStore[Ur]=so);const Mc={name:Ur,shader:so},ro=Object.freeze(Object.defineProperty({__proto__:null,postprocessVertexShader:Mc},Symbol.toStringTag,{value:"Module"})),Ar={positions:[1,1,-1,1,-1,-1,1,-1],indices:[0,1,2,0,2,3]};class P
vendor: 4,881 bytes, lines 36-37
36d{constructor(e,t=Ar){this._fullscreenViewport=new ki(0,0,1,1);const i=t.positions??Ar.positions,s=t.indices??Ar.indices;this.engine=e,this._vertexBuffers={[T.PositionKind]:new T(e,i,T.PositionKind,!1,!1,2)},this._indexBuffer=e.createIndexBuffer(s),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){this.engine.setState(!0),this.engine.depthCullingState.depthTest=!1,this.engine.stencilState.stencilTest=!1,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,6)}_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[T.PositionKind];e&&(e.dispose(),delete this._vertexBuffers[T.PositionKind]),this._indexBuffer&&this.engine._releaseBuffer(this._indexBuffer),this._onContextRestoredObserver&&(this.engine.onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)}}class ht{static RegisterShaderCodeProcessing(e,t){if(!t){delete ht._CustomShaderCodeProcessing[e??""];return}ht._CustomShaderCodeProcessing[e??""]=t}static _GetShaderCodeProcessing(e){return ht._CustomShaderCodeProcessing[e]??ht._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},this.options.uniformNames=this.options.uniforms,this.options.samplerNames=this.options.samplers,this.options.vertexShader=this.options.vertexUrl,this.options.useAsPostProcess&&(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 $r(this.options.engine),this._webGPUReady=this.options.shaderLanguage===1;const t=Array.isArray(this.options.defines)?this.options.defines.join(`
37`):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([j(()=>import("./postprocess.vertex-B
371o_Xii7.js"),__vite__mapDeps([16,1,2]),import.meta.url)])):t.push(Promise.all([j(()=>Promise.resolve().then(()=>r
vendor: 7,855 bytes, lines 37-38
37o),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&&!ht.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=ht._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 ke(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)),ht._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)}}ht.ForceGLSL=!1;ht._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)};ke.prototype.setTextureFromPostProcess=function(a,e){this._engine.setTextureFromPostProcess(this._samplers[a],e,a)};ke.prototype.setTextureFromPostProcessOutput=function(a,e){this._engine.setTextureFromPostProcessOutput(this._samplers[a],e,a)};class Ue{static get ForceGLSL(){return ht.ForceGLSL}static set ForceGLSL(e){ht.ForceGLSL=e}static RegisterShaderCodeProcessing(e,t){ht.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,m=5,b,y){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._webGPUReady=!1,this._reusable=!1,this._renderId=0,this.externalTextureSamplerBinding=!1,this._textures=new rt(2),this._textureCache=[],this._currentRenderTextureInd=0,this._scaleRatio=new Z(1,1),this._texelSize=Z.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 A=1,P=null,I;if(i&&!Array.isArray(i)){const x=i;i=x.uniforms??null,s=x.samplers??null,A=x.size??1,n=x.camera??null,o=x.samplingMode??1,h=x.engine,l=x.reusable,c=Array.isArray(x.defines)?x.defines.join(`
38`):x.defines??null,u=x.textureType??0,f=x.vertexUrl??"postprocess",d=x.indexParameters,g=x.blockCompilation??!1,m=x.textureFormat??5,b=x.shaderLanguage??0,P=x.uniformBuffers??null,y=x.extraInitializations,I=x.effectWrapper}else r&&(typeof r=="number"?A=r:A={width:r.width,height:r.height});if(this._useExistingThinPostProcess=!!I,this._effectWrapper=I??new ht({name:e,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:t,engine:h||n?.getScene().getEngine(),uniforms:i,samplers:s,uniformBuffers:P,defines:c,vertexUrl:f,indexParameters:d,blockCompilation:!0,shaderLanguage:b,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.postProcesses.push(this),this.uniqueId=this._scene.getUniqueId()):h&&(this._engine=h,this._engine.postProcesses.push(this)),this._options=A,this.renderTargetSamplingMode=o||1,this._reusable=l||!1,this._textureType=u,this._textureFormat=m,this._shaderLanguage=b||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=P||[],this._indexParameters=d,!this._useExistingThinPostProcess){this._webGPUReady=this._shaderLanguage===1;const x=[];this._gatherImports(this._engine.isWebGPU&&!Ue.ForceGLSL,x),this._effectWrapper._webGPUReady=this._webGPUReady,this._effectWrapper._postConstructor(g,c,y,x)}}_gatherImports(e=!1,t){e&&this._webGPUReady?t.push(Promise.all([j(()=>import("./postprocess.vertex-B
381o_Xii7.js"),__vite__mapDeps([16,1,2]),import.meta.url)])):t.push(Promise.all([j(()=>Promise.resolve().then(()=>r
vendor: 8,700 bytes, lines 38-39
38o),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 rt(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(`
39`):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?ns(c,o,this.scaleMode):c),this._options.height||(u=n.needPOTTextures?ns(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.postProcesses.indexOf(this),t!==-1&&this._scene.postProcesses.splice(t,1)),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=re.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=Ue.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=fi(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 re.Parse(()=>new Ue(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)}}p([E()],Ue.prototype,"uniqueId",void 0);p([E()],Ue.prototype,"name",null);p([E()],Ue.prototype,"width",void 0);p([E()],Ue.prototype,"height",void 0);p([E()],Ue.prototype,"renderTargetSamplingMode",void 0);p([
39ba()],Ue.prototype,"clearColor",void 0);p([E()],Ue.prototype,"autoClear",void 0);p([E()],Ue.prototype,"forceAutoClearInAlphaMode",void 0);p([E()],Ue.prototype,"alphaMode",null);p([E()],Ue.prototype,"alphaConstants",void 0);p([E()],Ue.prototype,"enablePixelPerfectMode",void 0);p([E()],Ue.prototype,"forceFullscreenViewport",void 0);p([E()],Ue.prototype,"scaleMode",void 0);p([E()],Ue.prototype,"alwaysForcePOT",void 0);p([E("samples")],Ue.prototype,"_samples",void 0);p([E()],Ue.prototype,"adaptScaleToCurrentViewport",void 0);it("BABYLON.PostProcess",Ue);class Nt{get renderList(){return this._renderList}set renderList(e){this._renderList!==e&&(this._unObserveRenderList&&(this._unObserveRenderList(),this._unObserveRenderList=null),e&&(this._unObserveRenderList=A
vendor: 19,487 bytes, line 39
39a(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 name(){return this._name}set name(e){if(this._name===e||(this._name=e,!this._scene))return;const t=this._scene.getEngine();for(let i=0;i<this._renderPassIds.length;++i){const s=this._renderPassIds[i];t._renderPassNames[s]=`${this._name}#${i}`}}get renderPassIds(){return this._renderPassIds}get currentRefreshId(){return this._currentRefreshId}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)}}constructor(e,t,i){this._unObserveRenderList=null,this._renderListHasChanged=(s,r)=>{const n=this._renderList?this._renderList.length:0;(r===0&&n>0||n===0)&&this._scene.meshes.forEach(o=>{o._markSubMeshesAsLightDirty()})},this.particleSystemList=null,this.getCustomRenderList=null,this.renderParticles=!0,this.renderSprites=!1,this.forceLayerMaskCheck=!1,this._disableImageProcessing=!1,this.onBeforeRenderObservable=new O,this.onAfterRenderObservable=new O,this.onBeforeRenderingManagerRenderObservable=new O,this.onAfterRenderingManagerRenderObservable=new O,this.onFastPathRenderObservable=new O,this._currentRefreshId=-1,this._refreshRate=1,this._currentApplyByPostProcessSetting=!1,this._currentSceneCamera=null,this.name=e,this._scene=t,this.renderList=[],this._renderPassIds=[],this.options={numPasses:1,doNotChangeAspectRatio:!0,...i},this._createRenderPassId(),this.renderPassId=this._renderPassIds[0],this._renderingManager=new st(t),this._renderingManager._useSceneAutoClearSetup=!0}_releaseRenderPassId(){const e=this._scene.getEngine();for(let t=0;t<this.options.numPasses;++t)e.releaseRenderPassId(this._renderPassIds[t]);this._renderPassIds.length=0}_createRenderPassId(){this._releaseRenderPassId();const e=this._scene.getEngine();for(let t=0;t<this.options.numPasses;++t)this._renderPassIds[t]=e.createRenderPassId(`${this.name}#${t}`)}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._currentRefreshId=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._scene.getEngine(),s=this.activeCamera??this._scene.activeCamera;this._currentSceneCamera=this._scene.activeCamera,s&&(s!==this._scene.activeCamera&&(this._scene.setTransformMatrix(s.getViewMatrix(),s.getProjectionMatrix(!0)),this._scene.activeCamera=s),i.setViewport(s.rigParent?s.rigParent.viewport:s.viewport,e,t)),this._defaultRenderListPrepared=!1}finishRender(){const e=this._scene;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)),e.getEngine().setViewport(this._currentSceneCamera.viewport)),e.resetCachedMaterial()}render(e=0,t=!1){const i=this._scene,s=i.getEngine(),r=s.currentRenderPassId;if(s.currentRenderPassId=this._renderPassIds[e],this.onBeforeRenderObservable.notifyObservers(e),s.snapshotRendering&&s.snapshotRenderingMode===1)this.onFastPathRenderObservable.notifyObservers(e);else{let o=null;const h=this.renderList?this.renderList:i.getActiveMeshes().data,l=this.renderList?this.renderList.length:i.getActiveMeshes().length;this.getCustomRenderList&&(o=this.getCustomRenderList(e,h,l)),o?this._prepareRenderingManager(o,o.length,this.forceLayerMaskCheck):(this._defaultRenderListPrepared||(this._prepareRenderingManager(h,l,!this.renderList||this.forceLayerMaskCheck),this._defaultRenderListPrepared=!0),o=h),this.onBeforeRenderingManagerRenderObservable.notifyObservers(e),this._renderingManager.render(this.customRenderFunction,o,this.renderParticles,this.renderSprites),this.onAfterRenderingManagerRenderObservable.notifyObservers(e)}t||this.onAfterRenderObservable.notifyObservers(e),s.currentRenderPassId=r}_checkReadiness(){const e=this._scene,t=e.getEngine(),i=t.currentRenderPassId;let s=!0;e.getViewMatrix()||e.updateTransformMatrix();const r=this.options.numPasses;for(let o=0;o<r&&s;o++){let h=null;const l=this.renderList?this.renderList:e.getActiveMeshes().data,c=this.renderList?this.renderList.length:e.getActiveMeshes().length;t.currentRenderPassId=this._renderPassIds[o],this.onBeforeRenderObservable.notifyObservers(o),this.getCustomRenderList&&(h=this.getCustomRenderList(o,l,c)),h||(h=l),this.options.doNotChangeAspectRatio||e.updateTransformMatrix(!0);for(let u=0;u<h.length&&s;++u){const f=h[u];if(!(!f.isEnabled()||f.isBlocked||!f.isVisible||!f.subMeshes)){if(this.customIsReadyFunction){if(!this.customIsReadyFunction(f,this.refreshRate,!0)){s=!1;continue}}else if(!f.isReady(!0)){s=!1;continue}}}this.onAfterRenderObservable.notifyObservers(o),r>1&&(e.incrementRenderId(),e.resetCachedMaterial())}const n=this.particleSystemList||e.particleSystems;for(const o of n)o.isReady()||(s=!1);return t.currentRenderPassId=i,s}_prepareRenderingManager(e,t,i){const s=this._scene,r=s.activeCamera,n=this.cameraForLOD??r;this._renderingManager.reset();const o=s.getRenderId(),h=s.getFrameId();for(let c=0;c<t;c++){const u=e[c];if(u&&!u.isBlocked){if(this.customIsReadyFunction){if(!this.customIsReadyFunction(u,this.refreshRate,!1)){this.resetRefreshCounter();continue}}else if(!u.isReady(this.refreshRate===0)){this.resetRefreshCounter();continue}let f=null;if(n){const g=u._internalAbstractMeshDataInfo._currentLOD.get(n);!g||g[1]!==h?(f=s.customLODSelector?s.customLODSelector(u,n):u.getLOD(n),g?(g[0]=f,g[1]=h):u._internalAbstractMeshDataInfo._currentLOD.set(n,[f,h])):f=g[0]}else f=u;if(!f)continue;f!==u&&f.billboardMode!==0&&f.computeWorldMatrix(),f._preActivateForIntermediateRendering(o);let d;if(i&&r?d=(u.layerMask&r.layerMask)===0:d=!1,u.isEnabled()&&u.isVisible&&u.subMeshes&&!d){if(f!==u&&f._activate(o,!0),u._activate(o,!0)&&u.subMeshes.length){u.isAnInstance?u._internalAbstractMeshDataInfo._actAsRegularMesh&&(f=u):f._internalAbstractMeshDataInfo._onlyForInstancesIntermediate=!1,f._internalAbstractMeshDataInfo._isActiveIntermediate=!0,s._prepareSkeleton(f);for(let g=0;g<f.subMeshes.length;g++){const m=f.subMeshes[g];this._renderingManager.dispatch(m,f)}}u._postActivate()}}}const l=this.particleSystemList||s.particleSystems;for(let c=0;c<l.length;c++){const u=l[c],f=u.emitter;!u.isStarted()||!f||f.position&&!f.isEnabled()||this._renderingManager.dispatchParticles(u)}}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),this._renderingManager._useSceneAutoClearSetup=!1}clone(){const e=new Nt(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.getMaterialForRenderPass(this.renderPassId)!==void 0&&s.setMaterialForRenderPass(this.renderPassId,void 0)}this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderingManagerRenderObservable.clear(),this.onAfterRenderingManagerRenderObservable.clear(),this.onFastPathRenderObservable.clear(),this._releaseRenderPassId(),this.renderList=null}_rebuild(){this.refreshRate===Nt.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=Nt.REFRESHRATE_RENDER_ONCE)}freeRenderingGroups(){this._renderingManager&&this._renderingManager.freeRenderingGroups()}}Nt.REFRESHRATE_RENDER_ONCE=0;Nt.REFRESHRATE_RENDER_ONEVERYFRAME=1;Nt.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2;ke.prototype.setDepthStencilTexture=function(a,e){this._engine.setDepthStencilTexture(this._samplers[a],this._uniforms[a],e,a)};class Xi extends V{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 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}get 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=V.TRILINEAR_SAMPLINGMODE,l=!0,c=!1,u=!1,f=5,d=!1,g,m,b=!1,y=!1){let A,P=!0,I;if(typeof s=="object"){const R=s;s=!!R.generateMipMaps,r=R.doNotChangeAspectRatio??!0,n=R.type??0,o=!!R.isCube,h=R.samplingMode??V.TRILINEAR_SAMPLINGMODE,l=R.generateDepthBuffer??!0,c=!!R.generateStencilBuffer,u=!!R.isMulti,f=R.format??5,d=!!R.delayAllocation,g=R.samples,m=R.creationFlags,b=!!R.noColorAttachment,y=!!R.useSRGBBuffer,A=R.colorAttachment,P=R.gammaSpace??P,I=R.existingObjectRenderer}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=P,this._coordinatesMode=V.PROJECTION_MODE,this.name=e,this.isRenderTarget=!0,this._initialSizeParameter=t,this._dontDisposeObjectRenderer=!!I,this._processSizeParameter(t),this._objectRenderer=I??new Nt(e,i,{numPasses:o?6:this.getRenderLayers()||1,doNotChangeAspectRatio:r}),this._onBeforeRenderingManagerRenderObserver=this._objectRenderer.onBeforeRenderingManagerRenderObservable.add(()=>{if(!this._disableEngineStages)for(const R of this._scene._beforeRenderTargetClearStage)R.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 R of this._scene._beforeRenderTargetDrawStage)R.action(this,this._currentFaceIndex,this._currentLayer)}),this._onAfterRenderingManagerRenderObserver=this._objectRenderer.onAfterRenderingManagerRenderObservable.add(()=>{if(!this._disableEngineStages)for(const S of this._scene._afterRenderTargetDrawStage)S.action(this,this._currentFaceIndex,this._currentLayer);const R=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 S of this._scene._afterRenderTargetPostProcessStage)S.action(this,this._currentFaceIndex,this._currentLayer);this._texture&&(this._texture.generateMipMaps=R),this._doNotChangeAspectRatio||this._scene.updateTransformMatrix(!0),this._currentDumpForDebug&&(this._dumpTools?this._dumpTools.DumpFramebuffer(this.getRenderWidth(),this.getRenderHeight(),x):F.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:m,noColorAttachment:b,useSRGBBuffer:y,colorAttachment:A,label:this.name},this.samplingMode===V.NEAREST_SAMPLINGMODE&&(this.wrapU=V.CLAMP_ADDRESSMODE,this.wrapV=V.CLAMP_ADDRESSMODE),d||(o?(this._renderTarget=i.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions),this.coordinatesMode=V.INVCUBIC_MODE,this._textureMatrix=M.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 Nr(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,j(()=>import("./dumpTools-
39FN1JTOHi.js"),__vite__mapDeps([9,1,2]),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
vendor: 5,176 bytes, lines 39-40
39inishRender()}}_bestReflectionRenderTargetDimension(e,t){const s=e*t,r=Wa(s+128*128/(128+s));return Math.min(Zr(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):(!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),n._debugPushGroup?.(`render to face #${e} layer #${s}`,2),this._objectRenderer.render(e+s,!0),n._debugPopGroup?.(2),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 Xi(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}}Xi.REFRESHRATE_RENDER_ONCE=Nt.REFRESHRATE_RENDER_ONCE;Xi.REFRESHRATE_RENDER_ONEVERYFRAME=Nt.REFRESHRATE_RENDER_ONEVERYFRAME;Xi.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=Nt.REFRESHRATE_RENDER_ONEVERYTWOFRAMES;V._CreateRenderTargetTexture=(a,e,t,i,s)=>new Xi(a,e,t,i);function Ic(a){return a.getPipelineContext===void 0}class Cc{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 Pc=/(flat\s)?\s*varying\s*.*/;class vc{constructor(){this.shaderLanguage=0}attributeProcessor(e){return e.replace("attribute","in")}varyingCheck(e,t){return Pc.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;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?"":`layout(location = 0) out vec4 glFragColor;
40`)+"void main(")}else if(t.indexOf("#define MULTIVIEW")!==-1)return`#extension GL_OVR_multiview2 : require
41layout (num_views = 2) in;
42`+e;return e}}class ls extends bs{constructor(e){super(),this._buffer=e}get underlyingResource(){return this._buffer}}class no{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 Yn(a){return a===13||a===14||a===15||a===16||a===17||a===18||a===19}function vd(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 cs(a){return a===13||a===17||a===18||a===19}class Dc{}class oe extends H{get name(){return this._name}set name(e){this._name=e}get version(){return this._webGLVersion}static get ShadersRepository(){return ke.ShadersRepository}static set ShadersRepository(e){ke.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 oe.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,b=new RegExp(d).exec(h);if(b&&b.length>0&&parseInt(b[b.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=()=>{pr(this._gl)}:(this._onContextLost=h=>{h.preventDefault(),this._contextWasLost=!0,pr(this._gl),F.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 Dc;this._shaderProcessor=this.webGLVersion>1?new vc:new C
vendor: 25,941 bytes, line 42
42c;const n=`Babylon.js v${oe.Version}`;F.Log(n+` - ${this.description}`),this._renderingCanvas&&this._renderingCanvas.setAttribute&&this._renderingCanvas.setAttribute("data-engine",n);const o=At(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),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")),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")},this._caps.supportFloatTexturesResolve=this._caps.colorBufferFloat,this._caps.rg11b10ufColorRenderable=this._caps.colorBufferFloat,this._glVersion=this._gl.getParameter(this._gl.VERSION);const e=this._gl.getExtension("WEBGL_debug_renderer_info");if(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),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 t=this._gl.getExtension("WEBGL_draw_buffers");if(t!==null){this._caps.drawBuffersExtension=!0,this._gl.drawBuffers=t.drawBuffersWEBGL.bind(t),this._caps.maxDrawBuffers=this._gl.getParameter(t.MAX_DRAW_BUFFERS_WEBGL),this._gl.DRAW_FRAMEBUFFER=this._gl.FRAMEBUFFER;for(let i=0;i<16;i++)this._gl["COLOR_ATTACHMENT"+i+"_WEBGL"]=t["COLOR_ATTACHMENT"+i+"_WEBGL"]}}if(this._webGLVersion>1)this._caps.depthTextureExtension=!0;else{const t=this._gl.getExtension("WEBGL_depth_texture");t!=null&&(this._caps.depthTextureExtension=!0,this._gl.UNSIGNED_INT_24_8=t.UNSIGNED_INT_24_8_WEBGL)}if(this.disableVertexArrayObjects)this._caps.vertexArrayObject=!1;else if(this._webGLVersion>1)this._caps.vertexArrayObject=!0;else{const t=this._gl.getExtension("OES_vertex_array_object");t!=null&&(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=t.createVertexArrayOES.bind(t),this._gl.bindVertexArray=t.bindVertexArrayOES.bind(t),this._gl.deleteVertexArray=t.deleteVertexArrayOES.bind(t))}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{const t=this._gl.getExtension("ANGLE_instanced_arrays");t!=null?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=t.drawArraysInstancedANGLE.bind(t),this._gl.drawElementsInstanced=t.drawElementsInstancedANGLE.bind(t),this._gl.vertexAttribDivisor=t.vertexAttribDivisorANGLE.bind(t)):this._caps.instancedArrays=!1}if(this._gl.getShaderPrecisionFormat){const t=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.HIGH_FLOAT),i=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);t&&i&&(this._caps.highPrecisionShaderSupported=t.precision!==0&&i.precision!==0)}if(this._webGLVersion>1)this._caps.blendMinMax=!0;else{const t=this._gl.getExtension("EXT_blend_minmax");t!=null&&(this._caps.blendMinMax=!0,this._gl.MAX=t.MAX_EXT,this._gl.MIN=t.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 t=this._gl.getExtension("EXT_sRGB");t!=null&&(this._caps.supportSRGBBuffers=!0,this._glSRGBExtensionValues={SRGB:t.SRGB_EXT,SRGB8:t.SRGB_ALPHA_EXT,SRGB8_ALPHA8:t.SRGB_ALPHA_EXT})}if(this._creationOptions){const t=this._creationOptions.forceSRGBBufferSupportState;t!==void 0&&(this._caps.supportSRGBBuffers=this._caps.supportSRGBBuffers&&t)}}this._depthCullingState.depthTest=!0,this._depthCullingState.depthFunc=this._gl.LEQUAL,this._depthCullingState.depthMask=!0,this._maxSimultaneousTextures=this._caps.maxCombinedTexturesImageUnits;for(let t=0;t<this._maxSimultaneousTextures;t++)this._nextFreeTextureSlots.push(t);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,supportSwitchCaseInShader: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){const r=this.stencilStateComposer.useStencilGlobalOnly;this.stencilStateComposer.useStencilGlobalOnly=!0,this.applyStates(),this.stencilStateComposer.useStencilGlobalOnly=r;let n=0;if(t&&e){let o=!0;if(this._currentRenderTarget){const h=this._currentRenderTarget.texture?.format;if(h===8||h===9||h===10||h===11){const l=this._currentRenderTarget.texture?.type;l===7||l===5?(oe._TempClearColorUint32[0]=e.r*255,oe._TempClearColorUint32[1]=e.g*255,oe._TempClearColorUint32[2]=e.b*255,oe._TempClearColorUint32[3]=e.a*255,this._gl.clearBufferuiv(this._gl.COLOR,0,oe._TempClearColorUint32),o=!1):(oe._TempClearColorInt32[0]=e.r*255,oe._TempClearColorInt32[1]=e.g*255,oe._TempClearColorInt32[2]=e.b*255,oe._TempClearColorInt32[3]=e.a*255,this._gl.clearBufferiv(this._gl.COLOR,0,oe._TempClearColorInt32),o=!1)}}o&&(this._gl.clearColor(e.r,e.g,e.b,e.a!==void 0?e.a:1),n|=this._gl.COLOR_BUFFER_BIT)}i&&(this.useReverseDepthBuffer?(this._depthCullingState.depthFunc=this._gl.GEQUAL,this._gl.clearDepth(0)):this._gl.clearDepth(1),n|=this._gl.DEPTH_BUFFER_BIT),s&&(this._gl.clearStencil(0),n|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(n)}_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.unBindFramebuffer(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)&&F.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}_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=!1,i){const s=e;this._currentRenderTarget=null,s.disableAutomaticMSAAResolve||(e.isMulti?this.resolveMultiFramebuffer(e):this.resolveFramebuffer(e)),t||(e.isMulti?this.generateMipMapsMultiFramebuffer(e):this.generateMipMapsFramebuffer(e)),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 ls(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 ls(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: 16,860 bytes, line 42
42Ua(t),this._gl&&this._gl.deleteProgram(t.program))}_getGlobalDefines(e){return Fa(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(),m=t.attributes!==void 0;let b=r??t.defines??"";g&&(b+=g);const y=f+"+"+d+"@"+b;if(this._compiledEffects[y]){const P=this._compiledEffects[y];return o&&P.isReady()&&o(P),P._refCount++,P}this._gl&&At(this._gl);const A=new ke(e,t,m?this:i,s,this,r,n,o,h,l,y,t.shaderLanguage??c,t.extraInitializationsAsync??u);return this._compiledEffects[y]=A,A}_getShaderSource(e){return this._gl.getShaderSource(e)}createRawShaderProgram(e,t,i,s,r=null){const n=At(this._gl);return n._contextWasLost=this._contextWasLost,n.validateShaderPrograms=this.validateShaderPrograms,Ba(e,t,i,s||this._gl,r)}createShaderProgram(e,t,i,s,r,n=null){const o=At(this._gl);return o._contextWasLost=this._contextWasLost,o.validateShaderPrograms=this.validateShaderPrograms,Na(e,t,i,s,r||this._gl,n)}inlineShaderCode(e){return e}createPipelineContext(e){if(this._gl){const i=At(this._gl);i.parallelShaderCompile=this._caps.parallelShaderCompile}const t=vh(this._gl);return t.engine=this,t}createMaterialContext(){}createDrawContext(){}_finalizePipelineContext(e){return zr(e,this._gl,this.validateShaderPrograms)}_preparePipelineContext(e,t,i,s,r,n,o,h,l,c,u){const f=At(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),Oh(e,t,i,s,r,n,o,h,l,c,u)}_createShaderProgram(e,t,i,s,r=null){return Gr(e,t,i,s,r)}_isRenderingStateCompiled(e){return this._isDisposed?!1:Dh(e,this._gl,this.validateShaderPrograms)}_executeWhenRenderingStateIsCompiled(e,t){wh(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&&Ic(e)?e.effect:e,!(!e||e===this._currentEffect)&&(this._stencilStateComposer.stencilMaterial=void 0,e=e,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._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._alphaMode=1,this._alphaEquation=0,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 no(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;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):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,F.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));const m=Yn(l),b=cs(l),y=this._gl,A=new Et(this,s),P=e.width||e,I=e.height||e,x=e.depth||0,R=e.layers||0,S=this._getSamplingParameters(h,(r||n)&&!m),D=R!==0?y.TEXTURE_2D_ARRAY:x!==0?y.TEXTURE_3D:y.TEXTURE_2D,G=m?this._getInternalFormatFromDepthTextureFormat(l,!0,b):this._getRGBABufferInternalSizedFormat(o,l,c),X=m?b?y.DEPTH_STENCIL:y.DEPTH_COMPONENT:this._getInternalFormat(l),Re=m?this._getWebGLTextureTypeFromDepthTextureFormat(l):this._getWebGLTextureType(o);if(this._bindTextureDirectly(D,A),R!==0?(A.is2DArray=!0,y.texImage3D(D,0,G,P,I,R,0,X,Re,null)):x!==0?(A.is3D=!0,y.texImage3D(D,0,G,P,I,x,0,X,Re,null)):y.texImage2D(D,0,G,P,I,0,X,Re,null),y.texParameteri(D,y.TEXTURE_MAG_FILTER,S.mag),y.texParameteri(D,y.TEXTURE_MIN_FILTER,S.min),y.texParameteri(D,y.TEXTURE_WRAP_S,y.CLAMP_TO_EDGE),y.texParameteri(D,y.TEXTURE_WRAP_T,y.CLAMP_TO_EDGE),m&&this.webGLVersion>1&&(g===0?(y.texParameteri(D,y.TEXTURE_COMPARE_FUNC,515),y.texParameteri(D,y.TEXTURE_COMPARE_MODE,y.NONE)):(y.texParameteri(D,y.TEXTURE_COMPARE_FUNC,g),y.texParameteri(D,y.TEXTURE_COMPARE_MODE,y.COMPARE_REF_TO_TEXTURE))),(r||n)&&this._gl.generateMipmap(D),this._bindTextureDirectly(D,null),A._useSRGBBuffer=c,A.baseWidth=P,A.baseHeight=I,A.width=P,A.height=I,A.depth=R||x,A.isReady=!0,A.samples=u,A.generateMipMaps=r,A.samplingMode=h,A.type=o,A.format=l,A.label=f,A.comparisonFunction=g,this._internalTexturesCache.push(A),d){let fe=null;if(Yn(A.format)?fe=this._setupFramebufferDepthAttachments(cs(A.format),A.format!==19,A.width,A.height,u,A.format,!0):fe=this._createRenderBuffer(A.width,A.height,u,-1,this._getRGBABufferInternalSizedFormat(A.type,A.format,A._useSRGBBuffer),-1),!fe)throw new Error("Unable to create render buffer");A._autoMSAAManagement=!0;let ge=A._hardwareTexture;ge||(ge=A._hardwareTexture=this._createHardwareTexture()),ge.addMSAARenderBuffer(fe)}return A}_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,m){return this._createTextureBase(e,t,i,s,r,n,o,(...b)=>this._prepareWebGLTexture(...b,c),(b,y,A,P,I,x)=>{const R=this._gl,S=A.width===b&&A.height===y;I._creationFlags=g??0;const D=this._getTexImageParametersForCreateTexture(I.format,I._useSRGBBuffer);if(S)return R.texImage2D(R.TEXTURE_2D,0,D.internalFormat,D.format,D.type,A),!1;const G=this._caps.maxTextureSize;if(A.width>G||A.height>G||!this._supportsHardwareTextureRescaling)return this._prepareWorkingCanvas(),!this._workingCanvas||!this._workingContext||(this._workingCanvas.width=b,this._workingCanvas.height=y,this._workingContext.drawImage(A,0,0,A.width,A.height,0,0,b,y),R.texImage2D(R.TEXTURE_2D,0,D.internalFormat,D.format,D.type,this._workingCanvas),I.width=b,I.height=y),!1;{const X=new Et(this,2);this._bindTextureDirectly(R.TEXTURE_2D,X,!0),R.texImage2D(R.TEXTURE_2D,0,D.internalFormat,D.format,D.type,A),this._rescaleTexture(X,I,s,D.format,()=>{this._releaseTexture(X),this._bindTextureDirectly(R.TEXTURE_2D,I,!0),x()})}return!0},h,l,c,u,f,d,m)}_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}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)),m=n?e.height:Math.pow(2,Math.max(d-s,0));o.texImage2D(u,s,c,g,m,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?ns(s.width,u):s.width),d=Math.min(u,this.needPOTTextures?ns(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&&(F
vendor: 13,899 bytes, line 42
42h(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 F.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(){et()&&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(),pr(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 F.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&&!!window.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}}oe._TempClearColorUint32=new Uint32Array(4);oe._TempClearColorInt32=new Int32Array(4);oe.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"]}];oe._ConcatenateShader=
vendor: 17,495 bytes, line 42
42Da;oe._IsSupported=null;oe._HasMajorPerformanceCaveat=null;const Dd=Object.freeze(Object.defineProperty({__proto__:null,ThinEngine:oe},Symbol.toStringTag,{value:"Module"}));class Oc{constructor(e=30){this._enabled=!0,this._rollingFrameTime=new Fc(e)}sampleFrame(e=Dt.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 Fc{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}}oe.prototype.setAlphaMode=function(a,e=!1){if(this._alphaMode===a){if(!e){const t=a===0;this.depthCullingState.depthMask!==t&&(this.depthCullingState.depthMask=t)}return}switch(a){case 0:this._alphaState.alphaBlend=!1;break;case 7:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 8:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case 2:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 6:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 1:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 3:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 4:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR,this._gl.ZERO,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 5:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 9:this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR,this._gl.ONE_MINUS_CONSTANT_COLOR,this._gl.CONSTANT_ALPHA,this._gl.ONE_MINUS_CONSTANT_ALPHA),this._alphaState.alphaBlend=!0;break;case 10:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case 11:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 12:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ZERO),this._alphaState.alphaBlend=!0;break;case 13:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE_MINUS_DST_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case 14:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case 15:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ONE,this._gl.ZERO),this._alphaState.alphaBlend=!0;break;case 16:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 17:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break}e||(this.depthCullingState.depthMask=a===0),this._alphaMode=a};oe.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};oe.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};oe.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,F.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):c===this._gl.HALF_FLOAT_OES&&!this._caps.textureHalfFloatLinearFiltering?(s=!1,n=1,F.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,F.Warn("Render to float textures is not supported. Mipmap generation forced to false.")):c===h.HALF_FLOAT&&!this._caps.colorBufferFloat&&(s=!1,F.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||rs(l.width)&&rs(l.height)||(s=!1),a)this.updateRawCubeTexture(l,a,t,i,r,o);else{const b=this._getRGBABufferInternalSizedFormat(i),y=0;this._bindTextureDirectly(h.TEXTURE_CUBE_MAP,l,!0);for(let A=0;A<6;A++)o?h.compressedTexImage2D(h.TEXTURE_CUBE_MAP_POSITIVE_X+A,y,this.getCaps().s3tc[o],l.width,l.height,0,void 0):h.texImage2D(h.TEXTURE_CUBE_MAP_POSITIVE_X+A,y,b,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 m=this._getSamplingParameters(n,s);return h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MAG_FILTER,m.mag),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MIN_FILTER,m.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};oe.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=ao(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||rs(a.width)&&rs(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};oe.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=(b,y)=>{e?.removePendingData(d),l&&b&&l(b.status+" "+b.statusText,y)},m=b=>{if(!d._hardwareTexture)return;const y=d.width,A=n(b);if(A){if(o){const P=this._getWebGLTextureType(s);let I=this._getInternalFormat(i);const x=this._getRGBABufferInternalSizedFormat(s);let R=!1;I===f.RGB&&(I=f.RGBA,R=!0),this._bindTextureDirectly(f.TEXTURE_CUBE_MAP,d,!0),this._unpackFlipY(!1);const S=o(A);for(let D=0;D<S.length;D++){const G=y>>D;for(let X=0;X<6;X++){let Re=S[D][X];R&&(Re=ao(Re,G,G,s)),f.texImage2D(X,D,x,G,G,0,I,P,Re)}}this._bindTextureDirectly(f.TEXTURE_CUBE_MAP,null)}else this.updateRawCubeTexture(d,A,i,s,u);d.isReady=!0,e?.removePendingData(d),d.onLoadedObservable.notifyObservers(d),d.onLoadedObservable.clear(),h&&h()}};return this._loadFile(a,b=>{m(b)},void 0,e?.offlineProvider,!0,g),d};function ao(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 oo(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.type=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}}oe.prototype.createRawTexture2DArray=oo(!1);oe.prototype.createRawTexture3D=oo(!0);function ho(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}}oe.prototype.updateRawTexture2DArray=ho(!1);oe.prototype.updateRawTexture3D=ho(!0);oe.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;if(o)r||(r=ph(a.type,4*e*t));else switch(u){case c.UNSIGNED_BYTE:r||(r=new Uint8Array(4*e*t)),u=c.UNSIGNED_BYTE;break;default:r||(r=new Float32Array(4*e*t)),u=c.FLOAT;break}return n&&this.flushFramebuffer(),c.readPixels(h,l,e,t,c.RGBA,u,r),c.bindFramebuffer(c.FRAMEBUFFER,this._currentFramebuffer),r};oe.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))};oe.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()};oe.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()};oe.prototype._createDepthStencilCubeTexture=function(a,e){const t=new Et(this,12);if(t.isCube=!0,this.webGLVersion===1)return F.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};oe.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)};oe.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 m=this._gl;return this.createCubeTextureBase(a,e,t,!!i,s,r,n,o,h,l,c,u,b=>this._bindTextureDirectly(m.TEXTURE_CUBE_MAP,b,!0),(b,y)=>{const A=this.needPOTTextures?ns(y[0].width,this._caps.maxCubemapTextureSize):y[0].width,P=A,I=[m.TEXTURE_CUBE_MAP_POSITIVE_X,m.TEXTURE_CUBE_MAP_POSITIVE_Y,m.TEXTURE_CUBE_MAP_POSITIVE_Z,m.TEXTURE_CUBE_MAP_NEGATIVE_X,m.TEXTURE_CUBE_MAP_NEGATIVE_Y,m.TEXTURE_CUBE_MAP_NEGATIVE_Z];this._bindTextureDirectly(m.TEXTURE_CUBE_MAP,b,!0),this._unpackFlipY(!1);const x=n?this._getInternalFormat(n,b._useSRGBBuffer):b._useSRGBBuffer?this._glSRGBExtensionValues.SRGB8_ALPHA8:m.RGBA;let R=n?this._getInternalFormat(n):m.RGBA;b._useSRGBBuffer&&this.webGLVersion===1&&(R=x);for(let S=0;S<I.length;S++)if(y[S].width!==A||y[S].height!==P){if(this._prepareWorkingCanvas(),!this._workingCanvas||!this._workingContext){F.Warn("Cannot create canvas to resize texture.");return}this._workingCanvas.width=A,this._workingCanvas.height=P,this._workingContext.drawImage(y[S],0,0,y[S].width,y[S].height,0,0,A,P),m.texImage2D(I[S],0,x,R,m.UNSIGNED_BYTE,this._workingCanvas)}else m.texImage2D(I[S],0,x,R,m.UNSIGNED_BYTE,y[S]);i||m.generateMipmap(m.TEXTURE_CUBE_MAP),this._setCubeMapTextureParams(b,!i),b.width=A,b.height=P,b.isReady=!0,n&&(b.format=n),b.onLoadedObservable.notifyObservers(b),b.onLoadedObservable.clear(),s&&s()},!!d,g)};oe.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 w
vendor: 6,378 bytes, line 42
42c{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=cs(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._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._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 y=0;y<s;++y){const A=t[y];o.push(A.samplingMode),h.push(A.type),l.push(A.format),g[A.uniqueId]!==void 0?(c.push(-1),d.push(0)):(g[A.uniqueId]=y,A.is2DArray?(c.push(35866),d.push(A.depth)):A.isCube?(c.push(34067),d.push(0)):A.is3D?(c.push(32879),d.push(A.depth)):(c.push(3553),d.push(0))),this._faceIndices&&u.push(this._faceIndices[y]??0),this._layerIndices&&f.push(this._layerIndices[y]??0)}const m={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},b={width:this.width,height:this.height,depth:this.depth};e=this._engine.createMultipleRenderTarget(b,m);for(let y=0;y<s;++y){if(c[y]!==-1)continue;const A=g[t[y].uniqueId];e.setTexture(e.textures[A],y)}}}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 
vendor: 48,509 bytes, line 42
42Lc extends wc{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,cs(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)};oe.prototype._createHardwareRenderTargetWrapper=function(a,e,t){const i=new Lc(a,e,t,this,this._gl);return this._renderTargetWrapperCache.push(i),i};oe.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 m=n._hardwareTexture.getMSAARenderBuffer(0);t._MSAAFramebuffer=d.createFramebuffer(),this._bindUnboundFramebuffer(t._MSAAFramebuffer),d.framebufferRenderbuffer(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.RENDERBUFFER,m),this._bindUnboundFramebuffer(null)}return t};oe.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 F.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 F.Error(`Depth texture ${h.depthTextureFormat} format is not supported.`),o;o.format=h.depthTextureFormat}else o.format=h.generateStencil?13:16;const l=cs(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};oe.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};oe.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)))};oe.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))};oe.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,F.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 Ht=[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))],Bc=[()=>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],jt=(a,e)=>Ht[a]*Bc[a](e),Zt=[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 us{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){C.Vector3[0].set(t.r,t.g,t.b);const s=C.Vector3[0],r=C.Vector3[1];s.scaleToRef(i,r),r.scaleToRef(jt(0,e),C.Vector3[2]),this.l00.addInPlace(C.Vector3[2]),r.scaleToRef(jt(1,e),C.Vector3[2]),this.l1_1.addInPlace(C.Vector3[2]),r.scaleToRef(jt(2,e),C.Vector3[2]),this.l10.addInPlace(C.Vector3[2]),r.scaleToRef(jt(3,e),C.Vector3[2]),this.l11.addInPlace(C.Vector3[2]),r.scaleToRef(jt(4,e),C.Vector3[2]),this.l2_2.addInPlace(C.Vector3[2]),r.scaleToRef(jt(5,e),C.Vector3[2]),this.l2_1.addInPlace(C.Vector3[2]),r.scaleToRef(jt(6,e),C.Vector3[2]),this.l20.addInPlace(C.Vector3[2]),r.scaleToRef(jt(7,e),C.Vector3[2]),this.l21.addInPlace(C.Vector3[2]),r.scaleToRef(jt(8,e),C.Vector3[2]),this.l22.addInPlace(C.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(Zt[0]),this.l1_1.scaleInPlace(Zt[1]),this.l10.scaleInPlace(Zt[2]),this.l11.scaleInPlace(Zt[3]),this.l2_2.scaleInPlace(Zt[4]),this.l2_1.scaleInPlace(Zt[5]),this.l20.scaleInPlace(Zt[6]),this.l21.scaleInPlace(Zt[7]),this.l22.scaleInPlace(Zt[8])}convertIrradianceToLambertianRadiance(){this.scaleInPlace(1/Math.PI)}preScaleForRendering(){this.preScaled=!0,this.l00.scaleInPlace(Ht[0]),this.l1_1.scaleInPlace(Ht[1]),this.l10.scaleInPlace(Ht[2]),this.l11.scaleInPlace(Ht[3]),this.l2_2.scaleInPlace(Ht[4]),this.l2_1.scaleInPlace(Ht[5]),this.l20.scaleInPlace(Ht[6]),this.l21.scaleInPlace(Ht[7]),this.l22.scaleInPlace(Ht[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 us().updateFromArray(e)}static FromPolynomial(e){const t=new us;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 ds{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=us.FromPolynomial(this)),this._harmonics.preScaled||this._harmonics.preScaleForRendering(),this._harmonics}addAmbient(e){C.Vector3[0].copyFromFloats(e.r,e.g,e.b);const t=C.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),C.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),C.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),this.xx.scaleInPlace(.886277).subtractInPlace(C.Vector3[0]).addInPlace(C.Vector3[1]),this.yy.copyFrom(e.l00),this.yy.scaleInPlace(.886277).subtractInPlace(C.Vector3[0]).subtractInPlace(C.Vector3[1]),this.zz.copyFrom(e.l00),C.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),this.zz.scaleInPlace(.886277).addInPlace(C.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 ds().updateFromHarmonics(e)}static FromArray(e){const t=new ds;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}}oe.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=new ds,u._source=9,this.getCaps().textureLOD){s&&s(u);return}const f=3,d=this._gl,g=c.width;if(!g)return;const{DDSTools:m}=await j(()=>import("./dds-DixzcEvL.js"),__vite__mapDeps([4,5,1,2]),import.meta.url),b=[];for(let y=0;y<f;y++){const P=1-y/(f-1),I=i,x=Math.log2(g)*t+i,R=I+(x-I)*P,S=Math.round(Math.min(Math.max(R,0),x)),D=new Et(this,2);if(D.type=u.type,D.format=u.format,D.width=Math.pow(2,Math.max(Math.log2(g)-S,0)),D.height=D.width,D.isCube=!0,D._cachedWrapU=0,D._cachedWrapV=0,this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,D,!0),D.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 X=c.info,Re=c.data;this._unpackFlipY(X.isCompressed),m.UploadDDSLevels(this,D,Re,X,!0,6,S)}else F.Warn("DDS is the only prefiltered cube map supported so far.");this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,null);const G=new Me(e);G._isCube=!0,G._texture=D,D.isReady=!0,b.push(G)}u._lodTextureHigh=b[2],u._lodTextureMid=b[1],u._lodTextureLow=b[0],s&&s(u)};return this.createCubeTexture(a,e,null,!1,l,r,n,o,h,t,i)};oe.prototype.createUniformBuffer=function(a,e){const t=this._gl.createBuffer();if(!t)throw new Error("Unable to create uniform buffer");const i=new ls(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};oe.prototype.createDynamicUniformBuffer=function(a,e){const t=this._gl.createBuffer();if(!t)throw new Error("Unable to create dynamic uniform buffer");const i=new ls(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};oe.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)};oe.prototype.bindUniformBuffer=function(a){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,a?a.underlyingResource:null)};oe.prototype.bindUniformBufferBase=function(a,e,t){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,e,a?a.underlyingResource:null)};oe.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(!et())return;const a=this.loadingScreen;a&&a.displayLoadingUI()};H.prototype.hideLoadingUI=function(){if(!et())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});Object.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){if(this._alphaEquation!==a){switch(a){case 0:this._alphaState.setAlphaEquationParameters(32774,32774);break;case 1:this._alphaState.setAlphaEquationParameters(32778,32778);break;case 2:this._alphaState.setAlphaEquationParameters(32779,32779);break;case 3:this._alphaState.setAlphaEquationParameters(32776,32776);break;case 4:this._alphaState.setAlphaEquationParameters(32775,32775);break;case 5:this._alphaState.setAlphaEquationParameters(32775,32774);break}this._alphaEquation=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.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.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.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.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail};H.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass};H.prototype.setStencilOperationFail=function(a){this._stencilState.stencilOpStencilFail=a};H.prototype.setStencilOperationDepthFail=function(a){this._stencilState.stencilOpDepthFail=a};H.prototype.setStencilOperationPass=function(a){this._stencilState.stencilOpStencilDepthPass=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.setAlphaConstants=function(a,e,t,i){this._alphaState.setAlphaBlendConstants(a,e,t,i)};H.prototype.getAlphaMode=function(){return this._alphaMode};H.prototype.getAlphaEquation=function(){return this._alphaEquation};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)}}};function Nc(a){!a||!a.setAttribute||(a.setAttribute("touch-action","none"),a.style.touchAction="none",a.style.webkitTapHighlightColor="transparent")}function Uc(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||Nc(e),!H.audioEngine&&t.audioEngine&&H.AudioEngineFactory&&(H.audioEngine=H.AudioEngineFactory(a.getRenderingCanvas(),a.getAudioContext(),a.getAudioDestination())),Zi()&&(a._onFullscreenChange=()=>{a.isFullscreen=!!document.fullscreenElement,a.isFullscreen&&a._pointerLockRequested&&e&&lo(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 kc(a,e){de.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)),Zi()&&(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 Vc(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}}function Hc(a,e,t){return new Promise((s,r)=>{const n=new Image;n.onload=()=>{n.decode().then(()=>{a.createImageBitmap(n,t).then(o=>{s(o)})})},n.onerror=()=>{r(`Error loading image ${n.src}`)},n.src=e})}function Gc(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 zc(a){const e=a.requestFullscreen||a.webkitRequestFullscreen;e&&e.call(a)}function Wc(){const a=document;document.exitFullscreen?document.exitFullscreen():a.webkitCancelFullScreen&&a.webkitCancelFullScreen()}function lo(a){if(a.requestPointerLock){const e=a.requestPointerLock();e instanceof Promise?e.then(()=>{a.focus()}).catch(()=>{}):a.focus()}}function Xc(){document.exitPointerLock&&document.exitPointerLock()}class k extends oe{static get NpmPackage(){return H.NpmPackage}static get Version(){return H.Version}static get Instances(){return de.Instances}static get LastCreatedEngine(){return de.LastCreatedEngine}static get LastCreatedScene(){return de.LastCreatedScene}static DefaultLoadingScreenFactory(e){return H.DefaultLoadingScreenFactory(e)}get _supportsHardwareTextureRescaling(){return!!k._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 Oc,this._drawCalls=new Gt,e&&(this._features.supportRenderPasses=!0,i=this._creationOptions)}_initGLContext(){super._initGLContext(),this._rescalePostProcess=null}_sharedInit(e){super._sharedInit(e),Uc(this,e,this._creationOptions)}resizeImageBitmap(e,t,i){return Gc(this,e,t,i)}_createImageBitmapFromSource(e,t){return Hc(this,e,t)}switchFullscreen(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)}enterFullscreen(e){this.isFullscreen||(this._pointerLockRequested=e,this._renderingCanvas&&zc(this._renderingCanvas))}exitFullscreen(){this.isFullscreen&&Wc()}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)}_loadFileAsync(e,t,i){return new Promise((s,r)=>{this._loadFile(e,n=>{s(n)},void 0,t,i,(n,o)=>{r(o)})})}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 Vc(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&&lo(this._renderingCanvas)}exitPointerlock(){Xc()}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),this.scenes.forEach(t=>{t.postProcesses.forEach(i=>{i._outputTexture===e&&(i._outputTexture=null)}),t.cameras.forEach(i=>{i._postProcesses.forEach(s=>{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&&k._RescalePostProcessFactory&&(this._rescalePostProcess=k._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 no(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){F.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 ls(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)}_clientWaitAsync(e,t=0,i=10){const s=this._gl;return new Promise((r,n)=>{La(()=>{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(),kc(this,this._renderingCanvas),super.dispose()}}k.ALPHA_DISABLE=0;k.ALPHA_ADD=1;k.ALPHA_COMBINE=2;k.ALPHA_SUBTRACT=3;k.ALPHA_MULTIPLY=4;k.ALPHA_MAXIMIZED=5;k.ALPHA_ONEONE=6;k.ALPHA_PREMULTIPLIED=7;k.ALPHA_PREMULTIPLIED_PORTERDUFF=8;k.ALPHA_INTERPOLATE=9;k.ALPHA_SCREENMODE=10;k.DELAYLOADSTATE_NONE=0;k.DELAYLOADSTATE_LOADED=1;k.DELAYLOADSTATE_LOADING=2;k.DELAYLOADSTATE_NOTLOADED=4;k.NEVER=512;k.ALWAYS=519;k.LESS=513;k.EQUAL=514;k.LEQUAL=515;k.GREATER=516;k.GEQUAL=518;k.NOTEQUAL=517;k.KEEP=7680;k.REPLACE=7681;k.INCR=7682;k.DECR=7683;k.INVERT=5386;k.INCR_WRAP=34055;k.DECR_WRAP=34056;k.TEXTURE_CLAMP_ADDRESSMODE=0;k.TEXTURE_WRAP_ADDRESSMODE=1;k.TEXTURE_MIRROR_ADDRESSMODE=2;k.TEXTUREFORMAT_ALPHA=0;k.TEXTUREFORMAT_LUMINANCE=1;k.TEXTUREFORMAT_LUMINANCE_ALPHA=2;k.TEXTUREFORMAT_RGB=4;k.TEXTUREFORMAT_RGBA=5;k.TEXTUREFORMAT_RED=6;k.TEXTUREFORMAT_R=6;k.TEXTUREFORMAT_R16_UNORM=33322;k.TEXTUREFORMAT_RG16_UNORM=33324;k.TEXTUREFORMAT_RGB16_UNORM=32852;k.TEXTUREFORMAT_RGBA16_UNORM=32859;k.TEXTUREFORMAT_R16_SNORM=36760;k.TEXTUREFORMAT_RG16_SNORM=36761;k.TEXTUREFORMAT_RGB16_SNORM=36762;k.TEXTUREFORMAT_RGBA16_SNORM=36763;k.TEXTUREFORMAT_RG=7;k.TEXTUREFORMAT_RED_INTEGER=8;k.TEXTUREFORMAT_R_INTEGER=8;k.TEXTUREFORMAT_RG_INTEGER=9;k.TEXTUREFORMAT_RGB_INTEGER=10;k.TEXTUREFORMAT_RGBA_INTEGER=11;k.TEXTURETYPE_UNSIGNED_BYTE=0;k.TEXTURETYPE_UNSIGNED_INT=0;k.TEXTURETYPE_FLOAT=1;k.TEXTURETYPE_HALF_FLOAT=2;k.TEXTURETYPE_BYTE=3;k.TEXTURETYPE_SHORT=4;k.TEXTURETYPE_UNSIGNED_SHORT=5;k.TEXTURETYPE_INT=6;k.TEXTURETYPE_UNSIGNED_INTEGER=7;k.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8;k.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9;k.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10;k.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11;k.TEXTURETYPE_UNSIGNED_INT_24_8=12;k.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13;k.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14;k.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15;k.TEXTURE_NEAREST_SAMPLINGMODE=1;k.TEXTURE_BILINEAR_SAMPLINGMODE=2;k.TEXTURE_TRILINEAR_SAMPLINGMODE=3;k.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8;k.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11;k.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3;k.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4;k.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5;k.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6;k.TEXTURE_NEAREST_LINEAR=7;k.TEXTURE_NEAREST_NEAREST=1;k.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9;k.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10;k.TEXTURE_LINEAR_LINEAR=2;k.TEXTURE_LINEAR_NEAREST=12;k.TEXTURE_EXPLICIT_MODE=0;k.TEXTURE_SPHERICAL_MODE=1;k.TEXTURE_PLANAR_MODE=2;k.TEXTURE_CUBIC_MODE=3;k.TEXTURE_PROJECTION_MODE=4;k.TEXTURE_SKYBOX_MODE=5;k.TEXTURE_INVCUBIC_MODE=6;k.TEXTURE_EQUIRECTANGULAR_MODE=7;k.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8;k.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9;k.SCALEMODE_FLOOR=1;k.SCALEMODE_NEAREST=2;k.SCALEMODE_CEILING=3;const Kc=Object.freeze(Object.defineProperty({__proto__:null,Engine:k},Symbol.toStringTag,{value:"Module"}));class Gi extends ht{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([j(()=>import("./pass.fragment-BmRfDBYP.js"),__vite__mapDeps([17,1,2]),import.meta.url)]))):t.push(Promise.all([j(()=>import("./pass.fragment-DM0HxvmX.js"),__vite__mapDeps([18,1,2]),import.meta.url)])),super._gatherImports(e,t)}constructor(e,t=null,i){super({...i,name:e,engine:t||k.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:Gi.FragmentUrl})}}Gi.FragmentUrl="pass";class tr extends ht{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([j(()=>import("./passCube.fragment-BrW21GVa.js"),__vite__mapDeps([19,1,2]),import.meta.url)]))):t.push(Promise.all([j(()=>import("./passCube.fragment-B9YksETb.js"),__vite__mapDeps([20,1,2]),import.meta.url)])),super._gatherImports(e,t)}constructor(e,t=null,i){super({...i,name:e,engine:t||k.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:tr.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}}}tr.FragmentUrl="passCube";class ir extends Ue{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,Gi.FragmentUrl,{effectWrapper:typeof t=="number"||!t.effectWrapper?new Gi(e,r,l):void 0,...l})}static _Parse(e,t,i,s){return re.Parse(()=>new ir(e.name,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable),e,i,s)}}it("BABYLON.PassPostProcess",ir);class sn extends Ue{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,Gi.FragmentUrl,{effectWrapper:typeof t=="number"||!t.effectWrapper?new tr(e,r,l):void 0,...l})}static _Parse(e,t,i,s){return re.Parse(()=>new sn(e.name,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable),e,i,s)}}p([E()],sn.prototype,"face",null);H._RescalePostProcessFactory=a=>new ir("rescale",1,null,2,a,!1,0);function Yc(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 Ue("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 Fs,qn;function Od(a){Fs||(Fs=new Float32Array(1),qn=new Int32Array(Fs.buffer)),Fs[0]=a;const e=qn[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 Fd(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 Qn{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 j(()=>import("./rgbdDecode.fragment-CQWUQfhY.js"),__vite__mapDeps([21,22,1,2]),import.meta.url):await j(()=>import("./rgbdDecode.fragment-zQMwkG3_.js"),__vite__mapDeps([23,24,1,2]),import.meta.url);const c=new Ue("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 j(()=>import("./rgbdEncode.fragment-JPw6oGdD.js"),__vite__mapDeps([25,22,1,2]),import.meta.url):await j(()=>import("./rgbdEncode.fragment-DZmmpssc.js"),__vite__mapDeps([26,24,1,2]),import.meta.url),Yc("rgbdEncode",e,t,i,1,5)}}const q
vendor: 5,850 bytes, line 42
42c="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,505 bytes, line 42
42+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==";
vendor: 37,262 bytes, lines 42-51
42let Qc=0;const co=a=>{if(!a.environmentBRDFTexture){const e=a.useDelayedTextureLoading;a.useDelayedTextureLoading=!1;const t=a._blockEntityCollection;a._blockEntityCollection=!1;const i=V.CreateFromBase64String(qc,"EnvironmentBRDFTexture"+Qc++,a,!0,!1,V.BILINEAR_SAMPLINGMODE);a._blockEntityCollection=t;const s=a.getEngine().getLoadedTexturesCache(),r=s.indexOf(i.getInternalTexture());r!==-1&&s.splice(r,1),i.isRGBD=!0,i.wrapU=V.CLAMP_ADDRESSMODE,i.wrapV=V.CLAMP_ADDRESSMODE,a.environmentBRDFTexture=i,a.useDelayedTextureLoading=e,Qn.ExpandRGBDTexture(i);const n=a.getEngine().onContextRestoredObservable.add(()=>{i.isRGBD=!0;const o=a.onBeforeRenderObservable.add(()=>{i.isReady()&&(a.onBeforeRenderObservable.remove(o),Qn.ExpandRGBDTexture(i))})});a.onDisposeObservable.add(()=>{a.getEngine().onContextRestoredObservable.remove(n)})}return a.environmentBRDFTexture};class pi{constructor(e){if(this._keys=[],this._isDirty=!0,this._areLightsDirty=!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(){this._keys.forEach(e=>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+`
43`;break;default:s&&(e+="#define "+i+`
44`);break}}return e}}const jc=new RegExp("^([gimus]+)!");class ui{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();ui._MaterialPluginClassToMainDefine[t]||(ui._MaterialPluginClassToMainDefine[t]="MATERIALPLUGIN_"+ ++ui._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[ui._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._callbackPluginEventFillRenderTargetTextures=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}this._uboDeclaration+=`uniform ${o.name}: ${l}${h>0?`[${h}]`:""};
45`}else this._uboDeclaration+=`${o.type} ${o.name}${h>0?`[${h}]`:""};
46`}this._uniformList.push(o.name)}n.vertex&&(this._vertexDeclaration+=n.vertex+`
47`),n.fragment&&(this._fragmentDeclaration+=n.fragment+`
48`)}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:Fe.GetShadersRepository(0),includesShadersStore:Fe.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",Gs(c,n,u=>c=u)),h+=c+`
49`)}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=jc.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,`
50`+h+`
51`+l)}}return s}}}ui._MaterialPluginClassToMainDefine={};ui._MaterialPluginCounter=0;de.OnEnginesDisposedObservable.add(()=>{Jc()});const Zc=[];let jn=null;function Jc(){Zc.length=0,v.OnEventObservable.remove(jn),jn=null}class Ft{isCompatible(e){switch(e){case 0:return!0;default:return!1}}_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 ui(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){re.Clone(()=>e,this)}serialize(){return re.Serialize(this)}parse(e,t,i){re.Parse(()=>this,e,t,i)}}p([E()],Ft.prototype,"name",void 0);p([E()],Ft.prototype,"priority",void 0);p([E()],Ft.prototype,"resolveIncludes",void 0);p([E()],Ft.prototype,"registerForExtraEvents",void 0);it("BABYLON.MaterialPluginBase",Ft);class $c extends pi{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}}class Ge extends Ft{_markAllSubMeshesAsMiscDirty(){this._internalMarkAllSubMeshesAsMiscDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRBRDF",90,new $c,t),this._useEnergyConservation=Ge.DEFAULT_USE_ENERGY_CONSERVATION,this.useEnergyConservation=Ge.DEFAULT_USE_ENERGY_CONSERVATION,this._useSmithVisibilityHeightCorrelated=Ge.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this.useSmithVisibilityHeightCorrelated=Ge.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this._useSphericalHarmonics=Ge.DEFAULT_USE_SPHERICAL_HARMONICS,this.useSphericalHarmonics=Ge.DEFAULT_USE_SPHERICAL_HARMONICS,this._useSpecularGlossinessInputEnergyConservation=Ge.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this.useSpecularGlossinessInputEnergyConservation=Ge.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this._mixIblRadianceWithIrradiance=Ge.DEFAULT_MIX_IBL_RADIANCE_WITH_IRRADIANCE,this.mixIblRadianceWithIrradiance=Ge.DEFAULT_MIX_IBL_RADIANCE_WITH_IRRADIANCE,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}getClassName(){return"PBRBRDFConfiguration"}}Ge.DEFAULT_USE_ENERGY_CONSERVATION=!0;Ge.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED=!0;Ge.DEFAULT_USE_SPHERICAL_HARMONICS=!0;Ge.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION=!0;Ge.DEFAULT_MIX_IBL_RADIANCE_WITH_IRRADIANCE=!0;p([E(),N("_markAllSubMeshesAsMiscDirty")],Ge.prototype,"useEnergyConservation",void 0);p([E(),N("_markAllSubMeshesAsMiscDirty")],Ge.prototype,"useSmithVisibilityHeightCorrelated",void 0);p([E(),N("_markAllSubMeshesAsMiscDirty")],Ge.prototype,"useSphericalHarmonics",void 0);p([E(),N("_markAllSubMeshesAsMiscDirty")],Ge.prototype,"useSpecularGlossinessInputEnergyConservation",void 0);p([E(),N("_markAllSubMeshesAsMiscDirty")],Ge.prototype,"mixIblRadianceWithIrradiance",void 0);class Zn{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 eu extends v{constructor(e,t,i=!0,s=!1){super(e,t,void 0,s),this._normalMatrix=new M,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)}}class L{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 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))}}L._DiffuseTextureEnabled=!0;L._BaseWeightTextureEnabled=!0;L._DetailTextureEnabled=!0;L._DecalMapEnabled=!0;L._AmbientTextureEnabled=!0;L._OpacityTextureEnabled=!0;L._ReflectionTextureEnabled=!0;L._EmissiveTextureEnabled=!0;L._SpecularTextureEnabled=!0;L._BumpTextureEnabled=!0;L._LightmapTextureEnabled=!0;L._RefractionTextureEnabled=!0;L._ColorGradingTextureEnabled=!0;L._FresnelEnabled=!0;L._ClearCoatTextureEnabled=!0;L._ClearCoatBumpTextureEnabled=!0;L._ClearCoatTintTextureEnabled=!0;L._SheenTextureEnabled=!0;L._AnisotropicTextureEnabled=!0;L._ThicknessTextureEnabled=!0;L._RefractionIntensityTextureEnabled=!0;L._TranslucencyIntensityTextureEnabled=!0;L._TranslucencyColorTextureEnabled=!0;L._IridescenceTextureEnabled=!0;class vi{constructor(e,t,i,s){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=i,this.worldAxisForFileY=s}}class sr{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,m,b,y,A])=>{const P={size:t,right:g,left:d,up:m,down:b,front:y,back:A,format:c,type:u,gammaSpace:l};f(this.ConvertCubeMapToSphericalPolynomial(P))})})}static _AreaElement(e,t){return Math.atan2(e*t,Math.sqrt(e*e+t*t+1))}static ConvertCubeMapToSphericalPolynomial(e){const t=new us;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 m=o;const b=e.format===5?4:3;for(let y=0;y<e.size;y++){let A=o;for(let P=0;P<e.size;P++){const I=d.worldAxisForFileX.scale(A).add(d.worldAxisForFileY.scale(m)).add(d.worldAxisForNormal);I.normalize();const x=this._AreaElement(A-n,m-n)-this._AreaElement(A-n,m+n)-this._AreaElement(A+n,m-n)+this._AreaElement(A+n,m+n);let R=g[y*e.size*b+P*b+0],S=g[y*e.size*b+P*b+1],D=g[y*e.size*b+P*b+2];isNaN(R)&&(R=0),isNaN(S)&&(S=0),isNaN(D)&&(D=0),e.type===0&&(R/=255,S/=255,D/=255),e.gammaSpace&&(R=Math.pow(Te(R),Ns),S=Math.pow(Te(S),Ns),D=Math.pow(Te(D),Ns));const G=this.MAX_HDRI_VALUE;if(this.PRESERVE_CLAMPED_COLORS){const Re=Math.max(R,S,D);if(Re>G){const fe=G/Re;R*=fe,S*=fe,D*=fe}}else R=Te(R,0,G),S=Te(S,0,G),D=Te(D,0,G);const X=new q(R,S,D);t.addLight(I,X,x),i+=x,A+=s}m+=r}}const u=4*Math.PI*6/6/i;return t.scaleInPlace(u),t.convertIncidentRadianceToIrradiance(),t.convertIrradianceToLambertianRadiance(),ds.FromHarmonics(t)}}sr._FileFaces=[new vi("right",new _(1,0,0),new _(0,0,-1),new _(0,-1,0)),new vi("left",new _(-1,0,0),new _(0,0,1),new _(0,-1,0)),new vi("up",new _(0,1,0),new _(1,0,0),new _(0,0,1)),new vi("down",new _(0,-1,0),new _(1,0,0),new _(0,0,-1)),new vi("front",new _(0,0,1),new _(1,0,0),new _(0,-1,0)),new vi("back",new _(0,0,-1),new _(-1,0,0),new _(0,-1,0))];sr.MAX_HDRI_VALUE=4096;sr.PRESERVE_CLAMPED_COLORS=!1;Me.prototype.forceSphericalPolynomialsRecompute=function(){this._texture&&(this._texture._sphericalPolynomial=null,this._texture._sphericalPolynomialPromise=null,this._texture._sphericalPolynomialComputed=!1)};Object.defineProperty(Me.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=sr.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 tu{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}}class iu extends pi{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 Je extends Ft{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRClearCoat",100,new iu,t),this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.roughness=0,this._indexOfRefraction=Je._DefaultIndexOfRefraction,this.indexOfRefraction=Je._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&&L.ClearCoatTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._textureRoughness&&L.ClearCoatTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking()||i.getCaps().standardDerivatives&&this._bumpTexture&&L.ClearCoatBumpTextureEnabled&&!s&&!this._bumpTexture.isReady()||this._isTintEnabled&&this._tintTexture&&L.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&&L.ClearCoatTextureEnabled?Le(this._texture,e,"CLEARCOAT_TEXTURE"):e.CLEARCOAT_TEXTURE=!1,this._textureRoughness&&L.ClearCoatTextureEnabled?Le(this._textureRoughness,e,"CLEARCOAT_TEXTURE_ROUGHNESS"):e.CLEARCOAT_TEXTURE_ROUGHNESS=!1,this._bumpTexture&&L.ClearCoatBumpTextureEnabled?Le(this._bumpTexture,e,"CLEARCOAT_BUMP"):e.CLEARCOAT_BUMP=!1,e.CLEARCOAT_DEFAULTIOR=this._indexOfRefraction===Je._DefaultIndexOfRefraction,this._isTintEnabled?(e.CLEARCOAT_TINT=!0,this._tintTexture&&L.ClearCoatTintTextureEnabled?(Le(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)&&L.ClearCoatTextureEnabled&&(e.updateFloat4("vClearCoatInfos",this._texture?.coordinatesIndex??0,this._texture?.level??0,this._textureRoughness?.coordinatesIndex??0,this._textureRoughness?.level??0),this._texture&&Be(this._texture,e,"clearCoat"),this._textureRoughness&&!r.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE&&Be(this._textureRoughness,e,"clearCoatRoughness")),this._bumpTexture&&i.getCaps().standardDerivatives&&L.ClearCoatTextureEnabled&&!o&&(e.updateFloat2("vClearCoatBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level),Be(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&&L.ClearCoatTintTextureEnabled&&(e.updateFloat2("vClearCoatTintInfos",this._tintTexture.coordinatesIndex,this._tintTexture.level),Be(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&&L.ClearCoatTextureEnabled&&e.setTexture("clearCoatSampler",this._texture),this._textureRoughness&&!r.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE&&L.ClearCoatTextureEnabled&&e.setTexture("clearCoatRoughnessSampler",this._textureRoughness),this._bumpTexture&&i.getCaps().standardDerivatives&&L.ClearCoatBumpTextureEnabled&&!o&&e.setTexture("clearCoatBumpSampler",this._bumpTexture),this._isTintEnabled&&this._tintTexture&&L.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"}]}}}Je._DefaultIndexOfRefraction=1.5;p([E(),N("_markAllSubMeshesAsTexturesDirty")],Je.prototype,"isEnabled",void 0);p([E()],Je.prototype,"intensity",void 0);p([E()],Je.prototype,"roughness",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Je.prototype,"indexOfRefraction",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],Je.prototype,"texture",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Je.prototype,"useRoughnessFromMainTexture",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],Je.prototype,"textureRoughness",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Je.prototype,"remapF0OnInterfaceChange",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],Je.prototype,"bumpTexture",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Je.prototype,"isTintEnabled",void 0);p([Rt()],Je.prototype,"tintColor",void 0);p([E()],Je.prototype,"tintColorAtDistance",void 0);p([E()],Je.prototype,"tintThickness",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],Je.prototype,"tintTexture",void 0);class su extends pi{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 gt extends Ft{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRIridescence",110,new su,t),this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.minimumThickness=gt._DefaultMinimumThickness,this.maximumThickness=gt._DefaultMaximumThickness,this.indexOfRefraction=gt._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&&L.IridescenceTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._thicknessTexture&&L.IridescenceTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())):!0}prepareDefinesBeforeAttributes(e,t){this._isEnabled?(e.IRIDESCENCE=!0,e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&L.IridescenceTextureEnabled?Le(this._texture,e,"IR
51IDESCENCE_TEXTURE"):e.IRIDESCENCE_TEXTURE=!1,this._thicknessTexture&&L.IridescenceTextureEnabled?Le(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)&&L.IridescenceTextureEnabled&&(e.updateFloat4("vIridescenceInfos",this._texture?.coordinatesIndex??0,this._texture?.level??0,this._thicknessTexture?.coordinatesIndex??0,this._thicknessTexture?.level??0),this._texture&&Be(this._texture,e,"iridescence"),this._thicknessTexture&&Be(this._thicknessTexture,e,"iridescenceThickness")),e.updateFloat4("vIridescenceParams",this.intensity,this.indexOfRefraction,this.minimumThickness,this.maximumThickness)),t.texturesEnabled&&(this._texture&&L.IridescenceTextureEnabled&&e.setTexture("iridescenceSampler",this._texture),this._thicknessTexture&&L.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"}]}}}gt._DefaultMinimumThickness=100;gt._DefaultMaximumThickness=400;gt._DefaultIndexOfRefraction=1.3;p([E(),N("_markAllSubMeshesAsTexturesDirty")],gt.prototype,"isEnabled",void 0);p([E()],gt.prototype,"intensity",void 0);p([E()],gt.prototype,"minimumThickness",void 0);p([E()],gt.prototype,"maximumThickness",void 0);p([E()],gt.prototype,"indexOfRefraction",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],gt.prototype,"texture",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],gt.prototype,"thicknessTexture",void 0);class ru extends pi{constructor(){super(...arguments),this.ANISOTROPIC=!1,this.ANISOTROPIC_TEXTURE=!1,this.ANISOTROPIC_TEXTUREDIRECTUV=0,this.ANISOTROPIC_LEGACY=!1,this.MAINUV1=!1}}class Ki extends Ft{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 ru,t),this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.direction=new Z(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&&L.AnisotropicTextureEnabled&&!this._texture.isReadyOrNotBlocking()):!0}prepareDefinesBeforeAttributes(e,t,i){this._isEnabled?(e.ANISOTROPIC=this._isEnabled,this._isEnabled&&!i.isVerticesDataPresent(T.TangentKind)&&(e._needUVs=!0,e.MAINUV1=!0),e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&L.AnisotropicTextureEnabled?Le(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&&L.AnisotropicTextureEnabled&&(e.updateFloat2("vAnisotropyInfos",this._texture.coordinatesIndex,this._texture.level),Be(this._texture,e,"anisotropy")),e.updateFloat3("vAnisotropy",this.direction.x,this.direction.y,this.intensity)),t.texturesEnabled&&this._texture&&L.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)}}p([E(),N("_markAllSubMeshesAsTexturesDirty")],Ki.prototype,"isEnabled",void 0);p([E()],Ki.prototype,"intensity",void 0);p([ma()],Ki.prototype,"direction",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],Ki.prototype,"texture",void 0);p([E(),N("_markAllSubMeshesAsMiscDirty")],Ki.prototype,"legacy",void 0);
vendor: 47,955 bytes, line 51
51class nu extends pi{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 zt extends Ft{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"Sheen",120,new nu,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&&L.SheenTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._textureRoughness&&L.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&&L.SheenTextureEnabled?(Le(this._texture,e,"SHEEN_TEXTURE"),e.SHEEN_GAMMATEXTURE=this._texture.gammaSpace):e.SHEEN_TEXTURE=!1,this._textureRoughness&&L.SheenTextureEnabled?Le(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)&&L.SheenTextureEnabled&&(e.updateFloat4("vSheenInfos",this._texture?.coordinatesIndex??0,this._texture?.level??0,this._textureRoughness?.coordinatesIndex??0,this._textureRoughness?.level??0),this._texture&&Be(this._texture,e,"sheen"),this._textureRoughness&&!r.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&Be(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&&L.SheenTextureEnabled&&e.setTexture("sheenSampler",this._texture),this._textureRoughness&&!r.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&L.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"}]}}}p([E(),N("_markAllSubMeshesAsTexturesDirty")],zt.prototype,"isEnabled",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],zt.prototype,"linkSheenWithAlbedo",void 0);p([E()],zt.prototype,"intensity",void 0);p([Rt()],zt.prototype,"color",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],zt.prototype,"texture",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],zt.prototype,"useRoughnessFromMainTexture",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],zt.prototype,"roughness",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],zt.prototype,"textureRoughness",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],zt.prototype,"albedoScaling",void 0);class au extends pi{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 be extends Ft{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}_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 au,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.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=be.DEFAULT_APPLY_ALBEDO_AFTERSUBSURFACE,this.legacyTransluceny=be.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;if(e._areTexturesDirty&&t.texturesEnabled){if(this._thicknessTexture&&L.ThicknessTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking()||this._translucencyColorTexture&&L.TranslucencyColorTextureEnabled&&!this._translucencyColorTexture.isReadyOrNotBlocking()||this._translucencyIntensityTexture&&L.TranslucencyIntensityTextureEnabled&&!this._translucencyIntensityTexture.isReadyOrNotBlocking())return!1;const i=this._getRefractionTexture(t);if(i&&L.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.legacyTransluceny,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&&L.ThicknessTextureEnabled&&Le(this._thicknessTexture,e,"SS_THICKNESSANDMASK_TEXTURE"),this._refractionIntensityTexture&&L.RefractionIntensityTextureEnabled&&Le(this._refractionIntensityTexture,e,"SS_REFRACTIONINTENSITY_TEXTURE"),this._translucencyIntensityTexture&&L.TranslucencyIntensityTextureEnabled&&Le(this._translucencyIntensityTexture,e,"SS_TRANSLUCENCYINTENSITY_TEXTURE"),this._translucencyColorTexture&&L.TranslucencyColorTextureEnabled&&(Le(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&&L.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(C.Vector3[0]);const r=Math.max(Math.abs(C.Vector3[0].x),Math.abs(C.Vector3[0].y),Math.abs(C.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&&L.ThicknessTextureEnabled&&(e.updateFloat2("vThicknessInfos",this._thicknessTexture.coordinatesIndex,this._thicknessTexture.level),Be(this._thicknessTexture,e,"thickness")),this._refractionIntensityTexture&&L.RefractionIntensityTextureEnabled&&r.SS_REFRACTIONINTENSITY_TEXTURE&&(e.updateFloat2("vRefractionIntensityInfos",this._refractionIntensityTexture.coordinatesIndex,this._refractionIntensityTexture.level),Be(this._refractionIntensityTexture,e,"refractionIntensity")),this._translucencyColorTexture&&L.TranslucencyColorTextureEnabled&&r.SS_TRANSLUCENCYCOLOR_TEXTURE&&(e.updateFloat2("vTranslucencyColorInfos",this._translucencyColorTexture.coordinatesIndex,this._translucencyColorTexture.level),Be(this._translucencyColorTexture,e,"translucencyColor")),this._translucencyIntensityTexture&&L.TranslucencyIntensityTextureEnabled&&r.SS_TRANSLUCENCYINTENSITY_TEXTURE&&(e.updateFloat2("vTranslucencyIntensityInfos",this._translucencyIntensityTexture.coordinatesIndex,this._translucencyIntensityTexture.level),Be(this._translucencyIntensityTexture,e,"translucencyIntensity")),l&&L.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&&L.ThicknessTextureEnabled&&e.setTexture("thicknessSampler",this._thicknessTexture),this._refractionIntensityTexture&&L.RefractionIntensityTextureEnabled&&r.SS_REFRACTIONINTENSITY_TEXTURE&&e.setTexture("refractionIntensitySampler",this._refractionIntensityTexture),this._translucencyIntensityTexture&&L.TranslucencyIntensityTextureEnabled&&r.SS_TRANSLUCENCYINTENSITY_TEXTURE&&e.setTexture("translucencyIntensitySampler",this._translucencyIntensityTexture),this._translucencyColorTexture&&L.TranslucencyColorTextureEnabled&&r.SS_TRANSLUCENCYCOLOR_TEXTURE&&e.setTexture("translucencyColorSampler",this._translucencyColorTexture),l&&L.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){L.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!!(L.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)}getActiveTextures(e){this._thicknessTexture&&e.push(this._thicknessTexture),this._refractionTexture&&e.push(this._refractionTexture),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._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._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"}]}}}be.DEFAULT_APPLY_ALBEDO_AFTERSUBSURFACE=!1;be.DEFAULT_LEGACY_TRANSLUCENCY=!1;p([E(),N("_markAllSubMeshesAsTexturesDirty")],be.prototype,"isRefractionEnabled",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],be.prototype,"isTranslucencyEnabled",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],be.prototype,"isDispersionEnabled",void 0);p([E(),N("_markScenePrePassDirty")],be.prototype,"isScatteringEnabled",void 0);p([E()],be.prototype,"_scatteringDiffusionProfileIndex",void 0);p([E()],be.prototype,"refractionIntensity",void 0);p([E()],be.prototype,"translucencyIntensity",void 0);p([E()],be.prototype,"useAlbedoToTintRefraction",void 0);p([E()],be.prototype,"useAlbedoToTintTranslucency",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],be.prototype,"thicknessTexture",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],be.prototype,"refractionTexture",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],be.prototype,"indexOfRefraction",void 0);p([E()],be.prototype,"_volumeIndexOfRefraction",void 0);p([N("_markAllSubMeshesAsTexturesDirty")],be.prototype,"volumeIndexOfRefraction",null);p([E(),N("_markAllSubMeshesAsTexturesDirty")],be.prototype,"invertRefractionY",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],be.prototype,"linkRefractionWithTransparency",void 0);p([E()],be.prototype,"minimumThickness",void 0);p([E()],be.prototype,"maximumThickness",void 0);p([E()],be.prototype,"useThicknessAsDepth",void 0);p([Rt()],be.prototype,"tintColor",void 0);p([E()],be.prototype,"tintColorAtDistance",void 0);p([E()],be.prototype,"dispersion",void 0);p([Rt()],be.prototype,"diffusionDistance",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],be.prototype,"useMaskFromThicknessTexture",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],be.prototype,"refractionIntensityTexture",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],be.prototype,"translucencyIntensityTexture",void 0);p([Rt()],be.prototype,"translucencyColor",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],be.prototype,"translucencyColorTexture",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],be.prototype,"useGltfStyleTextures",void 0);p([E()],be.prototype,"applyAlbedoAfterSubSurface",void 0);p([E()],be.prototype,"legacyTransluceny",void 0);class ou extends pi{constructor(){super(...arguments),this.DETAIL=!1,this.DETAILDIRECTUV=0,this.DETAIL_NORMALBLENDMETHOD=0}}class Ci extends Ft{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"DetailMap",140,new ou,t),this._texture=null,this.diffuseBlendLevel=1,this.roughnessBlendLevel=1,this.bumpLevel=1,this._normalBlendMethod=v.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&&L.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&&L.DetailTextureEnabled&&this._isEnabled?(Le(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&&L.DetailTextureEnabled&&(e.updateFloat4("vDetailInfos",this._texture.coordinatesIndex,this.diffuseBlendLevel,this.bumpLevel,this.roughnessBlendLevel),Be(this._texture,e,"detail")),t.texturesEnabled&&this._texture&&L.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"}]}}}p([Ie("detailTexture"),N("_markAllSubMeshesAsTexturesDirty")],Ci.prototype,"texture",void 0);p([E()],Ci.prototype,"diffuseBlendLevel",void 0);p([E()],Ci.prototype,"roughnessBlendLevel",void 0);p([E()],Ci.prototype,"bumpLevel",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Ci.prototype,"normalBlendMethod",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Ci.prototype,"isEnabled",void 0);var Jn;(function(a){a[a.Zero=0]="Zero",a[a.One=1]="One",a[a.MaxViewZ=2]="MaxViewZ"})(Jn||(Jn={}));class bt{static CreateConfiguration(e){return bt._Configurations[e]={defines:{},previousWorldMatrices:{},previousViewProjection:M.Zero(),currentViewProjection:M.Zero(),previousBones:{},lastUpdateFrameId:-1,excludedSkinnedMesh:[],reverseCulling:!1},bt._Configurations[e]}static DeleteConfiguration(e){delete bt._Configurations[e]}static GetConfiguration(e){return bt._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=bt._Configurations[e];if(!s)return;i.PREPASS=!0,i.PREPASS_COLOR=!1,i.PREPASS_COLOR_INDEX=-1;let r=0;for(let n=0;n<bt.GeometryTextureDescriptions.length;n++){const o=bt.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=bt._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))}}}}bt.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"}];bt._Configurations={};const Di={effect:null,subMesh:null};class $n extends pi{constructor(e){super(e),this.PBR=!0,this.NUM_SAMPLES="0",this.REALTIME_FILTERING=!1,this.IBL_CDF_FILTERING=!1,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,this.ALBEDO=!1,this.GAMMAALBEDO=!1,this.ALBEDODIRECTUV=0,this.VERTEXCOLOR=!1,this.BASEWEIGHT=!1,this.BASEWEIGHTDIRECTUV=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.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_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_UV=!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.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,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.rebuild()}reset(){super.reset(),this.ALPHATESTVALUE="0.5",this.PBR=!0,this.NORMALXYSCALE=!0}}class xe extends eu{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}_attachImageProcessingConfiguration(e){e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e?this._imageProcessingConfiguration=e:this._imageProcessingConfiguration=this.getScene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(()=>{this._markAllSubMeshesAsImageProcessingDirty()})))}constructor(e,t,i=!1){super(e,t,void 0,i||xe.ForceGLSL),this._directIntensity=1,this._emissiveIntensity=1,this._environmentIntensity=1,this._specularIntensity=1,this._lightingInfos=new he(this._directIntensity,this._emissiveIntensity,this._environmentIntensity,this._specularIntensity),this._disableBumpMap=!1,this._albedoTexture=null,this._baseWeightTexture=null,this._ambientTexture=null,this._ambientTextureStrength=1,this._ambientTextureImpactOnAnalyticalLights=xe.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._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=xe.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._imageProcessingObserver=null,this._renderTargets=new rt(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 Ge(this),this.clearCoat=new Je(this),this.iridescence=new gt(this),this.anisotropy=new Ki(this),this.sheen=new zt(this),this.subSurface=new be(this),this.detailMap=new Ci(this),this._attachImageProcessingConfiguration(null),this.getRenderTargetTextures=()=>(this._renderTargets.reset(),L.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._renderTargets.push(this._reflectionTexture),this._eventInfo.renderTargets=this._renderTargets,this._callbackPluginEventFillRenderTargetTextures(this._eventInfo),this._renderTargets),this._environmentBRDFTexture=co(this.getScene()),this.prePassConfiguration=new Zn}get hasRenderTargetTextures(){return L.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget?!0:this._cacheHasRenderTargetTextures}get isPrePassCapable(){return!this.disableDepthWrite}getClassName(){return"PBRBaseMaterial"}get _disableAlphaBlending(){return this._transparencyMode===xe.PBRMATERIAL_OPAQUE||this._transparencyMode===xe.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===xe.PBRMATERIAL_ALPHATEST)}_shouldUseAlphaFromAlbedoTexture(){return this._albedoTexture!=null&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture&&this._transparencyMode!==xe.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 $n(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&&L.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking()||this._baseWeightTexture&&L.BaseWeightTextureEnabled&&!this._baseWeightTexture.isReadyOrNotBlocking()||this._ambientTexture&&L.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking()||this._opacityTexture&&L.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;const f=this._getReflectionTexture();if(f&&L.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&&L.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking()||this._emissiveTexture&&L.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if(L.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&&L.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady()||this._environmentBRDFTexture&&L.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){for(let f=0;f<e.lightSources.length;f++)if(!e.lightSources[f]._isReady())return!1}!o.getCaps().standardDerivatives&&!e.isVerticesDataPresent(T.NormalKind)&&(e.createNormals(!0),F.Warn("PBRMaterial: Normals have been created for the mesh: "+e.name));const h=t.effect,l=r._areLightsDisposed;let c=this._prepareEffect(e,r,this.onCompiled,this.onError,i,null,t.getRenderingMesh().hasThinInstances),u=!1;if(c)if(this._onEffectCreatedObservable&&(Di.effect=c,Di.subMesh=t,this._onEffectCreatedObservable.notifyObservers(Di)),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=null,s=null,r=null,n=null,o){if(this._prepareDefines(e,t,r,n,o),!t.isDirty)return null;t.markAsProcessed();const l=this.getScene().getEngine(),c=new tu;let u=0;t.USESPHERICALINVERTEX&&c.addFallback(u++,"USESPHERICALINVERTEX"),t.FOG&&c.addFallback(u,"FOG"),t.SPECULARAA&&c.addFallback(u,"SPECULARAA"),t.POINTSIZE&&c.addFallback(u,"POINTSIZE"),t.LOGARITHMICDEPTH&&c.addFallback(u,"LOGARITHMICDEPTH"),t.PARALLAX&&c.addFallback(u,"PARALLAX"),t.PARALLAX_RHS&&c.addFallback(u,"PARALLAX_RHS"),t.PARALLAXOCCLUSION&&c.addFallback(u++,"PARALLAXOCCLUSION"),t.ENVIRONMENTBRDF&&c.addFallback(u++,"ENVIRONMENTBRDF"),t.TANGENT&&c.addFallback(u++,"TANGENT"),t.BUMP&&c.addFallback(u++,"BUMP"),u=Rl(t,c,this._maxSimultaneousLights,u++),t.SPECULARTERM&&c.addFallback(u++,"SPECULARTERM"),t.USESPHERICALFROMREFLECTIONMAP&&c.addFallback(u++,"USESPHERICALFROMREFLECTIONMAP"),t.USEIRRADIANCEMAP&&c.addFallback(u++,"USEIRRADIANCEMAP"),t.LIGHTMAP&&c.addFallback(u++,"LIGHTMAP"),t.NORMAL&&c.addFallback(u++,"NORMAL"),t.AMBIENT&&c.addFallback(u++,"AMBIENT"),t.EMISSIVE&&c.addFallback(u++,"EMISSIVE"),t.VERTEXCOLOR&&c.addFallback(u++,"VERTEXCOLOR"),t.MORPHTARGETS&&c.addFallback(u++,"MORPHTARGETS"),t.MULTIVIEW&&c.addFallback(0,"MULTIVIEW");const f=[T.PositionKind];t.NORMAL&&f.push(T.NormalKind),t.TANGENT&&f.push(T.TangentKind);for(let x=1;x<=6;++x)t["UV"+x]&&f.push(`uv${x===1?"":x}`);t.VERTEXCOLOR&&f.push(T.ColorKind),Al(f,e,t,c),El(f,t),dl(f,e,t),gl(f,e,t);let d="pbr";const g=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","baseWeight","vReflectivityColor","vMetallicReflectanceFactors","vEmissiveColor","visibility","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vBaseWeightInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vReflectionPosition","vReflectionSize","vEmissiveInfos","vReflectivityInfos","vReflectionFilteringInfo","vMetallicReflectanceInfos","vReflectanceInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","mBones","albedoMatrix","baseWeightMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","normalMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","metallicReflectanceMatrix","reflectanceMatrix","vLightingIntensity","logarithmicDepthConstant","vSphericalX","vSphericalY","vSphericalZ","vSphericalXX_ZZ","vSphericalYY_ZZ","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vSphericalL00","vSphericalL1_1","vSphericalL10","vSphericalL11","vSphericalL2_2","vSphericalL2_1","vSphericalL20","vSphericalL21","vSphericalL22","vReflectionMicrosurfaceInfos","vTangentSpaceParams","boneTextureWidth","vDebugMode","morphTargetTextureInfo","morphTargetTextureIndices"],m=["albedoSampler","baseWeightSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","irradianceSampler","microSurfaceSampler","environmentBrdfSampler","boneSampler","metallicReflectanceSampler","reflectanceSampler","morphTargets","oitDepthSampler","oitFrontColorSampler","icdfSampler","areaLightsLTC1Sampler","areaLightsLTC2Sampler"],b=["Material","Scene","Mesh"],y={maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:t.NUM_MORPH_INFLUENCERS};this._eventInfo.fallbacks=c,this._eventInfo.fallbackRank=u,this._eventInfo.defines=t,this._eventInfo.uniforms=g,this._eventInfo.attributes=f,this._eventInfo.samplers=m,this._eventInfo.uniformBuffersNames=b,this._eventInfo.customCode=void 0,this._eventInfo.mesh=e,this._eventInfo.indexParameters=y,this._callbackPluginEventGeneric(128,this._eventInfo),bt.AddUniformsAndSamplers(g,m),Zn.AddUniforms(g),ol(g),ae&&(ae.PrepareUniforms(g,t),ae.PrepareSamplers(m,t)),Nl({uniformsNames:g,uniformBuffersNames:b,samplers:m,defines:t,maxSimultaneousLights:this._maxSimultaneousLights});const A={};this.customShaderNameResolve&&(d=this.customShaderNameResolve(d,g,b,m,t,f,A));const P=t.toString(),I=l.createEffect(d,{attributes:f,uniformsNames:g,uniformBuffersNames:b,samplers:m,defines:P,fallbacks:c,onCompiled:i,onError:s,indexParameters:y,processFinalCode:A.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:t.PREPASS,shaderLanguage:this._shaderLanguage,extraInitializationsAsync:this._shadersLoaded?void 0:async()=>{this.shaderLanguage===1?await Promise.all([j(()=>import("./pbr.vertex-CT0VYelJ.js"),__vite__mapDeps([27,28,29,30,31,22,32,33,34,1,2]),import.meta.url),j(()=>import("./pbr.fragment-BNttJE0O.js"),__vite__mapDeps([35,36,28,29,31,37,34,22,38,39,1,2]),import.meta.url)]):await Promise.all([j(()=>import("./pbr.vertex-CtEhXYgW.js"),__vite__mapDeps([40,41,42,43,44,24,45,1,2]),import.meta.url),j(()=>import("./pbr.fragment-CqKe22ec.js"),__vite__mapDeps([46,47,42,43,44,48,24,49,1,2]),import.meta.url)]),this._shadersLoaded=!0}},l);return this._eventInfo.customCode=void 0,I}_prepareDefines(e,t,i=null,s=null,r=!1){const n=this.getScene(),o=n.getEngine();Sl(n,e,t,!0,this._maxSimultaneousLights,this._disableLighting),t._needNormals=!0,Ol(n,t);const h=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if(wl(n,t,this.canRenderToMRT&&!h),F
vendor: 7,563 bytes, line 51
51l(n,t,h),bt.PrepareDefines(o.currentRenderPassId,e,t),t.METALLICWORKFLOW=this.isMetallicWorkflow(),t._areTexturesDirty){t._needUVs=!1;for(let l=1;l<=6;++l)t["MAINUV"+l]=!1;if(n.texturesEnabled){t.ALBEDODIRECTUV=0,t.BASEWEIGHTDIRECTUV=0,t.AMBIENTDIRECTUV=0,t.OPACITYDIRECTUV=0,t.EMISSIVEDIRECTUV=0,t.REFLECTIVITYDIRECTUV=0,t.MICROSURFACEMAPDIRECTUV=0,t.METALLIC_REFLECTANCEDIRECTUV=0,t.REFLECTANCEDIRECTUV=0,t.BUMPDIRECTUV=0,t.LIGHTMAPDIRECTUV=0,o.getCaps().textureLOD&&(t.LODBASEDMICROSFURACE=!0),this._albedoTexture&&L.DiffuseTextureEnabled?(Le(this._albedoTexture,t,"ALBEDO"),t.GAMMAALBEDO=this._albedoTexture.gammaSpace):t.ALBEDO=!1,this._baseWeightTexture&&L.BaseWeightTextureEnabled?Le(this._baseWeightTexture,t,"BASEWEIGHT"):t.BASEWEIGHT=!1,this._ambientTexture&&L.AmbientTextureEnabled?(Le(this._ambientTexture,t,"AMBIENT"),t.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):t.AMBIENT=!1,this._opacityTexture&&L.OpacityTextureEnabled?(Le(this._opacityTexture,t,"OPACITY"),t.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):t.OPACITY=!1;const l=this._getReflectionTexture();if(l&&L.ReflectionTextureEnabled){switch(t.REFLECTION=!0,t.GAMMAREFLECTION=l.gammaSpace,t.RGBDREFLECTION=l.isRGBD,t.LODINREFLECTIONALPHA=l.lodLevelInAlpha,t.LINEARSPECULARREFLECTION=l.linearSpecularLOD,t.USEIRRADIANCEMAP=!1,this.realTimeFiltering&&this.realTimeFilteringQuality>0?(t.NUM_SAMPLES=""+this.realTimeFilteringQuality,o._features.needTypeSuffixInShaderConstants&&(t.NUM_SAMPLES=t.NUM_SAMPLES+"u"),t.REALTIME_FILTERING=!0,this.getScene().iblCdfGenerator&&(t.IBL_CDF_FILTERING=!0)):t.REALTIME_FILTERING=!1,t.INVERTCUBICMAP=l.coordinatesMode===V.INVCUBIC_MODE,t.REFLECTIONMAP_3D=l.isCube,t.REFLECTIONMAP_OPPOSITEZ=t.REFLECTIONMAP_3D&&this.getScene().useRightHandedSystem?!l.invertZ:l.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,l.coordinatesMode){case V.EXPLICIT_MODE:t.REFLECTIONMAP_EXPLICIT=!0;break;case V.PLANAR_MODE:t.REFLECTIONMAP_PLANAR=!0;break;case V.PROJECTION_MODE:t.REFLECTIONMAP_PROJECTION=!0;break;case V.SKYBOX_MODE:t.REFLECTIONMAP_SKYBOX=!0;break;case V.SPHERICAL_MODE:t.REFLECTIONMAP_SPHERICAL=!0;break;case V.EQUIRECTANGULAR_MODE:t.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case V.FIXED_EQUIRECTANGULAR_MODE:t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case V.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case V.CUBIC_MODE:case V.INVCUBIC_MODE:default:t.REFLECTIONMAP_CUBIC=!0,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!!l.boundingBoxSize;break}l.coordinatesMode!==V.SKYBOX_MODE&&(l.irradianceTexture?(t.USEIRRADIANCEMAP=!0,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USESPHERICALINVERTEX=!1):l.isCube&&(t.USESPHERICALFROMREFLECTIONMAP=!0,t.USEIRRADIANCEMAP=!1,this._forceIrradianceInFragment||this.realTimeFiltering||this._twoSidedLighting||o.getCaps().maxVaryingVectors<=8?t.USESPHERICALINVERTEX=!1:t.USESPHERICALINVERTEX=!0))}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.USESPHERICALINVERTEX=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.RGBDREFLECTION=!1,t.LINEARSPECULARREFLECTION=!1;this._lightmapTexture&&L.LightmapTextureEnabled?(Le(this._lightmapTexture,t,"LIGHTMAP"),t.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,t.GAMMALIGHTMAP=this._lightmapTexture.gammaSpace,t.RGBDLIGHTMAP=this._lightmapTexture.isRGBD):t.LIGHTMAP=!1,this._emissiveTexture&&L.EmissiveTextureEnabled?(Le(this._emissiveTexture,t,"EMISSIVE"),t.GAMMAEMISSIVE=this._emissiveTexture.gammaSpace):t.EMISSIVE=!1,L.SpecularTextureEnabled?(this._metallicTexture?(Le(this._metallicTexture,t,"REFLECTIVITY"),t.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,t.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,t.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,t.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed,t.REFLECTIVITY_GAMMA=!1):this._reflectivityTexture?(Le(this._reflectivityTexture,t,"REFLECTIVITY"),t.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,t.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap,t.REFLECTIVITY_GAMMA=this._reflectivityTexture.gammaSpace):t.REFLECTIVITY=!1,this._metallicReflectanceTexture||this._reflectanceTexture?(t.METALLIC_REFLECTANCE_USE_ALPHA_ONLY=this._useOnlyMetallicFromMetallicReflectanceTexture,this._metallicReflectanceTexture?(Le(this._metallicReflectanceTexture,t,"METALLIC_REFLECTANCE"),t.METALLIC_REFLECTANCE_GAMMA=this._metallicReflectanceTexture.gammaSpace):t.METALLIC_REFLECTANCE=!1,this._reflectanceTexture&&(!this._metallicReflectanceTexture||this._metallicReflectanceTexture&&this._useOnlyMetallicFromMetallicReflectanceTexture)?(Le(this._reflectanceTexture,t,"REFLECTANCE"),t.REFLECTANCE_GAMMA=this._reflectanceTexture.gammaSpace):t.REFLECTANCE=!1):(t.METALLIC_REFLECTANCE=!1,t.REFLECTANCE=!1),this._microSurfaceTexture?Le(this._microSurfaceTexture,t,"MICROSURFACEMAP"):t.MICROSURFACEMAP=!1):(t.REFLECTIVITY=!1,t.MICROSURFACEMAP=!1),o.getCaps().standardDerivatives&&this._bumpTexture&&L.BumpTextureEnabled&&!this._disableBumpMap?(Le(this._bumpTexture,t,"BUMP"),this._useParallax&&this._albedoTexture&&L.DiffuseTextureEnabled?(t.PARALLAX=!0,t.PARALLAX_RHS=n.useRightHandedSystem,t.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):t.PARALLAX=!1,t.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):(t.BUMP=!1,t.PARALLAX=!1,t.PARALLAX_RHS=!1,t.PARALLAXOCCLUSION=!1,t.OBJECTSPACE_NORMALMAP=!1),this._environmentBRDFTexture&&L.ReflectionTextureEnabled?(t.ENVIRONMENTBRDF=!0,t.ENVIRONMENTBRDF_RGBD=this._environmentBRDFTexture.isRGBD):(t.ENVIRONMENTBRDF=!1,t.ENVIRONMENTBRDF_RGBD=!1),this._shouldUseAlphaFromAlbedoTexture()?t.ALPHAFROMALBEDO=!0:t.ALPHAFROMALBEDO=!1}t.SPECULAROVERALPHA=this._useSpecularOverAlpha,this._lightFalloff===xe.LIGHTFALLOFF_STANDARD?(t.USEPHYSICALLIGHTFALLOFF=!1,t.USEGLTFLIGHTFALLOFF=!1):this._lightFalloff===xe.LIGHTFALLOFF_GLTF?(t.USEPHYSICALLIGHTFALLOFF=!1,t.USEGLTFLIGHTFALLOFF=!0):(t.USEPHYSICALLIGHTFALLOFF=!0,t.USEGLTFLIGHTFALLOFF=!1),t.RADIANCEOVERALPHA=this._useRadianceOverAlpha,!this.backFaceCulling&&this._twoSidedLighting?t.TWOSIDEDLIGHTING=!0:t.TWOSIDEDLIGHTING=!1,t.MIRRORED=!!n._mirroredCameraPosition,t.SPECULARAA=o.getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}(t._areTexturesDirty||t._areMiscDirty)&&(t.ALPHATESTVALUE=`${this._alphaCutOff}${this._alphaCutOff%1===0?".":""}`,t.PREMULTIPLYALPHA=this.alphaMode===7||this.alphaMode===8,t.ALPHABLEND=this.needAlphaBlendingForMesh(e),t.ALPHAFRESNEL=this._useAlphaFresnel||this._useLinearAlphaFresnel,t.LINEARALPHAFRESNEL=this._useLinearAlphaFresnel),t._areImageProcessingDirty&&this._imageProcessingConfiguration&&this._imageProcessingConfiguration.prepareDefines(t),t.FORCENORMALFORWARD=this._forceNormalForward,t.RADIANCEOCCLUSION=this._useRadianceOcclusion,t.HORIZONOCCLUSION=this._useHorizonOcclusion,t._areMiscDirty&&(
vendor: 3,758 bytes, line 51
51xl(e,n,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this.needAlphaTestingForMesh(e),t,this._applyDecalMapAfterDetailMap),t.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(T.NormalKind),t.DEBUGMODE=this._debugMode),Il(n,o,this,t,!!i,s,r),this._eventInfo.defines=t,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo),Dl(e,t,!0,!0,!0,this._transparencyMode!==xe.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 $n(this._eventInfo.defineNames),o=this._prepareEffect(e,n,void 0,void 0,s.useInstances,s.clipPlane,e.hasThinInstances);this._onEffectCreatedObservable&&(Di.effect=o,Di.subMesh=null,this._onEffectCreatedObservable.notifyObservers(Di)),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("vAmbientInfos",4),e.addUniform("vOpacityInfos",2),e.addUniform("vEmissiveInfos",2),e.addUniform("vLightmapInfos",2),e.addUniform("vReflectivityInfos",3),e.addUniform("vMicroSurfaceSamplerInfos",2),e.addUniform("vReflectionInfos",2),e.addUniform("vReflectionFilteringInfo",2),e.addUniform("vReflectionPosition",3),e.addUniform("vReflectionSize",3),e.addUniform("vBumpInfos",3),e.addUniform("albedoMatrix",16),e.addUniform("baseWeightMatrix",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("reflectionMatrix",16),e.addUniform("vReflectionColor",3),e.addUniform("vAlbedoColor",4),e.addUniform("baseWeight",1),e.addUniform("vLightingIntensity",4),e.addUniform("vReflectionMicrosurfaceInfos",3),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("vSphericalL00",3),e.addUniform("vSphericalL1_1",3),e.addUniform("vSphericalL10",3),e.addUniform("vSphericalL11",3),e.addUniform("vSphericalL2_2",3),e.addUniform("vSphericalL2_1",3),e.addUniform("vSphericalL20",3),e.addUniform("vSphericalL21",3),e.addUniform("vSphericalL22",3),e.addUniform("vSphericalX",3),e.addUniform("vSphericalY",3),e.addUniform("vSphericalZ",3),e.addUniform("vSphericalXX_ZZ",3),e.addUniform("vSphericalYY_ZZ",3),e.addUniform("vSphericalZZ",3),e.addUniform("vSphericalXY",3),e.addUniform("vSphericalYZ",3),e.addUniform("vSphericalZX",3),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),bt.Bind(o.currentRenderPassId,this._activeEffect,t,e,this),this._eventInfo.subMesh=i,this._callbackPluginEventHardBindForSubMesh(this._eventInfo),r.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));const h=this._mustRebind(s,n,i,t.visibility);m
vendor: 8,010 bytes, line 51
51l(t,this._activeEffect,this.prePassConfiguration);let l=null;const c=this._uniformBuffer;if(h){if(this.bindViewProjection(n),l=this._getReflectionTexture(),!c.useUbo||!this.isFrozen||!c.isSync||i._drawWrapper._forceRebindOnNextCall){if(s.texturesEnabled){if(this._albedoTexture&&L.DiffuseTextureEnabled&&(c.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),Be(this._albedoTexture,c,"albedo")),this._baseWeightTexture&&L.BaseWeightTextureEnabled&&(c.updateFloat2("vBaseWeightInfos",this._baseWeightTexture.coordinatesIndex,this._baseWeightTexture.level),Be(this._baseWeightTexture,c,"baseWeight")),this._ambientTexture&&L.AmbientTextureEnabled&&(c.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),Be(this._ambientTexture,c,"ambient")),this._opacityTexture&&L.OpacityTextureEnabled&&(c.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),Be(this._opacityTexture,c,"opacity")),l&&L.ReflectionTextureEnabled){if(c.updateMatrix("reflectionMatrix",l.getReflectionTextureMatrix()),c.updateFloat2("vReflectionInfos",l.level*s.iblIntensity,0),l.boundingBoxSize){const u=l;c.updateVector3("vReflectionPosition",u.boundingBoxPosition),c.updateVector3("vReflectionSize",u.boundingBoxSize)}if(this.realTimeFiltering){const u=l.getSize().width;c.updateFloat2("vReflectionFilteringInfo",u,Math.log2(u))}if(!r.USEIRRADIANCEMAP){const u=l.sphericalPolynomial;if(r.USESPHERICALFROMREFLECTIONMAP&&u)if(r.SPHERICAL_HARMONICS){const f=u.preScaledHarmonics;c.updateVector3("vSphericalL00",f.l00),c.updateVector3("vSphericalL1_1",f.l1_1),c.updateVector3("vSphericalL10",f.l10),c.updateVector3("vSphericalL11",f.l11),c.updateVector3("vSphericalL2_2",f.l2_2),c.updateVector3("vSphericalL2_1",f.l2_1),c.updateVector3("vSphericalL20",f.l20),c.updateVector3("vSphericalL21",f.l21),c.updateVector3("vSphericalL22",f.l22)}else c.updateFloat3("vSphericalX",u.x.x,u.x.y,u.x.z),c.updateFloat3("vSphericalY",u.y.x,u.y.y,u.y.z),c.updateFloat3("vSphericalZ",u.z.x,u.z.y,u.z.z),c.updateFloat3("vSphericalXX_ZZ",u.xx.x-u.zz.x,u.xx.y-u.zz.y,u.xx.z-u.zz.z),c.updateFloat3("vSphericalYY_ZZ",u.yy.x-u.zz.x,u.yy.y-u.zz.y,u.yy.z-u.zz.z),c.updateFloat3("vSphericalZZ",u.zz.x,u.zz.y,u.zz.z),c.updateFloat3("vSphericalXY",u.xy.x,u.xy.y,u.xy.z),c.updateFloat3("vSphericalYZ",u.yz.x,u.yz.y,u.yz.z),c.updateFloat3("vSphericalZX",u.zx.x,u.zx.y,u.zx.z)}c.updateFloat3("vReflectionMicrosurfaceInfos",l.getSize().width,l.lodGenerationScale,l.lodGenerationOffset)}this._emissiveTexture&&L.EmissiveTextureEnabled&&(c.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),Be(this._emissiveTexture,c,"emissive")),this._lightmapTexture&&L.LightmapTextureEnabled&&(c.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),Be(this._lightmapTexture,c,"lightmap")),L.SpecularTextureEnabled&&(this._metallicTexture?(c.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),Be(this._metallicTexture,c,"reflectivity")):this._reflectivityTexture&&(c.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),Be(this._reflectivityTexture,c,"reflectivity")),this._metallicReflectanceTexture&&(c.updateFloat2("vMetallicReflectanceInfos",this._metallicReflectanceTexture.coordinatesIndex,this._metallicReflectanceTexture.level),Be(this._metallicReflectanceTexture,c,"metallicReflectance")),this._reflectanceTexture&&r.REFLECTANCE&&(c.updateFloat2("vReflectanceInfos",this._reflectanceTexture.coordinatesIndex,this._reflectanceTexture.level),Be(this._reflectanceTexture,c,"reflectance")),this._microSurfaceTexture&&(c.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),Be(this._microSurfaceTexture,c,"microSurfaceSampler"))),this._bumpTexture&&o.getCaps().standardDerivatives&&L.BumpTextureEnabled&&!this._disableBumpMap&&(c.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),Be(this._bumpTexture,c,"bump"),s._mirroredCameraPosition?c.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):c.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1))}if(this.pointsCloud&&c.updateFloat("pointSize",this.pointSize),r.METALLICWORKFLOW){Ct.Color3[0].r=this._metallic===void 0||this._metallic===null?1:this._metallic,Ct.Color3[0].g=this._roughness===void 0||this._roughness===null?1:this._roughness;const u=this.subSurface?._indexOfRefraction??1.5,f=1;Ct.Color3[0].b=u,c.updateColor4("vReflectivityColor",Ct.Color3[0],1);const d=Math.pow((u-f)/(u+f),2);this._metallicReflectanceColor.scaleToRef(d*this._metallicF0Factor,Ct.Color3[0]);const g=this._metallicF0Factor;c.updateColor4("vMetallicReflectanceFactors",Ct.Color3[0],g)}else c.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface);c.updateColor3("vEmissiveColor",L.EmissiveTextureEnabled?this._emissiveColor:q.BlackReadOnly),c.updateColor3("vReflectionColor",this._reflectionColor),!r.SS_REFRACTION&&this.subSurface?._linkRefractionWithTransparency?c.updateColor4("vAlbedoColor",this._albedoColor,1):c.updateColor4("vAlbedoColor",this._albedoColor,this.alpha),c.updateFloat("baseWeight",this._baseWeight),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity*s.environmentIntensity,this._lightingInfos.w=this._specularIntensity,c.updateVector4("vLightingIntensity",this._lightingInfos),s.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor),c.updateColor3("vAmbientColor",this._globalAmbientColor),c.updateFloat2("vDebugMode",this.debugLimit,this.debugFactor)}if(s.texturesEnabled){if(this._albedoTexture&&L.DiffuseTextureEnabled&&c.setTexture("albedoSampler",this._albedoTexture),this._baseWeightTexture&&L.BaseWeightTextureEnabled&&c.setTexture("baseWeightSampler",this._baseWeightTexture),this._ambientTexture&&L.AmbientTextureEnabled&&c.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&L.OpacityTextureEnabled&&c.setTexture("opacitySampler",this._opacityTexture),l&&L.ReflectionTextureEnabled){r.LODBASEDMICROSFURACE?c.setTexture("reflectionSampler",l):(c.setTexture("reflectionSampler",l._lodTextureMid||l),c.setTexture("reflectionSamplerLow",l._lodTextureLow||l),c.setTexture("reflectionSamplerHigh",l._lodTextureHigh||l)),r.USEIRRADIANCEMAP&&c.setTexture("irradianceSampler",l.irradianceTexture);const u=this.getScene().iblCdfGenerator;this.realTimeFiltering&&u&&c.setTexture("icdfSampler",u.getIcdfTexture())}r.ENVIRONMENTBRDF&&c.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),this._emissiveTexture&&L.EmissiveTextureEnabled&&c.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&L.LightmapTextureEnabled&&c.setTexture("lightmapSampler",this._lightmapTexture),L.SpecularTextureEnabled&&(this._metallicTexture?c.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&c.setTexture("reflectivitySampler",this._reflectivityTexture),this._metallicReflectanceTexture&&c.setTexture("metallicReflectanceSampler",this._metallicReflectanceTexture),this._reflectanceTexture&&r.REFLECTANCE&&c.setTexture("reflectanceSampler",this._reflectanceTexture),this._microSurfaceTexture&&c.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&o.getCaps().standardDerivatives&&L.BumpTextureEnabled&&!this._disableBumpMap&&c.setTexture("bumpSampler",this._bumpTexture)}this.getScene().useOrderIndependentTransparency&&this.needAlphaBlendingForMesh(t)&&this.getScene().depthPeelingRenderer.bind(n),this._eventInfo.subMesh=i,this._callbackPluginEventBindForSubMesh(this._eventInfo),
vendor: 9,560 bytes, line 51
51ll(this._activeEffect,this,s),this.bindEyePosition(n)}else s.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);(h||!this.isFrozen)&&(s.lightsEnabled&&!this._disableLighting&&bl(s,t,this._activeEffect,r,this._maxSimultaneousLights),(s.fogEnabled&&t.applyFog&&s.fogMode!==Xe.FOGMODE_NONE||l||this.subSurface.refractionTexture||t.receiveShadows||r.PREPASS)&&this.bindView(n),ul(s,t,this._activeEffect,!0),r.NUM_MORPH_INFLUENCERS&&qa(t,this._activeEffect),r.BAKED_VERTEX_ANIMATION_TEXTURE&&t.bakedVertexAnimationManager?.bind(n,r.INSTANCES),this._imageProcessingConfiguration.bind(this._activeEffect),cl(r,this._activeEffect,s)),this._afterBind(t,this._activeEffect,i),c.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._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._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._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._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)}}xe.PBRMATERIAL_OPAQUE=v.MATERIAL_OPAQUE;xe.PBRMATERIAL_ALPHATEST=v.MATERIAL_ALPHATEST;xe.PBRMATERIAL_ALPHABLEND=v.MATERIAL_ALPHABLEND;xe.PBRMATERIAL_ALPHATESTANDBLEND=v.MATERIAL_ALPHATESTANDBLEND;xe.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=0;xe.LIGHTFALLOFF_PHYSICAL=0;xe.LIGHTFALLOFF_GLTF=1;xe.LIGHTFALLOFF_STANDARD=2;xe.ForceGLSL=!1;p([No()],xe.prototype,"_imageProcessingConfiguration",void 0);p([N("_markAllSubMeshesAsMiscDirty")],xe.prototype,"debugMode",void 0);class Y extends xe{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===xe.LIGHTFALLOFF_PHYSICAL}set usePhysicalLightFalloff(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),e?this._lightFalloff=xe.LIGHTFALLOFF_PHYSICAL:this._lightFalloff=xe.LIGHTFALLOFF_STANDARD)}get useGLTFLightFalloff(){return this._lightFalloff===xe.LIGHTFALLOFF_GLTF}set useGLTFLightFalloff(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),e?this._lightFalloff=xe.LIGHTFALLOFF_GLTF:this._lightFalloff=xe.LIGHTFALLOFF_STANDARD)}get imageProcessingConfiguration(){return this._imageProcessingConfiguration}set imageProcessingConfiguration(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()}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}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=Y.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=c
vendor: 6,918 bytes, line 51
51o(this.getScene())}getClassName(){return"PBRMaterial"}clone(e,t=!0,i=""){const s=re.Clone(()=>new Y(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=re.Parse(()=>new Y(e.name,t),e,t,i);return e.stencil&&s.stencil.parse(e.stencil,t,i),v._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}}Y.PBRMATERIAL_OPAQUE=xe.PBRMATERIAL_OPAQUE;Y.PBRMATERIAL_ALPHATEST=xe.PBRMATERIAL_ALPHATEST;Y.PBRMATERIAL_ALPHABLEND=xe.PBRMATERIAL_ALPHABLEND;Y.PBRMATERIAL_ALPHATESTANDBLEND=xe.PBRMATERIAL_ALPHATESTANDBLEND;Y.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=xe.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"directIntensity",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"emissiveIntensity",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"environmentIntensity",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"specularIntensity",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"disableBumpMap",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"albedoTexture",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"baseWeightTexture",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"ambientTexture",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"ambientTextureStrength",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"ambientTextureImpactOnAnalyticalLights",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesAndMiscDirty")],Y.prototype,"opacityTexture",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"reflectionTexture",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"emissiveTexture",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"reflectivityTexture",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"metallicTexture",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"metallic",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"roughness",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"metallicF0Factor",void 0);p([Rt(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"metallicReflectanceColor",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"useOnlyMetallicFromMetallicReflectanceTexture",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"metallicReflectanceTexture",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"reflectanceTexture",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"microSurfaceTexture",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"bumpTexture",void 0);p([Ie(),N("_markAllSubMeshesAsTexturesDirty",null)],Y.prototype,"lightmapTexture",void 0);p([Rt("ambient"),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"ambientColor",void 0);p([Rt("albedo"),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"albedoColor",void 0);p([E("baseWeight"),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"baseWeight",void 0);p([Rt("reflectivity"),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"reflectivityColor",void 0);p([Rt("reflection"),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"reflectionColor",void 0);p([Rt("emissive"),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"emissiveColor",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"microSurface",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"useLightmapAsShadowmap",void 0);p([E(),N("_markAllSubMeshesAsTexturesAndMiscDirty")],Y.prototype,"useAlphaFromAlbedoTexture",void 0);p([E(),N("_markAllSubMeshesAsTexturesAndMiscDirty")],Y.prototype,"forceAlphaTest",void 0);p([E(),N("_markAllSubMeshesAsTexturesAndMiscDirty")],Y.prototype,"alphaCutOff",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"useSpecularOverAlpha",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"useRoughnessFromMetallicTextureAlpha",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"useRoughnessFromMetallicTextureGreen",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"useMetallnessFromMetallicTextureBlue",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"useAmbientInGrayScale",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0);p([E()],Y.prototype,"usePhysicalLightFalloff",null);p([E()],Y.prototype,"useGLTFLightFalloff",null);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"useRadianceOverAlpha",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"useObjectSpaceNormalMap",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"useParallax",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"useParallaxOcclusion",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"parallaxScaleBias",void 0);p([E(),N("_markAllSubMeshesAsLightsDirty")],Y.prototype,"disableLighting",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"forceIrradianceInFragment",void 0);p([E(),N("_markAllSubMeshesAsLightsDirty")],Y.prototype,"maxSimultaneousLights",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"invertNormalMapX",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"invertNormalMapY",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"twoSidedLighting",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"useAlphaFresnel",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"useLinearAlphaFresnel",void 0);p([N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"environmentBRDFTexture",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"forceNormalForward",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"enableSpecularAntiAliasing",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"useHorizonOcclusion",void 0);p([E(),N("_markAllSubMeshesAsTexturesDirty")],Y.prototype,"useRadianceOcclusion",void 0);p([E(),N("_markAllSubMeshesAsMiscDirty")],Y.prototype,"unlit",void 0);p([E(),N("_markAllSubMeshesAsMiscDirty")],Y.prototype,"applyDecalMapAfterDetailMap",void 0);it("BABYLON.PBRMaterial",Y);function 
vendor: 25,786 bytes, line 51
51hu(a,e,t){const i=a.getVerticesData(T.PositionKind);if(!i)return!1;const s=e*3,r=[i[s+0],i[s+1],i[s+2]];if(r.some(n=>isNaN(n??Number.NaN)))return!1;if(a.morphTargetManager)for(let n=0;n<3;n++){let o=r[n];for(let h=0;h<a.morphTargetManager.numTargets;h++){const l=a.morphTargetManager.getTarget(h),c=l.influence;if(c!==0){const u=l.getPositions();u&&(o+=(u[s+n]-i[s+n])*c)}}r[n]=o}if(t.fromArray(r),a.skeleton){const n=a.getVerticesData(T.MatricesIndicesKind),o=a.getVerticesData(T.MatricesWeightsKind);if(o&&n){const h=a.numBoneInfluencers>4,l=h?a.getVerticesData(T.MatricesIndicesExtraKind):null,c=h?a.getVerticesData(T.MatricesWeightsExtraKind):null,u=a.skeleton.getTransformMatrices(a),f=C.Matrix[0],d=C.Matrix[1];f.reset();const g=e*4;let m,b;for(m=0;m<4;m++)b=o[g+m],b>0&&(M.FromFloat32ArrayToRefScaled(u,Math.floor(n[g+m]*16),b,d),f.addToSelf(d));if(l&&c)for(m=0;m<4;m++)b=c[g+m],b>0&&(M.FromFloat32ArrayToRefScaled(u,Math.floor(l[g+m]*16),b,d),f.addToSelf(d));_.TransformCoordinatesFromFloatsToRef(r[0],r[1],r[2],f,t)}}return!0}function lu(a,e,t,i){t.set(0,0,0);for(let s=0;s<3;s++){const r=e.pointIndex[s];if(!hu(a,r,C.Vector3[s]))return!1;C.Vector3[s].scaleAndAddToRef(e.barycentric[s],t)}if(_.TransformCoordinatesToRef(t,a.getWorldMatrix(),t),i){const s=C.Vector3[0],r=C.Vector3[1],n=C.Vector3[2],o=C.Vector3[3],h=C.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}se._GroundMeshParser=(a,e)=>ys.Parse(a,e);class ys extends se{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=C.Matrix[5];i.invertToRef(s);const r=C.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=C.Matrix[5];s.invertToRef(r);const n=C.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=new Array;for(let i=0;i<t;i++)for(let s=0;s<e;s++){const r={slope:Z.Zero(),facet1:new he(0,0,0,0),facet2:new he(0,0,0,0)};this._heightQuads[i*e+s]=r}return this}_computeHeightQuads(){const e=this.getVerticesData(T.PositionKind);if(!e)return this;const t=C.Vector3[3],i=C.Vector3[2],s=C.Vector3[1],r=C.Vector3[0],n=C.Vector3[4],o=C.Vector3[5],h=C.Vector3[6],l=C.Vector3[7],c=C.Vector3[8];let u=0,f=0,d=0,g=0,m=0,b=0,y=0;const A=this._subdivisionsX,P=this._subdivisionsY;for(let I=0;I<P;I++)for(let x=0;x<A;x++){u=x*3,f=I*(A+1)*3,d=(I+1)*(A+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),m=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(),b=-(l.x*t.x+l.y*t.y+l.z*t.z),y=-(c.x*i.x+c.y*i.y+c.z*i.z);const R=this._heightQuads[I*A+x];R.slope.copyFromFloats(g,m),R.facet1.copyFromFloats(l.x,l.y,l.z,b),R.facet2.copyFromFloats(c.x,c.y,c.z,y)}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 ys(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 uo(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 Q;return u.indices=e,u.positions=t,u.normals=i,u.uvs=s,u}function fo(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 m={w:(i-e)/r.w,h:(s-t)/r.h};function b(A,P,I,x){const R=h.length/3,S=n.w+1;for(u=0;u<n.h;u++)for(f=0;f<n.w;f++){const X=[R+f+u*S,R+(f+1)+u*S,R+(f+1)+(u+1)*S,R+f+(u+1)*S];o.push(X[1]),o.push(X[2]),o.push(X[3]),o.push(X[0]),o.push(X[1]),o.push(X[3])}const D=_.Zero(),G=new _(0,1,0);for(u=0;u<=n.h;u++)for(D.z=u*(x-P)/n.h+P,f=0;f<=n.w;f++)D.x=f*(I-A)/n.w+A,D.y=0,h.push(D.x,D.y,D.z),l.push(G.x,G.y,G.z),c.push(f/n.w,u/n.h)}for(d=0;d<r.h;d++)for(g=0;g<r.w;g++)b(e+g*m.w,t+d*m.h,e+(g+1)*m.w,t+(d+1)*m.h);const y=new Q;return y.indices=o,y.positions=h,y.normals=l,y.uvs=c,y}function _o(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 m=a.buffer[g]/255,b=a.buffer[g+1]/255,y=a.buffer[g+2]/255;const A=a.buffer[g+3]/255;l&&(m=1-m,b=1-b,y=1-y);const P=m*o.r+b*o.g+y*o.b;A>=h?u.y=a.minHeight+(a.maxHeight-a.minHeight)*P:u.y=a.minHeight-_e,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),m=t[u*3+1]>=a.minHeight,b=t[f*3+1]>=a.minHeight,y=t[d*3+1]>=a.minHeight;m&&b&&y&&(e.push(u),e.push(f),e.push(d)),t[g*3+1]>=a.minHeight&&m&&y&&(e.push(g),e.push(u),e.push(d))}Q.ComputeNormals(t,e,i);const c=new Q;return c.indices=e,c.positions=t,c.normals=i,c.uvs=s,c}function cu(a,e={},t){const i=new ys(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,uo(e).applyToMesh(i,e.updatable),i._setReady(!0),i}function uu(a,e,t=null){const i=new se(a,t);return fo(e).applyToMesh(i,e.updatable),i}function du(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||de.LastCreatedScene;const d=new ys(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 m=(b,y,A)=>{_o({width:s,height:r,subdivisions:n,minHeight:o,maxHeight:h,colorFilter:l,buffer:b,bufferWidth:y,bufferHeight:A,alphaFilter:c,heightBuffer:g}).applyToMesh(d,u),f&&f(d,g),d._setReady(!0)};if(typeof e=="string"){const b=y=>{const A=y.width,P=y.height;if(i.isDisposed)return;const I=i?.getEngine().resizeImageBitmap(y,A,P);m(I,A,P)};B.LoadImage(e,b,t.onError?t.onError:()=>{},i.offlineProvider)}else m(e.data,e.width,e.height);return d}Q.CreateGround=uo;Q.CreateTiledGround=fo;Q.CreateGroundFromHeightMap=_o;se.CreateGround=(a,e,t,i,s,r)=>cu(a,{width:e,height:t,subdivisions:i,updatable:r},s);se.CreateTiledGround=(a,e,t,i,s,r,n,o,h)=>uu(a,{xmin:e,zmin:t,xmax:i,zmax:s,subdivisions:r,precision:n,updatable:h},o);se.CreateGroundFromHeightMap=(a,e,t,i,s,r,n,o,h,l,c)=>du(a,e,{width:t,height:i,subdivisions:s,minHeight:r,maxHeight:n,updatable:h,onReady:l,alphaFilter:c},o);function go(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],m=d[u],b=[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],b=[-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]],D=[[-1,-1,1],[1,-1,1],[1,-1,-1],[-1,-1,-1]];const G=[17,18,19,16],X=[22,23,20,21];for(;g>0;)S.unshift(S.pop()),G.unshift(G.pop()),g--;for(;m>0;)D.unshift(D.pop()),X.unshift(X.pop()),m--;S=S.flat(),D=D.flat(),b=b.concat(S).concat(D),t.push(G[0],G[2],G[3],G[0],G[1],G[2]),t.push(X[0],X[2],X[3],X[0],X[1],X[2])}const y=[n/2,o/2,h/2];r=b.reduce((S,D,G)=>S.concat(D*y[G%3]),[]);const A=a.sideOrientation===0?0:a.sideOrientation||Q.DEFAULTSIDE,P=a.faceUV||new Array(6),I=a.faceColors,x=[];for(let S=0;S<6;S++)P[S]===void 0&&(P[S]=new he(0,0,1,1)),I&&I[S]===void 0&&(I[S]=new le(1,1,1,1));for(let S=0;S<6;S++)if(s.push(P[S].z,P[S].w),s.push(P[S].x,P[S].w),s.push(P[S].x,P[S].y),s.push(P[S].z,P[S].y),I)for(let D=0;D<4;D++)x.push(I[S].r,I[S].g,I[S].b,I[S].a);Q._ComputeSides(A,r,t,i,s,a.frontUVs,a.backUVs);const R=new Q;if(R.indices=t,R.positions=r,R.normals=i,R.uvs=s,I){const S=A===Q.DOUBLESIDE?x.concat(x):x;R.colors=S}return R}function po(a,e={},t=null){const i=new se(a,t);return e.sideOrientation=se._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,go(e).applyToMesh(i,e.updatable),i}Q.CreateBox=go;se.CreateBox=(a,e,t=null,i,s)=>po(a,{size:e,sideOrientation:s,updatable:i},t);function ea(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 fu(a,e=null,t=1/6){const i=C.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(T.PositionKind);if(!g)continue;const m=d.getTotalVertices();o.length=Math.max(o.length,m),h.length=Math.max(o.length,m);for(let I=0,x=0;I<m;I++,x+=3)i.set(g[x],g[x+1],g[x+2]),o[I].copyFrom(i),h[I].copyFrom(i);const b=d.morphTargetManager;if(b)for(let I=0;I<b.numTargets;++I){const R=b.getTarget(I).getPositions();if(R)for(let S=0,D=0;S<m;S++,D+=3)i.set(R[D],R[D+1],R[D+2]),o[S].minimizeInPlace(i),h[S].maximizeInPlace(i)}const y=d.skeleton,A=y?d.getVerticesData(T.MatricesWeightsKind):null,P=y?d.getVerticesData(T.MatricesIndicesKind):null;if(A&&P){const I=d.numBoneInfluencers>4,x=I?d.getVerticesData(T.MatricesWeightsExtraKind):null,R=I?d.getVerticesData(T.MatricesIndicesExtraKind):null,S=r.get(d.uniqueId)||new Map;r.set(d.uniqueId,S);const D=(G,X,Re,fe)=>{for(let ge=X;ge<X+4;ge++)if(Re[ge]>0){const ue=fe[ge],ze=S.get(ue);ze?(ze.minimum.minimizeInPlace(o[G]),ze.maximum.maximizeInPlace(h[G])):S.set(ue,{minimum:o[G].clone(),maximum:h[G].clone()})}};for(let G=0,X=0;G<m;G++,X+=4)D(G,X,A,P),x&&R&&D(G,X,x,R)}else{const I=s.get(d.uniqueId)||{minimum:new _().setAll(Number.POSITIVE_INFINITY),maximum:new _().setAll(Number.NEGATIVE_INFINITY)};s.set(d.uniqueId,I);for(let x=0;x<m;x++)I.minimum.minimizeInPlace(o[x]),I.maximum.maximizeInPlace(h[x])}}const l=new Map,c=new Map;for(const d of a){const g=s.get(d.uniqueId);if(g)l.set(d.uniqueId,ea(g));else{const m=r.get(d.uniqueId);if(m){const b=d.skeleton.bones,y=new Map;c.set(d.uniqueId,y),m.forEach((A,P)=>{const I=ea(A),x=b[P].getAbsoluteInverseBindMatrix();for(const R of I)_.TransformCoordinatesToRef(R,x,R);y.set(P,I)})}}}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(T.PositionKind))continue;const b=g.computeWorldMatrix(!0),y=g.skeleton;if(y){y.prepare(!0);const A=y.bones;c.get(g.uniqueId).forEach((I,x)=>{for(const R of I){const S=A[x].getFinalMatrix().multiplyToRef(b,C.Matrix[0]);_.TransformCoordinatesToRef(R,S,i),u[d].minimum.minimizeInPlace(i),u[d].maximum.maximizeInPlace(i)}})}else for(const A of l.get(g.uniqueId))_.TransformCoordinatesToRef(A,b,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 m=e.from;m<=e.to;m+=g)e.goToFrame(m),f();e.goToFrame(d)}else f();return u}class mo{get resolve(){return this._resolve}get reject(){return this._reject}constructor(){this.promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}}class ji{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 mo;let r=0;return t.forEach(n=>n.lockAsync(async()=>(r++,r===t.length&&s.resolve(await e()),s.promise),i).catch(o=>s.reject(o))),s.promise}}function To(...a){const e=t=>!!t&&typeof t=="object";return a.reduce((t,i)=>(Object.keys(i).forEach(s=>{const r=t[s],n=i[s];Array.isArray(r)&&Array.isArray(n)?t[s]=r.concat(...n):e(r)&&e(n)?t[s]=To(r,n):t[s]=n}),t),{})}class oi{getDescription(){return""}apply(e,t){return!0}constructor(e=0){this.priority=e}}class Er extends oi{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 kr extends oi{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 Rr extends oi{getDescription(){return"Turning shadows on/off"}apply(e,t){return e.shadowsEnabled=t.isInImprovementMode,!0}}class yr extends oi{getDescription(){return"Turning post-processes on/off"}apply(e,t){return e.postProcessesEnabled=t.isInImprovementMode,!0}}class xr extends oi{getDescription(){return"Turning lens flares on/off"}apply(e,t){return e.lensFlaresEnabled=t.isInImprovementMode,!0}}class _u extends oi{getDescription(){return this.onGetDescription?this.onGetDescription():"Running user defined callback"}apply(e,t){return this.onApply?this.onApply(e,t):!0}}class Sr extends oi{getDescription(){return"Turning particles on/off"}apply(e,t){return e.particlesEnabled=t.isInImprovementMode,!0}}class ta extends oi{getDescription(){return"Turning render targets off"}apply(e,t){return e.renderTargetsEnabled=t.isInImprovementMode,!0}}class di extends oi{constructor(){super(...arguments),this._canBeMerged=e=>{if(!(e instanceof se))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||se.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 Si{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 _u(i);return s.onApply=e,s.onGetDescription=t,this.optimizations.push(s),this}static LowDegradationAllowed(e){const t=new Si(e);let i=0;return t.addOptimization(new di(i)),t.addOptimization(new Rr(i)),t.addOptimization(new xr(i)),i++,t.addOptimization(new yr(i)),t.addOptimization(new Sr(i)),i++,t.addOptimization(new Er(i,1024)),t}static ModerateDegradationAllowed(e){const t=new Si(e);let i=0;return t.addOptimization(new di(i)),t.addOptimization(new Rr(i)),t.addOptimization(new xr(i)),i++,t.addOptimization(new yr(i)),t.addOptimization(new Sr(i)),i++,t.addOptimization(new Er(i,512)),i++,t.addOptimization(new ta(i)),i++,t.addOptimization(new kr(i,2)),t}static HighDegradationAllowed(e){const t=new Si(e);let i=0;return t.addOptimization(new di(i)),t.addOptimization(new Rr(i)),t.addOptimization(new xr(i)),i++,t.addOptimization(new yr(i)),t.addOptimization(new Sr(i)),i++,t.addOptimization(new Er(i,256)),i++,t.addOptimization(new ta(i)),i++,t.addOptimization(new kr(i,4)),t}}class rn{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 Si,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||de.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;r++){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 rn(e,t||Si.ModerateDegradationAllowed(),!1);return i&&r.onSuccessObservable.add(()=>{i()}),s&&r.onFailureObservable.add(()=>{s()}),r.start(),r}}class gu{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._log("onResize","end")}),this._scene.onBeforeRenderObservable.add(()=>{if(this._fastSnapshotRenderingEnabled){e.skeletons.forEach(i=>i.prepare(!0));for(const i of e.meshes)if(i.infiniteDistance&&i.transferToEffect(i.computeWorldMatrix(!0)),i.skeleton&&i.transferToEffect(i.computeWorldMatrix(!0)),i.getClassName()==="GaussianSplattingMesh"&&i._postToWorker(),i.morphTargetManager&&i.subMeshes)for(const s of i.subMeshes){const r=s._drawWrapper,n=r.effect;if(n){const o=r.drawContext.buffers.LeftOver,h=n._pipelineContext?.uniformBuffer;o&&h&&h.setDataBuffer(o)&&(i.morphTargetManager._bind(n),qa(i,n),h.update())}}}}))}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} "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}
51`),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)t._updateInstancedBuffers(i,t._getInstancesRenderList(i._id),t._instanceDataStorage.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.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.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())}}}}_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&&F.Log(`[Frame: ${this._engine.frameId}] SnapshotRenderingHelper:${e} - ${t}`)}}function pu(a){const e=a.split("?")[0],t=e.lastIndexOf(".");return t>-1?e.substring(t).toLowerCase():""}const ws="Z2xURg",ia={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,"+ws)||a.startsWith("data:;base64,"+ws)||a.startsWith("data:application/octet-stream;base64,"+ws)||a.startsWith("data:model/gltf-binary;base64,"+ws)}},sa={name:"obj",extensions:".obj"},ra={name:"splat",extensions:{".splat":{isBinary:!0},".ply":{isBinary:!0},".spz":{isBinary:!0}}},mu={name:"stl",extensions:{".stl":{isBinary:!0}}},nn=new Map,wd=nn;function Ee(a,e,t){Tu(a)&&F.Warn(`Extension with the name '${a}' already exists`),nn.set(a,{isGLTFExtension:e,factory:t})}function Tu(a){return nn.delete(a)}function bu(){Ee("EXT_lights_image_based",!0,async a=>{const{EXT_lights_image_based:e}=await j(()=>import("./EXT_lights_image_based-BsNp6JUy.js"),__vite__mapDeps([50,8,1,2,9,51,5,52,53,54,55,56]),import.meta.url);return new e(a)}),Ee("EXT_mesh_gpu_instancing",!0,async a=>{const{EXT_mesh_gpu_instancing:e}=await j(()=>import("./EXT_mesh_gpu_instancing-CAv0FSQb.js"),__vite__mapDeps([57,52,1,2,53,54,55,56,58]),import.meta.url);return new e(a)}),Ee("EXT_meshopt_compression",!0,async a=>{const{EXT_meshopt_compression:e}=await j(()=>import("./EXT_meshopt_compression-D4GQHsLC.js"),__vite__mapDeps([59,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("EXT_texture_avif",!0,async a=>{const{EXT_texture_avif:e}=await j(()=>import("./EXT_texture_avif-CA35hw-I.js"),__vite__mapDeps([60,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("EXT_texture_webp",!0,async a=>{const{EXT_texture_webp:e}=await j(()=>import("./EXT_texture_webp-Cst_912F.js"),__vite__mapDeps([61,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("ExtrasAsMetadata",!1,async a=>{const{ExtrasAsMetadata:e}=await j(()=>import("./ExtrasAsMetadata-dmBZGe0V.js"),__vite__mapDeps([62,1,2]),import.meta.url);return new e(a)}),Ee("KHR_animation_pointer",!0,async a=>{const{KHR_animation_pointer:e}=await j(()=>import("./KHR_animation_pointer--sdv68Zi.js"),__vite__mapDeps([63,56,64,1,2]),import.meta.url);return new e(a)}),Ee("KHR_draco_mesh_compression",!0,async a=>{const{KHR_draco_mesh_compression:e}=await j(()=>import("./KHR_draco_mesh_compression-BP13qWlt.js"),__vite__mapDeps([65,13,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("KHR_interactivity",!0,async a=>{const{KHR_interactivity:e}=await j(()=>import("./KHR_interactivity-BWDmpWVB.js").then(t=>
vendor: 63,752 bytes, lines 51-101
51t.K),__vite__mapDeps([66,1,2,67,56]),import.meta.url);return new e(a)}),Ee("KHR_lights_punctual",!0,async a=>{const{KHR_lights:e}=await j(()=>import("./KHR_lights_punctual-CqmCIXmi.js"),__vite__mapDeps([68,56,52,1,2,53,54,55]),import.meta.url);return new e(a)}),Ee("EXT_lights_ies",!0,async a=>{const{EXT_lights_ies:e}=await j(()=>import("./EXT_lights_ies-BEE0trGu.js"),__vite__mapDeps([69,56,52,1,2,53,54,55]),import.meta.url);return new e(a)}),Ee("KHR_materials_anisotropy",!0,async a=>{const{KHR_materials_anisotropy:e}=await j(()=>import("./KHR_materials_anisotropy-C7sSQ6HJ.js"),__vite__mapDeps([70,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("KHR_materials_clearcoat",!0,async a=>{const{KHR_materials_clearcoat:e}=await j(()=>import("./KHR_materials_clearcoat-DAzq7TUe.js"),__vite__mapDeps([71,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("KHR_materials_diffuse_transmission",!0,async a=>{const{KHR_materials_diffuse_transmission:e}=await j(()=>import("./KHR_materials_diffuse_transmission-DtXEk-Nm.js"),__vite__mapDeps([72,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("KHR_materials_dispersion",!0,async a=>{const{KHR_materials_dispersion:e}=await j(()=>import("./KHR_materials_dispersion-C909cV8R.js"),__vite__mapDeps([73,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("KHR_materials_emissive_strength",!0,async a=>{const{KHR_materials_emissive_strength:e}=await j(()=>import("./KHR_materials_emissive_strength-CHfA4dui.js"),__vite__mapDeps([74,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("KHR_materials_ior",!0,async a=>{const{KHR_materials_ior:e}=await j(()=>import("./KHR_materials_ior-D7SBRgdl.js"),__vite__mapDeps([75,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("KHR_materials_iridescence",!0,async a=>{const{KHR_materials_iridescence:e}=await j(()=>import("./KHR_materials_iridescence-qpOPL2zd.js"),__vite__mapDeps([76,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("KHR_materials_pbrSpecularGlossiness",!0,async a=>{const{KHR_materials_pbrSpecularGlossiness:e}=await j(()=>import("./KHR_materials_pbrSpecularGlossiness-xOTKMVvb.js"),__vite__mapDeps([77,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("KHR_materials_sheen",!0,async a=>{const{KHR_materials_sheen:e}=await j(()=>import("./KHR_materials_sheen-BFWfJKrE.js"),__vite__mapDeps([78,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("KHR_materials_specular",!0,async a=>{const{KHR_materials_specular:e}=await j(()=>import("./KHR_materials_specular-Dd7hqLZ_.js"),__vite__mapDeps([79,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("KHR_materials_transmission",!0,async a=>{const{KHR_materials_transmission:e}=await j(()=>import("./KHR_materials_transmission-CSC_ev2k.js"),__vite__mapDeps([80,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("KHR_materials_unlit",!0,async a=>{const{KHR_materials_unlit:e}=await j(()=>import("./KHR_materials_unlit-CAidPUi6.js"),__vite__mapDeps([81,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("KHR_materials_variants",!0,async a=>{const{KHR_materials_variants:e}=await j(()=>import("./KHR_materials_variants-DfvkIGRS.js"),__vite__mapDeps([82,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("KHR_materials_volume",!0,async a=>{const{KHR_materials_volume:e}=await j(()=>import("./KHR_materials_volume-ByedIIn-.js"),__vite__mapDeps([83,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("KHR_mesh_quantization",!0,async a=>{const{KHR_mesh_quantization:e}=await j(()=>import("./KHR_mesh_quantization-QxQB2tfe.js"),__vite__mapDeps([84,1,2]),import.meta.url);return new e(a)}),Ee("KHR_texture_basisu",!0,async a=>{const{KHR_texture_basisu:e}=await j(()=>import("./KHR_texture_basisu-BrUPMRDb.js"),__vite__mapDeps([85,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("KHR_texture_transform",!0,async a=>{const{KHR_texture_transform:e}=await j(()=>import("./KHR_texture_transform-CL2sV98D.js"),__vite__mapDeps([86,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("KHR_xmp_json_ld",!0,async a=>{const{KHR_xmp_json_ld:e}=await j(()=>import("./KHR_xmp_json_ld-C5VTzCWd.js"),__vite__mapDeps([87,1,2]),import.meta.url);return new e(a)}),Ee("MSFT_audio_emitter",!0,async a=>{const{MSFT_audio_emitter:e}=await j(()=>import("./MSFT_audio_emitter-CH-xxz_s.js"),__vite__mapDeps([88,52,1,2,53,54,55,56,89]),import.meta.url);return new e(a)}),Ee("MSFT_lod",!0,async a=>{const{MSFT_lod:e}=await j(()=>import("./MSFT_lod-xm5NYZKR.js"),__vite__mapDeps([90,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("MSFT_minecraftMesh",!0,async a=>{const{MSFT_minecraftMesh:e}=await j(()=>import("./MSFT_minecraftMesh-Rbkc50rD.js"),__vite__mapDeps([91,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("MSFT_sRGBFactors",!0,async a=>{const{MSFT_sRGBFactors:e}=await j(()=>import("./MSFT_sRGBFactors-BVQ-jX9H.js"),__vite__mapDeps([92,52,1,2,53,54,55,56]),import.meta.url);return new e(a)}),Ee("KHR_node_visibility",!0,async a=>{const{KHR_node_visibility:e}=await j(()=>import("./KHR_node_visibility-rjN_FMyb.js"),__vite__mapDeps([93,56,1,2]),import.meta.url);return new e(a)}),Ee("KHR_node_hoverability",!0,async a=>{const{KHR_node_hoverability:e}=await j(()=>import("./KHR_node_hoverability-XCLcvC4I.js"),__vite__mapDeps([94,67,56,1,2]),import.meta.url);return new e(a)}),Ee("KHR_node_selectability",!0,async a=>{const{KHR_node_selectability:e}=await j(()=>import("./KHR_node_selectability-DKourFKO.js"),__vite__mapDeps([95,67,56,1,2]),import.meta.url);return new e(a)})}function Au(){Os({...ia,createPlugin:async a=>{const{GLTFFileLoader:e}=await j(()=>import("./glTFLoader-D1J2X7DA.js"),__vite__mapDeps([52,1,2,53,54,55,56]),import.meta.url);return new e(a[ia.name])}}),bu(),Os({...sa,createPlugin:async a=>{const{OBJFileLoader:e}=await j(()=>import("./objFileLoader-D8fTW4lc.js"),__vite__mapDeps([96,55,97,1,2]),import.meta.url);return new e(a[sa.name])}}),Os({...ra,createPlugin:async a=>{const{SPLATFileLoader:e}=await j(()=>import("./splatFileLoader-B8s2l1yo.js"),__vite__mapDeps([98,1,2,48,43,45,24,37,34,29,22,33,54,58,55,99,97]),import.meta.url);return new e(a[ra.name])}}),Os({...mu,createPlugin:async()=>{const{STLFileLoader:a}=await j(()=>import("./stlFileLoader-BBIVtB-D.js"),__vite__mapDeps([100,55,97,1,2]),import.meta.url);return new a}})}const Eu=["none","standard","aces","neutral"];function bo(a){return Eu.includes(a)}function Mr(...a){for(const e of a)e?.throwIfAborted()}async function Ru(a,e,t){t=t??pu(a);const i=await(async()=>{if(t===".hdr"){const{HDRCubeTexture:r}=await j(()=>import("./hdrCubeTexture-C7L7dB6V.js"),__vite__mapDeps([101,11,1,2,54]),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 j(()=>import("./cubeTexture-BKRwbDv0.js"),__vite__mapDeps([51,5,1,2]),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 yu(a,e,t,i){const s=a.blockMaterialDirtyMechanism;a.blockMaterialDirtyMechanism=!0;try{const r=po("hdrSkyBox",void 0,a),n=new Y("skyBox",a);return n.imageProcessingConfiguration=new ae,n.backFaceCulling=!1,n.reflectionTexture=t,n.reflectionTexture&&(n.reflectionTexture.coordinatesMode=V.SKYBOX_MODE),n.microSurface=1-i,n.disableLighting=!0,n.twoSidedLighting=!0,r.material=n,r.isPickable=!1,r.infiniteDistance=!0,Ao(r,e),r}finally{a.blockMaterialDirtyMechanism=s}}function Ao(a,e){a?.scaling.setAll((e.maxZ-e.minZ)/2)}function xu(a){return a.flatMap(e=>fu(e.assetContainer.meshes,e.assetContainer.animationGroups[e.selectedAnimation]))}function Su(a){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 na(a){const e=xu(a);return Su(e)}function qi(a){(async()=>{try{await a}catch(e){e instanceof Mt||F.Error(e)}})()}async function Eo(a,e){await j(()=>import("./ray-TYnp1nlE.js"),__vite__mapDeps([99,1,2]),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),m=i.direction.clone();n.copyFrom(s),r=_.Distance(s,g),m.scaleAndAddToRef(r,n)}const h=_.Zero();s.subtractToRef(n,h),o&&o.hit&&(r=h.length());const l=Za(h),c=Ja(h.y,r),u=n.asArray();return{type:"world",position:u,normal:u,cameraOrbit:[l,c,r]}}const qe={clearColor:[0,0,0,0],autoSuspendRendering:!0,environmentConfig:{intensity:1,blur:.3,rotation:0,visible:!0},cameraAutoOrbit:{enabled:!1,delay:2e3,speed:.05},animationAutoPlay:!1,animationSpeed:1,postProcessing:{toneMapping:"neutral",contrast:1,exposure:1},useRightHandedSystem:!1},Mu={lighting:!0,skybox:!0};class an{constructor(){this.screenPosition=[NaN,NaN],this.worldPosition=[NaN,NaN,NaN],this.visibility=NaN}}class on{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.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=ni(4,_.Zero),this._meshDataCache=new Map,this._renderLoopController=null,this._loadedModelsBacking=[],this._activeModelBacking=null,this._skybox=null,this._skyboxBlur=this._options?.environmentConfig?.blur??qe.environmentConfig.blur,this._skyboxVisible=this._options?.environmentConfig?.visible??qe.environmentConfig.visible,this._skyboxTexture=null,this._reflectionTexture=null,this._reflectionsIntensity=this._options?.environmentConfig?.intensity??qe.environmentConfig.intensity,this._reflectionsRotation=this._options?.environmentConfig?.rotation??qe.environmentConfig.rotation,this._light=null,this._autoSuspendRendering=this._options?.autoSuspendRendering??qe.autoSuspendRendering,this._sceneMutated=!1,this._suspendRenderCount=0,this._isDisposed=!1,this._loadModelLock=new ji,this._loadModelAbortController=null,this._loadEnvironmentLock=new ji,this._loadEnvironmentAbortController=null,this._loadSkyboxLock=new ji,this._loadSkyboxAbortController=null,this._camerasAsHotSpotsAbortController=null,this._loadOperations=new Set,this._activeAnimationObservers=[],this._animationSpeed=this._options?.animationSpeed??qe.animationSpeed,this._camerasAsHotSpots=!1,this._hotSpots=this._options?.hotSpots??{},this._defaultHardwareScalingLevel=this._lastHardwareScalingLevel=this._engine.getHardwareScalingLevel();{const s=new Xe(this._engine);s.useRightHandedSystem=this._options?.useRightHandedSystem??qe.useRightHandedSystem,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 n=!1;this._toneMappingEnabled!==s.imageProcessingConfiguration.toneMappingEnabled&&(this._toneMappingEnabled=s.imageProcessingConfiguration.toneMappingEnabled,n=!0),this._toneMappingType!==s.imageProcessingConfiguration.toneMappingType&&(this._toneMappingType=s.imageProcessingConfiguration.toneMappingType,n=!0),this._contrast!==s.imageProcessingConfiguration.contrast&&(this._contrast=s.imageProcessingConfiguration.contrast,n=!0),this._exposure!==s.imageProcessingConfiguration.exposure&&(this._exposure=s.imageProcessingConfiguration.exposure,n=!0),n&&this.onPostProcessingChanged.notifyObservers()});const r=new Se("Viewer Default Camera",0,0,1,_.Zero(),s);r.useInputToRestoreState=!1,r.useAutoRotationBehavior=!0,r.onViewMatrixChangedObservable.add(()=>{this._markSceneMutated()}),s.onClearColorChangedObservable.add(()=>{this._markSceneMutated()}),s.onPointerObservable.add(async n=>{const o=await this._pick(n.event.offsetX,n.event.offsetY);if(o?.pickedPoint){const h=o.pickedPoint.subtract(r.position).dot(r.getForwardRay().direction);r.target=r.position.add(r.getForwardRay().direction.scale(h)),r.radius=h,r.interpolateTo(void 0,void 0,void 0,o.pickedPoint)}else this.resetCamera(!0)},ne.POINTERDOUBLETAP),s.onNewCameraAddedObservable.add(n=>{this.camerasAsHotSpots&&qi(this._addCameraHotSpot(n,this._camerasAsHotSpotsAbortController?.signal))}),s.onCameraRemovedObservable.add(n=>{this._removeCameraHotSpot(n)}),this._scene=s,this._camera=r}this._scene.skipFrustumClipping=!0,this._scene.skipPointerDownPicking=!0,this._scene.skipPointerUpPicking=!0,this._scene.skipPointerMovePicking=!0,this._snapshotHelper=new gu(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"),this.resetEnvironment().catch(()=>{}),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:(s,r)=>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,visible:this._skyboxVisible}}set environmentConfig(e){e.blur!==void 0&&this._changeSkyboxBlur(e.blur),e.intensity!==void 0&&this._changeEnvironmentIntensity(e.intensity),e.rotation!==void 0&&this._changeEnvironmentRotation(e.rotation),e.visible!==void 0&&this._changeSkyboxVisible(e.visible),this.onEnvironmentConfigurationChanged.notifyObservers()}_changeSkyboxBlur(e){if(e!==this._skyboxBlur&&(this._skyboxBlur=e,this._skybox)){const t=this._skybox.material;t instanceof Y&&(this._snapshotHelper.disableSnapshotRendering(),t.microSurface=1-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())}_changeSkyboxVisible(e){e!==this._skyboxVisible&&(this._skyboxVisible=e,this._skybox&&(this._snapshotHelper.disableSnapshotRendering(),this._skybox.setEnabled(this._skyboxVisible),this._updateAutoClear(),this._snapshotHelper.enableSnapshotRendering(),this._markSceneMutated()))}_updateAutoClear(){this._scene.autoClear=!0,this._markSceneMutated()}get postProcessing(){let e="none";if(this._toneMappingEnabled)switch(this._toneMappingType){case ae.TONEMAPPING_STANDARD:e="standard";break;case ae.TONEMAPPING_ACES:e="aces";break;case ae.TONEMAPPING_KHR_PBR_NEUTRAL:e="neutral";break}return{toneMapping:e,contrast:this._contrast,exposure:this._exposure}}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=ae.TONEMAPPING_STANDARD;break;case"aces":this._scene.imageProcessingConfiguration.toneMappingType=ae.TONEMAPPING_ACES;break;case"neutral":this._scene.imageProcessingConfiguration.toneMappingType=ae.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),this._scene.imageProcessingConfiguration.isEnabled=this._toneMappingEnabled||this._contrast!==1||this._exposure!==1,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(),this._applyAnimationSpeed(),this._selectAnimation(0,!1),this.onSelectedMaterialVariantChanged.notifyObservers(),this._reframeCamera(!0),this.onModelChanged.notifyObservers(i?.source??null))}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(Te(e,-1,this.animations.length-1)),this._activeModel&&e!==this._activeModel.selectedAnimation&&(this._activeAnimationObservers.forEach(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?.materialVariantsController?.selectedVariant??null}set selectedMaterialVariant(e){this._activeModel?.materialVariantsController&&(e||(e=this._activeModel.materialVariantsController.variants[0]),e!==this.selectedMaterialVariant&&this._activeModel.materialVariantsController.variants.includes(e)&&(this._snapshotHelper.disableSnapshotRendering(),this._activeModel.materialVariantsController.selectedVariant=e,this._snapshotHelper.enableSnapshotRendering(),this._markSceneMutated(),this.onSelectedMaterialVariantChanged.notifyObservers()))}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=To({onProgress:n,pluginOptions:{gltf:{transparencyAsCoverage:!0,extensionOptions:{KHR_materials_variants:{onLoaded:l}}}}},t??{}),this._snapshotHelper.disableSnapshotRendering();try{const u=await Rc(e,this._scene,t);u.animationGroups.forEach(m=>{m.start(!0,this.animationSpeed),m.pause()}),u.addAllToScene(),this._snapshotHelper.fixMeshes(u.meshes);let f=-1;const d=[],g={assetContainer:u,materialVariantsController:o,_animationPlaying:()=>u.animationGroups[f]?.isPlaying??!1,_shouldRender:()=>{const m=g?.assetContainer.animationGroups.some(b=>b.animatables.some(y=>y.animationStarted));return g._animationPlaying()||m},getHotSpotToRef:(m,b)=>this._getHotSpotToRef(u,m,b),dispose:()=>{this._snapshotHelper.disableSnapshotRendering(),u.meshes.forEach(b=>this._meshDataCache.delete(b)),u.dispose();const m=this._loadedModelsBacking.indexOf(g);m!==-1&&(this._loadedModelsBacking.splice(m,1),g===this._activeModel&&(this._activeModelBacking=null)),this._snapshotHelper.enableSnapshotRendering(),this._markSceneMutated()},getWorldBounds:(m=f)=>{let b=d[m];return b||(b=na([g]),b&&(d[m]=b)),b},resetWorldBounds:()=>{d.length=0},get selectedAnimation(){return f},set selectedAnimation(m){let b=u.animationGroups[f];const y=b?.isPlaying??!1;b&&(b.pause(),b.goToFrame(0)),f=m,b=u.animationGroups[f],b&&(b.goToFrame(0),b.play(!0),y||b.pause())},makeActive:m=>{this._setActiveModel(g,m)}};return this._loadedModelsBacking.push(g),g}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 Mt("New model is being loaded before previous model finished loading."));const s=this._loadModelAbortController=new AbortController;await this._loadModelLock.lockAsync(async()=>{Mr(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"))}),!this._scene.environmentTexture&&this._scene.materials.some(r=>r instanceof Y)&&await this.resetEnvironment({lighting:!0},i),this._startSceneOptimizer(!0)}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 Y)){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)}async _updateEnvironment(e,t,i){this._throwIfDisposedOrAborted(i);let s=e;if(e&&e.trim()==="auto"&&(t={...t,extension:".env"},s=(async()=>(await j(()=>import("./defaultEnvironment-C15qoIsh-DPUnnTO0.js"),[],import.meta.url)).default)()),t=t??Mu,!t.lighting&&!t.skybox)return;const r=[];t.lighting&&(this._loadEnvironmentAbortController?.abort(new Mt("New environment lighting is being loaded before previous environment lighting finished loading.")),r.push(this._loadEnvironmentLock)),t.skybox&&(this._loadSkyboxAbortController?.abort(new Mt("New environment skybox is being loaded before previous environment skybox finished loading.")),r.push(this._loadSkyboxLock));const n=this._loadEnvironmentAbortController=t.lighting?new AbortController:null,o=this._loadSkyboxAbortController=t.skybox?new AbortController:null;await ji.LockAsync(async()=>{Mr(i,n?.signal,o?.signal),this._snapshotHelper.disableSnapshotRendering();const h=()=>{t.lighting&&(this._reflectionTexture?.dispose(),this._reflectionTexture=null,this._scene.environmentTexture=null),t.skybox&&(this._skybox?.dispose(void 0,!0),this._skyboxTexture=null,this._skybox=null,this._updateAutoClear())};h();try{if(e=await s,e){const l=await Ru(e,this._scene,t.extension);t.lighting&&(this._reflectionTexture=l,this._scene.environmentTexture=this._reflectionTexture,l.level=this.environmentConfig.intensity,l.rotationY=this.environmentConfig.rotation),t.skybox&&(this._skyboxTexture=t.lighting?l.clone():l,this._skyboxTexture.level=this.environmentConfig.intensity,this._skyboxTexture.rotationY=this.environmentConfig.rotation,this._skybox=yu(this._scene,this._camera,this._skyboxTexture,this.environmentConfig.blur),this._skybox.setEnabled(this._skyboxVisible),this._snapshotHelper.fixMeshes([this._skybox]),this._updateAutoClear()),await new Promise((c,u)=>{const f=l.onLoadObservable.addOnce(()=>{f.remove(),d.remove(),c()}),d=V.OnTextureLoadErrorObservable.add(g=>{g===l&&(f.remove(),d.remove(),u(new Error("Failed to load environment texture.")))})})}this._updateLight(),this.onEnvironmentChanged.notifyObservers()}catch(l){throw h(),this.onEnvironmentError.notifyObservers(l),l}finally{this._snapshotHelper.enableSnapshotRendering(),this._markSceneMutated()}},r)}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"))&&qi(this._updateModel(this._options?.source)),(t.length===0||t.includes("environment"))&&(this._scene.clearColor=new le(...this._options?.clearColor??qe.clearColor),this.environmentConfig={intensity:this._options?.environmentConfig?.intensity??qe.environmentConfig.intensity,blur:this._options?.environmentConfig?.blur??qe.environmentConfig.blur,rotation:this._options?.environmentConfig?.rotation??qe.environmentConfig.rotation,visible:this._options?.environmentConfig?.visible??qe.environmentConfig.visible},this._options?.environmentLighting===this._options?.environmentSkybox?qi(this._updateEnvironment(this._options?.environmentLighting,{lighting:!0,skybox:!0},this._loadEnvironmentAbortController?.signal)):(qi(this._updateEnvironment(this._options?.environmentLighting,{lighting:!0},this._loadEnvironmentAbortController?.signal)),qi(this._updateEnvironment(this._options?.environmentSkybox,{skybox:!0},this._loadSkyboxAbortController?.signal)))),(t.length===0||t.includes("animation"))&&(this.animationSpeed=this._options?.animationSpeed??qe.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??qe.cameraAutoOrbit.enabled,speed:this._options?.cameraAutoOrbit?.speed??qe.cameraAutoOrbit.speed,delay:this._options?.cameraAutoOrbit?.delay??qe.cameraAutoOrbit.delay}}(t.length===0||t.includes("post-processing"))&&(this.postProcessing={toneMapping:this._options?.postProcessing?.toneMapping??qe.postProcessing.toneMapping,contrast:this._options?.postProcessing?.contrast??qe.postProcessing.contrast,exposure:this._options?.postProcessing?.exposure??qe.postProcessing.exposure}),(t.length===0||t.includes("material-variant"))&&(this.selectedMaterialVariant=this._options?.selectedMaterialVariant??null)}dispose(){this.selectedAnimation=-1,this.animationProgress=0,this._loadEnvironmentAbortController?.abort(new Mt("Thew viewer is being disposed.")),this._loadSkyboxAbortController?.abort(new Mt("Thew viewer is being disposed.")),this._loadModelAbortController?.abort(new Mt("Thew viewer is being disposed.")),this._camerasAsHotSpotsAbortController?.abort(new Mt("Thew viewer is being disposed.")),this._renderLoopController?.dispose(),this._activeModel?.dispose(),this._loadedModelsBacking.forEach(e=>e.dispose()),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._activeModel?.getHotSpotToRef(e,t)??!1}_getHotSpotToRef(e,t,i){const s=this._tempVectors[2],r=this._tempVectors[1],n=this._tempVectors[0];if(t.type==="surface"){const u=e?.meshes[t.meshIndex];if(!u||!lu(u,t,r,s))return!1}else r.copyFromFloats(t.position[0],t.position[1],t.position[2]),s.copyFromFloats(t.normal[0],t.normal[1],t.normal[2]);const o=this._camera.viewport.width*this._engine.getRenderWidth()*this._engine.getHardwareScalingLevel(),h=this._camera.viewport.height*this._engine.getRenderHeight()*this._engine.getHardwareScalingLevel(),l=this._scene;_.ProjectToRef(r,M.IdentityReadOnly,l.getTransformMatrix(),new ki(0,0,o,h),n),i.screenPosition[0]=n.x,i.screenPosition[1]=n.y,i.worldPosition[0]=r.x,i.worldPosition[1]=r.y,i.worldPosition[2]=r.z;const c=this._tempVectors[3];return c.copyFrom(this._camera.globalPosition),c.subtractInPlace(r),c.normalize(),i.visibility=_.Dot(c,s),!0}queryHotSpot(e,t){return this._queryHotSpot(e,t)!=null}focusHotSpot(e){const t=new an,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(t=>this._addCameraHotSpot(t,e.signal))}}async _createHotSpotFromCamera(e){if(e instanceof Se){const t=e.target.asArray();return{type:"world",position:t,normal:t,cameraOrbit:[e.alpha,e.beta,e.radius]}}return this._activeModel?Eo(this._activeModel,e):null}get _shouldRender(){return!this._autoSuspendRendering||this._sceneMutated||!this._snapshotHelper.isReady||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.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)}_reframeCameraFromBounds(e,t,i,s,r,n,o,h){let l=Math.PI/2,c=Math.PI/2.4,u=1,f=_.Zero();const d=na(t);d&&(this._camera.lowerRadiusLimit=null,u=_.FromArray(d.size).length()*1.1,f=_.FromArray(d.center),isFinite(u)||(u=1,f.copyFromFloats(0,0,0))),l=i??l,c=s??c,u=r??u,f.x=n??f.x,f.y=o??f.y,f.z=h??f.z,e?this._camera.interpolateTo(l,c,u,f,void 0,.1):(this._camera.stopInterpolation(),isNaN(l)||(this._camera.alpha=l),isNaN(c)||(this._camera.beta=c),isNaN(u)||(this._camera.radius=u,this._camera.lowerRadiusLimit=u*.001,this._camera.upperRadiusLimit=u*5,this._camera.minZ=u*.001,this._camera.maxZ=u*1e3),this._camera.setTarget(new _(isNaN(f.x)?this._camera.target.x:f.x,isNaN(f.y)?this._camera.target.y:f.y,isNaN(f.z)?this._camera.target.z:f.z),void 0,void 0,!0)),this._camera.wheelDeltaPercentage=.01,this._camera.useNaturalPinchZoom=!0,Ao(this._skybox,this._camera)}_updateLight(){let e;if(!this._activeModel)e=!1;else{const t=this._activeModel.assetContainer.lights.length>0,i=!!this._reflectionTexture,s=this._activeModel.assetContainer.materials.length>0,r=this._activeModel.assetContainer.materials.some(n=>!(n instanceof Y));t?e=!1:e=!i||!s||r}e?this._light||(this._light=new Rs("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 j(()=>import("./ray-TYnp1nlE.js"),__vite__mapDeps([99,1,2]),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 Si(60,1e3),i=new kr(void 0,1);t.addOptimization(i),this._sceneOptimizer=new rn(this._scene,t),this._sceneOptimizer.start()}_stopSceneOptimizer(){this._sceneOptimizer?.dispose(),this._sceneOptimizer=null}_log(e){this.showDebugLogs&&F.Log(e)}_throwIfDisposedOrAborted(...e){if(this._isDisposed)throw new Error("Viewer is disposed.");Mr(...e)}}Au();/**
52 * @license
53 * Copyright 2019 Google LLC
54 * SPDX-License-Identifier: BSD-3-Clause
55 */const ks=globalThis,hn=ks.ShadowRoot&&(ks.ShadyCSS===void 0||ks.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ln=Symbol(),aa=new WeakMap;let Ro=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==ln)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(hn&&e===void 0){const i=t!==void 0&&t.length===1;i&&(e=aa.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&aa.set(t,e))}return e}toString(){return this.cssText}};const Iu=a=>new Ro(typeof a=="string"?a:a+"",void 0,ln),yo=(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 Ro(t,a,ln)},Cu=(a,e)=>{if(hn)a.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const i=document.createElement("style"),s=ks.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=t.cssText,a.appendChild(i)}},oa=hn?a=>a:a=>a instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return Iu(t)})(a):a;/**
56 * @license
57 * Copyright 2017 Google LLC
58 * SPDX-License-Identifier: BSD-3-Clause
59 */const{is:Pu,defineProperty:vu,getOwnPropertyDescriptor:Du,getOwnPropertyNames:Ou,getOwnPropertySymbols:Fu,getPrototypeOf:wu}=Object,rr=globalThis,ha=rr.trustedTypes,Lu=ha?ha.emptyScript:"",Bu=rr.reactiveElementPolyfillSupport,es=(a,e)=>a,Qs={toAttribute(a,e){switch(e){case Boolean:a=a?Lu: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}},cn=(a,e)=>!Pu(a,e),la={attribute:!0,type:String,converter:Qs,reflect:!1,hasChanged:cn};Symbol.metadata??=Symbol("metadata"),rr.litPropertyMetadata??=new WeakMap;class Oi extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=la){if(t.state&&(t.attribute=!1),this._$Ei(),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(e,i,t);s!==void 0&&vu(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){const{get:s,set:r}=Du(this.prototype,e)??{get(){return this[t]},set(n){this[t]=n}};return{get(){return s?.call(this)},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)??la}static _$Ei(){if(this.hasOwnProperty(es("elementProperties")))return;const e=wu(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(es("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(es("properties"))){const t=this.properties,i=[...Ou(t),...Fu(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(oa(s))}else e!==void 0&&t.push(oa(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 Cu(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)}_$EC(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:Qs).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:Qs;this._$Em=s,this[s]=n.fromAttribute(t,r.type),this._$Em=null}}requestUpdate(e,t,i){if(e!==void 0){if(i??=this.constructor.getPropertyOptions(e),!(i.hasChanged??cn)(this[e],t))return;this.P(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(e,t,i){this._$AL.has(e)||this._$AL.set(e,t),i.reflect===!0&&this._$Em!==e&&(this._$Ej??=new Set).add(e)}async _$ET(){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)r.wrapped!==!0||this._$AL.has(s)||this[s]===void 0||this.P(s,this[s],r)}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._$EU()}catch(i){throw e=!1,this._$EU(),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)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Ej&&=this._$Ej.forEach(t=>this._$EC(t,this[t])),this._$EU()}updated(e){}firstUpdated(e){}}Oi.elementStyles=[],Oi.shadowRootOptions={mode:"open"},Oi[es("elementProperties")]=new Map,Oi[es("finalized")]=new Map,Bu?.({ReactiveElement:Oi}),(rr.reactiveElementVersions??=[]).push("2.0.4");/**
60 * @license
61 * Copyright 2017 Google LLC
62 * SPDX-License-Identifier: BSD-3-Clause
63 */const un=globalThis,js=un.trustedTypes,ca=js?js.createPolicy("lit-html",{createHTML:a=>a}):void 0,xo="$lit$",ci=`lit$${Math.random().toFixed(9).slice(2)}$`,So="?"+ci,Nu=`<${So}>`,Mi=document,fs=()=>Mi.createComment(""),_s=a=>a===null||typeof a!="object"&&typeof a!="function",dn=Array.isArray,Uu=a=>dn(a)||typeof a?.[Symbol.iterator]=="function",Ir=`[ 	
64\f\r]`,Qi=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ua=/-->/g,da=/>/g,Ti=RegExp(`>|${Ir}(?:([^\\s"'>=/]+)(${Ir}*=${Ir}*(?:[^ 	
65\f\r"'\`<>=]|("|')|))|$)`,"g"),fa=/'/g,_a=/"/g,Mo=/^(?:script|style|textarea|title)$/i,ku=a=>(e,...t)=>({_$litType$:a,strings:e,values:t}),Qe=ku(1),zi=Symbol.for("lit-noChange"),Ze=Symbol.for("lit-nothing"),ga=new WeakMap,Ri=Mi.createTreeWalker(Mi,129);function Io(a,e){if(!dn(a)||!a.hasOwnProperty("raw"))throw Error("invalid template strings array");return ca!==void 0?ca.createHTML(e):e}const Vu=(a,e)=>{const t=a.length-1,i=[];let s,r=e===2?"<svg>":e===3?"<math>":"",n=Qi;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===Qi?c[1]==="!--"?n=ua:c[1]!==void 0?n=da:c[2]!==void 0?(Mo.test(c[2])&&(s=RegExp("</"+c[2],"g")),n=Ti):c[3]!==void 0&&(n=Ti):n===Ti?c[0]===">"?(n=s??Qi,u=-1):c[1]===void 0?u=-2:(u=n.lastIndex-c[2].length,l=c[1],n=c[3]===void 0?Ti:c[3]==='"'?_a:fa):n===_a||n===fa?n=Ti:n===ua||n===da?n=Qi:(n=Ti,s=void 0);const d=n===Ti&&a[o+1].startsWith("/>")?" ":"";r+=n===Qi?h+Nu:u>=0?(i.push(l),h.slice(0,u)+xo+h.slice(u)+ci+d):h+ci+(u===-2?o:d)}return[Io(a,r+(a[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]};class gs{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]=Vu(e,t);if(this.el=gs.createElement(l,i),Ri.currentNode=this.el.content,t===2||t===3){const u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(s=Ri.nextNode())!==null&&h.length<o;){if(s.nodeType===1){if(s.hasAttributes())for(const u of s.getAttributeNames())if(u.endsWith(xo)){const f=c[n++],d=s.getAttribute(u).split(ci),g=/([.?@])?(.*)/.exec(f);h.push({type:1,index:r,name:g[2],strings:d,ctor:g[1]==="."?Gu:g[1]==="?"?zu:g[1]==="@"?Wu:nr}),s.removeAttribute(u)}else u.startsWith(ci)&&(h.push({type:6,index:r}),s.removeAttribute(u));if(Mo.test(s.tagName)){const u=s.textContent.split(ci),f=u.length-1;if(f>0){s.textContent=js?js.emptyScript:"";for(let d=0;d<f;d++)s.append(u[d],fs()),Ri.nextNode(),h.push({type:2,index:++r});s.append(u[f],fs())}}}else if(s.nodeType===8)if(s.data===So)h.push({type:2,index:r});else{let u=-1;for(;(u=s.data.indexOf(ci,u+1))!==-1;)h.push({type:7,index:r}),u+=ci.length-1}r++}}static createElement(e,t){const i=Mi.createElement("template");return i.innerHTML=e,i}}function Wi(a,e,t=a,i){if(e===zi)return e;let s=i!==void 0?t._$Co?.[i]:t._$Cl;const r=_s(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=Wi(a,s._$AS(a,e.values),s,i)),e}class Hu{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??Mi).importNode(t,!0);Ri.currentNode=s;let r=Ri.nextNode(),n=0,o=0,h=i[0];for(;h!==void 0;){if(n===h.index){let l;h.type===2?l=new xs(r,r.nextSibling,this,e):h.type===1?l=new h.ctor(r,h.name,h.strings,this,e):h.type===6&&(l=new Xu(r,this,e)),this._$AV.push(l),h=i[++o]}n!==h?.index&&(r=Ri.nextNode(),n++)}return Ri.currentNode=Mi,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 xs{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=Ze,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=Wi(this,e,t),_s(e)?e===Ze||e==null||e===""?(this._$AH!==Ze&&this._$AR(),this._$AH=Ze):e!==this._$AH&&e!==zi&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Uu(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!==Ze&&_s(this._$AH)?this._$AA.nextSibling.data=e:this.T(Mi.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=gs.createElement(Io(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(t);else{const r=new Hu(s,this),n=r.u(this.options);r.p(t),this.T(n),this._$AH=r}}_$AC(e){let t=ga.get(e.strings);return t===void 0&&ga.set(e.strings,t=new gs(e)),t}k(e){dn(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 xs(this.O(fs()),this.O(fs()),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 nr{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,r){this.type=1,this._$AH=Ze,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=Ze}_$AI(e,t=this,i,s){const r=this.strings;let n=!1;if(r===void 0)e=Wi(this,e,t,0),n=!_s(e)||e!==this._$AH&&e!==zi,n&&(this._$AH=e);else{const o=e;let h,l;for(e=r[0],h=0;h<r.length-1;h++)l=Wi(this,o[i+h],t,h),l===zi&&(l=this._$AH[h]),n||=!_s(l)||l!==this._$AH[h],l===Ze?e=Ze:e!==Ze&&(e+=(l??"")+r[h+1]),this._$AH[h]=l}n&&!s&&this.j(e)}j(e){e===Ze?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class Gu extends nr{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Ze?void 0:e}}class zu extends nr{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==Ze)}}class Wu extends nr{constructor(e,t,i,s,r){super(e,t,i,s,r),this.type=5}_$AI(e,t=this){if((e=Wi(this,e,t,0)??Ze)===zi)return;const i=this._$AH,s=e===Ze&&i!==Ze||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==Ze&&(i===Ze||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 Xu{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){Wi(this,e)}}const Ku=un.litHtmlPolyfillSupport;Ku?.(gs,xs),(un.litHtmlVersions??=[]).push("3.2.1");const Yu=(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 xs(e.insertBefore(fs(),r),r,void 0,t??{})}return s._$AI(a),s};/**
66 * @license
67 * Copyright 2017 Google LLC
68 * SPDX-License-Identifier: BSD-3-Clause
69 */let Ui=class extends Oi{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=Yu(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return zi}};Ui._$litElement$=!0,Ui.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:Ui});const qu=globalThis.litElementPolyfillSupport;qu?.({LitElement:Ui});(globalThis.litElementVersions??=[]).push("4.1.1");/**
70 * @license
71 * Copyright 2017 Google LLC
72 * SPDX-License-Identifier: BSD-3-Clause
73 */const Co=a=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(a,e)}):customElements.define(a,e)};/**
74 * @license
75 * Copyright 2017 Google LLC
76 * SPDX-License-Identifier: BSD-3-Clause
77 */const Qu={attribute:!0,type:String,converter:Qs,reflect:!1,hasChanged:cn},ju=(a=Qu,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),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.P(n,void 0,a),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 Pe(a){return(e,t)=>typeof t=="object"?ju(a,e,t):((i,s,r)=>{const n=s.hasOwnProperty(r);return s.constructor.createProperty(r,n?{...i,wrapped:!0}:i),n?Object.getOwnPropertyDescriptor(s,r):void 0})(a,e,t)}/**
78 * @license
79 * Copyright 2017 Google LLC
80 * SPDX-License-Identifier: BSD-3-Clause
81 */function Ss(a){return Pe({...a,state:!0,attribute:!1})}/**
82 * @license
83 * Copyright 2017 Google LLC
84 * SPDX-License-Identifier: BSD-3-Clause
85 */const Zu=(a,e,t)=>(t.configurable=!0,t.enumerable=!0,Reflect.decorate&&typeof e!="object"&&Object.defineProperty(a,e,t),t);/**
86 * @license
87 * Copyright 2017 Google LLC
88 * SPDX-License-Identifier: BSD-3-Clause
89 */function Po(a,e){return(t,i,s)=>{const r=n=>n.renderRoot?.querySelector(a)??null;return Zu(t,i,{get(){return r(this)}})}}/**
90 * @license
91 * Copyright 2020 Google LLC
92 * SPDX-License-Identifier: BSD-3-Clause
93 */const Ju=a=>a.strings===void 0;/**
94 * @license
95 * Copyright 2017 Google LLC
96 * SPDX-License-Identifier: BSD-3-Clause
97 */const $u={CHILD:2},ed=a=>(...e)=>({_$litDirective$:a,values:e});class td{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)}}/**
98 * @license
99 * Copyright 2017 Google LLC
100 * SPDX-License-Identifier: BSD-3-Clause
101 */const ts=(a,e)=>{const t=a._$AN;if(t===void 0)return!1;for(const i of t)i._$AO?.(e,!1),ts(i,e);return!0},Zs=a=>{let e,t;do{if((e=a._$AM)===void 0)break;t=e._$AN,t.delete(a),a=e}while(t?.size===0)},vo=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),rd(e)}};function id(a){this._$AN!==void 0?(Zs(this),this._$AM=a,vo(this)):this._$AM=a}function sd(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++)ts(i[r],!1),Zs(i[r]);else i!=null&&(ts(i,!1),Zs(i));else ts(this,a)}const rd=a=>{a.type==$u.CHILD&&(a._$AP??=sd,a._$AQ??=id)};class nd extends td{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,i){super._$AT(e,t,i),vo(this),this.isConnected=e._$AU}_$AO(e,t=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),t&&(ts(this,e),Zs(this))}setValue(e){if(Ju(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 Cr=new WeakMap,ad=ed(class extends nd{render(a){return Ze}update(a,[e]){const t=e!==this.Y;return t&&this.Y!==void 0&&this.rt(void 0),(t||this.lt!==this.ct)&&(this.Y=e,this.ht=a.options?.host,this.rt(this.ct=a.element)),Ze}rt(a){if(this.isConnected||(a=void 0),typeof this.Y=="function"){const e=this.ht??globalThis;let t=Cr.get(e);t===void 0&&(t=new WeakMap,Cr.set(e,t)),t.get(this.Y)!==void 0&&this.Y.call(this.ht,void 0),t.set(this.Y,a),a!==void 0&&this.Y.call(this.ht,a)}else this.Y.value=a}get lt(){return typeof this.Y=="function"?Cr.get(this.ht??globalThis)?.get(this.Y):this.Y?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}}),Pr={antialias:!0,adaptToDeviceRatio:!0};function od(){return"gpu"in navigator&&"chrome"in window?"WebGPU":"WebGL"}async function Do(a,e){e?e=new Proxy(e,{get(o,h){switch(h){case"antialias":return o.antialias??Pr.antialias;case"adaptToDeviceRatio":return o.adaptToDeviceRatio??Pr.adaptToDeviceRatio;default:return o[h]}}}):e=Pr;const t=[];let i;switch(e.engine??od()){case"WebGL":{const{Engine:o}=await j(()=>Promise.resolve().then(()=>Kc),void 0,import.meta.url);i=new o(a,void 0,e);break}case"WebGPU":{const{WebGPUEngine:o}=await j(()=>import("./webgpuEngine-DNcJ2-XH.js"),__vite__mapDeps([102,32,22,103,29,39,89,1,2]),import.meta.url),h=new o(a,e);await h.initAsync(),i=h;break}}if(e.onFaulted){const o=e.onFaulted,h=i.onContextLostObservable.addOnce(()=>{o(new Error("The engine context was lost."))});t.push(()=>h.remove())}const s=e.onInitialized;e.onInitialized=o=>{let h=!1;const l=new ResizeObserver(()=>{h=!0,o.markSceneMutated()});l.observe(a),t.push(()=>l.disconnect());const c=o.scene.onBeforeRenderObservable.add(()=>{h&&(i.resize(),h=!1)});t.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),t.push(()=>f.disconnect()),s?.(o)};const r=e?.viewerClass??on,n=new r(i,e);return t.push(n.dispose.bind(n)),t.push(()=>i.dispose()),n.dispose=()=>t.forEach(o=>o()),n}const hd="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",ld="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",cd="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",ud="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",dd="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",pa=[.5,1,1.5,2];function fd(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 le(i[0]/255,i[1]/255,i[2]/255,i[3]/255)}function _d(a){if(a==="WebGL"||a==="WebGPU")return a}function Jt(a){return a==null?null:Number(a)}function Ls(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 gd(a){return!a||!bo(a)?null:a}function pd(a){return!a||a==="auto"?"auto":a==="reframe"?"reframe":a.trim().split(/\s+/)}class Ae extends Ui{constructor(e,t={}){super(),this._viewerClass=e,this._options=t,this._viewerLock=new ji,this._animationSliderResizeObserver=null,this._propertyBindings=[this._createPropertyBinding("clearColor",i=>i.scene.onClearColorChangedObservable,i=>i.scene.clearColor=this.clearColor??new le(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("environmentVisible",i=>i.viewer.onEnvironmentConfigurationChanged,i=>i.viewer.environmentConfig={visible:this.environmentVisible??i.viewer.environmentConfig.visible},i=>this.environmentVisible=i.viewer.environmentConfig.visible),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("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=p
vendor: 6,089 bytes, lines 101-118
101a.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.environmentVisible=this._options.environmentConfig?.visible??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.clearColor=this._options.clearColor?new le(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")}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=Ls(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=Ls(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")}))}render(){return Qe`
102            <div class="full-size">
103                <div id="canvasContainer" class="full-size"></div>
104                ${this._renderOverlay()}
105            </div>
106        `}_renderProgressBar(){const e=this.loadingProgress!==!1,t=typeof this.loadingProgress=="boolean"?0:this.loadingProgress*100,i=this.loadingProgress===!0;return Qe`
107            <div part="progress-bar" class="bar loading-progress-outer ${e?"":"loading-progress-outer-inactive"}" aria-label="Loading Progress">
108                <div
109                    class="loading-progress-inner ${i?"loading-progress-inner-indeterminate":""}"
110                    style="${i?"":`width: ${t}%`}"
111                ></div>
112            </div>
113        `}_renderToolbar(){let e=[];if(this._viewerDetails?.model!=null){this._hasAnimations&&e.push(Qe`
114                    <div class="animation-timeline">
115                        <button aria-label="${this.isAnimationPlaying?"Pause":"Play"}" @click="${this.toggleAnimation}">
116                            ${this.isAnimationPlaying?Qe`
117                                      <svg viewBox="0 0 24 24">
118                                          <path d="${
vendor: 17,624 bytes, lines 118-429
118ld}" fill="currentColor"></path>
119                                      </svg>
120                                  `:Qe`
121                                      <svg viewBox="0 0 24 24">
122                                          <path d="${hd}" fill="currentColor"></path>
123                                      </svg>
124                                  `}
125                        </button>
126                        <input
127                            ${ad(this._onAnimationSliderChanged)}
128                            aria-label="Animation Progress"
129                            class="animation-timeline-input"
130                            style="${this._showAnimationSlider?"":"visibility: hidden"}"
131                            type="range"
132                            min="0"
133                            max="1"
134                            step="0.0001"
135                            .value="${this.animationProgress}"
136                            @input="${this._onAnimationTimelineChanged}"
137                            @pointerdown="${this._onAnimationTimelinePointerDown}"
138                        />
139                    </div>
140                    <select aria-label="Select Animation Speed" @change="${this._onAnimationSpeedChanged}">
141                        ${pa.map(s=>Qe`<option value="${s}" .selected="${this.animationSpeed===s}">${s}x</option> `)}
142                    </select>
143                    ${this.animations.length>1?Qe`<select aria-label="Select Animation" @change="${this._onSelectedAnimationChanged}">
144                              ${this.animations.map((s,r)=>Qe`<option value="${r}" .selected="${this.selectedAnimation===r}">${s}</option>`)}
145                          </select>`:""}
146                `),this.materialVariants.length>1&&e.push(Qe`
147                    <select aria-label="Select Material Variant" @change="${this._onMaterialVariantChanged}">
148                        ${this.materialVariants.map(s=>Qe`<option value="${s}" .selected="${this.selectedMaterialVariant===s}">${s}</option>`)}
149                    </select>
150                `),e.push(Qe`
151                <button aria-label="Reset Camera Pose" @click="${this.reset}">
152                    <svg viewBox="0 0 24 24">
153                        <path d="${cd}" fill="currentColor"></path>
154                    </svg>
155                </button>
156            `),this._hasHotSpots&&e.push(Qe`
157                    <div class="select-container">
158                        <select id="hotSpotSelect" aria-label="Select HotSpot" @change="${this._onHotSpotsChanged}">
159                            <!-- When the select is forced to be less wide than the options, padding on the right is lost. Pad with white space. -->
160                            ${Object.keys(this.hotSpots).map(s=>Qe`<option value="${s}">${s}&nbsp;&nbsp;</option>`)}
161                        </select>
162                        <!-- This button is not actually interactive, we want input to pass through to the select below. -->
163                        <button style="pointer-events: none">
164                            <svg viewBox="0 0 24 24">
165                                <path d="${ud}" fill="currentColor"></path>
166                            </svg>
167                        </button>
168                    </div>
169                `);const t=e.length,i=Qe`<div class="divider"></div>`;e=e.reduce((s,r,n)=>n<t-1?[...s,r,i]:[...s,r],new Array)}return e.length>0?Qe` <div part="tool-bar" class="bar ${this._hasAnimations?"":"bar-min"} tool-bar">${e}</div>`:Qe``}_renderReloadButton(){return Qe`${this._isFaulted?Qe`
170                  <button aria-label="Reload" part="reload-button" class="reload-button" @click="${this._setupViewer}">
171                      <svg viewBox="0 0 24 24">
172                          <path d="${dd}" fill="currentColor"></path>
173                      </svg>
174                  </button>
175              `:""}`}_renderOverlay(){return Qe`
176            <slot class="full-size children-slot"></slot>
177            <slot name="progress-bar">${this._renderProgressBar()}</slot>
178            <slot name="tool-bar">${this._renderToolbar()}</slot>
179            <slot name="reload-button">${this._renderReloadButton()}</slot>
180        `}_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()=>{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 mo,s=this,r=await this._createViewer(e,{get engine(){return s.engine??s._options.engine},get autoSuspendRendering(){return!(s.hasAttribute("render-when-idle")||s._options.autoSuspendRendering===!1)},get source(){return s.getAttribute("source")??s._options.source},get environmentLighting(){return s.getAttribute("environment-lighting")??s.getAttribute("environment")??s._options.environmentLighting},get environmentSkybox(){return s.getAttribute("environment-skybox")??s.getAttribute("environment")??s._options.environmentSkybox},get environmentConfig(){return{intensity:Jt(s.getAttribute("environment-intensity"))??s._options.environmentConfig?.intensity,blur:Jt(s.getAttribute("skybox-blur"))??s._options.environmentConfig?.blur,rotation:Jt(s.getAttribute("environment-rotation"))??s._options.environmentConfig?.rotation,visible:s.hasAttribute("environment-visible")||s._options.environmentConfig?.visible}},get cameraOrbit(){return Ls(s.getAttribute("camera-orbit"))??s._options.cameraOrbit},get cameraTarget(){return Ls(s.getAttribute("camera-target"))??s._options.cameraTarget},get cameraAutoOrbit(){return{enabled:s.hasAttribute("camera-auto-orbit")||s._options.cameraAutoOrbit?.enabled,speed:Jt(s.getAttribute("camera-auto-orbit-speed"))??s._options.cameraAutoOrbit?.speed,delay:Jt(s.getAttribute("camera-auto-orbit-delay"))??s._options.cameraAutoOrbit?.delay}},get animationAutoPlay(){return s.hasAttribute("animation-auto-play")||s._options.animationAutoPlay},get animationSpeed(){return Jt(s.getAttribute("animation-speed"))??s._options.animationSpeed},get selectedAnimation(){return Jt(s.getAttribute("selected-animation"))??s._options.selectedAnimation},get postProcessing(){return{toneMapping:gd(s.getAttribute("tone-mapping"))??s._options.postProcessing?.toneMapping,contrast:Jt(s.getAttribute("contrast"))??s._options.postProcessing?.contrast,exposure:Jt(s.getAttribute("exposure"))??s._options.postProcessing?.exposure}},get selectedMaterialVariant(){return s.getAttribute("material-variant")??s._options.selectedMaterialVariant},onInitialized:o=>{i.resolve(o)},onFaulted:()=>{this._isFaultedBacking=!0,this._tearDownViewer()}}),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.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.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.scene.onAfterRenderCameraObservable.add(()=>{this._dispatchCustomEvent("viewerrender",i=>new Event(i))}),this._updateModel(),this._updateEnv({lighting:!0,skybox:!0}),this._propertyBindings.forEach(i=>i.onInitialized(t)),this._dispatchCustomEvent("viewerready",i=>new Event(i))}this._isFaultedBacking=!1})}async _createViewer(e,t){return Do(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 Mt||F.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 Mt||F.Error(t)}}}Ae.styles=yo`
181        :host {
182            --ui-foreground-color: white;
183            --ui-background-hue: 233;
184            --ui-background-saturation: 8%;
185            --ui-background-lightness: 39%;
186            --ui-background-opacity: 0.75;
187            --ui-background-color: hsla(var(--ui-background-hue), var(--ui-background-saturation), var(--ui-background-lightness), var(--ui-background-opacity));
188            --ui-background-color-hover: hsla(
189                var(--ui-background-hue),
190                var(--ui-background-saturation),
191                calc(var(--ui-background-lightness) - 10%),
192                calc(var(--ui-background-opacity) - 0.1)
193            );
194            all: inherit;
195            overflow: hidden;
196        }
197
198        .full-size {
199            display: block;
200            position: relative;
201            width: 100%;
202            height: 100%;
203        }
204
205        .canvas {
206            outline: none;
207        }
208
209        .children-slot {
210            position: absolute;
211            top: 0;
212            background: transparent;
213            pointer-events: none;
214        }
215
216        .reload-button {
217            position: absolute;
218            top: 50%;
219            left: 50%;
220            width: 25%;
221            transform: translate(-50%, -50%);
222            color: var(--ui-foreground-color);
223            background-color: var(--ui-background-color);
224            border: 1px solid transparent;
225            border-radius: 24px;
226            padding: 0;
227            cursor: pointer;
228            outline: none;
229        }
230
231        .reload-button:hover {
232            background-color: var(--ui-background-color-hover);
233        }
234
235        .bar {
236            position: absolute;
237            width: calc(100% - 24px);
238            min-width: 370px;
239            max-width: 1280px;
240            left: 50%;
241            transform: translateX(-50%);
242            background-color: var(--ui-background-color);
243        }
244
245        .bar-min {
246            width: unset;
247            min-width: unset;
248            max-width: unset;
249        }
250
251        .loading-progress-outer {
252            height: 4px;
253            border-radius: 4px;
254            border: 1px solid var(--ui-background-color);
255            outline: none;
256            top: 12px;
257            pointer-events: none;
258            transition: opacity 0.5s ease;
259        }
260
261        .loading-progress-outer-inactive {
262            opacity: 0;
263            /* 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. */
264            background-color: var(--ui-foreground-color);
265        }
266
267        .loading-progress-inner {
268            width: 0;
269            height: 100%;
270            border-radius: inherit;
271            background-color: var(--ui-foreground-color);
272            transition: width 0.3s linear;
273        }
274
275        /* The right side of the inner progress bar starts aligned with the left side of the outer progress bar (container).
276           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.
277           This is why the first keyframe is at 23% ((100/130)*30).
278         */
279        @keyframes indeterminate {
280            0% {
281                left: 0%;
282                width: 0%;
283            }
284            23% {
285                left: 0%;
286                width: 30%;
287            }
288            77% {
289                left: 70%;
290                width: 30%;
291            }
292            100% {
293                left: 100%;
294                width: 0%;
295            }
296        }
297
298        .loading-progress-inner-indeterminate {
299            position: absolute;
300            animation: indeterminate 1.5s infinite;
301            animation-timing-function: linear;
302        }
303
304        .tool-bar {
305            display: flex;
306            flex-direction: row;
307            align-items: center;
308            border-radius: 12px;
309            border-color: var(--ui-foreground-color);
310            height: 48px;
311            bottom: 12px;
312            color: var(--ui-foreground-color);
313            -webkit-tap-highlight-color: transparent;
314        }
315
316        .tool-bar * {
317            height: 100%;
318            min-width: 48px;
319        }
320
321        .tool-bar .divider {
322            min-width: 1px;
323            margin: 0px 6px;
324            height: 66%;
325            background-color: var(--ui-foreground-color);
326        }
327
328        .tool-bar select {
329            background: none;
330            min-width: 52px;
331            max-width: 128px;
332            border: 1px solid transparent;
333            border-radius: inherit;
334            color: inherit;
335            font-size: 14px;
336            padding: 0px 12px;
337            cursor: pointer;
338            outline: none;
339            appearance: none; /* Remove default styling */
340            -webkit-appearance: none; /* Remove default styling for Safari */
341        }
342
343        .tool-bar .select-container {
344            position: relative;
345            display: flex;
346            border-radius: inherit;
347            border-width: 0;
348            padding: 0;
349        }
350
351        .tool-bar .select-container select {
352            position: absolute;
353            min-width: 0;
354            width: 100%;
355        }
356
357        .tool-bar .select-container button {
358            position: absolute;
359            border-width: 0;
360        }
361
362        .tool-bar select:hover,
363        .tool-bar select:focus {
364            background-color: var(--ui-background-color-hover);
365        }
366
367        .tool-bar select option {
368            background-color: var(--ui-background-color);
369            color: var(--ui-foreground-color);
370        }
371
372        .tool-bar select:focus-visible {
373            border-color: inherit;
374        }
375
376        .tool-bar button {
377            background: none;
378            border: 1px solid transparent;
379            border-radius: inherit;
380            color: inherit;
381            padding: 0;
382            cursor: pointer;
383            outline: none;
384        }
385
386        .tool-bar button:hover {
387            background-color: var(--ui-background-color-hover);
388        }
389
390        .tool-bar button:focus-visible {
391            border-color: inherit;
392        }
393
394        .tool-bar button svg {
395            width: 32px;
396            height: 32px;
397        }
398
399        .animation-timeline {
400            display: flex;
401            flex: 1;
402            position: relative;
403            overflow: hidden;
404            cursor: pointer;
405            align-items: center;
406            border-radius: inherit;
407            border-color: inherit;
408        }
409
410        .animation-timeline-input {
411            -webkit-appearance: none;
412            cursor: pointer;
413            width: 100%;
414            height: 100%;
415            outline: none;
416            border: 1px solid transparent;
417            border-radius: inherit;
418            padding: 0 12px;
419            background-color: transparent;
420        }
421
422        .animation-timeline-input:focus-visible {
423            border-color: inherit;
424        }
425
426        /*Chrome -webkit */
427
428        .animation-timeline-input::-webkit-slider-thumb {
429            -webkit-appearance: none;
430            width: 20px;
431            height: 20px;
432            border: 2px solid;
433            color: var(--ui-foreground-color);
434            border-radius: 50%;
435            background: hsla(var(--ui-background-hue), var(--ui-background-saturation), var(--ui-background-lightness), 1);
436            margin-top: -10px;
437        }
438
439        .animation-timeline-input::-webkit-slider-runnable-track {
440            height: 2px;
441            -webkit-appearance: none;
442            background-color: var(--ui-foreground-color);
443        }
444
445        /** FireFox -moz */
446
447        .animation-timeline-input::-moz-range-progress {
448            height: 2px;
449            background-color: var(--ui-foreground-color);
450        }
451
452        .animation-timeline-input::-moz-range-thumb {
453            width: 16px;
454            height: 16px;
455            border: 2px solid var(--ui-foreground-color);
456            border-radius: 50%;
457            background: hsla(var(--ui-background-hue), var(--ui-background-saturation), var(--ui-background-lightness), 1);
458        }
459
460        .animation-timeline-input::-moz-range-track {
461            height: 2px;
462            background: var(--ui-foreground-color);
463        }
464    `;p([Ss()],Ae.prototype,"_isFaultedBacking",void 0);p([Pe({converter:_d})],Ae.prototype,"engine",void 0);p([Pe({attribute:"render-when-idle",type:Boolean})],Ae.prototype,"renderWhenIdle",void 0);p([Pe()],Ae.prototype,"source",void 0);p([Pe()],Ae.prototype,"extension",void 0);p([Pe({hasChanged:(a,e)=>a.lighting!==e.lighting||a.skybox!==e.skybox})],Ae.prototype,"environment",null);p([Pe({attribute:"environment-lighting"})],Ae.prototype,"environmentLighting",void 0);p([Pe({attribute:"environment-skybox"})],Ae.prototype,"environmentSkybox",void 0);p([Pe({type:Number,attribute:"environment-intensity"})],Ae.prototype,"environmentIntensity",void 0);p([Pe({type:Number,attribute:"environment-rotation"})],Ae.prototype,"environmentRotation",void 0);p([Pe({attribute:"environment-visible"})],Ae.prototype,"environmentVisible",void 0);p([Ss()],Ae.prototype,"_loadingProgress",void 0);p([Pe({attribute:"skybox-blur"})],Ae.prototype,"skyboxBlur",void 0);p([Pe({attribute:"tone-mapping",converter:a=>!a||!bo(a)?"neutral":a})],Ae.prototype,"toneMapping",void 0);p([Pe()],Ae.prototype,"contrast",void 0);p([Pe()],Ae.prototype,"exposure",void 0);p([Pe({attribute:"clear-color",converter:{fromAttribute:fd,toAttribute:a=>a?a.toHexString():null}})],Ae.prototype,"clearColor",void 0);p([Pe({attribute:"camera-auto-orbit",type:Boolean})],Ae.prototype,"cameraAutoOrbit",void 0);p([Pe({attribute:"camera-auto-orbit-speed",type:Number})],Ae.prototype,"cameraAutoOrbitSpeed",void 0);p([Pe({attribute:"camera-auto-orbit-delay",type:Number})],Ae.prototype,"cameraAutoOrbitDelay",void 0);p([Pe({attribute:"hotspots",converter:a=>a?JSON.parse(a):{}})],Ae.prototype,"hotSpots",void 0);p([Pe({attribute:"animation-auto-play",type:Boolean})],Ae.prototype,"animationAutoPlay",void 0);p([Pe({attribute:"selected-animation",type:Number})],Ae.prototype,"selectedAnimation",void 0);p([Pe({attribute:"animation-speed"})],Ae.prototype,"animationSpeed",void 0);p([Pe({attribute:!1})],Ae.prototype,"animationProgress",void 0);p([Ss()],Ae.prototype,"_animations",void 0);p([Ss()],Ae.prototype,"_isAnimationPlaying",void 0);p([Ss()],Ae.prototype,"_showAnimationSlider",void 0);p([Pe({attribute:"material-variant"})],Ae.prototype,"selectedMaterialVariant",void 0);p([Pe({attribute:"cameras-as-hotspots",type:Boolean})],Ae.prototype,"camerasAsHotSpots",void 0);p([Pe({attribute:"reset-mode",converter:pd})],Ae.prototype,"resetMode",void 0);p([Po("#canvasContainer")],Ae.prototype,"_canvasContainer",void 0);p([Po("#hotSpotSelect")],Ae.prototype,"_hotSpotSelect",void 0);let Vr=class extends Ae{constructor(e){super(on,e)}};Vr=p([Co("babylon-viewer")],Vr);let ps=class extends Ui{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,527 bytes, lines 464-505
464{if(this.parentElement?.matches(":not(:defined)")&&(await customElements.whenDefined(this.parentElement?.tagName.toLowerCase()),e.aborted))return;if(!(this.parentElement instanceof Ae)){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 an,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 Qe` <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="")}};ps.styles=yo`
465        :host {
466            --annotation-foreground-color: black;
467            --annotation-background-color: white;
468            display: inline-block;
469            position: absolute;
470            transition: opacity 0.25s;
471        }
472
473        :host([hidden]) {
474            display: none;
475        }
476
477        :host(:state(back-facing)) {
478            opacity: 0.2;
479        }
480
481        :host(:state(invalid)) {
482            display: none;
483        }
484
485        .annotation {
486            transform: translate(-50%, -135%);
487            font-size: 14px;
488            padding: 0px 6px;
489            border-radius: 6px;
490            color: var(--annotation-foreground-color);
491            background-color: var(--annotation-background-color);
492        }
493
494        .annotation::after {
495            content: "";
496            position: absolute;
497            left: 50%;
498            height: 60%;
499            aspect-ratio: 1;
500            transform: translate(-50%, 110%) rotate(-45deg);
501            background-color: inherit;
502            clip-path: polygon(0 0, 100% 100%, 0 100%, 0 0);
503        }
504    `;p([Pe({attribute:"hotspot"})],ps.prototype,"hotSpot",void 0);ps=p([Co("babylon-viewer-annotation")],ps);const kd=Object.freeze(Object.defineProperty({__proto__:null,CreateHotSpotFromCamera:Eo,DefaultViewerOptions:qe,get HTML3DAnnotationElement(){return ps},get HTML3DElement(){return Vr},Viewer:on,ViewerElement:Ae,ViewerHotSpotResult:an,createViewerForCanvas:Do},Symbol.toStringTag,{value:"Module"}));export{ol as $,H as A,Me as B,q as C,Ci as D,xl as E,Il as F,fi as G,Dl as H,Et as I,Rl as J,Al as K,Kr as L,M,Ve as N,O,eu as P,U as Q,it as R,re as S,V as T,El as U,_ as V,dl as W,gl as X,ae as Y,Nl as Z,p as _,C as a,Yl as a$,ml as a0,Be as a1,ll as a2,bl as a3,ul as a4,qa as a5,cl as a6,L as a7,pi as a8,tu as a9,Kl as aA,Id as aB,Md as aC,Sd as aD,Xl as aE,xd as aF,Cd as aG,_e as aH,xn as aI,as as aJ,eo as aK,J as aL,pt as aM,ie as aN,Ca as aO,pe as aP,us as aQ,Hr as aR,le as aS,ot as aT,Q as aU,sa as aV,Jl as aW,Zl as aX,jl as aY,Ql as aZ,ql as a_,T as aa,se as ab,qs as ac,St as ad,mu as ae,Os as af,jo as ag,Ue as ah,ds as ai,Te as aj,de as ak,Pd as al,ht as am,Tu as an,Ee as ao,w as ap,ce as aq,Y as ar,Xi as as,mo as at,Fd as au,Od as av,sr as aw,ne as ax,Z as ay,he as az,B as b,Dt as b0,Vi as b1,te as b2,$r as b3,k as b4,ee as b5,Go as b6,La as b7,os as b8,hs as b9,Eh as bA,Tn as bB,Rh as bC,bs as bD,ph as bE,Vh as bF,kh as bG,wc as bH,vd as bI,cs as bJ,Vc as bK,Oc as bL,Uc as bM,Gc as bN,Hc as bO,zc as bP,Wc as bQ,lo as bR,Xc as bS,ke as bT,Ic as bU,Ua as bV,kc as bW,Dd as bX,kd as bY,As as ba,$l as bb,He as bc,er as bd,Ed as be,ia as bf,ws as bg,Qr as bh,Ii as bi,ms as bj,wd as bk,To as bl,Rd as bm,qr as bn,Ws as bo,yd as bp,Ad as bq,Ma as br,vt as bs,Qh as bt,Jr as bu,qh as bv,Oe as bw,ra as bx,Gt as by,W as bz,ri as c,bd as d,jr as e,pu as f,Wh as g,F as h,et as i,Fe as j,ti as k,Ie as l,N as m,Rt as n,Td as o,Xe as p,rt as q,Zn as r,E as s,v as t,Sl as u,Ol as v,wl as w,Fl as x,bt as y,Le as z};
505//# sourceMappingURL=index-CFHfsWZK.js.map

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.