mirror of
git://soft.sys114.com/mainsail
synced 2026-02-04 14:30:36 +09:00
3 lines
1.8 MiB
3 lines
1.8 MiB
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ddsTextureLoader-7rBWB6fI.js","assets/dds-C4nWUSlI.js","assets/cubemapToSphericalPolynomial-DI79UW0r.js","assets/vuetify-Ce4WN_Dg.js","assets/overlayscrollbars-CiKU261J.js","assets/overlayscrollbars-BJn_P54_.css","assets/vuetify-BSwS9o2d.css","assets/index-Bku7SJna.js","assets/echarts-DzoUeqWp.js","assets/index-DdkGOISd.css","assets/codemirror-ZSHHXwGs.js","assets/basisTextureLoader-C2AKop91.js","assets/envTextureLoader-0a1UyQXk.js","assets/hdrTextureLoader-CbSWrxkf.js","assets/ktxTextureLoader-DFWsW27H.js","assets/tgaTextureLoader-CGo25llH.js","assets/exrTextureLoader-CpwykM8r.js","assets/postprocess.vertex-DvFhjUjz.js","assets/pass.fragment-CM2j9WLA.js","assets/pass.fragment-BkcfUm5b.js","assets/default.vertex-Caa9iT2n.js","assets/mainUVVaryingDeclaration-Byysp88Q.js","assets/bonesVertex-B72aYlMi.js","assets/clipPlaneVertex-L9tMAQxe.js","assets/vertexColorMixing-D-DdWwxQ.js","assets/morphTargetsVertex-B2hbMuPn.js","assets/logDepthDeclaration-QTuRqmDC.js","assets/logDepthVertex-SrVRb0bM.js","assets/default.fragment-DzWBfowK.js","assets/clipPlaneFragment-ef4zNzcj.js","assets/fogFragment-BYUe2MTZ.js","assets/logDepthFragment-CVSnEUp_.js","assets/default.vertex-B3P8Ow0L.js","assets/mainUVVaryingDeclaration-DltpozJN.js","assets/meshUboDeclaration-BEPmj8E0.js","assets/helperFunctions-CmftqOHQ.js","assets/bakedVertexAnimation-jXsepPDt.js","assets/morphTargetsVertex-Dur5DJ01.js","assets/vertexColorMixing-CVYhb6uZ.js","assets/default.fragment-BQ0cgw4g.js","assets/fxaa.fragment-CKBSH8ak.js","assets/fxaa.vertex-pl3gzfER.js","assets/fxaa.fragment-CQ-OctB5.js","assets/fxaa.vertex-D11BDiUg.js","assets/color.vertex-Ccg8Ge1R.js","assets/color.fragment-DNkpzaOC.js","assets/color.vertex-BL9BK6Le.js","assets/color.fragment-BjUREcw_.js","assets/line.vertex-ChOZncX4.js","assets/line.fragment-azBhzxfj.js","assets/line.vertex-DNyxgHBi.js","assets/line.fragment-thDij4Gq.js","assets/kernelBlur.fragment-BJnJE4Wi.js","assets/kernelBlurVaryingDeclaration-DuItmes5.js","assets/kernelBlur.vertex-SB8k7aXt.js","assets/kernelBlur.fragment-CAduVWsS.js","assets/kernelBlurVaryingDeclaration-DOqeMSlf.js","assets/kernelBlur.vertex-Dciph_cp.js","assets/glowMapGeneration.vertex-O7p-xSBA.js","assets/glowMapGeneration.fragment-CfLBq-Y2.js","assets/glowMapGeneration.vertex-BcKlBU7O.js","assets/glowMapGeneration.fragment-C2VnGqtj.js","assets/glowBlurPostProcess.fragment-D0h3Yhq8.js","assets/glowBlurPostProcess.fragment-BmYiq-YF.js","assets/glowMapMerge.fragment-z1wsxOL6.js","assets/glowMapMerge.vertex-BOpN3rPY.js","assets/glowMapMerge.fragment-C9pBmOul.js","assets/glowMapMerge.vertex-CYvG5BDv.js"])))=>i.map(i=>d[i]);
|
||
import{V as pf,f as Bt,c as Ri,i as Ro,m as sr,n as ds,S as gf,Y as mf,P as Io,D as vf,E as bf,y as Bi,q as Li,j as xf,w as Eo,k as da,h as yf,_ as Tf,a as Af,b as Rf,p as If,d as Ef}from"./vuetify-Ce4WN_Dg.js";import{k as Cf,l as Sf,P as Vr,W as nt,C as a0,n as o0,o as Oe,m as El,B as Cl,p as Mf,q as Pf,r as wf,s as Df,t as Ff,u as Of,v as Bf,w as Lf,x as Nf,y as Uf,z as kf,A as Vf,D as Gf,E as Co,F as zf,R as Sl,G as Ml,_ as Pl}from"./index-Bku7SJna.js";import{E as Wf,b as Hf,a as Kf}from"./codemirror-ZSHHXwGs.js";function Xf(a,e){return e===void 0&&(e={}),function(t,i){Cf(e,t,i),Sf(function(s,n){(s.props||(s.props={}))[a]=e,(s.computed||(s.computed={}))[n]={get:function(){return this[a]},set:function(r){this.$emit("update:"+a,r)}}})(t,i)}}var Yf=Object.defineProperty,qf=Object.getOwnPropertyDescriptor,Ws=(a,e,t,i)=>{for(var s=i>1?void 0:i?qf(e,t):e,n=a.length-1,r;n>=0;n--)(r=a[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&Yf(e,t,s),s};let ns=class extends pf{constructor(){super(...arguments),this.view=void 0}mounted(){this.view=new Wf({doc:this.document,extensions:[Hf,Kf.readOnly.of(!0)],parent:this.$refs.view})}mouseUp(){if(this.view){let a=this.view.state.doc.lineAt(this.view.state.selection.ranges[0].from);this.$emit("update:currentline",a.to),this.view.contentDOM.blur(),this.$emit("got-focus")}}keyPress(){if(this.view){let a=this.view.state.doc.lineAt(this.view.state.selection.ranges[0].from);this.$emit("update:currentline",a.to),this.$emit("got-focus")}}documentUpdated(){this.view&&this.shown&&this.view.dispatch({changes:{from:0,to:this.view.state.doc.length,insert:this.document}})}currentlineUpdated(a){if(this.view&&this.shown){let e=this.view.state.doc.lineAt(a);this.view.dispatch({selection:{anchor:e.from,head:e.from},scrollIntoView:!0})}}};Ws([Xf("currentline")],ns.prototype,"currentLineNumber",2);Ws([Vr({type:String,default:""})],ns.prototype,"document",2);Ws([Vr({type:Boolean,default:!1})],ns.prototype,"isSimulating",2);Ws([Vr({type:Boolean,default:!1})],ns.prototype,"shown",2);Ws([nt("document")],ns.prototype,"documentUpdated",1);Ws([nt("currentLineNumber")],ns.prototype,"currentlineUpdated",1);ns=Ws([a0({})],ns);var jf=function(){var e=this,t=e._self._c;return e._self._setupProxy,t("div",{ref:"view",staticClass:"codeview",on:{mouseup:e.mouseUp,keydown:e.keyPress}})},$f=[],Zf=o0(ns,jf,$f,!1,null,"083209f9");const wl=Zf.exports,Qf=typeof WeakRef<"u";class Jf{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 ed{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 Z{static FromPromise(e,t){const i=new Z;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 Jf(0),e&&(this._onObserverAdded=e)}add(e,t=-1,i=!1,s=null,n=!1){if(!e)return null;const r=new ed(e,t,s);r.unregisterOnNextCall=n,i?this._observers.unshift(r):this._observers.push(r),this._onObserverAdded&&this._onObserverAdded(r),this._hasNotified&&this.notifyIfTriggered&&this._lastNotifiedValue!==void 0&&this.notifyObserver(r,this._lastNotifiedValue);const o=Qf?new WeakRef(this):{deref:()=>this};return r._remove=()=>{const h=o.deref();h&&h._remove(r)},r}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,n){if(this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=e),!this._observers.length)return!0;const r=this._eventState;r.mask=t,r.target=i,r.currentTarget=s,r.skipNextObservers=!1,r.lastReturnValue=e,r.userInfo=n;for(const o of this._observers)if(!o._willBeUnregistered&&(o.mask&t&&(o.unregisterOnNextCall&&this._deferUnregister(o),o.scope?r.lastReturnValue=o.callback.apply(o.scope,[e,r]):r.lastReturnValue=o.callback(e,r)),r.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 Z;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}}class td{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,n=2,r=0){return this._cachedWrapU=e,this._cachedWrapV=t,this._cachedWrapR=i,this._cachedAnisotropicFilteringLevel=s,this.samplingMode=n,this._comparisonFunction=r,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 So;(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"})(So||(So={}));function Mo(a){return a===13||a===14||a===15||a===16||a===17||a===18||a===19}function id(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 br(a){return a===13||a===17||a===18||a===19}class ft extends td{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 Z,this.onErrorObservable=new Z,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=ft._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(){var t,i;if(this.isReady=!1,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedWrapR=null,this._cachedAnisotropicFilteringLevel=null,this.onRebuildCallback){const s=this.onRebuildCallback(this),n=r=>{r._swapAndDie(this,!1),this.isReady=s.isReady};s.isAsync?s.proxy.then(n):n(s.proxy);return}let e;switch(this.source){case 2:break;case 1:e=this._engine.createTexture((t=this._originalUrl)!=null?t:this.url,!this.generateMipMaps,this.invertY,null,this.samplingMode,s=>{s._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,(i=this._originalFormat)!=null?i: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,s=>{s&&s._swapAndDie(this,!1),this.isReady=!0},null,this.format,this._extension),e._sphericalPolynomial=this._sphericalPolynomial;return}}_swapAndDie(e,t=!0){var n;(n=this._hardwareTexture)==null||n.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.onLoadedObservable.clear(),this.onErrorObservable.clear(),this._references===0&&(this._engine._releaseTexture(this),this._hardwareTexture=null,this._dynamicTextureSource=null)}}ft._Counter=0;class Ee{static get LastCreatedEngine(){return this.Instances.length===0?null:this.Instances[this.Instances.length-1]}static get LastCreatedScene(){return this._LastCreatedScene}}Ee.Instances=[];Ee.OnEnginesDisposedObservable=new Z;Ee._LastCreatedScene=null;Ee.UseFallbackTexture=!0;Ee.FallbackTexture="";class sd{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,n,r,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<n.length;u++)e.getUniform(n[u])==null&&(n.splice(u,1),u--);n.forEach((f,d)=>{r[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 n=!1;return s[0]!==t&&(s[0]=t,n=!0),s[1]!==i&&(s[1]=i,n=!0),n}_cacheFloat3(e,t,i,s){let n=this._valueCache[e];if(!n||n.length!==3)return n=[t,i,s],this._valueCache[e]=n,!0;let r=!1;return n[0]!==t&&(n[0]=t,r=!0),n[1]!==i&&(n[1]=i,r=!0),n[2]!==s&&(n[2]=s,r=!0),r}_cacheFloat4(e,t,i,s,n){let r=this._valueCache[e];if(!r||r.length!==4)return r=[t,i,s,n],this._valueCache[e]=r,!0;let o=!1;return r[0]!==t&&(r[0]=t,o=!0),r[1]!==i&&(r[1]=i,o=!0),r[2]!==s&&(r[2]=s,o=!0),r[3]!==n&&(r[3]=n,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,n){this._cacheFloat4(e,t,i,s,n)&&(this.engine.setInt4(this._uniforms[e],t,i,s,n)||(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,n){this._cacheFloat4(e,t,i,s,n)&&(this.engine.setUInt4(this._uniforms[e],t,i,s,n)||(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,n){this._cacheFloat4(e,t,i,s,n)&&(this.engine.setFloat4(this._uniforms[e],t,i,s,n)||(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 Po={};function ye(a,e=!1){if(!(e&&Po[a]))return Po[a]=!0,"".concat(a," needs to be imported before as it contains a side-effect required by your code.")}function St(){return typeof window<"u"}function Qs(){return typeof navigator<"u"}function En(){return typeof document<"u"}function h0(a){let e="",t=a.firstChild;for(;t;)t.nodeType===3&&(e+=t.textContent),t=t.nextSibling;return e}const xr={};function Dl(a,e,t=""){return t+(e?e+"\n":"")+a}function Fl(a,e,t,i,s,n,r){const o=r||xr.loadFile;if(o)return o(a,e,t,i,s,n);throw ye("FileTools")}function Ol(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+="\n"),s+="#define USE_REVERSE_DEPTHBUFFER"),i&&(s&&(s+="\n"),s+="#define USE_EXACT_SRGB_CONVERSIONS"),s}}function Pa(a,e,t=!1,i){switch(a){case 3:{const n=e instanceof ArrayBuffer?new Int8Array(e):new Int8Array(e);return i&&n.set(new Int8Array(i)),n}case 0:{const n=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e);return i&&n.set(new Uint8Array(i)),n}case 4:{const n=e instanceof ArrayBuffer?new Int16Array(e):new Int16Array(t?e/2:e);return i&&n.set(new Int16Array(i)),n}case 5:case 8:case 9:case 10:case 2:{const n=e instanceof ArrayBuffer?new Uint16Array(e):new Uint16Array(t?e/2:e);return i&&n.set(new Uint16Array(i)),n}case 6:{const n=e instanceof ArrayBuffer?new Int32Array(e):new Int32Array(t?e/4:e);return i&&n.set(new Int32Array(i)),n}case 7:case 11:case 12:case 13:case 14:case 15:{const n=e instanceof ArrayBuffer?new Uint32Array(e):new Uint32Array(t?e/4:e);return i&&n.set(new Uint32Array(i)),n}case 1:{const n=e instanceof ArrayBuffer?new Float32Array(e):new Float32Array(t?e/4:e);return i&&n.set(new Float32Array(i)),n}}const s=e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e);return i&&s.set(new Uint8Array(i)),s}const wa=new WeakMap,nd={_webGLVersion:2,cachedPipelines:{}};function ii(a){let e=wa.get(a);if(!e){if(!a)return nd;e={_webGLVersion:a.TEXTURE_BINDING_3D?2:1,_context:a,parallelShaderCompile:a.getExtension("KHR_parallel_shader_compile")||void 0,cachedPipelines:{}},wa.set(a,e)}return e}function rd(a){wa.delete(a)}function Bl(a,e,t,i,s,n){var l;const r=ii(i);n||(n=(l=r._createShaderProgramInjection)!=null?l:l0);const o=Da(e,"vertex",i,r._contextWasLost),h=Da(t,"fragment",i,r._contextWasLost);return n(a,o,h,i,s,r.validateShaderPrograms)}function Ll(a,e,t,i,s,n=null,r){var u;const o=ii(s);r||(r=(u=o._createShaderProgramInjection)!=null?u:l0);const h=o._webGLVersion>1?"#version 300 es\n#define WEBGL2 \n":"",l=wo(e,"vertex",i,h,s,o._contextWasLost),c=wo(t,"fragment",i,h,s,o._contextWasLost);return r(a,l,c,s,n,o.validateShaderPrograms)}function ad(a,e){const t=new sd,i=ii(a);return i.parallelShaderCompile&&(t.isParallelCompiled=!0),t.context=i._context,t}function l0(a,e,t,i,s=null,n){const r=i.createProgram();if(a.program=r,!r)throw new Error("Unable to create program");return i.attachShader(r,e),i.attachShader(r,t),i.linkProgram(r),a.context=i,a.vertexShader=e,a.fragmentShader=t,a.isParallelCompiled||c0(a,i,n),r}function od(a,e,t){const i=a;if(i._isDisposed)return!1;const s=ii(e);return e.getProgramParameter(i.program,s.parallelShaderCompile.COMPLETION_STATUS_KHR)?(c0(i,e,t),!0):!1}function c0(a,e,t){const i=a.context,s=a.vertexShader,n=a.fragmentShader,r=a.program;if(!i.getProgramParameter(r,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(n,e.COMPILE_STATUS)){const l=e.getShaderInfoLog(n);if(l)throw a.fragmentCompilationError=l,new Error("FRAGMENT SHADER "+l)}const h=i.getProgramInfoLog(r);if(h)throw a.programLinkError=h,new Error(h)}if(t&&(i.validateProgram(r),!i.getProgramParameter(r,i.VALIDATE_STATUS))){const l=i.getProgramInfoLog(r);if(l)throw a.programValidationError=l,new Error(l)}i.deleteShader(s),i.deleteShader(n),a.vertexShader=void 0,a.fragmentShader=void 0,a.onCompiled&&(a.onCompiled(),a.onCompiled=void 0)}function hd(a,e,t,i,s,n,r,o,h,l="",c,u,f){var p,g;const d=ii(a.context);u||(u=(p=d.createRawShaderProgramInjection)!=null?p:Bl),f||(f=(g=d.createShaderProgramInjection)!=null?g:Ll);const _=a;i?_.program=u(_,e,t,_.context,h):_.program=f(_,e,t,o,_.context,h),_.program.__SPECTOR_rebuildProgram=r,c()}function wo(a,e,t,i,s,n){return Da(Dl(a,t,i),e,s,n)}function Da(a,e,t,i){const s=t.createShader(e==="vertex"?t.VERTEX_SHADER:t.FRAGMENT_SHADER);if(!s){let n=t.NO_ERROR,r=t.NO_ERROR;for(;(r=t.getError())!==t.NO_ERROR;)n=r;throw new Error("Something went wrong while creating a gl ".concat(e," shader object. gl error=").concat(n,", gl isContextLost=").concat(t.isContextLost(),", _contextWasLost=").concat(i))}return t.shaderSource(s,a),t.compileShader(s),s}function ld(a,e){e.useProgram(a)}function cd(a,e){const t=a;if(!t.isParallelCompiled){e(a);return}const i=t.onCompiled;t.onCompiled=()=>{i==null||i(),e(a)}}function Nl(a){return a.getPipelineContext===void 0}class U{static _CheckLimit(e,t){let i=U._LogLimitOutputs[e];return i?i.current++:(i={limit:t,current:1},U._LogLimitOutputs[e]=i),i.current<=i.limit}static _GenerateLimitMessage(e,t=1){var n;const i=U._LogLimitOutputs[e];if(!i||!U.MessageLimitReached)return;const s=this._Levels[t];i.current===i.limit&&U[s.name](U.MessageLimitReached.replace(/%LIMIT%/g,""+i.limit).replace(/%TYPE%/g,(n=s.name)!=null?n:""))}static _AddLogEntry(e){U._LogCache=e+U._LogCache,U.OnNewCacheEntry&&U.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&&!U._CheckLimit(s,i))return;const n=U._FormatMessage(s),r=this._Levels[e],o=Array.isArray(t)?t.slice(1):[];r.logFunc&&r.logFunc("BJS - "+n,...o);const h="<div style='color:".concat(r.color,"'>").concat(n,"</div><br>");U._AddLogEntry(h),U._GenerateLimitMessage(s,e)}static get LogCache(){return U._LogCache}static ClearLogCache(){U._LogCache="",U._LogLimitOutputs={},U.errorsCount=0}static set LogLevels(e){U.Log=U._LogDisabled,U.Warn=U._LogDisabled,U.Error=U._LogDisabled,[U.MessageLogLevel,U.WarningLogLevel,U.ErrorLogLevel].forEach(t=>{if((e&t)===t){const i=this._Levels[t];U[i.name]=U._LogEnabled.bind(U,t)}})}}U.NoneLogLevel=0;U.MessageLogLevel=1;U.WarningLogLevel=2;U.ErrorLogLevel=4;U.AllLogLevel=7;U.MessageLimitReached="Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.";U._LogCache="";U._LogLimitOutputs={};U._Levels=[{},{color:"white",logFunc:console.log,name:"Log"},{color:"orange",logFunc:console.warn,name:"Warn"},{},{color:"red",logFunc:console.error,name:"Error"}];U.errorsCount=0;U.Log=U._LogEnabled.bind(U,U.MessageLogLevel);U.Warn=U._LogEnabled.bind(U,U.WarningLogLevel);U.Error=U._LogEnabled.bind(U,U.ErrorLogLevel);class ud{constructor(){this.shaderLanguage=0}postProcessor(e,t,i,s,n){if(n.drawBuffersExtensionDisabled){const r=/#extension.+GL_EXT_draw_buffers.+(enable|require)/g;e=e.replace(r,"")}return e}}const fd=/(flat\s)?\s*varying\s*.*/;class dd{constructor(){this.shaderLanguage=0}attributeProcessor(e){return e.replace("attribute","in")}varyingCheck(e,t){return fd.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,n=/#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(n,""),e=e.replace(/texture2D\s*\(/g,"texture("),i){const r=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||r?"":"layout(location = 0) out vec4 glFragColor;\n")+"void main(")}else if(t.indexOf("#define MULTIVIEW")!==-1)return"#extension GL_OVR_multiview2 : require\nlayout (num_views = 2) in;\n"+e;return e}}class pn{get underlyingResource(){return null}constructor(){this.references=0,this.capacity=0,this.is32Bits=!1,this.uniqueId=pn._Counter++}}pn._Counter=0;class Pn extends pn{constructor(e){super(),this._buffer=e}get underlyingResource(){return this._buffer}}function wn(a){let e=1;do e*=2;while(e<a);return e===a}function Fa(a,e,t){return a*(1-t)+e*t}function Ul(a){const e=kl(a),t=u0(a);return e-a>a-t?t:e}function kl(a){return a--,a|=a>>1,a|=a>>2,a|=a>>4,a|=a>>8,a|=a>>16,a++,a}function u0(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 fi(a,e,t=2){let i;switch(t){case 1:i=u0(a);break;case 2:i=Ul(a);break;case 3:default:i=kl(a);break}return Math.min(i,e)}class Me{static GetShadersRepository(e=0){return e===0?Me.ShadersRepository:Me.ShadersRepositoryWGSL}static GetShadersStore(e=0){return e===0?Me.ShadersStore:Me.ShadersStoreWGSL}static GetIncludesShadersStore(e=0){return e===0?Me.IncludesShadersStore:Me.IncludesShadersStoreWGSL}}Me.ShadersRepository="src/Shaders/";Me.ShadersStore={};Me.IncludesShadersStore={};Me.ShadersRepositoryWGSL="src/ShadersWGSL/";Me.ShadersStoreWGSL={};Me.IncludesShadersStoreWGSL={};const _d="attribute",pd="varying";class Hn{constructor(){this.children=[]}isValid(e){return!0}process(e,t){var s,n,r,o,h,l,c;let i="";if(this.line){let u=this.line;const f=t.processor;if(f){f.lineProcessor&&(u=f.lineProcessor(u,t.isFragment,t.processingContext));const d=(n=(s=t.processor)==null?void 0:s.attributeKeywordName)!=null?n:_d,_=t.isFragment&&((r=t.processor)!=null&&r.varyingFragmentKeywordName)?(o=t.processor)==null?void 0:o.varyingFragmentKeywordName:!t.isFragment&&((h=t.processor)!=null&&h.varyingVertexKeywordName)?(l=t.processor)==null?void 0:l.varyingVertexKeywordName:pd;!t.isFragment&&f.attributeProcessor&&this.line.startsWith(d)?u=f.attributeProcessor(this.line,e,t.processingContext):f.varyingProcessor&&((c=f.varyingCheck)!=null&&c.call(f,this.line,t.isFragment)||!f.varyingCheck&&this.line.startsWith(_))?u=f.varyingProcessor(this.line,t.isFragment,e,t.processingContext):f.uniformProcessor&&f.uniformRegexp&&f.uniformRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(u=f.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):f.uniformBufferProcessor&&f.uniformBufferRegexp&&f.uniformBufferRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(u=f.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0):f.textureProcessor&&f.textureRegexp&&f.textureRegexp.test(this.line)?u=f.textureProcessor(this.line,t.isFragment,e,t.processingContext):(f.uniformProcessor||f.uniformBufferProcessor)&&this.line.startsWith("uniform")&&!t.lookForClosingBracketForUniformBuffer&&(/uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/.test(this.line)?f.uniformProcessor&&(u=f.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):f.uniformBufferProcessor&&(u=f.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0)),t.lookForClosingBracketForUniformBuffer&&this.line.indexOf("}")!==-1&&(t.lookForClosingBracketForUniformBuffer=!1,f.endOfUniformBufferProcessor&&(u=f.endOfUniformBufferProcessor(this.line,t.isFragment,t.processingContext)))}i+=u+"\n"}return this.children.forEach(u=>{i+=u.process(e,t)}),this.additionalDefineKey&&(e[this.additionalDefineKey]=this.additionalDefineValue||"true"),i}}class gd{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 n=t.split(";");for(let r=0;r<n.length;r++){let o=n[r];o&&(o=o.trim(),o&&this._lines.push(o+(r!==n.length-1?";":"")))}}}}}class _a extends Hn{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 md extends Hn{isValid(e){return this.testExpression.isTrue(e)}}class ct{isTrue(e){return!0}static postfixToInfix(e){const t=[];for(const i of e)if(ct._OperatorPriority[i]===void 0)t.push(i);else{const s=t[t.length-1],n=t[t.length-2];t.length-=2,t.push("(".concat(n).concat(i).concat(s,")"))}return t[t.length-1]}static infixToPostfix(e){const t=ct._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 n=()=>{c=c.trim(),c!==""&&(i.push(c),c="")},r=u=>{s<ct._Stack.length-1&&(ct._Stack[++s]=u)},o=()=>ct._Stack[s],h=()=>s===-1?"!!INVALID EXPRESSION!!":ct._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="",r(u);else if(u===")"){for(n();s!==-1&&o()!=="(";)i.push(h());h()}else if(ct._OperatorPriority[f]>1){for(n();s!==-1&&ct._OperatorPriority[o()]>=ct._OperatorPriority[f];)i.push(h());r(f),l++}else c+=u;l++}for(n();s!==-1;)o()==="("?h():i.push(h());return ct._InfixToPostfixCache.size>=ct.InfixToPostfixCacheLimitSize&&ct.ClearCache(),ct._InfixToPostfixCache.set(e,{result:i,accessTime:Date.now()}),i}static ClearCache(){const e=Array.from(ct._InfixToPostfixCache.entries()).sort((t,i)=>t[1].accessTime-i[1].accessTime);for(let t=0;t<ct.InfixToPostfixCacheCleanupSize;t++)ct._InfixToPostfixCache.delete(e[t][0])}}ct.InfixToPostfixCacheLimitSize=5e4;ct.InfixToPostfixCacheCleanupSize=25e3;ct._InfixToPostfixCache=new Map;ct._OperatorPriority={")":0,"(":1,"||":2,"&&":3};ct._Stack=["","","","","","","","","","","","","","","","","","","",""];class yr extends ct{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 vd extends ct{isTrue(e){return this.leftOperand.isTrue(e)||this.rightOperand.isTrue(e)}}class bd extends ct{isTrue(e){return this.leftOperand.isTrue(e)&&this.rightOperand.isTrue(e)}}class xd extends ct{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),n=parseInt(this.testValue);switch(this.operand){case">":i=s>n;break;case"<":i=s<n;break;case"<=":i=s<=n;break;case">=":i=s>=n;break;case"==":i=s===n;break;case"!=":i=s!==n;break}return i}}const yd=/defined\s*?\((.+?)\)/g,pa=/defined\s*?\[(.+?)\]/g,Td=/#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g,Ad=/__decl__/,Do=/light\{X\}.(\w*)/g,Fo=/\{X\}/g,nr=[],Rd=/(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/;function f0(a){a.processor&&a.processor.initializeShaders&&a.processor.initializeShaders(a.processingContext)}function Tr(a,e,t,i){var s;(s=e.processor)!=null&&s.preProcessShaderCode&&(a=e.processor.preProcessShaderCode(a,e.isFragment)),Dn(a,e,n=>{e.processCodeAfterIncludes&&(n=e.processCodeAfterIncludes(e.isFragment?"fragment":"vertex",n,e.defines));const r=Sd(n,e,i);t(r,n)})}function Id(a,e,t,i){var s;(s=e.processor)!=null&&s.preProcessShaderCode&&(a=e.processor.preProcessShaderCode(a,e.isFragment)),Dn(a,e,n=>{e.processCodeAfterIncludes&&(n=e.processCodeAfterIncludes(e.isFragment?"fragment":"vertex",n,e.defines));const r=Md(n,e,i);t(r,n)})}function d0(a,e,t){return!t.processor||!t.processor.finalizeShaders?{vertexCode:a,fragmentCode:e}:t.processor.finalizeShaders(a,e,t.processingContext)}function Ed(a,e){var i;if((i=e.processor)!=null&&i.noPrecision)return a;const t=e.shouldUseHighPrecisionShader;return a.indexOf("precision highp float")===-1?t?a="precision highp float;\n"+a:a="precision mediump float;\n"+a:t||(a=a.replace("precision highp float","precision mediump float")),a}function ga(a){const t=/defined\((.+)\)/.exec(a);if(t&&t.length)return new yr(t[1].trim(),a[0]==="!");const i=["==","!=",">=","<=","<",">"];let s="",n=0;for(s of i)if(n=a.indexOf(s),n>-1)break;if(n===-1)return new yr(a);const r=a.substring(0,n).trim(),o=a.substring(n+s.length).trim();return new xd(r,s,o)}function Cd(a){a=a.replace(yd,"defined[$1]");const e=ct.infixToPostfix(a),t=[];for(const s of e)if(s!=="||"&&s!=="&&")t.push(s);else if(t.length>=2){let n=t[t.length-1],r=t[t.length-2];t.length-=2;const o=s=="&&"?new bd:new vd;typeof n=="string"&&(n=n.replace(pa,"defined($1)")),typeof r=="string"&&(r=r.replace(pa,"defined($1)")),o.leftOperand=typeof r=="string"?ga(r):r,o.rightOperand=typeof n=="string"?ga(n):n,t.push(o)}let i=t[t.length-1];return typeof i=="string"&&(i=i.replace(pa,"defined($1)")),typeof i=="string"?ga(i):i}function dr(a,e){const t=new md,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 yr(s):i==="#ifndef"?t.testExpression=new yr(s,!0):t.testExpression=Cd(s),t}function ma(a,e,t){let i=a.currentLine;for(;Oa(a,t);){i=a.currentLine;const s=i.substring(0,5).toLowerCase();if(s==="#else"){const n=new Hn;e.children.push(n),Oa(a,n);return}else if(s==="#elif"){const n=dr(i,5);e.children.push(n),t=n}}}function Oa(a,e){for(;a.canRead;){a.lineIndex++;const t=a.currentLine;if(t.indexOf("#")>=0){const s=Rd.exec(t);if(s&&s.length){switch(s[0]){case"#ifdef":{const r=new _a;e.children.push(r);const o=dr(t,6);r.children.push(o),ma(a,r,o);break}case"#else":case"#elif":return!0;case"#endif":return!1;case"#ifndef":{const r=new _a;e.children.push(r);const o=dr(t,7);r.children.push(o),ma(a,r,o);break}case"#if":{const r=new _a,o=dr(t,3);e.children.push(r),r.children.push(o),ma(a,r,o);break}}continue}}const i=new Hn;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 Vl(a,e,t){const i=new Hn,s=new gd;return s.lineIndex=-1,s.lines=a.split("\n"),Oa(s,i),i.process(e,t)}function Gl(a,e){var s;const t=a.defines,i={};for(const n of t){const o=n.replace("#define","").replace(";","").trim().split(" ");i[o[0]]=o.length>1?o[1]:""}return((s=a.processor)==null?void 0:s.shaderLanguage)===0&&(i.GL_ES="true"),i.__VERSION__=a.version,i[a.platformName]="true",Ol(i,e==null?void 0:e.isNDCHalfZRange,e==null?void 0:e.useReverseDepthBuffer,e==null?void 0:e.useExactSrgbConversions),i}function Sd(a,e,t){let i=Ed(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,n=Gl(e,t);return e.processor.preProcessor&&(i=e.processor.preProcessor(i,s,n,e.isFragment,e.processingContext)),i=Vl(i,n,e),e.processor.postProcessor&&(i=e.processor.postProcessor(i,s,e.isFragment,e.processingContext,t?{drawBuffersExtensionDisabled:!t.getCaps().drawBuffersExtension}:{})),t!=null&&t._features.needShaderCodeInlining&&(i=t.inlineShaderCode(i)),i}function Md(a,e,t){var r,o;let i=a;const s=e.defines,n=Gl(e,t);return(r=e.processor)!=null&&r.preProcessor&&(i=e.processor.preProcessor(i,s,n,e.isFragment,e.processingContext)),i=Vl(i,n,e),(o=e.processor)!=null&&o.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 Dn(a,e,t){nr.length=0;let i;for(;(i=Td.exec(a))!==null;)nr.push(i);let s=String(a),n=[a],r=!1;for(const o of nr){let h=o[1];if(h.indexOf("__decl__")!==-1&&(h=h.replace(Ad,""),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"),_=u[f+1];l=l.replace(d,_)}}if(o[4]){const u=o[5];if(u.indexOf("..")!==-1){const f=u.split(".."),d=parseInt(f[0]);let _=parseInt(f[1]),p=l.slice(0);l="",isNaN(_)&&(_=e.indexParameters[f[1]]);for(let g=d;g<_;g++)e.supportsUniformBuffers||(p=p.replace(Do,(m,b)=>b+"{X}")),l+=p.replace(Fo,g.toString())+"\n"}else e.supportsUniformBuffers||(l=l.replace(Do,(f,d)=>d+"{X}")),l=l.replace(Fo,u)}const c=[];for(const u of n){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])}n=c,r=r||l.indexOf("#include<")>=0||l.indexOf("#include <")>=0}else{const l=e.shadersRepository+"ShadersInclude/"+h+".fx";zl.loadFile(l,c=>{e.includesShadersStore[h]=c,Dn(n.join(""),e,t)});return}}nr.length=0,s=n.join(""),r?Dn(s.toString(),e,t):t(s)}const zl={loadFile:(a,e,t,i,s,n)=>{throw ye("FileTools")}};function Pd(a,e){return ii(e).cachedPipelines[a]}function _0(a){const e=a._name,t=a.context;if(e&&t){const i=ii(t),s=i.cachedPipelines[e];s==null||s.dispose(),delete i.cachedPipelines[e]}}function wd(a,e,t,i,s,n,r){let o,h;const l=St()?n==null?void 0:n.getHostDocument():null;typeof e=="string"?o=e:e.vertexSource?o="source:"+e.vertexSource:e.vertexElement?o=(l==null?void 0: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==null?void 0: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;Tr(d,a,(_,p)=>{r&&(r._fragmentSourceCodeBeforeMigration=p),t&&(_=t("fragment",_));const g=d0(f,_,a);a=null;const m=Dd(g.vertexCode,g.fragmentCode,e,s);i==null||i(m.vertexSourceCode,m.fragmentSourceCode)},n)}};Oo(o,"Vertex","",f=>{f0(a),Tr(f,a,(d,_)=>{r&&(r._rawVertexSourceCode=f,r._vertexSourceCodeBeforeMigration=_),t&&(d=t("vertex",d)),c[0]=d,u()},n)},s),Oo(h,"Fragment","Pixel",f=>{r&&(r._rawFragmentSourceCode=f),c[1]=f,u()},s)}function Oo(a,e,t,i,s,n){if(typeof HTMLElement<"u"&&a instanceof HTMLElement){const h=h0(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 r=Me.GetShadersStore(s);if(r[a+e+"Shader"]){i(r[a+e+"Shader"]);return}if(t&&r[a+t+"Shader"]){i(r[a+t+"Shader"]);return}let o;if(a[0]==="."||a[0]==="/"||a.indexOf("http")>-1?o=a:o=Me.GetShadersRepository(s)+a,n=n||Fl,!n)throw new Error("loadFileInjection is not defined");n(o+"."+e.toLowerCase()+".fx",i)}function Dd(a,e,t,i){if(t){const s=t.vertexElement||t.vertex||t.spectorName||t,n=t.fragmentElement||t.fragment||t.spectorName||t;return{vertexSourceCode:(i===1?"//":"")+"#define SHADER_NAME vertex:"+s+"\n"+a,fragmentSourceCode:(i===1?"//":"")+"#define SHADER_NAME fragment:"+n+"\n"+e}}else return{vertexSourceCode:a,fragmentSourceCode:e}}const Fd=(a,e,t,i)=>{try{const s=a.existingPipelineContext||e(a.shaderProcessingContext);if(s._name=a.name,a.name&&a.context){const n=ii(a.context);n.cachedPipelines[a.name]=s}return t(s,a.vertex,a.fragment,!!a.createAsRaw,"","",a.rebuildRebind,a.defines,a.transformFeedbackVaryings,"",()=>{i(s,()=>{var n;(n=a.onRenderingStateCompiled)==null||n.call(a,s)})}),s}catch(s){throw U.Error("Error compiling effect"),s}},Od=(a,e,t,i=16,s=1e3)=>{const n=setInterval(()=>{try{a()&&(clearInterval(n),e())}catch(r){clearInterval(n),t==null||t(r)}s-=i,s<0&&(clearInterval(n),t==null||t())},i)};class Et{static get ShadersRepository(){return Me.ShadersRepository}static set ShadersRepository(e){Me.ShadersRepository=e}get isDisposed(){return this._isDisposed}get onBindObservable(){return this._onBindObservable||(this._onBindObservable=new Z),this._onBindObservable}get shaderLanguage(){return this._shaderLanguage}constructor(e,t,i,s=null,n,r=null,o=null,h=null,l=null,c,u="",f=0,d){var g,m,b,I;this.defines="",this.onCompiled=null,this.onError=null,this.onBind=null,this.uniqueId=0,this.onCompileObservable=new Z,this.onErrorObservable=new Z,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._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 _=this._key.replace(/\r/g,"").replace(/\n/g,"|");let p;if(t.attributes){const T=t;if(this._engine=i,this._attributesNames=T.attributes,this._uniformsNames=T.uniformsNames.concat(T.samplers),this._samplerList=T.samplers.slice(),this.defines=T.defines,this.onError=T.onError,this.onCompiled=T.onCompiled,this._fallbacks=T.fallbacks,this._indexParameters=T.indexParameters,this._transformFeedbackVaryings=T.transformFeedbackVaryings||null,this._multiTarget=!!T.multiTarget,this._shaderLanguage=(g=T.shaderLanguage)!=null?g:0,T.uniformBuffersNames){this._uniformBuffersNamesList=T.uniformBuffersNames.slice();for(let x=0;x<T.uniformBuffersNames.length;x++)this._uniformBuffersNames[T.uniformBuffersNames[x]]=x}this._processFinalCode=(m=T.processFinalCode)!=null?m:null,this._processCodeAfterIncludes=(b=T.processCodeAfterIncludes)!=null?b:void 0,p=T.existingPipelineContext}else this._engine=n,this.defines=r==null?"":r,this._uniformsNames=i.concat(s),this._samplerList=s?s.slice():[],this._attributesNames=t,this._uniformBuffersNamesList=[],this._shaderLanguage=f,this.onError=l,this.onCompiled=h,this._indexParameters=c,this._fallbacks=o;this._engine.shaderPlatformName==="WEBGL2"&&(p=(I=Pd(_,this._engine._gl))!=null?I:p),this._attributeLocationByName={},this.uniqueId=Et._UniqueIdSeed++,p?(this._pipelineContext=p,this._pipelineContext.setEngine(this._engine),this._onRenderingStateCompiled(this._pipelineContext),this._pipelineContext.program&&(this._pipelineContext.program.__SPECTOR_rebuildProgram=this._rebuildProgram.bind(this))):this._processShaderCodeAsync(null,!1,null,d)}async _processShaderCodeAsync(e=null,t=!1,i=null,s){s&&await s(),this._processingContext=i||this._engine._getShaderProcessingContext(this._shaderLanguage,!1);const n={defines:this.defines.split("\n"),indexParameters:this._indexParameters,isFragment:!1,shouldUseHighPrecisionShader:this._engine._shouldUseHighPrecisionShader,processor:e!=null?e:this._engine._getShaderProcessor(this._shaderLanguage),supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:Me.GetShadersRepository(this._shaderLanguage),includesShadersStore:Me.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};wd(n,this.name,this._processFinalCode,(r,o)=>{this._vertexSourceCode=r,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}executeWhenCompiled(e){if(this.isReady()){e(this);return}this.onCompileObservable.add(t=>{e(t)}),(!this._pipelineContext||this._pipelineContext.isAsync)&&this._checkIsReady(null)}_checkIsReady(e){Od(()=>this._isReadyInternal()||this._isDisposed,()=>{},t=>{this._processCompilationErrors(t,e)})}get vertexSourceCode(){var e,t;return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._vertexSourceCodeOverride:(t=(e=this._pipelineContext)==null?void 0:e._getVertexShaderCode())!=null?t:this._vertexSourceCode}get fragmentSourceCode(){var e,t;return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._fragmentSourceCodeOverride:(t=(e=this._pipelineContext)==null?void 0:e._getFragmentShaderCode())!=null?t: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("\n"),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=(n,r)=>{s&&s(r)},this.onCompiled=()=>{var r,o;const n=this.getEngine().scenes;if(n)for(let h=0;h<n.length;h++)n[h].markAllMaterialsAsDirty(63);(o=(r=this._pipelineContext)._handlesSpectorRebuildCallback)==null||o.call(r,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(),Et.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,n=i?this._vertexSourceCodeOverride:this._vertexSourceCode,r=i?this._fragmentSourceCodeOverride:this._fragmentSourceCode,o=this._engine;this._pipelineContext=Fd({existingPipelineContext:e?t:null,vertex:n,fragment:r,context:o.shaderPlatformName==="WEBGL2"?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,parallelShaderCompile:o._caps.parallelShaderCompile,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 n=null;if(t&&e){const r=t.match(s);if(r&&r.length===2){const o=parseInt(r[1]),h=e.split("\n",-1);h.length>=o&&(n="Offending line [".concat(o,"] in ").concat(i?"fragment":"vertex"," code: ").concat(h[o-1]))}}return[e,n]}_processCompilationErrors(e,t=null){var r,o,h;this._compilationError=e.message;const i=this._attributesNames,s=this._fallbacks;if(U.Error("Unable to compile effect:"),U.Error("Uniforms: "+this._uniformsNames.map(function(l){return" "+l})),U.Error("Attributes: "+i.map(function(l){return" "+l})),U.Error("Defines:\n"+this.defines),Et.LogShaderCodeOnCompilationError){let l=null,c=null,u=null;(r=this._pipelineContext)!=null&&r._getVertexShaderCode()&&([u,l]=this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(),this._compilationError,!1),u&&(U.Error("Vertex code:"),U.Error(u))),(o=this._pipelineContext)!=null&&o._getFragmentShaderCode()&&([u,c]=this._getShaderCodeAndErrorLine((h=this._pipelineContext)==null?void 0:h._getFragmentShaderCode(),this._compilationError,!0),u&&(U.Error("Fragment code:"),U.Error(u))),l&&U.Error(l),c&&U.Error(c)}U.Error("Error: "+this._compilationError);const n=()=>{this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this)};t&&(this._pipelineContext=t,this._isReady=!0,n()),s?(this._pipelineContext=null,s.hasMoreFallbacks?(this._allFallbacksProcessed=!1,U.Error("Trying next fallback."),this.defines=s.reduce(this.defines,this),this._prepareEffect()):(this._allFallbacksProcessed=!0,n(),this.onErrorObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh())):(this._allFallbacksProcessed=!0,t||n())}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 r=1;r<t.length;r++){const o=i+(r-1).toString();this._samplerList.splice(s+r,0,o)}let n=0;for(const r of this._samplerList)this._samplers[r]=n,n+=1}this._engine.setTextureArray(this._samplers[e],this._uniforms[e],t,e)}bindUniformBuffer(e,t){const i=this._uniformBuffersNames[t];i===void 0||Et._BaseCache[i]===e&&this._engine._features.useUBOBindingCache||(Et._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,n){return this._pipelineContext.setInt4(e,t,i,s,n),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,n){return this._pipelineContext.setUInt4(e,t,i,s,n),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,n){return this._pipelineContext.setFloat4(e,t,i,s,n),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){e?this._refCount=0:this._refCount--,!(this._refCount>0||this._isDisposed)&&(this._pipelineContext&&_0(this._pipelineContext),this._engine._releaseEffect(this),this.clearCodeCache(),this._isDisposed=!0)}static RegisterShader(e,t,i,s=0){t&&(Me.GetShadersStore(s)["".concat(e,"PixelShader")]=t),i&&(Me.GetShadersStore(s)["".concat(e,"VertexShader")]=i)}static ResetCache(){Et._BaseCache={}}}Et.LogShaderCodeOnCompilationError=!0;Et.AutomaticallyClearCodeCache=!1;Et._UniqueIdSeed=0;Et._BaseCache={};Et.ShadersStore=Me.ShadersStore;Et.IncludesShadersStore=Me.IncludesShadersStore;class Dt{static SetMatrixPrecision(e){if(Dt.MatrixTrackPrecisionChange=!1,e&&!Dt.MatrixUse64Bits&&Dt.MatrixTrackedMatrices)for(let t=0;t<Dt.MatrixTrackedMatrices.length;++t){const i=Dt.MatrixTrackedMatrices[t],s=i._m;i._m=new Array(16);for(let n=0;n<16;++n)i._m[n]=s[n]}Dt.MatrixUse64Bits=e,Dt.MatrixCurrentType=Dt.MatrixUse64Bits?Array:Float32Array,Dt.MatrixTrackedMatrices=null}}Dt.MatrixUse64Bits=!1;Dt.MatrixTrackPrecisionChange=!0;Dt.MatrixCurrentType=Float32Array;Dt.MatrixTrackedMatrices=[];class bi{static get Now(){return St()&&window.performance&&window.performance.now?window.performance.now():Date.now()}}class Wl{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 Hl{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(){var e;this.stencilMaterial=void 0,(e=this.stencilGlobal)==null||e.reset(),this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0}apply(e){var i;if(!e)return;const t=!this.useStencilGlobalOnly&&!!((i=this.stencilMaterial)!=null&&i.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 ss{constructor(){this.reset()}reset(){this.enabled=!1,this.mask=255,this.func=ss.ALWAYS,this.funcRef=1,this.funcMask=255,this.opStencilFail=ss.KEEP,this.opDepthFail=ss.KEEP,this.opStencilDepthPass=ss.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}}ss.ALWAYS=519;ss.KEEP=7680;ss.REPLACE=7681;class Bd{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))}}const Ar=new Map;function _s(a,e){Ld(a)&&U.Warn("Extension with the name '".concat(name,"' already exists")),Ar.set(a,e)}function Ld(a){return Ar.delete(a)}function Nd(a,e){(e==="image/ktx"||e==="image/ktx2")&&(a=".ktx"),Ar.has(a)||(a.endsWith(".dds")&&_s(".dds",()=>Oe(()=>import("./ddsTextureLoader-7rBWB6fI.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(i=>new i._DDSTextureLoader)),a.endsWith(".basis")&&_s(".basis",()=>Oe(()=>import("./basisTextureLoader-C2AKop91.js"),__vite__mapDeps([11,3,4,5,6,7,8,9,10])).then(i=>new i._BasisTextureLoader)),a.endsWith(".env")&&_s(".env",()=>Oe(()=>import("./envTextureLoader-0a1UyQXk.js"),__vite__mapDeps([12,7,3,4,5,6,8,9,2,10])).then(i=>new i._ENVTextureLoader)),a.endsWith(".hdr")&&_s(".hdr",()=>Oe(()=>import("./hdrTextureLoader-CbSWrxkf.js"),__vite__mapDeps([13,3,4,5,6,7,8,9,10])).then(i=>new i._HDRTextureLoader)),(a.endsWith(".ktx")||a.endsWith(".ktx2"))&&(_s(".ktx",()=>Oe(()=>import("./ktxTextureLoader-DFWsW27H.js"),__vite__mapDeps([14,3,4,5,6,7,8,9,10])).then(i=>new i._KTXTextureLoader)),_s(".ktx2",()=>Oe(()=>import("./ktxTextureLoader-DFWsW27H.js"),__vite__mapDeps([14,3,4,5,6,7,8,9,10])).then(i=>new i._KTXTextureLoader))),a.endsWith(".tga")&&_s(".tga",()=>Oe(()=>import("./tgaTextureLoader-CGo25llH.js"),__vite__mapDeps([15,3,4,5,6,7,8,9,10])).then(i=>new i._TGATextureLoader)),a.endsWith(".exr")&&_s(".exr",()=>Oe(()=>import("./exrTextureLoader-CpwykM8r.js"),__vite__mapDeps([16,3,4,5,6,7,8,9,10])).then(i=>new i._ExrTextureLoader)));const t=Ar.get(a);return t?Promise.resolve(t(e)):null}function Kl(a,e){if(St()){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 ae{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+="\n"),t+="#define USE_REVERSE_DEPTHBUFFER"),this.useExactSrgbConversions&&(t&&(t+="\n"),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()}Et.ResetCache()}_rebuildGraphicsResources(){var e;this.wipeCaches(!0),this._rebuildEffects(),(e=this._rebuildComputeEffects)==null||e.call(this),this._rebuildBuffers(),this._rebuildInternalTextures(),this._rebuildTextures(),this._rebuildRenderTargetWrappers(),this.wipeCaches(!0)}_flagContextRestored(){U.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,n=this._stencilState.stencilTest;await e(),this._rebuildGraphicsResources(),this._depthCullingState.depthTest=t,this._depthCullingState.depthFunc=i,this._depthCullingState.depthMask=s,this._stencilState.stencilTest=n,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,St()){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)}_renderLoop(){if(this._frameHandler=0,!this._contextWasLost){let e=!0;(this._isDisposed||!this.renderEvenInBackground&&this._windowIsBackground)&&(e=!1),e&&(this.beginFrame(),this._renderViews()||this._renderFrame(),this.endFrame())}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 Kl(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 St()?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(),n=i||this.getRenderHeight(),r=e.x||0,o=e.y||0;this._cachedViewport=e,this._viewport(r*s,o*n,s*e.width,n*e.height)}createCanvasImage(){return document.createElement("img")}get description(){let e=this.name+this.version;return this._caps.parallelShaderCompile&&(e+=" - Parallel shader compilation"),e}_createTextureBase(e,t,i,s,n=3,r=null,o=null,h,l,c=null,u=null,f=null,d=null,_,p,g){e=e||"";const m=e.substr(0,5)==="data:",b=e.substr(0,5)==="blob:",I=m&&e.indexOf(";base64,")!==-1,T=u||new ft(this,1);T!==u&&(T.label=e.substring(0,60));const x=e;this._transformTextureUrl&&!I&&!u&&!c&&(e=this._transformTextureUrl(e)),x!==e&&(T._originalUrl=x);const y=e.lastIndexOf(".");let R=d||(y>-1?e.substring(y).toLowerCase():"");R.indexOf("?")>-1&&(R=R.split("?")[0]);const C=Nd(R,_);s&&s.addPendingData(T),T.url=e,T.generateMipMaps=!t,T.samplingMode=n,T.invertY=i,T._useSRGBBuffer=this._getUseSRGBBuffer(!!g,t),this._doNotHandleContextLost||(T._buffer=c);let S=null;r&&!u&&(S=T.onLoadedObservable.add(r)),u||this._internalTexturesCache.push(T);const w=(P,G)=>{s&&s.removePendingData(T),e===x?(S&&T.onLoadedObservable.remove(S),Ee.UseFallbackTexture&&e!==Ee.FallbackTexture&&this._createTextureBase(Ee.FallbackTexture,t,T.invertY,s,n,null,o,h,l,c,T),P=(P||"Unknown error")+(Ee.UseFallbackTexture?" - Fallback texture was used":""),T.onErrorObservable.notifyObservers({message:P,exception:G}),o&&o(P,G)):(U.Warn("Failed to load ".concat(e,", falling back to ").concat(x)),this._createTextureBase(x,t,T.invertY,s,n,r,o,h,l,c,T,f,d,_,p,g))};if(C){const P=async G=>{(await C).loadData(G,T,(W,K,ce,$,z,k)=>{k?w("TextureLoader failed to load data"):h(T,R,s,{width:W,height:K},T.invertY,!ce,$,()=>(z(),!1),n)},p)};c?c instanceof ArrayBuffer?P(new Uint8Array(c)):ArrayBuffer.isView(c)?P(c):o&&o("Unable to load: only ArrayBuffer or ArrayBufferView is supported",null):this._loadFile(e,G=>P(new Uint8Array(G)),void 0,s?s.offlineProvider:void 0,!0,(G,L)=>{w("Unable to load "+(G&&G.responseURL,L))})}else{const P=G=>{b&&!this._doNotHandleContextLost&&(T._buffer=G),h(T,R,s,G,T.invertY,t,!1,l,n)};!m||I?c&&(typeof c.decoding=="string"||c.close)?P(c):ae._FileToolsLoadImage(e||"",P,w,s?s.offlineProvider:null,_,T.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0):typeof c=="string"||c instanceof ArrayBuffer||ArrayBuffer.isView(c)||c instanceof Blob?ae._FileToolsLoadImage(c,P,w,s?s.offlineProvider:null,_,T.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0):c&&P(c)}return T}_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:En()?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"babylonjs@7.37.0"}static get Version(){return"7.37.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){var r,o,h,l,c,u,f,d,_,p,g;this._colorWrite=!0,this._colorWriteChanged=!0,this._depthCullingState=new Wl,this._stencilStateComposer=new Hl,this._stencilState=new ss,this._alphaState=new Bd,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 Z,this.onCanvasFocusObservable=new Z,this.onNewSceneAddedObservable=new Z,this.onResizeObservable=new Z,this.onCanvasPointerOutObservable=new Z,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 Z,this.renderEvenInBackground=!0,this.preventCacheWipeBetweenFrames=!1,this._frameHandler=0,this._activeRenderLoops=new Array,this._windowIsBackground=!1,this._boundRenderFunction=()=>this._renderLoop(),this.onBeforeShaderCompilationObservable=new Z,this.onAfterShaderCompilationObservable=new Z,this.onBeginFrameObservable=new Z,this.onEndFrameObservable=new Z,this._transformTextureUrl=null,this._uniformBuffers=new Array,this._storageBuffers=new Array,this._highPrecisionShadersAllowed=!0,this.onContextLostObservable=new Z,this.onContextRestoredObservable=new Z,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 Z,Ee.Instances.push(this),this.startTime=bi.Now,this._stencilStateComposer.stencilGlobal=this._stencilState,Dt.SetMatrixPrecision(!!t.useHighPrecisionMatrix),Qs()&&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!=null?i:!1,t.antialias=e!=null?e:t.antialias,t.deterministicLockstep=(r=t.deterministicLockstep)!=null?r:!1,t.lockstepMaxSteps=(o=t.lockstepMaxSteps)!=null?o:4,t.timeStep=(h=t.timeStep)!=null?h:1/60,t.audioEngine=(l=t.audioEngine)!=null?l:!0,t.stencil=(c=t.stencil)!=null?c:!0,this._audioContext=(f=(u=t.audioEngineOptions)==null?void 0:u.audioContext)!=null?f:null,this._audioDestination=(_=(d=t.audioEngineOptions)==null?void 0:d.audioDestination)!=null?_:null,this.premultipliedAlpha=(p=t.premultipliedAlpha)!=null?p:!0,this._doNotHandleContextLost=!!t.doNotHandleContextLost,this._isStencilEnable=!!t.stencil,this.useExactSrgbConversions=(g=t.useExactSrgbConversions)!=null?g:!1;const s=St()&&window.devicePixelRatio||1,n=t.limitDeviceRatio||s;i=i||t.adaptToDeviceRatio||!1,this._hardwareScalingLevel=i?1/Math.min(n,s):1,this._lastDevicePixelRatio=s,this._creationOptions=t}resize(e=!1){let t,i;if(this.adaptToDeviceRatio){const s=St()&&window.devicePixelRatio||1,n=this._lastDevicePixelRatio/s;this._lastDevicePixelRatio=s,this._hardwareScalingLevel*=n}if(St()&&En())if(this._renderingCanvas){const s=this._renderingCanvas.getBoundingClientRect?this._renderingCanvas.getBoundingClientRect():{width:this._renderingCanvas.width*this._hardwareScalingLevel,height:this._renderingCanvas.height*this._hardwareScalingLevel};t=this._renderingCanvas.clientWidth||s.width||this._renderingCanvas.width||100,i=this._renderingCanvas.clientHeight||s.height||this._renderingCanvas.height||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 n=this.scenes[s];for(let r=0;r<n.cameras.length;r++){const o=n.cameras[r];o._currentRenderId=0}}this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this)}return!0}createRawTexture(e,t,i,s,n,r,o,h,l,c,u){throw ye("engine.rawTexture")}createRawCubeTexture(e,t,i,s,n,r,o,h){throw ye("engine.rawTexture")}createRawTexture3D(e,t,i,s,n,r,o,h,l,c,u){throw ye("engine.rawTexture")}createRawTexture2DArray(e,t,i,s,n,r,o,h,l,c,u){throw ye("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&&En()&&"ontouchend"in document},this._checkForMobile(),St()&&window.addEventListener("resize",this._checkForMobile))}createVideoElement(e){return document.createElement("video")}_reportDrawCall(e=1){var t;(t=this._drawCalls)==null||t.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 ae._CreateCanvas(e,t)}static _FileToolsLoadImage(e,t,i,s,n,r){throw ye("FileTools")}_loadFile(e,t,i,s,n,r){const o=Fl(e,t,i,s,n,r);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,n,r){if(xr.loadFile)return xr.loadFile(e,t,i,s,n,r);throw ye("FileTools")}dispose(){var t;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();(t=this.releaseComputeEffects)==null||t.call(this),Et.ResetCache();for(const i of this._activeRequests)i.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(),St()&&window.removeEventListener("resize",this._checkForMobile);const e=Ee.Instances.indexOf(this);e>=0&&Ee.Instances.splice(e,1),Ee.Instances.length||(Ee.OnEnginesDisposedObservable.notifyObservers(this),Ee.OnEnginesDisposedObservable.clear()),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear()}static DefaultLoadingScreenFactory(e){throw ye("LoadingScreen")}static MarkAllMaterialsAsDirty(e,t){for(let i=0;i<Ee.Instances.length;i++){const s=Ee.Instances[i];for(let n=0;n<s.scenes.length;n++)s.scenes[n].markAllMaterialsAsDirty(e,t)}}}ae._RenderPassIdCounter=0;ae._RescalePostProcessFactory=null;ae.CollisionsEpsilon=.001;ae.QueueNewFrame=Kl;class Xl{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){var t,i;return(i=(t=this._MSAARenderBuffers)==null?void 0:t[e])!=null?i:null}release(){this.releaseMSAARenderBuffers(),this._webGLTexture&&this._context.deleteTexture(this._webGLTexture),this.reset()}}class Ud{}class we extends ae{get name(){return this._name}set name(e){this._name=e}get version(){return this._webGLVersion}static get ShadersRepository(){return Et.ShadersRepository}static set ShadersRepository(e){Et.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!=null?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 n=null;if(e.getContext){if(n=e,this._renderingCanvas=n,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 we.ExceptionList){const c=l.key,u=l.targets;if(new RegExp(c).test(h)){if(l.capture&&l.captureConstraint){const d=l.capture,_=l.captureConstraint,g=new RegExp(d).exec(h);if(g&&g.length>0&&parseInt(g[g.length-1])>=_)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=h=>{h.preventDefault(),this._contextWasLost=!0,U.Warn("WebGL context lost."),this.onContextLostObservable.notifyObservers(this)},this._onContextRestored=()=>{this._restoreEngineAfterContextLost(()=>this._initGLContext())},n.addEventListener("webglcontextlost",this._onContextLost,!1),n.addEventListener("webglcontextrestored",this._onContextRestored,!1),i.powerPreference=i.powerPreference||"high-performance"),this._badDesktopOS&&(i.xrCompatible=!1),!i.disableWebGL2Support)try{this._gl=n.getContext("webgl2",i)||n.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(!n)throw new Error("The provided canvas is null or undefined.");try{this._gl=n.getContext("webgl",i)||n.getContext("experimental-webgl",i)}catch{throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported")}else{this._gl=e,this._renderingCanvas=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._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 Ud;this._shaderProcessor=this.webGLVersion>1?new dd:new ud;const r="Babylon.js v".concat(we.Version);U.Log(r+" - ".concat(this.description)),this._renderingCanvas&&this._renderingCanvas.setAttribute&&this._renderingCanvas.setAttribute("data-engine",r);const o=ii(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(){var t;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=((t=this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT,this._caps.timerQuery.QUERY_COUNTER_BITS_EXT))!=null?t: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 i=this._gl.getExtension("WEBGL_draw_buffers");if(i!==null){this._caps.drawBuffersExtension=!0,this._gl.drawBuffers=i.drawBuffersWEBGL.bind(i),this._caps.maxDrawBuffers=this._gl.getParameter(i.MAX_DRAW_BUFFERS_WEBGL),this._gl.DRAW_FRAMEBUFFER=this._gl.FRAMEBUFFER;for(let s=0;s<16;s++)this._gl["COLOR_ATTACHMENT"+s+"_WEBGL"]=i["COLOR_ATTACHMENT"+s+"_WEBGL"]}}if(this._webGLVersion>1)this._caps.depthTextureExtension=!0;else{const i=this._gl.getExtension("WEBGL_depth_texture");i!=null&&(this._caps.depthTextureExtension=!0,this._gl.UNSIGNED_INT_24_8=i.UNSIGNED_INT_24_8_WEBGL)}if(this.disableVertexArrayObjects)this._caps.vertexArrayObject=!1;else if(this._webGLVersion>1)this._caps.vertexArrayObject=!0;else{const i=this._gl.getExtension("OES_vertex_array_object");i!=null&&(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=i.createVertexArrayOES.bind(i),this._gl.bindVertexArray=i.bindVertexArrayOES.bind(i),this._gl.deleteVertexArray=i.deleteVertexArrayOES.bind(i))}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{const i=this._gl.getExtension("ANGLE_instanced_arrays");i!=null?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=i.drawArraysInstancedANGLE.bind(i),this._gl.drawElementsInstanced=i.drawElementsInstancedANGLE.bind(i),this._gl.vertexAttribDivisor=i.vertexAttribDivisorANGLE.bind(i)):this._caps.instancedArrays=!1}if(this._gl.getShaderPrecisionFormat){const i=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.HIGH_FLOAT),s=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);i&&s&&(this._caps.highPrecisionShaderSupported=i.precision!==0&&s.precision!==0)}if(this._webGLVersion>1)this._caps.blendMinMax=!0;else{const i=this._gl.getExtension("EXT_blend_minmax");i!=null&&(this._caps.blendMinMax=!0,this._gl.MAX=i.MAX_EXT,this._gl.MIN=i.MIN_EXT)}if(!this._caps.supportSRGBBuffers){if(this._webGLVersion>1)this._caps.supportSRGBBuffers=!0,this._glSRGBExtensionValues={SRGB:WebGL2RenderingContext.SRGB,SRGB8:WebGL2RenderingContext.SRGB8,SRGB8_ALPHA8:WebGL2RenderingContext.SRGB8_ALPHA8};else{const i=this._gl.getExtension("EXT_sRGB");i!=null&&(this._caps.supportSRGBBuffers=!0,this._glSRGBExtensionValues={SRGB:i.SRGB_EXT,SRGB8:i.SRGB_ALPHA_EXT,SRGB8_ALPHA8:i.SRGB_ALPHA_EXT})}if(this._creationOptions){const i=this._creationOptions.forceSRGBBufferSupportState;i!==void 0&&(this._caps.supportSRGBBuffers=this._caps.supportSRGBBuffers&&i)}}this._depthCullingState.depthTest=!0,this._depthCullingState.depthFunc=this._gl.LEQUAL,this._depthCullingState.depthMask=!0,this._maxSimultaneousTextures=this._caps.maxCombinedTexturesImageUnits;for(let i=0;i<this._maxSimultaneousTextures;i++)this._nextFreeTextureSlots.push(i);this._glRenderer==="Mali-G72"&&(this._caps.disableMorphTargetTexture=!0)}_initFeatures(){this._features={forceBitmapOverHTMLImageElement:typeof HTMLImageElement>"u",supportRenderAndCopyToLodForFloatTextures:this._webGLVersion!==1,supportDepthStencilTexture:this._webGLVersion!==1,supportShadowSamplers:this._webGLVersion!==1,uniformBufferHardCheckMatrix:!1,allowTexturePrefiltering:this._webGLVersion!==1,trackUbosInFrame:!1,checkUbosContentBeforeUpload:!1,supportCSM:this._webGLVersion!==1,basisNeedsPOT:this._webGLVersion===1,support3DTextures:this._webGLVersion!==1,needTypeSuffixInShaderConstants:this._webGLVersion!==1,supportMSAA:this._webGLVersion!==1,supportSSAO2:this._webGLVersion!==1,supportIBLShadows:this._webGLVersion!==1,supportExtendedTextureFormats:this._webGLVersion!==1,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){var o,h;const n=this.stencilStateComposer.useStencilGlobalOnly;this.stencilStateComposer.useStencilGlobalOnly=!0,this.applyStates(),this.stencilStateComposer.useStencilGlobalOnly=n;let r=0;if(t&&e){let l=!0;if(this._currentRenderTarget){const c=(o=this._currentRenderTarget.texture)==null?void 0:o.format;if(c===8||c===9||c===10||c===11){const u=(h=this._currentRenderTarget.texture)==null?void 0:h.type;u===7||u===5?(we._TempClearColorUint32[0]=e.r*255,we._TempClearColorUint32[1]=e.g*255,we._TempClearColorUint32[2]=e.b*255,we._TempClearColorUint32[3]=e.a*255,this._gl.clearBufferuiv(this._gl.COLOR,0,we._TempClearColorUint32),l=!1):(we._TempClearColorInt32[0]=e.r*255,we._TempClearColorInt32[1]=e.g*255,we._TempClearColorInt32[2]=e.b*255,we._TempClearColorInt32[3]=e.a*255,this._gl.clearBufferiv(this._gl.COLOR,0,we._TempClearColorInt32),l=!1)}}l&&(this._gl.clearColor(e.r,e.g,e.b,e.a!==void 0?e.a:1),r|=this._gl.COLOR_BUFFER_BIT)}i&&(this.useReverseDepthBuffer?(this._depthCullingState.depthFunc=this._gl.GEQUAL,this._gl.clearDepth(0)):this._gl.clearDepth(1),r|=this._gl.DEPTH_BUFFER_BIT),s&&(this._gl.clearStencil(0),r|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(r)}_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,n,r=0,o=0){var u,f,d,_,p,g;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,(u=e.texture._hardwareTexture)==null?void 0:u.underlyingResource,r,o),h._currentLOD=r):e.isCube?l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_CUBE_MAP_POSITIVE_X+t,(f=e.texture._hardwareTexture)==null?void 0:f.underlyingResource,r):h._currentLOD!==r&&(l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,(d=e.texture._hardwareTexture)==null?void 0:d.underlyingResource,r),h._currentLOD=r));const c=e._depthStencilTexture;if(c){e.is3D&&(e.texture.width!==c.width||e.texture.height!==c.height||e.texture.depth!==c.depth)&&U.Warn("Depth/Stencil attachment for 3D target must have same dimensions as color attachment");const m=e._depthStencilTextureWithStencil?l.DEPTH_STENCIL_ATTACHMENT:l.DEPTH_ATTACHMENT;e.is2DArray||e.is3D?l.framebufferTextureLayer(l.FRAMEBUFFER,m,(_=c._hardwareTexture)==null?void 0:_.underlyingResource,r,o):e.isCube?l.framebufferTexture2D(l.FRAMEBUFFER,m,l.TEXTURE_CUBE_MAP_POSITIVE_X+t,(p=c._hardwareTexture)==null?void 0:p.underlyingResource,r):l.framebufferTexture2D(l.FRAMEBUFFER,m,l.TEXTURE_2D,(g=c._hardwareTexture)==null?void 0:g.underlyingResource,r)}h._MSAAFramebuffer&&this._bindUnboundFramebuffer(h._MSAAFramebuffer),this._cachedViewport&&!n?this.setViewport(this._cachedViewport,i,s):(i||(i=e.width,r&&(i=i/Math.pow(2,r))),s||(s=e.height,r&&(s=s/Math.pow(2,r))),this._viewport(0,0,i,s)),this.wipeCaches()}setState(e,t=0,i,s=!1,n,r,o=0){var c,u;(this._depthCullingState.cull!==e||i)&&(this._depthCullingState.cull=e);const h=(u=(c=this.cullBackFaces)!=null?c:n)==null||u?this._gl.BACK:this._gl.FRONT;(this._depthCullingState.cullFace!==h||i)&&(this._depthCullingState.cullFace=h),this.setZOffset(t),this.setZOffsetUnits(o);const l=s?this._gl.CW:this._gl.CCW;(this._depthCullingState.frontFace!==l||i)&&(this._depthCullingState.frontFace=l),this._stencilStateComposer.stencilMaterial=r}_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){var t;!e.isMulti&&((t=e.texture)!=null&&t.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 Pn(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(),n=new Pn(s);if(!s)throw new Error("Unable to create index buffer");this.bindIndexBuffer(n);const r=this._normalizeIndexData(e);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,r,t?this._gl.DYNAMIC_DRAW:this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),n.references=1,n.is32Bits=r.BYTES_PER_ELEMENT===4,n}_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,n=this._gl.getUniformBlockIndex(s,t);this._gl.uniformBlockBinding(s,n,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,n,r,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!==n&&(h.normalized=n,l=!0),h.stride!==r&&(h.stride=r,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=n,h.stride=r,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,r,o):this._gl.vertexAttribPointer(t,i,s,n,r,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 n=0;n<s.length;n++){const r=t.getAttributeLocation(n);if(r>=0){const o=s[n];let h=null;if(i&&(h=i[o]),h||(h=e[o]),!h)continue;this._gl.enableVertexAttribArray(r),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[r]=!0);const l=h.getBuffer();l&&(this._vertexAttribPointer(l,r,h.getSize(),h.type,h.normalized,h.byteStride,h.byteOffset),h.getIsInstanced()&&(this._gl.vertexAttribDivisor(r,h.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(r),this._currentInstanceBuffers.push(l))))}}}recordVertexArrayObject(e,t,i,s){const n=this._gl.createVertexArray();if(!n)throw new Error("Unable to create VAO");return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(n),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(e,i,s),this.bindIndexBuffer(t),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),n}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,n){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==n){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n;const r=n.getAttributesCount();this._unbindVertexArrayObject(),this.unbindAllAttributes();let o=0;for(let h=0;h<r;h++)if(h<i.length){const l=n.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 n=this._currentInstanceLocations[t];this._gl.vertexAttribDivisor(n,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 n=i[s];this._vertexAttribArraysEnabled[n]||(this._gl.enableVertexAttribArray(n),this._vertexAttribArraysEnabled[n]=!0),this._vertexAttribPointer(e,n,4,this._gl.FLOAT,!1,64,s*16),this._gl.vertexAttribDivisor(n,1),this._currentInstanceLocations.push(n),this._currentInstanceBuffers.push(e)}}bindInstancesBuffer(e,t,i=!0){this.bindArrayBuffer(e);let s=0;if(i)for(let n=0;n<t.length;n++){const r=t[n];s+=r.attributeSize*4}for(let n=0;n<t.length;n++){const r=t[n];r.index===void 0&&(r.index=this._currentEffect.getAttributeLocationByName(r.attributeName)),!(r.index<0)&&(this._vertexAttribArraysEnabled[r.index]||(this._gl.enableVertexAttribArray(r.index),this._vertexAttribArraysEnabled[r.index]=!0),this._vertexAttribPointer(e,r.index,r.attributeSize,r.attributeType||this._gl.FLOAT,r.normalized||!1,s,r.offset),this._gl.vertexAttribDivisor(r.index,r.divisor===void 0?1:r.divisor),this._currentInstanceLocations.push(r.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 n=this._drawMode(e),r=this._uintIndicesCurrentlySet?this._gl.UNSIGNED_INT:this._gl.UNSIGNED_SHORT,o=this._uintIndicesCurrentlySet?4:2;s?this._gl.drawElementsInstanced(n,i,r,t*o,s):this._gl.drawElements(n,i,r,t*o)}drawArraysType(e,t,i,s){this.applyStates(),this._reportDrawCall();const n=this._drawMode(e);s?this._gl.drawArraysInstanced(n,t,i,s):this._gl.drawArrays(n,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,_0(t),this._gl&&this._gl.deleteProgram(t.program))}_getGlobalDefines(e){return Ol(e,this.isNDCHalfZRange,this.useReverseDepthBuffer,this.useExactSrgbConversions)}createEffect(e,t,i,s,n,r,o,h,l,c=0,u){var b,I,T;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,_=this._getGlobalDefines();let p=(b=n!=null?n:t.defines)!=null?b:"";_&&(p+=_);const g=f+"+"+d+"@"+p;if(this._compiledEffects[g]){const x=this._compiledEffects[g];return o&&x.isReady()&&o(x),x._refCount++,x}this._gl&&ii(this._gl);const m=new Et(e,t,i,s,this,n,r,o,h,l,g,(I=t.shaderLanguage)!=null?I:c,(T=t.extraInitializationsAsync)!=null?T:u);return this._compiledEffects[g]=m,m}_getShaderSource(e){return this._gl.getShaderSource(e)}createRawShaderProgram(e,t,i,s,n=null){const r=ii(this._gl);return r._contextWasLost=this._contextWasLost,r.validateShaderPrograms=this.validateShaderPrograms,Bl(e,t,i,s||this._gl,n)}createShaderProgram(e,t,i,s,n,r=null){const o=ii(this._gl);return o._contextWasLost=this._contextWasLost,o.validateShaderPrograms=this.validateShaderPrograms,Ll(e,t,i,s,n||this._gl,r)}inlineShaderCode(e){return e}createPipelineContext(e){if(this._gl){const i=ii(this._gl);i.parallelShaderCompile=this._caps.parallelShaderCompile}const t=ad(this._gl);return t.engine=this,t}createMaterialContext(){}createDrawContext(){}_finalizePipelineContext(e){return c0(e,this._gl,this.validateShaderPrograms)}_preparePipelineContext(e,t,i,s,n,r,o,h,l,c,u){const f=ii(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),hd(e,t,i,s,n,r,o,h,l,c,u)}_createShaderProgram(e,t,i,s,n=null){return l0(e,t,i,s,n)}_isRenderingStateCompiled(e){return this._isDisposed?!1:od(e,this._gl,this.validateShaderPrograms)}_executeWhenRenderingStateIsCompiled(e,t){cd(e,t)}getUniforms(e,t){const i=new Array,s=e;for(let n=0;n<t.length;n++)i.push(this._gl.getUniformLocation(s.program,t[n]));return i}getAttributes(e,t){const i=[],s=e;for(let n=0;n<t.length;n++)try{i.push(this._gl.getAttribLocation(s.program,t[n]))}catch{i.push(-1)}return i}enableEffect(e){e=e!==null&&Nl(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,n){return e?(this._gl.uniform4i(e,t,i,s,n),!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,n){return e?(this._gl.uniform4ui(e,t,i,s,n),!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,n){return e?(this._gl.uniform4f(e,t,i,s,n),!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,n=i.NEAREST;switch(e){case 11:s=i.LINEAR,t?n=i.LINEAR_MIPMAP_NEAREST:n=i.LINEAR;break;case 3:s=i.LINEAR,t?n=i.LINEAR_MIPMAP_LINEAR:n=i.LINEAR;break;case 8:s=i.NEAREST,t?n=i.NEAREST_MIPMAP_LINEAR:n=i.NEAREST;break;case 4:s=i.NEAREST,t?n=i.NEAREST_MIPMAP_NEAREST:n=i.NEAREST;break;case 5:s=i.NEAREST,t?n=i.LINEAR_MIPMAP_NEAREST:n=i.LINEAR;break;case 6:s=i.NEAREST,t?n=i.LINEAR_MIPMAP_LINEAR:n=i.LINEAR;break;case 7:s=i.NEAREST,n=i.LINEAR;break;case 1:s=i.NEAREST,n=i.NEAREST;break;case 9:s=i.LINEAR,t?n=i.NEAREST_MIPMAP_NEAREST:n=i.NEAREST;break;case 10:s=i.LINEAR,t?n=i.NEAREST_MIPMAP_LINEAR:n=i.NEAREST;break;case 2:s=i.LINEAR,n=i.LINEAR;break;case 12:s=i.LINEAR,n=i.NEAREST;break}return{min:n,mag:s}}_createTexture(){const e=this._gl.createTexture();if(!e)throw new Error("Unable to create texture");return e}_createHardwareTexture(){return new Xl(this._createTexture(),this._gl)}_createInternalTexture(e,t,i=!0,s=0){var P;let n=!1,r=!1,o=0,h=3,l=5,c=!1,u=1,f,d=!1,_=0;t!==void 0&&typeof t=="object"?(n=!!t.generateMipMaps,r=!!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=(P=t.samples)!=null?P:1,f=t.label,d=!!t.createMSAATexture,_=t.comparisonFunction||0):n=!!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,U.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));const p=Mo(l),g=br(l),m=this._gl,b=new ft(this,s),I=e.width||e,T=e.height||e,x=e.depth||0,y=e.layers||0,R=this._getSamplingParameters(h,(n||r)&&!p),E=y!==0?m.TEXTURE_2D_ARRAY:x!==0?m.TEXTURE_3D:m.TEXTURE_2D,C=p?this._getInternalFormatFromDepthTextureFormat(l,!0,g):this._getRGBABufferInternalSizedFormat(o,l,c),S=p?g?m.DEPTH_STENCIL:m.DEPTH_COMPONENT:this._getInternalFormat(l),w=p?this._getWebGLTextureTypeFromDepthTextureFormat(l):this._getWebGLTextureType(o);if(this._bindTextureDirectly(E,b),y!==0?(b.is2DArray=!0,m.texImage3D(E,0,C,I,T,y,0,S,w,null)):x!==0?(b.is3D=!0,m.texImage3D(E,0,C,I,T,x,0,S,w,null)):m.texImage2D(E,0,C,I,T,0,S,w,null),m.texParameteri(E,m.TEXTURE_MAG_FILTER,R.mag),m.texParameteri(E,m.TEXTURE_MIN_FILTER,R.min),m.texParameteri(E,m.TEXTURE_WRAP_S,m.CLAMP_TO_EDGE),m.texParameteri(E,m.TEXTURE_WRAP_T,m.CLAMP_TO_EDGE),p&&this.webGLVersion>1&&(_===0?(m.texParameteri(E,m.TEXTURE_COMPARE_FUNC,515),m.texParameteri(E,m.TEXTURE_COMPARE_MODE,m.NONE)):(m.texParameteri(E,m.TEXTURE_COMPARE_FUNC,_),m.texParameteri(E,m.TEXTURE_COMPARE_MODE,m.COMPARE_REF_TO_TEXTURE))),(n||r)&&this._gl.generateMipmap(E),this._bindTextureDirectly(E,null),b._useSRGBBuffer=c,b.baseWidth=I,b.baseHeight=T,b.width=I,b.height=T,b.depth=y||x,b.isReady=!0,b.samples=u,b.generateMipMaps=n,b.samplingMode=h,b.type=o,b.format=l,b.label=f,b.comparisonFunction=_,this._internalTexturesCache.push(b),d){let G=null;if(Mo(b.format)?G=this._setupFramebufferDepthAttachments(br(b.format),b.format!==19,b.width,b.height,u,b.format,!0):G=this._createRenderBuffer(b.width,b.height,u,-1,this._getRGBABufferInternalSizedFormat(b.type,b.format,b._useSRGBBuffer),-1),!G)throw new Error("Unable to create render buffer");b._autoMSAAManagement=!0;let L=b._hardwareTexture;L||(L=b._hardwareTexture=this._createHardwareTexture()),L.addMSAARenderBuffer(G)}return b}_getUseSRGBBuffer(e,t){return e&&this._caps.supportSRGBBuffers&&(this.webGLVersion>1||t)}createTexture(e,t,i,s,n=3,r=null,o=null,h=null,l=null,c=null,u=null,f,d,_,p){return this._createTextureBase(e,t,i,s,n,r,o,(...g)=>this._prepareWebGLTexture(...g,c),(g,m,b,I,T,x)=>{const y=this._gl,R=b.width===g&&b.height===m;T._creationFlags=_!=null?_:0;const E=this._getTexImageParametersForCreateTexture(T.format,T._useSRGBBuffer);if(R)return y.texImage2D(y.TEXTURE_2D,0,E.internalFormat,E.format,E.type,b),!1;const C=this._caps.maxTextureSize;if(b.width>C||b.height>C||!this._supportsHardwareTextureRescaling)return this._prepareWorkingCanvas(),!this._workingCanvas||!this._workingContext||(this._workingCanvas.width=g,this._workingCanvas.height=m,this._workingContext.drawImage(b,0,0,b.width,b.height,0,0,g,m),y.texImage2D(y.TEXTURE_2D,0,E.internalFormat,E.format,E.type,this._workingCanvas),T.width=g,T.height=m),!1;{const S=new ft(this,2);this._bindTextureDirectly(y.TEXTURE_2D,S,!0),y.texImage2D(y.TEXTURE_2D,0,E.internalFormat,E.format,E.type,b),this._rescaleTexture(S,T,s,E.format,()=>{this._releaseTexture(S),this._bindTextureDirectly(y.TEXTURE_2D,T,!0),x()})}return!0},h,l,c,u,f,d,p)}_getTexImageParametersForCreateTexture(e,t){let i,s;return this.webGLVersion===1?(i=this._getInternalFormat(e,t),s=i):(i=this._getInternalFormat(e,!1),s=this._getRGBABufferInternalSizedFormat(0,e,t)),{internalFormat:s,format:i,type:this._gl.UNSIGNED_BYTE}}_rescaleTexture(e,t,i,s,n){}_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),n=this._getSamplingParameters(e,t.useMipMaps||i);this._setTextureParameterInteger(s,this._gl.TEXTURE_MAG_FILTER,n.mag,t),this._setTextureParameterInteger(s,this._gl.TEXTURE_MIN_FILTER,n.min),i&&(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 n=this._getTextureTarget(e);t!==null&&(this._setTextureParameterInteger(n,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t),e),e._cachedWrapU=t),i!==null&&(this._setTextureParameterInteger(n,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(i),e),e._cachedWrapV=i),(e.is2DArray||e.is3D)&&s!==null&&(this._setTextureParameterInteger(n,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(s),e),e._cachedWrapR=s),this._bindTextureDirectly(n,null)}_uploadCompressedDataToTextureDirectly(e,t,i,s,n,r=0,o=0){const h=this._gl;let l=h.TEXTURE_2D;if(e.isCube&&(l=h.TEXTURE_CUBE_MAP_POSITIVE_X+r),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,n)}_uploadDataToTextureDirectly(e,t,i=0,s=0,n,r=!1){const o=this._gl,h=this._getWebGLTextureType(e.type),l=this._getInternalFormat(e.format),c=n===void 0?this._getRGBABufferInternalSizedFormat(e.type,e.format,e._useSRGBBuffer):this._getInternalFormat(n,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),_=r?e.width:Math.pow(2,Math.max(f-s,0)),p=r?e.height:Math.pow(2,Math.max(d-s,0));o.texImage2D(u,s,c,_,p,0,l,h,t)}updateTextureData(e,t,i,s,n,r,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,_=c.TEXTURE_2D;e.isCube&&(_=c.TEXTURE_CUBE_MAP_POSITIVE_X+o,d=c.TEXTURE_CUBE_MAP),this._bindTextureDirectly(d,e,!0),c.texSubImage2D(_,h,i,s,n,r,f,u,t),l&&this._gl.generateMipmap(_),this._bindTextureDirectly(d,null)}_uploadArrayBufferViewToTexture(e,t,i=0,s=0){const n=this._gl,r=e.isCube?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D;this._bindTextureDirectly(r,e,!0),this._uploadDataToTextureDirectly(e,t,i,s),this._bindTextureDirectly(r,null,!0)}_prepareWebGLTextureContinuation(e,t,i,s,n){const r=this._gl;if(!r)return;const o=this._getSamplingParameters(n,!i);r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,o.mag),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,o.min),!i&&!s&&r.generateMipmap(r.TEXTURE_2D),this._bindTextureDirectly(r.TEXTURE_2D,null),t&&t.removePendingData(e),e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear()}_prepareWebGLTexture(e,t,i,s,n,r,o,h,l,c){const u=this.getCaps().maxTextureSize,f=Math.min(u,this.needPOTTextures?fi(s.width,u):s.width),d=Math.min(u,this.needPOTTextures?fi(s.height,u):s.height),_=this._gl;if(_){if(!e._hardwareTexture){i&&i.removePendingData(e);return}this._bindTextureDirectly(_.TEXTURE_2D,e,!0),this._unpackFlipY(n===void 0?!0:!!n),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!=null?c:t===".jpg"&&!e._useSRGBBuffer?4:5,!h(f,d,s,t,e,()=>{this._prepareWebGLTextureContinuation(e,i,r,o,l)})&&this._prepareWebGLTextureContinuation(e,i,r,o,l)}}_getInternalFormatFromDepthTextureFormat(e,t,i){const s=this._gl;if(!t)return s.STENCIL_INDEX8;let r=i?s.DEPTH_STENCIL:s.DEPTH_COMPONENT;return this.webGLVersion>1?e===15?r=s.DEPTH_COMPONENT16:e===16?r=s.DEPTH_COMPONENT24:e===17||e===13?r=i?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24:e===14?r=s.DEPTH_COMPONENT32F:e===18&&(r=i?s.DEPTH32F_STENCIL8:s.DEPTH_COMPONENT32F):r=s.DEPTH_COMPONENT16,r}_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,n=1,r,o=!1){const h=this._gl;r=r!=null?r:e?13:14;const l=this._getInternalFormatFromDepthTextureFormat(r,t,e);return e&&t?this._createRenderBuffer(i,s,n,h.DEPTH_STENCIL,l,o?-1:h.DEPTH_STENCIL_ATTACHMENT):t?this._createRenderBuffer(i,s,n,l,l,o?-1:h.DEPTH_ATTACHMENT):e?this._createRenderBuffer(i,s,n,l,l,o?-1:h.STENCIL_ATTACHMENT):null}_createRenderBuffer(e,t,i,s,n,r,o=!0){const l=this._gl.createRenderbuffer();return this._updateRenderBuffer(l,e,t,i,s,n,r,o)}_updateRenderBuffer(e,t,i,s,n,r,o,h=!0){const l=this._gl;return l.bindRenderbuffer(l.RENDERBUFFER,e),s>1&&l.renderbufferStorageMultisample?l.renderbufferStorageMultisample(l.RENDERBUFFER,s,r,t,i):l.renderbufferStorage(l.RENDERBUFFER,n,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==null||e.release()}_setProgram(e){this._currentProgram!==e&&(ld(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 n=e.getUniform(i[s]);n&&(this._boundUniforms[s]=n)}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){var h,l;let n=!1;const r=t&&t._associatedChannel>-1;if(i&&r&&(this._activeChannel=t._associatedChannel),this._boundTexturesCache[this._activeChannel]!==t||s){if(this._activateCurrentTexture(),t&&t.isMultiview)throw U.Error(["_bindTextureDirectly called with a multiview texture!",e,t]),"_bindTextureDirectly called with a multiview texture!";this._gl.bindTexture(e,(l=(h=t==null?void 0:t._hardwareTexture)==null?void 0:h.underlyingResource)!=null?l:null),this._boundTexturesCache[this._activeChannel]=t,t&&(t._associatedChannel=this._activeChannel)}else i&&(n=!0,this._activateCurrentTexture());return r&&!i&&this._bindSamplerUniformToChannel(t._associatedChannel,this._activeChannel),n}_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,n=""){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 r;s?r=t.depthStencilTexture:t.isReady()?r=t.getInternalTexture():t.isCube?r=this.emptyCubeTexture:t.is3D?r=this.emptyTexture3D:t.is2DArray?r=this.emptyTexture2DArray:r=this.emptyTexture,!i&&r&&(r._associatedChannel=e);let o=!0;this._boundTexturesCache[e]===r&&(i||this._bindSamplerUniformToChannel(r._associatedChannel,e),o=!1),this._activeChannel=e;const h=this._getTextureTarget(r);if(o&&this._bindTextureDirectly(h,r,i),r&&!r.isMultiview){if(r.isCube&&r._cachedCoordinatesMode!==t.coordinatesMode){r._cachedCoordinatesMode=t.coordinatesMode;const l=t.coordinatesMode!==3&&t.coordinatesMode!==5?1:0;t.wrapU=l,t.wrapV=l}r._cachedWrapU!==t.wrapU&&(r._cachedWrapU=t.wrapU,this._setTextureParameterInteger(h,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t.wrapU),r)),r._cachedWrapV!==t.wrapV&&(r._cachedWrapV=t.wrapV,this._setTextureParameterInteger(h,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(t.wrapV),r)),r.is3D&&r._cachedWrapR!==t.wrapR&&(r._cachedWrapR=t.wrapR,this._setTextureParameterInteger(h,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(t.wrapR),r)),this._setAnisotropicLevel(h,r,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 n=0;n<i.length;n++){const r=i[n].getInternalTexture();r?(this._textureUnits[n]=e+n,r._associatedChannel=e+n):this._textureUnits[n]=-1}this._gl.uniform1iv(t,this._textureUnits);for(let n=0;n<i.length;n++)this._setTexture(this._textureUnits[n],i[n],!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(){const e=Object.keys(this._compiledEffects);for(const t of e)this._compiledEffects[t].dispose(!0);this._compiledEffects={}}dispose(){var e;St()&&this._renderingCanvas&&(this._doNotHandleContextLost||(this._renderingCanvas.removeEventListener("webglcontextlost",this._onContextLost),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&&((e=this._gl.getExtension("WEBGL_lose_context"))==null||e.loseContext()),rd(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 n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0);const r=t.checkFramebufferStatus(t.FRAMEBUFFER);if(i=i&&r===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(n),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,n=!0,r=!0){const o=n?4:3,h=n?this._gl.RGBA:this._gl.RGB,l=new Uint8Array(s*i*o);return r&&this.flushFramebuffer(),this._gl.readPixels(e,t,i,s,h,this._gl.UNSIGNED_BYTE,l),Promise.resolve(l)}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=ae._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=ae._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}}we._TempClearColorUint32=new Uint32Array(4);we._TempClearColorInt32=new Int32Array(4);we.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"]}];we._ConcatenateShader=Dl;we._IsSupported=null;we._HasMajorPerformanceCaveat=null;const kd=Object.freeze(Object.defineProperty({__proto__:null,ThinEngine:we},Symbol.toStringTag,{value:"Module"}));class Yl{constructor(e=30){this._enabled=!0,this._rollingFrameTime=new Vd(e)}sampleFrame(e=bi.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 Vd{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}}we.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};we.prototype.updateRawTexture=function(a,e,t,i,s=null,n=0,r=!1){if(!a)return;const o=this._getRGBABufferInternalSizedFormat(n,t,r),h=this._getInternalFormat(t),l=this._getWebGLTextureType(n);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=n,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};we.prototype.createRawTexture=function(a,e,t,i,s,n,r,o=null,h=0,l=0,c=!1){const u=new ft(this,3);u.baseWidth=e,u.baseHeight=t,u.width=e,u.height=t,u.format=i,u.generateMipMaps=s,u.samplingMode=r,u.invertY=n,u._compression=o,u.type=h,u._useSRGBBuffer=this._getUseSRGBBuffer(c,!s),this._doNotHandleContextLost||(u._bufferView=a),this.updateRawTexture(u,a,i,n,o,h,u._useSRGBBuffer),this._bindTextureDirectly(this._gl.TEXTURE_2D,u,!0);const f=this._getSamplingParameters(r,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};we.prototype.createRawCubeTexture=function(a,e,t,i,s,n,r,o=null){const h=this._gl,l=new ft(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,r=1,U.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,r=1,U.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,U.Warn("Render to float textures is not supported. Mipmap generation forced to false.")):c===h.HALF_FLOAT&&!this._caps.colorBufferFloat&&(s=!1,U.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=n,l._compression=o,!this.needPOTTextures||wn(l.width)&&wn(l.height)||(s=!1),a)this.updateRawCubeTexture(l,a,t,i,n,o);else{const g=this._getRGBABufferInternalSizedFormat(i),m=0;this._bindTextureDirectly(h.TEXTURE_CUBE_MAP,l,!0);for(let b=0;b<6;b++)o?h.compressedTexImage2D(h.TEXTURE_CUBE_MAP_POSITIVE_X+b,m,this.getCaps().s3tc[o],l.width,l.height,0,void 0):h.texImage2D(h.TEXTURE_CUBE_MAP_POSITIVE_X+b,m,g,l.width,l.height,0,u,c,null);this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)}this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,l,!0),a&&s&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);const p=this._getSamplingParameters(r,s);return h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MAG_FILTER,p.mag),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MIN_FILTER,p.min),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),this._bindTextureDirectly(h.TEXTURE_CUBE_MAP,null),l.generateMipMaps=s,l.samplingMode=r,l.isReady=!0,l};we.prototype.updateRawCubeTexture=function(a,e,t,i,s,n=null,r=0){a._bufferViewArray=e,a.format=t,a.type=i,a.invertY=s,a._compression=n;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 _=e[d];n?o.compressedTexImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+d,r,this.getCaps().s3tc[n],a.width,a.height,0,_):(u&&(_=ql(_,a.width,a.height,i)),o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+d,r,c,a.width,a.height,0,l,h,_))}(!this.needPOTTextures||wn(a.width)&&wn(a.height))&&a.generateMipMaps&&r===0&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),a.isReady=!0};we.prototype.createRawCubeTextureFromUrl=function(a,e,t,i,s,n,r,o,h=null,l=null,c=3,u=!1){const f=this._gl,d=this.createRawCubeTexture(null,t,i,s,!n,u,c,null);e==null||e.addPendingData(d),d.url=a,d.isReady=!1,this._internalTexturesCache.push(d);const _=(g,m)=>{e==null||e.removePendingData(d),l&&g&&l(g.status+" "+g.statusText,m)},p=g=>{const m=d.width,b=r(g);if(b){if(o){const I=this._getWebGLTextureType(s);let T=this._getInternalFormat(i);const x=this._getRGBABufferInternalSizedFormat(s);let y=!1;T===f.RGB&&(T=f.RGBA,y=!0),this._bindTextureDirectly(f.TEXTURE_CUBE_MAP,d,!0),this._unpackFlipY(!1);const R=o(b);for(let E=0;E<R.length;E++){const C=m>>E;for(let S=0;S<6;S++){let w=R[E][S];y&&(w=ql(w,C,C,s)),f.texImage2D(S,E,x,C,C,0,T,I,w)}}this._bindTextureDirectly(f.TEXTURE_CUBE_MAP,null)}else this.updateRawCubeTexture(d,b,i,s,u);d.isReady=!0,e==null||e.removePendingData(d),d.onLoadedObservable.notifyObservers(d),d.onLoadedObservable.clear(),h&&h()}};return this._loadFile(a,g=>{p(g)},void 0,e==null?void 0:e.offlineProvider,!0,_),d};function ql(a,e,t,i){let s,n=1;i===1?s=new Float32Array(e*t*4):i===2?(s=new Uint16Array(e*t*4),n=15360):i===7?s=new Uint32Array(e*t*4):s=new Uint8Array(e*t*4);for(let r=0;r<e;r++)for(let o=0;o<t;o++){const h=(o*e+r)*3,l=(o*e+r)*4;s[l+0]=a[h+0],s[l+1]=a[h+1],s[l+2]=a[h+2],s[l+3]=n}return s}function jl(a){return function(e,t,i,s,n,r,o,h,l=null,c=0){const u=a?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D_ARRAY,f=a?10:11,d=new ft(this,f);d.baseWidth=t,d.baseHeight=i,d.baseDepth=s,d.width=t,d.height=i,d.depth=s,d.format=n,d.type=c,d.generateMipMaps=r,d.samplingMode=h,a?d.is3D=!0:d.is2DArray=!0,this._doNotHandleContextLost||(d._bufferView=e),a?this.updateRawTexture3D(d,e,n,o,l,c):this.updateRawTexture2DArray(d,e,n,o,l,c),this._bindTextureDirectly(u,d,!0);const _=this._getSamplingParameters(h,r);return this._gl.texParameteri(u,this._gl.TEXTURE_MAG_FILTER,_.mag),this._gl.texParameteri(u,this._gl.TEXTURE_MIN_FILTER,_.min),r&&this._gl.generateMipmap(u),this._bindTextureDirectly(u,null),this._internalTexturesCache.push(d),d}}we.prototype.createRawTexture2DArray=jl(!1);we.prototype.createRawTexture3D=jl(!0);function $l(a){return function(e,t,i,s,n=null,r=0){const o=a?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D_ARRAY,h=this._getWebGLTextureType(r),l=this._getInternalFormat(i),c=this._getRGBABufferInternalSizedFormat(r,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=n),e.width%4!==0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),n&&t?this._gl.compressedTexImage3D(o,0,this.getCaps().s3tc[n],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}}we.prototype.updateRawTexture2DArray=$l(!1);we.prototype.updateRawTexture3D=$l(!0);we.prototype._readTexturePixelsSync=function(a,e,t,i=-1,s=0,n=null,r=!0,o=!1,h=0,l=0){var f,d;const c=this._gl;if(!c)throw new Error("Engine does not have gl rendering context.");if(!this._dummyFramebuffer){const _=c.createFramebuffer();if(!_)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=_}c.bindFramebuffer(c.FRAMEBUFFER,this._dummyFramebuffer),i>-1?c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_CUBE_MAP_POSITIVE_X+i,(f=a._hardwareTexture)==null?void 0:f.underlyingResource,s):c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,(d=a._hardwareTexture)==null?void 0:d.underlyingResource,s);let u=a.type!==void 0?this._getWebGLTextureType(a.type):c.UNSIGNED_BYTE;if(o)n||(n=Pa(a.type,4*e*t));else switch(u){case c.UNSIGNED_BYTE:n||(n=new Uint8Array(4*e*t)),u=c.UNSIGNED_BYTE;break;default:n||(n=new Float32Array(4*e*t)),u=c.FLOAT;break}return r&&this.flushFramebuffer(),c.readPixels(h,l,e,t,c.RGBA,u,n),c.bindFramebuffer(c.FRAMEBUFFER,this._currentFramebuffer),n};we.prototype._readTexturePixels=function(a,e,t,i=-1,s=0,n=null,r=!0,o=!1,h=0,l=0){return Promise.resolve(this._readTexturePixelsSync(a,e,t,i,s,n,r,o,h,l))};we.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()};we.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,0,new Float32Array(e).subarray(t,t+i)):(e instanceof ArrayBuffer?e=new Uint8Array(e,t,i):e=new Uint8Array(e.buffer,e.byteOffset+t,i),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)),this._resetVertexBufferBinding()};we.prototype._createDepthStencilCubeTexture=function(a,e){const t=new ft(this,12);if(t.isCube=!0,this.webGLVersion===1)return U.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 n=0;n<6;n++)i.generateStencil?s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,s.DEPTH24_STENCIL8,a,a,0,s.DEPTH_STENCIL,s.UNSIGNED_INT_24_8,null):s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+n,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};we.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)};we.prototype.createCubeTexture=function(a,e,t,i,s=null,n=null,r,o=null,h=!1,l=0,c=0,u=null,f,d=!1,_=null){const p=this._gl;return this.createCubeTextureBase(a,e,t,!!i,s,n,r,o,h,l,c,u,g=>this._bindTextureDirectly(p.TEXTURE_CUBE_MAP,g,!0),(g,m)=>{const b=this.needPOTTextures?fi(m[0].width,this._caps.maxCubemapTextureSize):m[0].width,I=b,T=[p.TEXTURE_CUBE_MAP_POSITIVE_X,p.TEXTURE_CUBE_MAP_POSITIVE_Y,p.TEXTURE_CUBE_MAP_POSITIVE_Z,p.TEXTURE_CUBE_MAP_NEGATIVE_X,p.TEXTURE_CUBE_MAP_NEGATIVE_Y,p.TEXTURE_CUBE_MAP_NEGATIVE_Z];this._bindTextureDirectly(p.TEXTURE_CUBE_MAP,g,!0),this._unpackFlipY(!1);const x=r?this._getInternalFormat(r,g._useSRGBBuffer):g._useSRGBBuffer?this._glSRGBExtensionValues.SRGB8_ALPHA8:p.RGBA;let y=r?this._getInternalFormat(r):p.RGBA;g._useSRGBBuffer&&this.webGLVersion===1&&(y=x);for(let R=0;R<T.length;R++)if(m[R].width!==b||m[R].height!==I){if(this._prepareWorkingCanvas(),!this._workingCanvas||!this._workingContext){U.Warn("Cannot create canvas to resize texture.");return}this._workingCanvas.width=b,this._workingCanvas.height=I,this._workingContext.drawImage(m[R],0,0,m[R].width,m[R].height,0,0,b,I),p.texImage2D(T[R],0,x,y,p.UNSIGNED_BYTE,this._workingCanvas)}else p.texImage2D(T[R],0,x,y,p.UNSIGNED_BYTE,m[R]);i||p.generateMipmap(p.TEXTURE_CUBE_MAP),this._setCubeMapTextureParams(g,!i),g.width=b,g.height=I,g.isReady=!0,r&&(g.format=r),g.onLoadedObservable.notifyObservers(g),g.onLoadedObservable.clear(),s&&s()},!!d,_)};we.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 Zl{get depthStencilTexture(){return this._depthStencilTexture}setDepthStencilTexture(e,t=!0){t&&this._depthStencilTexture&&this._depthStencilTexture.dispose(),this._depthStencilTexture=e,this._generateDepthBuffer=this._generateStencilBuffer=!1,e&&(this._generateDepthBuffer=!0,this._generateStencilBuffer=br(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(){var e;return(e=this._size.width)!=null?e:this._size}get height(){var e;return(e=this._size.height)!=null?e:this._size}get layers(){return this._size.layers||0}get depth(){return this._size.depth||0}get texture(){var e,t;return(t=(e=this._textures)==null?void 0:e[0])!=null?t:null}get textures(){return this._textures}get faceIndices(){return this._faceIndices}get layerIndices(){return this._layerIndices}getBaseArrayLayer(e){var n,r,o,h;if(!this._textures)return-1;const t=this._textures[e],i=(r=(n=this._layerIndices)==null?void 0:n[e])!=null?r:0,s=(h=(o=this._faceIndices)==null?void 0:o[e])!=null?h: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,n){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=n}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,n=14,r){var o;return(o=this._depthStencilTexture)==null||o.dispose(),this._depthStencilTextureWithStencil=i,this._depthStencilTextureLabel=r,this._depthStencilTexture=this._engine.createDepthStencilTexture(this._size,{bilinearFiltering:t,comparisonFunction:e,generateStencil:i,isCube:this._isCube,samples:s,depthTextureFormat:n,label:r},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(){var t,i,s,n,r,o,h,l;let e=null;if(this._isMulti){const c=this.textures;if(c&&c.length>0){let u=!1,f=c.length,d=-1;const _=c[c.length-1]._source;(_===14||_===12)&&(u=!0,d=c[c.length-1].format,f--);const p=[],g=[],m=[],b=[],I=[],T=[],x=[],y={};for(let C=0;C<f;++C){const S=c[C];p.push(S.samplingMode),g.push(S.type),m.push(S.format),y[S.uniqueId]!==void 0?(b.push(-1),x.push(0)):(y[S.uniqueId]=C,S.is2DArray?(b.push(35866),x.push(S.depth)):S.isCube?(b.push(34067),x.push(0)):S.is3D?(b.push(32879),x.push(S.depth)):(b.push(3553),x.push(0))),this._faceIndices&&I.push((t=this._faceIndices[C])!=null?t:0),this._layerIndices&&T.push((i=this._layerIndices[C])!=null?i:0)}const R={samplingModes:p,generateMipMaps:c[0].generateMipMaps,generateDepthBuffer:this._generateDepthBuffer,generateStencilBuffer:this._generateStencilBuffer,generateDepthTexture:u,depthTextureFormat:d,types:g,formats:m,textureCount:f,targetTypes:b,faceIndex:I,layerIndex:T,layerCounts:x,label:this.label},E={width:this.width,height:this.height,depth:this.depth};e=this._engine.createMultipleRenderTarget(E,R);for(let C=0;C<f;++C){if(b[C]!==-1)continue;const S=y[c[C].uniqueId];e.setTexture(e.textures[S],C)}}}else{const c={};if(c.generateDepthBuffer=this._generateDepthBuffer,c.generateMipMaps=(n=(s=this.texture)==null?void 0:s.generateMipMaps)!=null?n:!1,c.generateStencilBuffer=this._generateStencilBuffer,c.samplingMode=(r=this.texture)==null?void 0:r.samplingMode,c.type=(o=this.texture)==null?void 0:o.type,c.format=(h=this.texture)==null?void 0:h.format,c.noColorAttachment=!this._textures,c.label=this.label,this.isCube)e=this._engine.createRenderTargetCubeTexture(this.width,c);else{const u={width:this.width,height:this.height,layers:this.is2DArray||this.is3D?(l=this.texture)==null?void 0:l.depth:void 0};e=this._engine.createRenderTargetTexture(u,c)}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){var t;e||((t=this._depthStencilTexture)==null||t.dispose(),this._depthStencilTexture=null,this.releaseTextures()),this._engine._releaseRenderTargetWrapper(this)}}class Gd extends Zl{setDepthStencilTexture(e,t=!0){if(super.setDepthStencilTexture(e,t),!e)return;const i=this._engine,s=this._context,n=e._hardwareTexture;if(n&&e._autoMSAAManagement&&this._MSAAFramebuffer){const r=i._currentFramebuffer;i._bindUnboundFramebuffer(this._MSAAFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,br(e.format)?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,s.RENDERBUFFER,n.getMSAARenderBuffer()),i._bindUnboundFramebuffer(r)}}constructor(e,t,i,s,n){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=n}_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,n=14,r){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,n,r)}shareDepth(e){super.shareDepth(e);const t=this._context,i=this._depthStencilBuffer,s=e._MSAAFramebuffer||e._framebuffer,n=this._engine;e._depthStencilBuffer&&e._depthStencilBuffer!==i&&t.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=i;const r=e._generateStencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;n._bindUnboundFramebuffer(s),t.framebufferRenderbuffer(t.FRAMEBUFFER,r,t.RENDERBUFFER,i),n._bindUnboundFramebuffer(null)}_bindTextureRenderTarget(e,t=0,i,s=0){var c,u,f,d;const n=e._hardwareTexture;if(!n)return;const r=this._framebuffer,o=this._engine,h=o._currentFramebuffer;o._bindUnboundFramebuffer(r);let l;if(o.webGLVersion>1){const _=this._context;l=_["COLOR_ATTACHMENT"+t],e.is2DArray||e.is3D?(i=(u=i!=null?i:(c=this.layerIndices)==null?void 0:c[t])!=null?u:0,_.framebufferTextureLayer(_.FRAMEBUFFER,l,n.underlyingResource,s,i)):e.isCube?(i=(d=i!=null?i:(f=this.faceIndices)==null?void 0:f[t])!=null?d:0,_.framebufferTexture2D(_.FRAMEBUFFER,l,_.TEXTURE_CUBE_MAP_POSITIVE_X+i,n.underlyingResource,s)):_.framebufferTexture2D(_.FRAMEBUFFER,l,_.TEXTURE_2D,n.underlyingResource,s)}else{const _=this._context;l=_["COLOR_ATTACHMENT"+t+"_WEBGL"];const p=i!==void 0?_.TEXTURE_CUBE_MAP_POSITIVE_X+i:_.TEXTURE_2D;_.framebufferTexture2D(_.FRAMEBUFFER,l,p,n.underlyingResource,s)}if(e._autoMSAAManagement&&this._MSAAFramebuffer){const _=this._context;o._bindUnboundFramebuffer(this._MSAAFramebuffer),_.framebufferRenderbuffer(_.FRAMEBUFFER,l,_.RENDERBUFFER,n.getMSAARenderBuffer())}o._bindUnboundFramebuffer(h)}setTexture(e,t=0,i=!0){super.setTexture(e,t,i),this._bindTextureRenderTarget(e,t)}setLayerAndFaceIndices(e,t){var s,n;if(super.setLayerAndFaceIndices(e,t),!this.textures||!this.layerIndices||!this.faceIndices)return;const i=(n=(s=this._attachments)==null?void 0:s.length)!=null?n:this.textures.length;for(let r=0;r<i;r++){const o=this.textures[r];o&&(o.is2DArray||o.is3D?this._bindTextureRenderTarget(o,r,this.layerIndices[r]):o.isCube?this._bindTextureRenderTarget(o,r,this.faceIndices[r]):this._bindTextureRenderTarget(o,r))}}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)}}ae.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)};we.prototype._createHardwareRenderTargetWrapper=function(a,e,t){const i=new Gd(a,e,t,this,this._gl);return this._renderTargetWrapperCache.push(i),i};we.prototype.createRenderTargetTexture=function(a,e){var p,g;const t=this._createHardwareRenderTargetWrapper(!1,!1,a);let i=!0,s=!1,n=!1,r,o=1,h;e!==void 0&&typeof e=="object"&&(i=(p=e.generateDepthBuffer)!=null?p:!0,s=!!e.generateStencilBuffer,n=!!e.noColorAttachment,r=e.colorAttachment,o=(g=e.samples)!=null?g:1,h=e.label);const l=r||(n?null:this._createInternalTexture(a,e,!0,5)),c=a.width||a,u=a.height||a,f=this._currentFramebuffer,d=this._gl,_=d.createFramebuffer();if(this._bindUnboundFramebuffer(_),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!=null?h:"RenderTargetWrapper",t._framebuffer=_,t._generateDepthBuffer=i,t._generateStencilBuffer=s,t.setTextures(l),!r)this.updateRenderTargetTextureSampleCount(t,o);else if(t._samples=r.samples,r.samples>1){const m=r._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};we.prototype._createDepthStencilTexture=function(a,e,t){var d;const i=this._gl,s=a.layers||0,n=a.depth||0;let r=i.TEXTURE_2D;s!==0?r=i.TEXTURE_2D_ARRAY:n!==0&&(r=i.TEXTURE_3D);const o=new ft(this,12);if(o.label=e.label,!this._caps.depthTextureExtension)return U.Error("Depth texture is not supported by your browser or hardware."),o;const h={bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,...e};if(this._bindTextureDirectly(r,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 U.Error("Depth texture ".concat(h.depthTextureFormat," format is not supported.")),o;o.format=h.depthTextureFormat}else o.format=h.generateStencil?13:16;const l=o.format===17||o.format===13||o.format===18,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(r,0,f,o.width,o.height,s,0,u,c,null):o.is3D?i.texImage3D(r,0,f,o.width,o.height,n,0,u,c,null):i.texImage2D(r,0,f,o.width,o.height,0,u,c,null),this._bindTextureDirectly(r,null),this._internalTexturesCache.push(o),t._depthStencilBuffer&&(i.deleteRenderbuffer(t._depthStencilBuffer),t._depthStencilBuffer=null),this._bindUnboundFramebuffer((d=t._MSAAFramebuffer)!=null?d: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};we.prototype.updateRenderTargetTextureSampleCount=function(a,e){var n,r;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=(n=a.texture)==null?void 0:n._hardwareTexture;if(i==null||i.releaseMSAARenderBuffers(),a.texture&&e>1&&typeof t.renderbufferStorageMultisample=="function"){const o=t.createFramebuffer();if(!o)throw new Error("Unable to create multi sampled framebuffer");a._MSAAFramebuffer=o,this._bindUnboundFramebuffer(a._MSAAFramebuffer);const h=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(!h)throw new Error("Unable to create multi sampled framebuffer");i==null||i.addMSAARenderBuffer(h)}this._bindUnboundFramebuffer((r=a._MSAAFramebuffer)!=null?r: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};we.prototype._setupDepthStencilTexture=function(a,e,t,i,s=1){var f,d;const n=(f=e.width)!=null?f:e,r=(d=e.height)!=null?d:e,o=e.layers||0,h=e.depth||0;a.baseWidth=n,a.baseHeight=r,a.width=n,a.height=r,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)))};we.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))};we.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,n=new ft(this,5);this._bindTextureDirectly(s.TEXTURE_CUBE_MAP,n,!0);const r=this._getSamplingParameters(i.samplingMode,i.generateMipMaps);i.type===1&&!this._caps.textureFloat&&(i.type=0,U.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,r.mag),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,r.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,n.width=a,n.height=a,n.isReady=!0,n.isCube=!0,n.samples=1,n.generateMipMaps=i.generateMipMaps,n.samplingMode=i.samplingMode,n.type=i.type,n.format=i.format,this._internalTexturesCache.push(n),t.setTextures(n),t};const zd=1/2.2,Wd=2.2,yt=(1+Math.sqrt(5))/2,Le=.001;function zi(a,e){const t=[];for(let i=0;i<a;++i)t.push(e());return t}function Rs(a,e){return zi(a,e)}function Hd(a,e,t){const i=a[e];if(typeof i!="function")return null;const s=function(){const n=a.length,r=s.previous.apply(a,arguments);return t(e,n),r};return i.next=s,s.previous=i,a[e]=s,()=>{const n=s.previous;if(!n)return;const r=s.next;r?(n.next=r,r.previous=n):(n.next=void 0,a[e]=n),s.next=void 0,s.previous=void 0}}const Kd=["push","splice","pop","shift","unshift"];function Ql(a,e){const t=Kd.map(i=>Hd(a,i,e));return()=>{t.forEach(i=>{i==null||i()})}}const Jl={};function vt(a,e){Jl[a]=e}function ys(a){return Jl[a]}function lt(a,e,t=1401298e-51){return Math.abs(a-e)<=t}function gt(a,e){return a===e?a:Math.random()*(e-a)+a}function Rr(a,e,t){return a+(e-a)*t}function Xd(a,e,t,i,s){const n=s*s,r=s*n,o=2*r-3*n+1,h=-2*r+3*n,l=r-2*n+s,c=r-n;return a*o+t*h+e*l+i*c}function ht(a,e=0,t=1){return Math.min(t,Math.max(e,a))}function Yd(a){return a-=Math.PI*2*Math.floor((a+Math.PI)/(Math.PI*2)),a}function Ui(a){const e=a.toString(16);return a<=15?("0"+e).toUpperCase():e.toUpperCase()}function ec(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 Ba(a,e){const t=a%e;return t===0?e:Ba(e,t)}const $t=a=>parseInt(a.toString().replace(/\W/g,""));class oe{constructor(e=0,t=0){this.x=e,this.y=t}toString(){return"{X: ".concat(this.x," Y: ").concat(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 oe.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 oe(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 oe(this.x+e.x,this.y+e.y)}subtract(e){return new oe(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 oe(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 oe(this.x*e,this.y*t)}divide(e){return new oe(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 oe(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 oe(-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 oe(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=Le){return e&<(this.x,e.x,t)&<(this.y,e.y,t)}equalsToFloats(e,t){return this.x===e&&this.y===t}floor(){return new oe(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 oe(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),n=i*this.x-s*this.y,r=s*this.x+i*this.y;return t.x=n,t.y=r,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 oe;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 oe(this.x,this.y)}dot(e){return this.x*e.x+this.y*e.y}static Zero(){return new oe(0,0)}static One(){return new oe(1,1)}static Random(e=0,t=1){return new oe(gt(e,t),gt(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(gt(e,t),gt(e,t))}static get ZeroReadOnly(){return oe._ZeroReadOnly}static FromArray(e,t=0){return new oe(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,n){const r=n*n,o=n*r,h=.5*(2*t.x+(-e.x+i.x)*n+(2*e.x-5*t.x+4*i.x-s.x)*r+(-e.x+3*t.x-3*i.x+s.x)*o),l=.5*(2*t.y+(-e.y+i.y)*n+(2*e.y-5*t.y+4*i.y-s.y)*r+(-e.y+3*t.y-3*i.y+s.y)*o);return new oe(h,l)}static ClampToRef(e,t,i,s){return s.x=ht(e.x,t.x,i.x),s.y=ht(e.y,t.y,i.y),s}static Clamp(e,t,i){const s=ht(e.x,t.x,i.x),n=ht(e.y,t.y,i.y);return new oe(s,n)}static Hermite(e,t,i,s,n){const r=n*n,o=n*r,h=2*o-3*r+1,l=-2*o+3*r,c=o-2*r+n,u=o-r,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 oe(f,d)}static Hermite1stDerivative(e,t,i,s,n){return this.Hermite1stDerivativeToRef(e,t,i,s,n,new oe)}static Hermite1stDerivativeToRef(e,t,i,s,n,r){const o=n*n;return r.x=(o-n)*6*e.x+(3*o-4*n+1)*t.x+(-o+n)*6*i.x+(3*o-2*n)*s.x,r.y=(o-n)*6*e.y+(3*o-4*n+1)*t.y+(-o+n)*6*i.y+(3*o-2*n)*s.y,r}static Lerp(e,t,i){return oe.LerpToRef(e,t,i,new oe)}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 oe.NormalizeToRef(e,new oe)}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 oe(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 oe(i,s)}static Transform(e,t){return oe.TransformToRef(e,t,new oe)}static TransformToRef(e,t,i){const s=t.m,n=e.x*s[0]+e.y*s[4]+s[12],r=e.x*s[1]+e.y*s[5]+s[13];return i.x=n,i.y=r,i}static PointInTriangle(e,t,i,s){const n=.5*(-i.y*s.x+t.y*(-i.x+s.x)+t.x*(i.y-s.y)+i.x*s.y),r=n<0?-1:1,o=(t.y*s.x-t.x*s.y+(s.y-t.y)*e.x+(t.x-s.x)*e.y)*r,h=(t.x*i.y-t.y*i.x+(t.y-i.y)*e.x+(i.x-t.x)*e.y)*r;return o>0&&h>0&&o+h<2*n*r}static Distance(e,t){return Math.sqrt(oe.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 oe.CenterToRef(e,t,new oe)}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=oe.DistanceSquared(t,i);if(s===0)return oe.Distance(e,t);const n=i.subtract(t),r=Math.max(0,Math.min(1,oe.Dot(e.subtract(t),n)/s)),o=t.add(n.multiplyByFloats(r,r));return oe.Distance(e,o)}}oe._V8PerformanceHack=new oe(.5,.5);oe._ZeroReadOnly=oe.Zero();Object.defineProperties(oe.prototype,{dimension:{value:[2]},rank:{value:1}});class v{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: ".concat(this._x," Y: ").concat(this._y," Z: ").concat(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 v.FromArrayToRef(e,t,this),this}toQuaternion(){return re.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 v(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 v(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 v(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 v(-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 v(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 n=t*Math.sin(i)*Math.cos(s),r=t*Math.cos(i),o=t*Math.sin(i)*Math.sin(s);return e.set(n,r,o),e}applyRotationQuaternionToRef(e,t){const i=this._x,s=this._y,n=this._z,r=e._x,o=e._y,h=e._z,l=e._w,c=2*(o*n-h*s),u=2*(h*i-r*n),f=2*(r*s-o*i);return t._x=i+l*c+o*f-h*u,t._y=s+l*u+h*c-r*f,t._z=n+l*f+r*u-o*c,t._isDirty=!0,t}applyRotationQuaternionInPlace(e){return this.applyRotationQuaternionToRef(e,this)}applyRotationQuaternion(e){return this.applyRotationQuaternionToRef(e,new v)}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 v)}projectOnPlaneToRef(e,t,i){const s=e.normal,n=e.d,r=_e.Vector3[0];this.subtractToRef(t,r),r.normalize();const o=v.Dot(r,s);if(Math.abs(o)<1e-10)i.setAll(1/0);else{const h=-(v.Dot(t,s)+n)/o,l=r.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=Le){return e&<(this._x,e._x,t)&<(this._y,e._y,t)&<(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 v(this._x*e,this._y*t,this._z*i)}divide(e){return new v(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(!lt(t,i,e))return!0;const s=Math.abs(this._z);return!lt(t,s,e)||!lt(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 v(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 v(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=_e.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(_e.Matrix[0]),v.TransformCoordinatesToRef(this,_e.Matrix[0],t),t}rotateByQuaternionAroundPointToRef(e,t,i){return this.subtractToRef(t,_e.Vector3[0]),_e.Vector3[0].rotateByQuaternionToRef(e,_e.Vector3[0]),t.addToRef(_e.Vector3[0],i),i}cross(e){return v.CrossToRef(this,e,new v)}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){return this.normalizeToRef(new v)}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 v(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 n=v.Dot(e,i),r=v.Dot(t,i);return(n-s)/(n-r)}static GetAngleBetweenVectors(e,t,i){const s=e.normalizeToRef(_e.Vector3[1]),n=t.normalizeToRef(_e.Vector3[2]);let r=v.Dot(s,n);r=ht(r,-1,1);const o=Math.acos(r),h=_e.Vector3[3];return v.CrossToRef(s,n,h),v.Dot(h,i)>0?isNaN(o)?0:o:isNaN(o)?-Math.PI:-Math.acos(r)}static GetAngleBetweenVectorsOnPlane(e,t,i){_e.Vector3[0].copyFrom(e);const s=_e.Vector3[0];_e.Vector3[1].copyFrom(t);const n=_e.Vector3[1];_e.Vector3[2].copyFrom(i);const r=_e.Vector3[2],o=_e.Vector3[3],h=_e.Vector3[4];s.normalize(),n.normalize(),r.normalize(),v.CrossToRef(r,s,o),v.CrossToRef(o,r,h);const l=Math.atan2(v.Dot(n,o),v.Dot(n,h));return Yd(l)}static PitchYawRollToMoveBetweenPointsToRef(e,t,i){const s=N.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=v.Zero();return v.PitchYawRollToMoveBetweenPointsToRef(e,t,i)}static SlerpToRef(e,t,i,s){i=ht(i,0,1);const n=_e.Vector3[0],r=_e.Vector3[1];n.copyFrom(e);const o=n.length();n.normalizeFromLength(o),r.copyFrom(t);const h=r.length();r.normalizeFromLength(h);const l=v.Dot(n,r);let c,u;if(l<1-Le){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 n.scaleInPlace(c),r.scaleInPlace(u),s.copyFrom(n).addInPlace(r),s.scaleInPlace(Rr(o,h,i)),s}static SmoothToRef(e,t,i,s,n){return v.SlerpToRef(e,t,s===0?1:i/s,n),n}static FromArray(e,t=0){return new v(e[t],e[t+1],e[t+2])}static FromFloatArray(e,t){return v.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 v.FromArrayToRef(e,t,i)}static FromFloatsToRef(e,t,i,s){return s.copyFromFloats(e,t,i),s}static Zero(){return new v(0,0,0)}static One(){return new v(1,1,1)}static Up(){return new v(0,1,0)}static get UpReadOnly(){return v._UpReadOnly}static get DownReadOnly(){return v._DownReadOnly}static get RightReadOnly(){return v._RightReadOnly}static get LeftReadOnly(){return v._LeftReadOnly}static get LeftHandedForwardReadOnly(){return v._LeftHandedForwardReadOnly}static get RightHandedForwardReadOnly(){return v._RightHandedForwardReadOnly}static get LeftHandedBackwardReadOnly(){return v._LeftHandedBackwardReadOnly}static get RightHandedBackwardReadOnly(){return v._RightHandedBackwardReadOnly}static get ZeroReadOnly(){return v._ZeroReadOnly}static get OneReadOnly(){return v._OneReadOnly}static Down(){return new v(0,-1,0)}static Forward(e=!1){return new v(0,0,e?-1:1)}static Backward(e=!1){return new v(0,0,e?1:-1)}static Right(){return new v(1,0,0)}static Left(){return new v(-1,0,0)}static Random(e=0,t=1){return new v(gt(e,t),gt(e,t),gt(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(gt(e,t),gt(e,t),gt(e,t))}static TransformCoordinates(e,t){const i=v.Zero();return v.TransformCoordinatesToRef(e,t,i),i}static TransformCoordinatesToRef(e,t,i){return v.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformCoordinatesFromFloatsToRef(e,t,i,s,n){const r=s.m,o=e*r[0]+t*r[4]+i*r[8]+r[12],h=e*r[1]+t*r[5]+i*r[9]+r[13],l=e*r[2]+t*r[6]+i*r[10]+r[14],c=1/(e*r[3]+t*r[7]+i*r[11]+r[15]);return n._x=o*c,n._y=h*c,n._z=l*c,n._isDirty=!0,n}static TransformNormal(e,t){const i=v.Zero();return v.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,n){const r=s.m;return n._x=e*r[0]+t*r[4]+i*r[8],n._y=e*r[1]+t*r[5]+i*r[9],n._z=e*r[2]+t*r[6]+i*r[10],n._isDirty=!0,n}static CatmullRom(e,t,i,s,n){const r=n*n,o=n*r,h=.5*(2*t._x+(-e._x+i._x)*n+(2*e._x-5*t._x+4*i._x-s._x)*r+(-e._x+3*t._x-3*i._x+s._x)*o),l=.5*(2*t._y+(-e._y+i._y)*n+(2*e._y-5*t._y+4*i._y-s._y)*r+(-e._y+3*t._y-3*i._y+s._y)*o),c=.5*(2*t._z+(-e._z+i._z)*n+(2*e._z-5*t._z+4*i._z-s._z)*r+(-e._z+3*t._z-3*i._z+s._z)*o);return new v(h,l,c)}static Clamp(e,t,i){const s=new v;return v.ClampToRef(e,t,i,s),s}static ClampToRef(e,t,i,s){let n=e._x;n=n>i._x?i._x:n,n=n<t._x?t._x:n;let r=e._y;r=r>i._y?i._y:r,r=r<t._y?t._y:r;let o=e._z;return o=o>i._z?i._z:o,o=o<t._z?t._z:o,s.copyFromFloats(n,r,o),s}static CheckExtends(e,t,i){t.minimizeInPlace(e),i.maximizeInPlace(e)}static Hermite(e,t,i,s,n){const r=n*n,o=n*r,h=2*o-3*r+1,l=-2*o+3*r,c=o-2*r+n,u=o-r,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,_=e._z*h+i._z*l+t._z*c+s._z*u;return new v(f,d,_)}static Hermite1stDerivative(e,t,i,s,n){const r=new v;return this.Hermite1stDerivativeToRef(e,t,i,s,n,r),r}static Hermite1stDerivativeToRef(e,t,i,s,n,r){const o=n*n;return r._x=(o-n)*6*e._x+(3*o-4*n+1)*t._x+(-o+n)*6*i._x+(3*o-2*n)*s._x,r._y=(o-n)*6*e._y+(3*o-4*n+1)*t._y+(-o+n)*6*i._y+(3*o-2*n)*s._y,r._z=(o-n)*6*e._z+(3*o-4*n+1)*t._z+(-o+n)*6*i._z+(3*o-2*n)*s._z,r._isDirty=!0,r}static Lerp(e,t,i){const s=new v(0,0,0);return v.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 v;return v.CrossToRef(e,t,i),i}static CrossToRef(e,t,i){const s=e._y*t._z-e._z*t._y,n=e._z*t._x-e._x*t._z,r=e._x*t._y-e._y*t._x;return i.copyFromFloats(s,n,r),i}static Normalize(e){const t=v.Zero();return v.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Project(e,t,i,s){const n=new v;return v.ProjectToRef(e,t,i,s,n),n}static ProjectToRef(e,t,i,s,n){var p;const r=s.width,o=s.height,h=s.x,l=s.y,c=_e.Matrix[1],u=(p=Ee.LastCreatedEngine)==null?void 0:p.isNDCHalfZRange,f=u?1:.5,d=u?0:.5;O.FromValuesToRef(r/2,0,0,0,0,-o/2,0,0,0,0,f,0,h+r/2,o/2+l,d,1,c);const _=_e.Matrix[0];return t.multiplyToRef(i,_),_.multiplyToRef(c,_),v.TransformCoordinatesToRef(e,_,n),n}static Reflect(e,t){return this.ReflectToRef(e,t,new v)}static ReflectToRef(e,t,i){const s=N.Vector3[0];return s.copyFrom(t).scaleInPlace(2*v.Dot(e,t)),i.copyFrom(e).subtractInPlace(s)}static _UnprojectFromInvertedMatrixToRef(e,t,i){v.TransformCoordinatesToRef(e,t,i);const s=t.m,n=e._x*s[3]+e._y*s[7]+e._z*s[11]+s[15];return lt(n,1)&&i.scaleInPlace(1/n),i}static UnprojectFromTransform(e,t,i,s,n){return this.Unproject(e,t,i,s,n,O.IdentityReadOnly)}static Unproject(e,t,i,s,n,r){const o=new v;return v.UnprojectToRef(e,t,i,s,n,r,o),o}static UnprojectToRef(e,t,i,s,n,r,o){return v.UnprojectFloatsToRef(e._x,e._y,e._z,t,i,s,n,r,o),o}static UnprojectFloatsToRef(e,t,i,s,n,r,o,h,l){var f;const c=_e.Matrix[0];r.multiplyToRef(o,c),c.multiplyToRef(h,c),c.invert();const u=_e.Vector3[0];return u.x=e/s*2-1,u.y=-(t/n*2-1),(f=Ee.LastCreatedEngine)!=null&&f.isNDCHalfZRange?u.z=i:u.z=2*i-1,v._UnprojectFromInvertedMatrixToRef(u,c,l),l}static Minimize(e,t){const i=new v;return i.copyFrom(e),i.minimizeInPlace(t),i}static Maximize(e,t){const i=new v;return i.copyFrom(e),i.maximizeInPlace(t),i}static Distance(e,t){return Math.sqrt(v.DistanceSquared(e,t))}static DistanceSquared(e,t){const i=e._x-t._x,s=e._y-t._y,n=e._z-t._z;return i*i+s*s+n*n}static ProjectOnTriangleToRef(e,t,i,s,n){const r=_e.Vector3[0],o=_e.Vector3[1],h=_e.Vector3[2],l=_e.Vector3[3],c=_e.Vector3[4];i.subtractToRef(t,r),s.subtractToRef(t,o),s.subtractToRef(i,h);const u=r.length(),f=o.length(),d=h.length();if(u<Le||f<Le||d<Le)return n.copyFrom(t),v.Distance(e,t);e.subtractToRef(t,c),v.CrossToRef(r,o,l);const _=l.length();if(_<Le)return n.copyFrom(t),v.Distance(e,t);l.normalizeFromLength(_);let p=c.length();if(p<Le)return n.copyFrom(t),0;c.normalizeFromLength(p);const g=v.Dot(l,c),m=_e.Vector3[5],b=_e.Vector3[6];m.copyFrom(l).scaleInPlace(-p*g),b.copyFrom(e).addInPlace(m);const I=_e.Vector3[4],T=_e.Vector3[5],x=_e.Vector3[7],y=_e.Vector3[8];I.copyFrom(r).scaleInPlace(1/u),y.copyFrom(o).scaleInPlace(1/f),I.addInPlace(y).scaleInPlace(-1),T.copyFrom(r).scaleInPlace(-1/u),y.copyFrom(h).scaleInPlace(1/d),T.addInPlace(y).scaleInPlace(-1),x.copyFrom(h).scaleInPlace(-1/d),y.copyFrom(o).scaleInPlace(-1/f),x.addInPlace(y).scaleInPlace(-1);const R=_e.Vector3[9];let E;R.copyFrom(b).subtractInPlace(t),v.CrossToRef(I,R,y),E=v.Dot(y,l);const C=E;R.copyFrom(b).subtractInPlace(i),v.CrossToRef(T,R,y),E=v.Dot(y,l);const S=E;R.copyFrom(b).subtractInPlace(s),v.CrossToRef(x,R,y),E=v.Dot(y,l);const w=E,P=_e.Vector3[10];let G,L;C>0&&S<0?(P.copyFrom(r),G=t,L=i):S>0&&w<0?(P.copyFrom(h),G=i,L=s):(P.copyFrom(o).scaleInPlace(-1),G=s,L=t);const W=_e.Vector3[9],K=_e.Vector3[4];if(G.subtractToRef(b,y),L.subtractToRef(b,W),v.CrossToRef(y,W,K),!(v.Dot(K,l)<0))return n.copyFrom(b),Math.abs(p*g);const $=_e.Vector3[5];v.CrossToRef(P,K,$),$.normalize();const z=_e.Vector3[9];z.copyFrom(G).subtractInPlace(b);const k=z.length();if(k<Le)return n.copyFrom(G),v.Distance(e,G);z.normalizeFromLength(k);const M=v.Dot($,z),V=_e.Vector3[7];V.copyFrom(b).addInPlace($.scaleInPlace(k*M)),y.copyFrom(V).subtractInPlace(G),p=P.length(),P.normalizeFromLength(p);let q=v.Dot(y,P)/Math.max(p,Le);return q=ht(q,0,1),V.copyFrom(G).addInPlace(P.scaleInPlace(q*p)),n.copyFrom(V),v.Distance(e,V)}static Center(e,t){return v.CenterToRef(e,t,v.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 v;return v.RotationFromAxisToRef(e,t,i,s),s}static RotationFromAxisToRef(e,t,i,s){const n=_e.Quaternion[0];return re.RotationQuaternionFromAxisToRef(e,t,i,n),n.toEulerAnglesToRef(s),s}}v._V8PerformanceHack=new v(.5,.5,.5);v._UpReadOnly=v.Up();v._DownReadOnly=v.Down();v._LeftHandedForwardReadOnly=v.Forward(!1);v._RightHandedForwardReadOnly=v.Forward(!0);v._LeftHandedBackwardReadOnly=v.Backward(!1);v._RightHandedBackwardReadOnly=v.Backward(!0);v._RightReadOnly=v.Right();v._LeftReadOnly=v.Left();v._ZeroReadOnly=v.Zero();v._OneReadOnly=v.One();Object.defineProperties(v.prototype,{dimension:{value:[3]},rank:{value:1}});class Pe{constructor(e=0,t=0,i=0,s=0){this.x=e,this.y=t,this.z=i,this.w=s}toString(){return"{X: ".concat(this.x," Y: ").concat(this.y," Z: ").concat(this.z," W: ").concat(this.w,"}")}getClassName(){return"Vector4"}getHashCode(){const e=$t(this.x),t=$t(this.y),i=$t(this.z),s=$t(this.w);let n=e;return n=n*397^t,n=n*397^i,n=n*397^s,n}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 Pe.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 Pe(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 Pe(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 Pe(this.x-e,this.y-t,this.z-i,this.w-s)}subtractFromFloatsToRef(e,t,i,s,n){return n.x=this.x-e,n.y=this.y-t,n.z=this.z-i,n.w=this.w-s,n}negate(){return new Pe(-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 Pe(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=Le){return e&<(this.x,e.x,t)&<(this.y,e.y,t)&<(this.z,e.z,t)&<(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 Pe(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 Pe(this.x*e,this.y*t,this.z*i,this.w*s)}divide(e){return new Pe(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 Pe(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 Pe(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 Pe)}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 v(this.x,this.y,this.z)}clone(){return new Pe(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 Pe(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 Pe.FromArrayToRef(e,t,i),i}static FromFloatsToRef(e,t,i,s,n){return n.x=e,n.y=t,n.z=i,n.w=s,n}static Zero(){return new Pe(0,0,0,0)}static One(){return new Pe(1,1,1,1)}static Random(e=0,t=1){return new Pe(gt(e,t),gt(e,t),gt(e,t),gt(e,t))}static RandomToRef(e=0,t=1,i){return i.x=gt(e,t),i.y=gt(e,t),i.z=gt(e,t),i.w=gt(e,t),i}static Clamp(e,t,i){return Pe.ClampToRef(e,t,i,new Pe)}static ClampToRef(e,t,i,s){return s.x=ht(e.x,t.x,i.x),s.y=ht(e.y,t.y,i.y),s.z=ht(e.z,t.z,i.z),s.w=ht(e.w,t.w,i.w),s}static CheckExtends(e,t,i){t.minimizeInPlace(e),i.maximizeInPlace(e)}static get ZeroReadOnly(){return Pe._ZeroReadOnly}static Normalize(e){return Pe.NormalizeToRef(e,new Pe)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){const i=new Pe;return i.copyFrom(e),i.minimizeInPlace(t),i}static Maximize(e,t){const i=new Pe;return i.copyFrom(e),i.maximizeInPlace(t),i}static Distance(e,t){return Math.sqrt(Pe.DistanceSquared(e,t))}static DistanceSquared(e,t){const i=e.x-t.x,s=e.y-t.y,n=e.z-t.z,r=e.w-t.w;return i*i+s*s+n*n+r*r}static Center(e,t){return Pe.CenterToRef(e,t,new Pe)}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 Pe.TransformCoordinatesToRef(e,t,new Pe)}static TransformCoordinatesToRef(e,t,i){return Pe.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformCoordinatesFromFloatsToRef(e,t,i,s,n){const r=s.m,o=e*r[0]+t*r[4]+i*r[8]+r[12],h=e*r[1]+t*r[5]+i*r[9]+r[13],l=e*r[2]+t*r[6]+i*r[10]+r[14],c=e*r[3]+t*r[7]+i*r[11]+r[15];return n.x=o,n.y=h,n.z=l,n.w=c,n}static TransformNormal(e,t){return Pe.TransformNormalToRef(e,t,new Pe)}static TransformNormalToRef(e,t,i){const s=t.m,n=e.x*s[0]+e.y*s[4]+e.z*s[8],r=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=n,i.y=r,i.z=o,i.w=e.w,i}static TransformNormalFromFloatsToRef(e,t,i,s,n,r){const o=n.m;return r.x=e*o[0]+t*o[4]+i*o[8],r.y=e*o[1]+t*o[5]+i*o[9],r.z=e*o[2]+t*o[6]+i*o[10],r.w=s,r}static FromVector3(e,t=0){return new Pe(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}}Pe._V8PerformanceHack=new Pe(.5,.5,.5,.5);Pe._ZeroReadOnly=Pe.Zero();Object.defineProperties(Pe.prototype,{dimension:{value:[4]},rank:{value:1}});class re{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: ".concat(this._x," Y: ").concat(this._y," Z: ").concat(this._z," W: ").concat(this._w,"}")}getClassName(){return"Quaternion"}getHashCode(){const e=$t(this._x),t=$t(this._y),i=$t(this._z),s=$t(this._w);let n=e;return n=n*397^t,n=n*397^i,n=n*397^s,n}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 re.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=Le){return e&<(this._x,e._x,t)&<(this._y,e._y,t)&<(this._z,e._z,t)&<(this._w,e._w,t)}clone(){return new re(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 re(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 re)}subtractFromFloatsToRef(e,t,i,s,n){return n._x=this._x-e,n._y=this._y-t,n._z=this._z-i,n._w=this._w-s,n._isDirty=!0,n}subtract(e){return new re(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 re(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 re(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,n=this._x*e._y-this._y*e._x+this._z*e._w+this._w*e._z,r=-this._x*e._x-this._y*e._y-this._z*e._z+this._w*e._w;return t.copyFromFloats(i,s,n,r),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 re)}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 re(-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 re(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=v.Zero();return this.toEulerAnglesToRef(e),e}toEulerAnglesToRef(e){const t=this._z,i=this._x,s=this._y,n=this._w,r=s*t-i*n,o=.4999999;if(r<-.4999999)e._y=2*Math.atan2(s,n),e._x=Math.PI/2,e._z=0,e._isDirty=!0;else if(r>o)e._y=2*Math.atan2(s,n),e._x=-Math.PI/2,e._z=0,e._isDirty=!0;else{const h=n*n,l=t*t,c=i*i,u=s*s;e._z=Math.atan2(2*(i*s+t*n),-l-c+u+h),e._x=Math.asin(-2*r),e._y=Math.atan2(2*(t*i+s*n),l-c-u+h),e._isDirty=!0}return e}toAlphaBetaGammaToRef(e){const t=this._z,i=this._x,s=this._y,n=this._w,r=Math.sqrt(i*i+s*s),o=Math.sqrt(t*t+n*n),h=2*Math.atan2(r,o),l=2*Math.atan2(t,n),c=2*Math.atan2(s,i),u=(l+c)/2,f=(l-c)/2;return e.set(f,h,u),e}toRotationMatrix(e){return O.FromQuaternionToRef(this,e),e}fromRotationMatrix(e){return re.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 re;return re.FromRotationMatrixToRef(e,t),t}static FromRotationMatrixToRef(e,t){const i=e.m,s=i[0],n=i[4],r=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 _;return d>0?(_=.5/Math.sqrt(d+1),t._w=.25/_,t._x=(u-l)*_,t._y=(r-c)*_,t._z=(o-n)*_,t._isDirty=!0):s>h&&s>f?(_=2*Math.sqrt(1+s-h-f),t._w=(u-l)/_,t._x=.25*_,t._y=(n+o)/_,t._z=(r+c)/_,t._isDirty=!0):h>f?(_=2*Math.sqrt(1+h-s-f),t._w=(r-c)/_,t._x=(n+o)/_,t._y=.25*_,t._z=(l+u)/_,t._isDirty=!0):(_=2*Math.sqrt(1+f-s-h),t._w=(o-n)/_,t._x=(r+c)/_,t._y=(l+u)/_,t._z=.25*_,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=re.Dot(e,t);return 1-s*s<=i}static SmoothToRef(e,t,i,s,n){let r=s===0?1:i/s;return r=ht(r,0,1),re.SlerpToRef(e,t,r,n),n}static Zero(){return new re(0,0,0,0)}static Inverse(e){return new re(-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 re(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 re.RotationAxisToRef(e,t,new re)}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 re(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,n){return n.copyFromFloats(e,t,i,s),n}static FromEulerAngles(e,t,i){const s=new re;return re.RotationYawPitchRollToRef(t,e,i,s),s}static FromEulerAnglesToRef(e,t,i,s){return re.RotationYawPitchRollToRef(t,e,i,s),s}static FromEulerVector(e){const t=new re;return re.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromEulerVectorToRef(e,t){return re.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromUnitVectorsToRef(e,t,i,s=Le){const n=v.Dot(e,t)+1;return n<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):(v.CrossToRef(e,t,N.Vector3[0]),i.set(N.Vector3[0].x,N.Vector3[0].y,N.Vector3[0].z,n)),i.normalize()}static RotationYawPitchRoll(e,t,i){const s=new re;return re.RotationYawPitchRollToRef(e,t,i,s),s}static RotationYawPitchRollToRef(e,t,i,s){const n=i*.5,r=t*.5,o=e*.5,h=Math.sin(n),l=Math.cos(n),c=Math.sin(r),u=Math.cos(r),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 re;return re.RotationAlphaBetaGammaToRef(e,t,i,s),s}static RotationAlphaBetaGammaToRef(e,t,i,s){const n=(i+e)*.5,r=(i-e)*.5,o=t*.5;return s._x=Math.cos(r)*Math.sin(o),s._y=Math.sin(r)*Math.sin(o),s._z=Math.sin(n)*Math.cos(o),s._w=Math.cos(n)*Math.cos(o),s._isDirty=!0,s}static RotationQuaternionFromAxis(e,t,i){const s=new re(0,0,0,0);return re.RotationQuaternionFromAxisToRef(e,t,i,s),s}static RotationQuaternionFromAxisToRef(e,t,i,s){const n=_e.Matrix[0];return e=e.normalizeToRef(_e.Vector3[0]),t=t.normalizeToRef(_e.Vector3[1]),i=i.normalizeToRef(_e.Vector3[2]),O.FromXYZAxesToRef(e,t,i,n),re.FromRotationMatrixToRef(n,s),s}static FromLookDirectionLH(e,t){const i=new re;return re.FromLookDirectionLHToRef(e,t,i),i}static FromLookDirectionLHToRef(e,t,i){const s=_e.Matrix[0];return O.LookDirectionLHToRef(e,t,s),re.FromRotationMatrixToRef(s,i),i}static FromLookDirectionRH(e,t){const i=new re;return re.FromLookDirectionRHToRef(e,t,i),i}static FromLookDirectionRHToRef(e,t,i){const s=_e.Matrix[0];return O.LookDirectionRHToRef(e,t,s),re.FromRotationMatrixToRef(s,i)}static Slerp(e,t,i){const s=re.Identity();return re.SlerpToRef(e,t,i,s),s}static SlerpToRef(e,t,i,s){let n,r,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)r=1-i,n=h?-i:i;else{const l=Math.acos(o),c=1/Math.sin(l);r=Math.sin((1-i)*l)*c,n=h?-Math.sin(i*l)*c:Math.sin(i*l)*c}return s._x=r*e._x+n*t._x,s._y=r*e._y+n*t._y,s._z=r*e._z+n*t._z,s._w=r*e._w+n*t._w,s._isDirty=!0,s}static Hermite(e,t,i,s,n){const r=n*n,o=n*r,h=2*o-3*r+1,l=-2*o+3*r,c=o-2*r+n,u=o-r,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,_=e._z*h+i._z*l+t._z*c+s._z*u,p=e._w*h+i._w*l+t._w*c+s._w*u;return new re(f,d,_,p)}static Hermite1stDerivative(e,t,i,s,n){const r=new re;return this.Hermite1stDerivativeToRef(e,t,i,s,n,r),r}static Hermite1stDerivativeToRef(e,t,i,s,n,r){const o=n*n;return r._x=(o-n)*6*e._x+(3*o-4*n+1)*t._x+(-o+n)*6*i._x+(3*o-2*n)*s._x,r._y=(o-n)*6*e._y+(3*o-4*n+1)*t._y+(-o+n)*6*i._y+(3*o-2*n)*s._y,r._z=(o-n)*6*e._z+(3*o-4*n+1)*t._z+(-o+n)*6*i._z+(3*o-2*n)*s._z,r._w=(o-n)*6*e._w+(3*o-4*n+1)*t._w+(-o+n)*6*i._w+(3*o-2*n)*s._w,r._isDirty=!0,r}static Normalize(e){const t=re.Zero();return re.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Clamp(e,t,i){const s=new re;return re.ClampToRef(e,t,i,s),s}static ClampToRef(e,t,i,s){return s.copyFromFloats(ht(e.x,t.x,i.x),ht(e.y,t.y,i.y),ht(e.z,t.z,i.z),ht(e.w,t.w,i.w))}static Random(e=0,t=1){return new re(gt(e,t),gt(e,t),gt(e,t),gt(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(gt(e,t),gt(e,t),gt(e,t),gt(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(re.DistanceSquared(e,t))}static DistanceSquared(e,t){const i=e.x-t.x,s=e.y-t.y,n=e.z-t.z,r=e.w-t.w;return i*i+s*s+n*n+r*r}static Center(e,t){return re.CenterToRef(e,t,re.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)}}re._V8PerformanceHack=new re(.5,.5,.5,.5);Object.defineProperties(re.prototype,{dimension:{value:[4]},rank:{value:1}});class O{static get Use64Bits(){return Dt.MatrixUse64Bits}get m(){return this._m}markAsUpdated(){this.updateFlag=O._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,Dt.MatrixTrackPrecisionChange&&Dt.MatrixTrackedMatrices.push(this),this._m=new Dt.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],n=e[3],r=e[4],o=e[5],h=e[6],l=e[7],c=e[8],u=e[9],f=e[10],d=e[11],_=e[12],p=e[13],g=e[14],m=e[15],b=f*m-g*d,I=u*m-p*d,T=u*g-p*f,x=c*m-_*d,y=c*g-f*_,R=c*p-_*u,E=+(o*b-h*I+l*T),C=-(r*b-h*x+l*y),S=+(r*I-o*x+l*R),w=-(r*T-o*y+h*R);return t*E+i*C+s*S+n*w}toString(){return"{".concat(this.m[0],", ").concat(this.m[1],", ").concat(this.m[2],", ").concat(this.m[3],"\n").concat(this.m[4],", ").concat(this.m[5],", ").concat(this.m[6],", ").concat(this.m[7],"\n").concat(this.m[8],", ").concat(this.m[9],", ").concat(this.m[10],", ").concat(this.m[11],"\n").concat(this.m[12],", ").concat(this.m[13],", ").concat(this.m[14],", ").concat(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 O.FromArrayToRef(e,t,this)}copyFromFloats(...e){return O.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 O.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 O;return this.addToRef(e,t),t}addToRef(e,t){const i=this._m,s=t._m,n=e.m;for(let r=0;r<16;r++)s[r]=i[r]+n[r];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,n=t._m;for(let r=0;r<16;r++)n[r]=i[r]-s[r];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 O)}subtractFromFloatsToRef(...e){const t=e.pop(),i=this._m,s=t._m,n=e;for(let r=0;r<16;r++)s[r]=i[r]-n[r];return t.markAsUpdated(),t}invertToRef(e){if(this._isIdentity===!0)return O.IdentityToRef(e),e;const t=this._m,i=t[0],s=t[1],n=t[2],r=t[3],o=t[4],h=t[5],l=t[6],c=t[7],u=t[8],f=t[9],d=t[10],_=t[11],p=t[12],g=t[13],m=t[14],b=t[15],I=d*b-m*_,T=f*b-g*_,x=f*m-g*d,y=u*b-p*_,R=u*m-d*p,E=u*g-p*f,C=+(h*I-l*T+c*x),S=-(o*I-l*y+c*R),w=+(o*T-h*y+c*E),P=-(o*x-h*R+l*E),G=i*C+s*S+n*w+r*P;if(G===0)return e.copyFrom(this),e;const L=1/G,W=l*b-m*c,K=h*b-g*c,ce=h*m-g*l,$=o*b-p*c,z=o*m-p*l,k=o*g-p*h,M=l*_-d*c,V=h*_-f*c,q=h*d-f*l,he=o*_-u*c,pe=o*d-u*l,se=o*f-u*h,ue=-(s*I-n*T+r*x),me=+(i*I-n*y+r*R),ne=-(i*T-s*y+r*E),Ie=+(i*x-s*R+n*E),Se=+(s*W-n*K+r*ce),Q=-(i*W-n*$+r*z),be=+(i*K-s*$+r*k),Be=-(i*ce-s*z+n*k),ze=-(s*M-n*V+r*q),Ke=+(i*M-n*he+r*pe),Rt=-(i*V-s*he+r*se),Ct=+(i*q-s*pe+n*se);return O.FromValuesToRef(C*L,ue*L,Se*L,ze*L,S*L,me*L,Q*L,Ke*L,w*L,ne*L,be*L,Rt*L,P*L,Ie*L,Be*L,Ct*L,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 v(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 O.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 O;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,n=e;for(let r=0;r<16;r++)s[r]=i[r]*n[r];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,n=e.m,r=s[0],o=s[1],h=s[2],l=s[3],c=s[4],u=s[5],f=s[6],d=s[7],_=s[8],p=s[9],g=s[10],m=s[11],b=s[12],I=s[13],T=s[14],x=s[15],y=n[0],R=n[1],E=n[2],C=n[3],S=n[4],w=n[5],P=n[6],G=n[7],L=n[8],W=n[9],K=n[10],ce=n[11],$=n[12],z=n[13],k=n[14],M=n[15];return t[i]=r*y+o*S+h*L+l*$,t[i+1]=r*R+o*w+h*W+l*z,t[i+2]=r*E+o*P+h*K+l*k,t[i+3]=r*C+o*G+h*ce+l*M,t[i+4]=c*y+u*S+f*L+d*$,t[i+5]=c*R+u*w+f*W+d*z,t[i+6]=c*E+u*P+f*K+d*k,t[i+7]=c*C+u*G+f*ce+d*M,t[i+8]=_*y+p*S+g*L+m*$,t[i+9]=_*R+p*w+g*W+m*z,t[i+10]=_*E+p*P+g*K+m*k,t[i+11]=_*C+p*G+g*ce+m*M,t[i+12]=b*y+I*S+T*L+x*$,t[i+13]=b*R+I*w+T*W+x*z,t[i+14]=b*E+I*P+T*K+x*k,t[i+15]=b*C+I*G+T*ce+x*M,this}divide(e){return this.divideToRef(e,new O)}divideToRef(e,t){const i=this._m,s=e.m,n=t._m;for(let r=0;r<16;r++)n[r]=i[r]/s[r];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 O)}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 n=0;n<16;n++)if(!lt(i[n],s[n],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 O)}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 O)}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 O;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 re,this.decompose(e.scaling,e.rotationQuaternion,e.position)}decompose(e,t,i,s,n=!0){if(this._isIdentity)return i&&i.setAll(0),e&&e.setAll(1),t&&t.copyFromFloats(0,0,0,1),!0;const r=this._m;if(i&&i.copyFromFloats(r[12],r[13],r[14]),e=e||_e.Vector3[0],e.x=Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]),e.y=Math.sqrt(r[4]*r[4]+r[5]*r[5]+r[6]*r[6]),e.z=Math.sqrt(r[8]*r[8]+r[9]*r[9]+r[10]*r[10]),s){const o=(n?s.absoluteScaling.x:s.scaling.x)<0?-1:1,h=(n?s.absoluteScaling.y:s.scaling.y)<0?-1:1,l=(n?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;O.FromValuesToRef(r[0]*o,r[1]*o,r[2]*o,0,r[4]*h,r[5]*h,r[6]*h,0,r[8]*l,r[9]*l,r[10]*l,0,0,0,0,1,_e.Matrix[0]),re.FromRotationMatrixToRef(_e.Matrix[0],t)}return!0}getRow(e){if(e<0||e>3)return null;const t=e*4;return new Pe(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 O;return O.TransposeToRef(this,e),e}transposeToRef(e){return O.TransposeToRef(this,e),e}setRowFromFloats(e,t,i,s,n){if(e<0||e>3)return this;const r=e*4;return this._m[r+0]=t,this._m[r+1]=i,this._m[r+2]=s,this._m[r+3]=n,this.markAsUpdated(),this}scale(e){const t=new O;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=_e.Matrix[0];this.invertToRef(t),t.transposeToRef(e);const i=e._m;return O.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 O;return this.getRotationMatrixToRef(e),e}getRotationMatrixToRef(e){const t=_e.Vector3[0];if(!this.decompose(t))return O.IdentityToRef(e),e;const i=this._m,s=1/t._x,n=1/t._y,r=1/t._z;return O.FromValuesToRef(i[0]*s,i[1]*s,i[2]*s,0,i[4]*n,i[5]*n,i[6]*n,0,i[8]*r,i[9]*r,i[10]*r,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 O;return O.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 O._IdentityReadOnly}static FromValuesToRef(e,t,i,s,n,r,o,h,l,c,u,f,d,_,p,g,m){const b=m._m;b[0]=e,b[1]=t,b[2]=i,b[3]=s,b[4]=n,b[5]=r,b[6]=o,b[7]=h,b[8]=l,b[9]=c,b[10]=u,b[11]=f,b[12]=d,b[13]=_,b[14]=p,b[15]=g,m.markAsUpdated()}static FromValues(e,t,i,s,n,r,o,h,l,c,u,f,d,_,p,g){const m=new O,b=m._m;return b[0]=e,b[1]=t,b[2]=i,b[3]=s,b[4]=n,b[5]=r,b[6]=o,b[7]=h,b[8]=l,b[9]=c,b[10]=u,b[11]=f,b[12]=d,b[13]=_,b[14]=p,b[15]=g,m.markAsUpdated(),m}static Compose(e,t,i){const s=new O;return O.ComposeToRef(e,t,i,s),s}static ComposeToRef(e,t,i,s){const n=s._m,r=t._x,o=t._y,h=t._z,l=t._w,c=r+r,u=o+o,f=h+h,d=r*c,_=r*u,p=r*f,g=o*u,m=o*f,b=h*f,I=l*c,T=l*u,x=l*f,y=e._x,R=e._y,E=e._z;return n[0]=(1-(g+b))*y,n[1]=(_+x)*y,n[2]=(p-T)*y,n[3]=0,n[4]=(_-x)*R,n[5]=(1-(d+b))*R,n[6]=(m+I)*R,n[7]=0,n[8]=(p+T)*E,n[9]=(m-I)*E,n[10]=(1-(d+g))*E,n[11]=0,n[12]=i._x,n[13]=i._y,n[14]=i._z,n[15]=1,s.markAsUpdated(),s}static Identity(){const e=O.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 O.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=O.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 O;return O.RotationXToRef(e,t),t}static Invert(e){const t=new O;return e.invertToRef(t),t}static RotationXToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return O.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 O;return O.RotationYToRef(e,t),t}static RotationYToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return O.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 O;return O.RotationZToRef(e,t),t}static RotationZToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return O.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 O;return O.RotationAxisToRef(e,t,i),i}static RotationAxisToRef(e,t,i){const s=Math.sin(-t),n=Math.cos(-t),r=1-n;e=e.normalizeToRef(_e.Vector3[0]);const o=i._m;return o[0]=e._x*e._x*r+n,o[1]=e._x*e._y*r-e._z*s,o[2]=e._x*e._z*r+e._y*s,o[3]=0,o[4]=e._y*e._x*r+e._z*s,o[5]=e._y*e._y*r+n,o[6]=e._y*e._z*r-e._x*s,o[7]=0,o[8]=e._z*e._x*r-e._y*s,o[9]=e._z*e._y*r+e._x*s,o[10]=e._z*e._z*r+n,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 n=v.Dot(t,e),r=i._m;if(n<-1+Le)r[0]=-1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=s?1:-1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=s?-1:1,r[11]=0;else{const o=v.Cross(t,e),h=1/(1+n);r[0]=o._x*o._x*h+n,r[1]=o._y*o._x*h-o._z,r[2]=o._z*o._x*h+o._y,r[3]=0,r[4]=o._x*o._y*h+o._z,r[5]=o._y*o._y*h+n,r[6]=o._z*o._y*h-o._x,r[7]=0,r[8]=o._x*o._z*h-o._y,r[9]=o._y*o._z*h+o._x,r[10]=o._z*o._z*h+n,r[11]=0}return r[12]=0,r[13]=0,r[14]=0,r[15]=1,i.markAsUpdated(),i}static RotationYawPitchRoll(e,t,i){const s=new O;return O.RotationYawPitchRollToRef(e,t,i,s),s}static RotationYawPitchRollToRef(e,t,i,s){return re.RotationYawPitchRollToRef(e,t,i,_e.Quaternion[0]),_e.Quaternion[0].toRotationMatrix(s),s}static Scaling(e,t,i){const s=new O;return O.ScalingToRef(e,t,i,s),s}static ScalingToRef(e,t,i,s){return O.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 O;return O.TranslationToRef(e,t,i,s),s}static TranslationToRef(e,t,i,s){return O.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 O;return O.LerpToRef(e,t,i,s),s}static LerpToRef(e,t,i,s){const n=s._m,r=e.m,o=t.m;for(let h=0;h<16;h++)n[h]=r[h]*(1-i)+o[h]*i;return s.markAsUpdated(),s}static DecomposeLerp(e,t,i){const s=new O;return O.DecomposeLerpToRef(e,t,i,s),s}static DecomposeLerpToRef(e,t,i,s){const n=_e.Vector3[0],r=_e.Quaternion[0],o=_e.Vector3[1];e.decompose(n,r,o);const h=_e.Vector3[2],l=_e.Quaternion[1],c=_e.Vector3[3];t.decompose(h,l,c);const u=_e.Vector3[4];v.LerpToRef(n,h,i,u);const f=_e.Quaternion[2];re.SlerpToRef(r,l,i,f);const d=_e.Vector3[5];return v.LerpToRef(o,c,i,d),O.ComposeToRef(u,f,d,s),s}static LookAtLH(e,t,i){const s=new O;return O.LookAtLHToRef(e,t,i,s),s}static LookAtLHToRef(e,t,i,s){const n=_e.Vector3[0],r=_e.Vector3[1],o=_e.Vector3[2];t.subtractToRef(e,o),o.normalize(),v.CrossToRef(i,o,n);const h=n.lengthSquared();h===0?n.x=1:n.normalizeFromLength(Math.sqrt(h)),v.CrossToRef(o,n,r),r.normalize();const l=-v.Dot(n,e),c=-v.Dot(r,e),u=-v.Dot(o,e);return O.FromValuesToRef(n._x,r._x,o._x,0,n._y,r._y,o._y,0,n._z,r._z,o._z,0,l,c,u,1,s),s}static LookAtRH(e,t,i){const s=new O;return O.LookAtRHToRef(e,t,i,s),s}static LookAtRHToRef(e,t,i,s){const n=_e.Vector3[0],r=_e.Vector3[1],o=_e.Vector3[2];e.subtractToRef(t,o),o.normalize(),v.CrossToRef(i,o,n);const h=n.lengthSquared();h===0?n.x=1:n.normalizeFromLength(Math.sqrt(h)),v.CrossToRef(o,n,r),r.normalize();const l=-v.Dot(n,e),c=-v.Dot(r,e),u=-v.Dot(o,e);return O.FromValuesToRef(n._x,r._x,o._x,0,n._y,r._y,o._y,0,n._z,r._z,o._z,0,l,c,u,1,s),s}static LookDirectionLH(e,t){const i=new O;return O.LookDirectionLHToRef(e,t,i),i}static LookDirectionLHToRef(e,t,i){const s=_e.Vector3[0];s.copyFrom(e),s.scaleInPlace(-1);const n=_e.Vector3[1];return v.CrossToRef(t,s,n),O.FromValuesToRef(n._x,n._y,n._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 O;return O.LookDirectionRHToRef(e,t,i),i}static LookDirectionRHToRef(e,t,i){const s=_e.Vector3[2];return v.CrossToRef(t,e,s),O.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,n){const r=new O;return O.OrthoLHToRef(e,t,i,s,r,n),r}static OrthoLHToRef(e,t,i,s,n,r){const o=i,h=s,l=2/e,c=2/t,u=2/(h-o),f=-(h+o)/(h-o);return O.FromValuesToRef(l,0,0,0,0,c,0,0,0,0,u,0,0,0,f,1,n),r&&n.multiplyToRef(Cs,n),n._updateIdentityStatus(l===1&&c===1&&u===1&&f===0),n}static OrthoOffCenterLH(e,t,i,s,n,r,o){const h=new O;return O.OrthoOffCenterLHToRef(e,t,i,s,n,r,h,o),h}static OrthoOffCenterLHToRef(e,t,i,s,n,r,o,h){const l=n,c=r,u=2/(t-e),f=2/(s-i),d=2/(c-l),_=-(c+l)/(c-l),p=(e+t)/(e-t),g=(s+i)/(i-s);return O.FromValuesToRef(u,0,0,0,0,f,0,0,0,0,d,0,p,g,_,1,o),h&&o.multiplyToRef(Cs,o),o.markAsUpdated(),o}static ObliqueOffCenterLHToRef(e,t,i,s,n,r,o,h,l,c,u){const f=-o*Math.cos(h),d=-o*Math.sin(h);return O.TranslationToRef(0,0,-l,_e.Matrix[1]),O.FromValuesToRef(1,0,0,0,0,1,0,0,f,d,1,0,0,0,0,1,_e.Matrix[0]),_e.Matrix[1].multiplyToRef(_e.Matrix[0],_e.Matrix[0]),O.TranslationToRef(0,0,l,_e.Matrix[1]),_e.Matrix[0].multiplyToRef(_e.Matrix[1],_e.Matrix[0]),O.OrthoOffCenterLHToRef(e,t,i,s,n,r,c,u),_e.Matrix[0].multiplyToRef(c,c),c}static OrthoOffCenterRH(e,t,i,s,n,r,o){const h=new O;return O.OrthoOffCenterRHToRef(e,t,i,s,n,r,h,o),h}static OrthoOffCenterRHToRef(e,t,i,s,n,r,o,h){return O.OrthoOffCenterLHToRef(e,t,i,s,n,r,o,h),o._m[10]*=-1,o}static ObliqueOffCenterRHToRef(e,t,i,s,n,r,o,h,l,c,u){const f=o*Math.cos(h),d=o*Math.sin(h);return O.TranslationToRef(0,0,l,_e.Matrix[1]),O.FromValuesToRef(1,0,0,0,0,1,0,0,f,d,1,0,0,0,0,1,_e.Matrix[0]),_e.Matrix[1].multiplyToRef(_e.Matrix[0],_e.Matrix[0]),O.TranslationToRef(0,0,-l,_e.Matrix[1]),_e.Matrix[0].multiplyToRef(_e.Matrix[1],_e.Matrix[0]),O.OrthoOffCenterRHToRef(e,t,i,s,n,r,c,u),_e.Matrix[0].multiplyToRef(c,c),c}static PerspectiveLH(e,t,i,s,n,r=0){const o=new O,h=i,l=s,c=2*h/e,u=2*h/t,f=(l+h)/(l-h),d=-2*l*h/(l-h),_=Math.tan(r);return O.FromValuesToRef(c,0,0,0,0,u,0,_,0,0,f,1,0,0,d,0,o),n&&o.multiplyToRef(Cs,o),o._updateIdentityStatus(!1),o}static PerspectiveFovLH(e,t,i,s,n,r=0,o=!1){const h=new O;return O.PerspectiveFovLHToRef(e,t,i,s,h,!0,n,r,o),h}static PerspectiveFovLHToRef(e,t,i,s,n,r=!0,o,h=0,l=!1){const c=i,u=s,f=1/Math.tan(e*.5),d=r?f/t:f,_=r?f:f*t,p=l&&c===0?-1:u!==0?(u+c)/(u-c):1,g=l&&c===0?2*u:u!==0?-2*u*c/(u-c):-2*c,m=Math.tan(h);return O.FromValuesToRef(d,0,0,0,0,_,0,m,0,0,p,1,0,0,g,0,n),o&&n.multiplyToRef(Cs,n),n._updateIdentityStatus(!1),n}static PerspectiveFovReverseLHToRef(e,t,i,s,n,r=!0,o,h=0){const l=1/Math.tan(e*.5),c=r?l/t:l,u=r?l:l*t,f=Math.tan(h);return O.FromValuesToRef(c,0,0,0,0,u,0,f,0,0,-i,1,0,0,1,0,n),o&&n.multiplyToRef(Cs,n),n._updateIdentityStatus(!1),n}static PerspectiveFovRH(e,t,i,s,n,r=0,o=!1){const h=new O;return O.PerspectiveFovRHToRef(e,t,i,s,h,!0,n,r,o),h}static PerspectiveFovRHToRef(e,t,i,s,n,r=!0,o,h=0,l=!1){const c=i,u=s,f=1/Math.tan(e*.5),d=r?f/t:f,_=r?f:f*t,p=l&&c===0?1:u!==0?-(u+c)/(u-c):-1,g=l&&c===0?2*u:u!==0?-2*u*c/(u-c):-2*c,m=Math.tan(h);return O.FromValuesToRef(d,0,0,0,0,_,0,m,0,0,p,-1,0,0,g,0,n),o&&n.multiplyToRef(Cs,n),n._updateIdentityStatus(!1),n}static PerspectiveFovReverseRHToRef(e,t,i,s,n,r=!0,o,h=0){const l=1/Math.tan(e*.5),c=r?l/t:l,u=r?l:l*t,f=Math.tan(h);return O.FromValuesToRef(c,0,0,0,0,u,0,f,0,0,-i,-1,0,0,-1,0,n),o&&n.multiplyToRef(Cs,n),n._updateIdentityStatus(!1),n}static GetFinalMatrix(e,t,i,s,n,r){const o=e.width,h=e.height,l=e.x,c=e.y,u=O.FromValues(o/2,0,0,0,0,-h/2,0,0,0,0,r-n,0,l+o/2,h/2+c,n,1),f=new O;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 Dt.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 Dt.MatrixUse64Bits?i:new Float32Array(i)}static Transpose(e){const t=new O;return O.TransposeToRef(e,t),t}static TransposeToRef(e,t){const i=e.m,s=i[0],n=i[4],r=i[8],o=i[12],h=i[1],l=i[5],c=i[9],u=i[13],f=i[2],d=i[6],_=i[10],p=i[14],g=i[3],m=i[7],b=i[11],I=i[15],T=t._m;return T[0]=s,T[1]=n,T[2]=r,T[3]=o,T[4]=h,T[5]=l,T[6]=c,T[7]=u,T[8]=f,T[9]=d,T[10]=_,T[11]=p,T[12]=g,T[13]=m,T[14]=b,T[15]=I,t.markAsUpdated(),t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty),t}static Reflection(e){const t=new O;return O.ReflectionToRef(e,t),t}static ReflectionToRef(e,t){e.normalize();const i=e.normal.x,s=e.normal.y,n=e.normal.z,r=-2*i,o=-2*s,h=-2*n;return O.FromValuesToRef(r*i+1,o*i,h*i,0,r*s,o*s+1,h*s,0,r*n,o*n,h*n+1,0,r*e.d,o*e.d,h*e.d,1,t),t}static FromXYZAxesToRef(e,t,i,s){return O.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,n=e._z*e._z,r=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+n),t._m[1]=2*(r+o),t._m[2]=2*(h-l),t._m[3]=0,t._m[4]=2*(r-o),t._m[5]=1-2*(n+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}}O._UpdateFlagSeed=0;O._IdentityReadOnly=O.Identity();Object.defineProperties(O.prototype,{dimension:{value:[4,4]},rank:{value:2}});class _e{}_e.Vector3=Rs(11,v.Zero);_e.Matrix=Rs(2,O.Identity);_e.Quaternion=Rs(3,re.Zero);class N{}N.Vector2=Rs(3,oe.Zero);N.Vector3=Rs(13,v.Zero);N.Vector4=Rs(3,Pe.Zero);N.Quaternion=Rs(3,re.Zero);N.Matrix=Rs(8,O.Identity);vt("BABYLON.Vector2",oe);vt("BABYLON.Vector3",v);vt("BABYLON.Vector4",Pe);vt("BABYLON.Matrix",O);const Cs=O.FromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);var ci;(function(a){a[a.LOCAL=0]="LOCAL",a[a.WORLD=1]="WORLD",a[a.BONE=2]="BONE"})(ci||(ci={}));class Gt{}Gt.X=new v(1,0,0);Gt.Y=new v(0,1,0);Gt.Z=new v(0,0,1);var Bo;(function(a){a[a.X=0]="X",a[a.Y=1]="Y",a[a.Z=2]="Z"})(Bo||(Bo={}));function tn(a){return Math.pow(a,Wd)}function sn(a){return a<=.04045?.0773993808*a:Math.pow(.947867299*(a+.055),2.4)}function nn(a){return Math.pow(a,zd)}function rn(a){return a<=.0031308?12.92*a:1.055*Math.pow(a,.41666)-.055}class de{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 de.FromArrayToRef(e,t,this),this}toColor4(e=1){return new H(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 de(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 de(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=Le){return lt(this.r,e.r,t)&<(this.g,e.g,t)&<(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 de(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=ht(this.r,e,t),i.g=ht(this.g,e,t),i.b=ht(this.b,e,t),i}add(e){return new de(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 de(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 de(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 de(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"#"+Ui(e)+Ui(t)+Ui(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 de)}toHSVToRef(e){const t=this.r,i=this.g,s=this.b,n=Math.max(t,i,s),r=Math.min(t,i,s);let o=0,h=0;const l=n,c=n-r;return n!==0&&(h=c/n),n!=r&&(n==t?(o=(i-s)/c,i<s&&(o+=6)):n==i?o=(s-t)/c+2:n==s&&(o=(t-i)/c+4),o*=60),e.r=o,e.g=h,e.b=l,e}toLinearSpace(e=!1){const t=new de;return this.toLinearSpaceToRef(t,e),t}toLinearSpaceToRef(e,t=!1){return t?(e.r=sn(this.r),e.g=sn(this.g),e.b=sn(this.b)):(e.r=tn(this.r),e.g=tn(this.g),e.b=tn(this.b)),this}toGammaSpace(e=!1){const t=new de;return this.toGammaSpaceToRef(t,e),t}toGammaSpaceToRef(e,t=!1){return t?(e.r=rn(this.r),e.g=rn(this.g),e.b=rn(this.b)):(e.r=nn(this.r),e.g=nn(this.g),e.b=nn(this.b)),this}static HSVtoRGBToRef(e,t,i,s){const n=i*t,r=e/60,o=n*(1-Math.abs(r%2-1));let h=0,l=0,c=0;r>=0&&r<=1?(h=n,l=o):r>=1&&r<=2?(h=o,l=n):r>=2&&r<=3?(l=n,c=o):r>=3&&r<=4?(l=o,c=n):r>=4&&r<=5?(h=o,c=n):r>=5&&r<=6&&(h=n,c=o);const u=i-n;return s.r=h+u,s.g=l+u,s.b=c+u,s}static FromHSV(e,t,i){const s=new de(0,0,0);return de.HSVtoRGBToRef(e,t,i,s),s}static FromHexString(e){return new de(0,0,0).fromHexString(e)}static FromArray(e,t=0){return new de(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 de(e/255,t/255,i/255)}static Lerp(e,t,i){const s=new de(0,0,0);return de.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,n){const r=n*n,o=n*r,h=2*o-3*r+1,l=-2*o+3*r,c=o-2*r+n,u=o-r,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,_=e.b*h+i.b*l+t.b*c+s.b*u;return new de(f,d,_)}static Hermite1stDerivative(e,t,i,s,n){const r=de.Black();return this.Hermite1stDerivativeToRef(e,t,i,s,n,r),r}static Hermite1stDerivativeToRef(e,t,i,s,n,r){const o=n*n;r.r=(o-n)*6*e.r+(3*o-4*n+1)*t.r+(-o+n)*6*i.r+(3*o-2*n)*s.r,r.g=(o-n)*6*e.g+(3*o-4*n+1)*t.g+(-o+n)*6*i.g+(3*o-2*n)*s.g,r.b=(o-n)*6*e.b+(3*o-4*n+1)*t.b+(-o+n)*6*i.b+(3*o-2*n)*s.b}static Red(){return new de(1,0,0)}static Green(){return new de(0,1,0)}static Blue(){return new de(0,0,1)}static Black(){return new de(0,0,0)}static get BlackReadOnly(){return de._BlackReadOnly}static White(){return new de(1,1,1)}static Purple(){return new de(.5,0,.5)}static Magenta(){return new de(1,0,1)}static Yellow(){return new de(1,1,0)}static Gray(){return new de(.5,.5,.5)}static Teal(){return new de(0,1,1)}static Random(){return new de(Math.random(),Math.random(),Math.random())}}de._V8PerformanceHack=new de(.5,.5,.5);de._BlackReadOnly=de.Black();Object.defineProperties(de.prototype,{dimension:{value:[3]},rank:{value:1}});class H{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 H(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 H(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 H(this.r-e,this.g-t,this.b-i,this.a-s)}subtractFromFloatsToRef(e,t,i,s,n){return n.r=this.r-e,n.g=this.g-t,n.b=this.b-i,n.a=this.a-s,n}scale(e){return new H(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=ht(this.r,e,t),i.g=ht(this.g,e,t),i.b=ht(this.b,e,t),i.a=ht(this.a,e,t),i}multiply(e){return new H(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 H(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=Le){return lt(this.r,e.r,t)&<(this.g,e.g,t)&<(this.b,e.b,t)&<(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 H().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"#"+Ui(t)+Ui(i)+Ui(s);const n=Math.round(this.a*255);return"#"+Ui(t)+Ui(i)+Ui(s)+Ui(n)}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 H;return this.toLinearSpaceToRef(t,e),t}toLinearSpaceToRef(e,t=!1){return t?(e.r=sn(this.r),e.g=sn(this.g),e.b=sn(this.b)):(e.r=tn(this.r),e.g=tn(this.g),e.b=tn(this.b)),e.a=this.a,this}toGammaSpace(e=!1){const t=new H;return this.toGammaSpaceToRef(t,e),t}toGammaSpaceToRef(e,t=!1){return t?(e.r=rn(this.r),e.g=rn(this.g),e.b=rn(this.b)):(e.r=nn(this.r),e.g=nn(this.g),e.b=nn(this.b)),e.a=this.a,this}static FromHexString(e){return e.substring(0,1)!=="#"||e.length!==9&&e.length!==7?new H(0,0,0,0):new H(0,0,0,1).fromHexString(e)}static Lerp(e,t,i){return H.LerpToRef(e,t,i,new H)}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,n){const r=n*n,o=n*r,h=2*o-3*r+1,l=-2*o+3*r,c=o-2*r+n,u=o-r,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,_=e.b*h+i.b*l+t.b*c+s.b*u,p=e.a*h+i.a*l+t.a*c+s.a*u;return new H(f,d,_,p)}static Hermite1stDerivative(e,t,i,s,n){const r=new H;return this.Hermite1stDerivativeToRef(e,t,i,s,n,r),r}static Hermite1stDerivativeToRef(e,t,i,s,n,r){const o=n*n;r.r=(o-n)*6*e.r+(3*o-4*n+1)*t.r+(-o+n)*6*i.r+(3*o-2*n)*s.r,r.g=(o-n)*6*e.g+(3*o-4*n+1)*t.g+(-o+n)*6*i.g+(3*o-2*n)*s.g,r.b=(o-n)*6*e.b+(3*o-4*n+1)*t.b+(-o+n)*6*i.b+(3*o-2*n)*s.b,r.a=(o-n)*6*e.a+(3*o-4*n+1)*t.a+(-o+n)*6*i.a+(3*o-2*n)*s.a}static FromColor3(e,t=1){return new H(e.r,e.g,e.b,t)}static FromArray(e,t=0){return new H(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 H(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 n=s/3*4;i[n]=e[s],i[n+1]=e[s+1],i[n+2]=e[s+2],i[n+3]=1}return i}return e}}H._V8PerformanceHack=new H(.5,.5,.5,.5);Object.defineProperties(H.prototype,{dimension:{value:[4]},rank:{value:1}});class Js{}Js.Color3=zi(3,de.Black);Js.Color4=zi(3,()=>new H(0,0,0,0));vt("BABYLON.Color3",de);vt("BABYLON.Color4",H);class Xt{constructor(e,t,i,s){this.normal=new v(e,t,i),this.d=s}asArray(){return[this.normal.x,this.normal.y,this.normal.z,this.d]}clone(){return new Xt(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=Xt._TmpMatrix;e.invertToRef(t);const i=t.m,s=this.normal.x,n=this.normal.y,r=this.normal.z,o=this.d,h=s*i[0]+n*i[1]+r*i[2]+o*i[3],l=s*i[4]+n*i[5]+r*i[6]+o*i[7],c=s*i[8]+n*i[9]+r*i[10]+o*i[11],u=s*i[12]+n*i[13]+r*i[14]+o*i[15];return new Xt(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,n=t.y-e.y,r=t.z-e.z,o=i.x-e.x,h=i.y-e.y,l=i.z-e.z,c=n*l-r*h,u=r*o-s*l,f=s*h-n*o,d=Math.sqrt(c*c+u*u+f*f);let _;return d!==0?_=1/d:_=0,this.normal.x=c*_,this.normal.y=u*_,this.normal.z=f*_,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this}isFrontFacingTo(e,t){return v.Dot(this.normal,e)<=t}signedDistanceTo(e){return v.Dot(e,this.normal)+this.d}static FromArray(e){return new Xt(e[0],e[1],e[2],e[3])}static FromPoints(e,t,i){const s=new Xt(0,0,0,0);return s.copyFromPoints(e,t,i),s}static FromPositionAndNormal(e,t){const i=new Xt(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 v.Dot(i,t)+s}}Xt._TmpMatrix=O.Identity();class mi{static GetPlanes(e){const t=[];for(let i=0;i<6;i++)t.push(new Xt(0,0,0,0));return mi.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){mi.GetNearPlaneToRef(e,t[0]),mi.GetFarPlaneToRef(e,t[1]),mi.GetLeftPlaneToRef(e,t[2]),mi.GetRightPlaneToRef(e,t[3]),mi.GetTopPlaneToRef(e,t[4]),mi.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}}var Lo;(function(a){a[a.CW=0]="CW",a[a.CCW=1]="CCW"})(Lo||(Lo={}));class ki{constructor(e){this._radians=e,this._radians<0&&(this._radians+=2*Math.PI)}degrees(){return this._radians*180/Math.PI}radians(){return this._radians}static BetweenTwoPoints(e,t){const i=t.subtract(e),s=Math.atan2(i.y,i.x);return new ki(s)}static BetweenTwoVectors(e,t){let i=e.lengthSquared()*t.lengthSquared();if(i===0)return new ki(Math.PI/2);i=Math.sqrt(i);let s=e.dot(t)/i;s=ht(s,-1,1);const n=Math.acos(s);return new ki(n)}static FromRadians(e){return new ki(e)}static FromDegrees(e){return new ki(e*Math.PI/180)}}class qd{constructor(e,t,i){this.startPoint=e,this.midPoint=t,this.endPoint=i;const s=Math.pow(t.x,2)+Math.pow(t.y,2),n=(Math.pow(e.x,2)+Math.pow(e.y,2)-s)/2,r=(s-Math.pow(i.x,2)-Math.pow(i.y,2))/2,o=(e.x-t.x)*(t.y-i.y)-(t.x-i.x)*(e.y-t.y);this.centerPoint=new oe((n*(t.y-i.y)-r*(e.y-t.y))/o,((e.x-t.x)*r-(t.x-i.x)*n)/o),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=ki.BetweenTwoPoints(this.centerPoint,this.startPoint);const h=this.startAngle.degrees();let l=ki.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),c=ki.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();l-h>180&&(l-=360),l-h<-180&&(l+=360),c-l>180&&(c-=360),c-l<-180&&(c+=360),this.orientation=l-h<0?0:1,this.angle=ki.FromDegrees(this.orientation===0?h-c:c-h)}}class Gr{constructor(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new oe(e,t))}addLineTo(e,t){if(this.closed)return this;const i=new oe(e,t),s=this._points[this._points.length-1];return this._points.push(i),this._length+=i.subtract(s).length(),this}addArcTo(e,t,i,s,n=36){if(this.closed)return this;const r=this._points[this._points.length-1],o=new oe(e,t),h=new oe(i,s),l=new qd(r,o,h);let c=l.angle.radians()/n;l.orientation===0&&(c*=-1);let u=l.startAngle.radians()+c;for(let f=0;f<n;f++){const d=Math.cos(u)*l.radius+l.centerPoint.x,_=Math.sin(u)*l.radius+l.centerPoint.y;this.addLineTo(d,_),u+=c}return this}addQuadraticCurveTo(e,t,i,s,n=36){if(this.closed)return this;const r=(h,l,c,u)=>(1-h)*(1-h)*l+2*h*(1-h)*c+h*h*u,o=this._points[this._points.length-1];for(let h=0;h<=n;h++){const l=h/n,c=r(l,o.x,e,i),u=r(l,o.y,t,s);this.addLineTo(c,u)}return this}addBezierCurveTo(e,t,i,s,n,r,o=36){if(this.closed)return this;const h=(c,u,f,d,_)=>(1-c)*(1-c)*(1-c)*u+3*c*(1-c)*(1-c)*f+3*c*c*(1-c)*d+c*c*c*_,l=this._points[this._points.length-1];for(let c=0;c<=o;c++){const u=c/o,f=h(u,l.x,e,i,n),d=h(u,l.y,t,s,r);this.addLineTo(f,d)}return this}isPointInside(e){let t=!1;const i=this._points.length;for(let s=i-1,n=0;n<i;s=n++){let r=this._points[s],o=this._points[n],h=o.x-r.x,l=o.y-r.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(r=this._points[n],h=-h,o=this._points[s],l=-l),e.y<r.y||e.y>o.y)continue;if(e.y===r.y&&e.x===r.x)return!0;{const c=l*(e.x-r.x)-h*(e.y-r.y);if(c===0)return!0;if(c<0)continue;t=!t}}else{if(e.y!==r.y)continue;if(o.x<=e.x&&e.x<=r.x||r.x<=e.x&&e.x<=o.x)return!0}}return t}close(){return this.closed=!0,this}length(){let e=this._length;if(this.closed){const t=this._points[this._points.length-1],i=this._points[0];e+=i.subtract(t).length()}return e}area(){const e=this._points.length;let t=0;for(let i=e-1,s=0;s<e;i=s++)t+=this._points[i].x*this._points[s].y-this._points[s].x*this._points[i].y;return t*.5}getPoints(){return this._points}getPointAtLengthPosition(e){if(e<0||e>1)return oe.Zero();const t=e*this.length();let i=0;for(let s=0;s<this._points.length;s++){const n=(s+1)%this._points.length,r=this._points[s],h=this._points[n].subtract(r),l=h.length()+i;if(t>=i&&t<=l){const c=h.normalize(),u=t-i;return new oe(r.x+c.x*u,r.y+c.y*u)}i=l}return oe.Zero()}static StartingAt(e,t){return new Gr(e,t)}}class Fn{constructor(e,t=null,i,s=!1){this.path=e,this._curve=new Array,this._distances=new Array,this._tangents=new Array,this._normals=new Array,this._binormals=new Array,this._pointAtData={id:0,point:v.Zero(),previousPointArrayIndex:0,position:0,subPosition:0,interpolateReady:!1,interpolationMatrix:O.Identity()};for(let n=0;n<e.length;n++)this._curve[n]=e[n].clone();this._raw=i||!1,this._alignTangentsWithPath=s,this._compute(t,s)}getCurve(){return this._curve}getPoints(){return this._curve}length(){return this._distances[this._distances.length-1]}getTangents(){return this._tangents}getNormals(){return this._normals}getBinormals(){return this._binormals}getDistances(){return this._distances}getPointAt(e){return this._updatePointAtData(e).point}getTangentAt(e,t=!1){return this._updatePointAtData(e,t),t?v.TransformCoordinates(v.Forward(),this._pointAtData.interpolationMatrix):this._tangents[this._pointAtData.previousPointArrayIndex]}getNormalAt(e,t=!1){return this._updatePointAtData(e,t),t?v.TransformCoordinates(v.Right(),this._pointAtData.interpolationMatrix):this._normals[this._pointAtData.previousPointArrayIndex]}getBinormalAt(e,t=!1){return this._updatePointAtData(e,t),t?v.TransformCoordinates(v.UpReadOnly,this._pointAtData.interpolationMatrix):this._binormals[this._pointAtData.previousPointArrayIndex]}getDistanceAt(e){return this.length()*e}getPreviousPointIndexAt(e){return this._updatePointAtData(e),this._pointAtData.previousPointArrayIndex}getSubPositionAt(e){return this._updatePointAtData(e),this._pointAtData.subPosition}getClosestPositionTo(e){let t=Number.MAX_VALUE,i=0;for(let s=0;s<this._curve.length-1;s++){const n=this._curve[s+0],r=this._curve[s+1].subtract(n).normalize(),o=this._distances[s+1]-this._distances[s+0],h=Math.min(Math.max(v.Dot(r,e.subtract(n).normalize()),0)*v.Distance(n,e)/o,1),l=v.Distance(n.add(r.scale(h*o)),e);l<t&&(t=l,i=(this._distances[s+0]+o*h)/this.length())}return i}slice(e=0,t=1){if(e<0&&(e=1-e*-1%1),t<0&&(t=1-t*-1%1),e>t){const l=e;e=t,t=l}const i=this.getCurve(),s=this.getPointAt(e);let n=this.getPreviousPointIndexAt(e);const r=this.getPointAt(t),o=this.getPreviousPointIndexAt(t)+1,h=[];return e!==0&&(n++,h.push(s)),h.push(...i.slice(n,o)),(t!==1||e===1)&&h.push(r),new Fn(h,this.getNormalAt(e),this._raw,this._alignTangentsWithPath)}update(e,t=null,i=!1){for(let s=0;s<e.length;s++)this._curve[s].x=e[s].x,this._curve[s].y=e[s].y,this._curve[s].z=e[s].z;return this._compute(t,i),this}_compute(e,t=!1){const i=this._curve.length;if(i<2)return;this._tangents[0]=this._getFirstNonNullVector(0),this._raw||this._tangents[0].normalize(),this._tangents[i-1]=this._curve[i-1].subtract(this._curve[i-2]),this._raw||this._tangents[i-1].normalize();const s=this._tangents[0],n=this._normalVector(s,e);this._normals[0]=n,this._raw||this._normals[0].normalize(),this._binormals[0]=v.Cross(s,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;let r,o,h,l,c;for(let u=1;u<i;u++)r=this._getLastNonNullVector(u),u<i-1&&(o=this._getFirstNonNullVector(u),this._tangents[u]=t?o:r.add(o),this._tangents[u].normalize()),this._distances[u]=this._distances[u-1]+this._curve[u].subtract(this._curve[u-1]).length(),h=this._tangents[u],c=this._binormals[u-1],this._normals[u]=v.Cross(c,h),this._raw||(this._normals[u].length()===0?(l=this._normals[u-1],this._normals[u]=l.clone()):this._normals[u].normalize()),this._binormals[u]=v.Cross(h,this._normals[u]),this._raw||this._binormals[u].normalize();this._pointAtData.id=NaN}_getFirstNonNullVector(e){let t=1,i=this._curve[e+t].subtract(this._curve[e]);for(;i.length()===0&&e+t+1<this._curve.length;)t++,i=this._curve[e+t].subtract(this._curve[e]);return i}_getLastNonNullVector(e){let t=1,i=this._curve[e].subtract(this._curve[e-t]);for(;i.length()===0&&e>t+1;)t++,i=this._curve[e].subtract(this._curve[e-t]);return i}_normalVector(e,t){let i,s=e.length();if(s===0&&(s=1),t==null){let n;lt(Math.abs(e.y)/s,1,Le)?lt(Math.abs(e.x)/s,1,Le)?lt(Math.abs(e.z)/s,1,Le)?n=v.Zero():n=new v(0,0,1):n=new v(1,0,0):n=new v(0,-1,0),i=v.Cross(e,n)}else i=v.Cross(e,t),v.CrossToRef(i,e,i);return i.normalize(),i}_updatePointAtData(e,t=!1){if(this._pointAtData.id===e)return this._pointAtData.interpolateReady||this._updateInterpolationMatrix(),this._pointAtData;this._pointAtData.id=e;const i=this.getPoints();if(e<=0)return this._setPointAtData(0,0,i[0],0,t);if(e>=1)return this._setPointAtData(1,1,i[i.length-1],i.length-1,t);let s=i[0],n,r=0;const o=e*this.length();for(let h=1;h<i.length;h++){n=i[h];const l=v.Distance(s,n);if(r+=l,r===o)return this._setPointAtData(e,1,n,h,t);if(r>o){const u=(r-o)/l,f=s.subtract(n),d=n.add(f.scaleInPlace(u));return this._setPointAtData(e,1-u,d,h-1,t)}s=n}return this._pointAtData}_setPointAtData(e,t,i,s,n){return this._pointAtData.point=i,this._pointAtData.position=e,this._pointAtData.subPosition=t,this._pointAtData.previousPointArrayIndex=s,this._pointAtData.interpolateReady=n,n&&this._updateInterpolationMatrix(),this._pointAtData}_updateInterpolationMatrix(){this._pointAtData.interpolationMatrix=O.Identity();const e=this._pointAtData.previousPointArrayIndex;if(e!==this._tangents.length-1){const t=e+1,i=this._tangents[e].clone(),s=this._normals[e].clone(),n=this._binormals[e].clone(),r=this._tangents[t].clone(),o=this._normals[t].clone(),h=this._binormals[t].clone(),l=re.RotationQuaternionFromAxis(s,n,i),c=re.RotationQuaternionFromAxis(o,h,r);re.Slerp(l,c,this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)}}}class hi{constructor(e,t){this.width=e,this.height=t}toString(){return"{W: ".concat(this.width,", H: ").concat(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 hi(this.width*e,this.height*t)}clone(){return new hi(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 hi(0,0)}add(e){return new hi(this.width+e.width,this.height+e.height)}subtract(e){return new hi(this.width-e.width,this.height-e.height)}scale(e){return new hi(this.width*e,this.height*e)}static Lerp(e,t,i){const s=e.width+(t.width-e.width)*i,n=e.height+(t.height-e.height)*i;return new hi(s,n)}}class on{constructor(e,t,i,s){this.x=e,this.y=t,this.width=i,this.height=s}toGlobal(e,t){return new on(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 on(this.x,this.y,this.width,this.height)}}const Ni=[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))],jd=[()=>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],Zi=(a,e)=>Ni[a]*jd[a](e),Qi=[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 Ir{constructor(){this.preScaled=!1,this.l00=v.Zero(),this.l1_1=v.Zero(),this.l10=v.Zero(),this.l11=v.Zero(),this.l2_2=v.Zero(),this.l2_1=v.Zero(),this.l20=v.Zero(),this.l21=v.Zero(),this.l22=v.Zero()}addLight(e,t,i){N.Vector3[0].set(t.r,t.g,t.b);const s=N.Vector3[0],n=N.Vector3[1];s.scaleToRef(i,n),n.scaleToRef(Zi(0,e),N.Vector3[2]),this.l00.addInPlace(N.Vector3[2]),n.scaleToRef(Zi(1,e),N.Vector3[2]),this.l1_1.addInPlace(N.Vector3[2]),n.scaleToRef(Zi(2,e),N.Vector3[2]),this.l10.addInPlace(N.Vector3[2]),n.scaleToRef(Zi(3,e),N.Vector3[2]),this.l11.addInPlace(N.Vector3[2]),n.scaleToRef(Zi(4,e),N.Vector3[2]),this.l2_2.addInPlace(N.Vector3[2]),n.scaleToRef(Zi(5,e),N.Vector3[2]),this.l2_1.addInPlace(N.Vector3[2]),n.scaleToRef(Zi(6,e),N.Vector3[2]),this.l20.addInPlace(N.Vector3[2]),n.scaleToRef(Zi(7,e),N.Vector3[2]),this.l21.addInPlace(N.Vector3[2]),n.scaleToRef(Zi(8,e),N.Vector3[2]),this.l22.addInPlace(N.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(Qi[0]),this.l1_1.scaleInPlace(Qi[1]),this.l10.scaleInPlace(Qi[2]),this.l11.scaleInPlace(Qi[3]),this.l2_2.scaleInPlace(Qi[4]),this.l2_1.scaleInPlace(Qi[5]),this.l20.scaleInPlace(Qi[6]),this.l21.scaleInPlace(Qi[7]),this.l22.scaleInPlace(Qi[8])}convertIrradianceToLambertianRadiance(){this.scaleInPlace(1/Math.PI)}preScaleForRendering(){this.preScaled=!0,this.l00.scaleInPlace(Ni[0]),this.l1_1.scaleInPlace(Ni[1]),this.l10.scaleInPlace(Ni[2]),this.l11.scaleInPlace(Ni[3]),this.l2_2.scaleInPlace(Ni[4]),this.l2_1.scaleInPlace(Ni[5]),this.l20.scaleInPlace(Ni[6]),this.l21.scaleInPlace(Ni[7]),this.l22.scaleInPlace(Ni[8])}updateFromArray(e){return v.FromArrayToRef(e[0],0,this.l00),v.FromArrayToRef(e[1],0,this.l1_1),v.FromArrayToRef(e[2],0,this.l10),v.FromArrayToRef(e[3],0,this.l11),v.FromArrayToRef(e[4],0,this.l2_2),v.FromArrayToRef(e[5],0,this.l2_1),v.FromArrayToRef(e[6],0,this.l20),v.FromArrayToRef(e[7],0,this.l21),v.FromArrayToRef(e[8],0,this.l22),this}updateFromFloatsArray(e){return v.FromFloatsToRef(e[0],e[1],e[2],this.l00),v.FromFloatsToRef(e[3],e[4],e[5],this.l1_1),v.FromFloatsToRef(e[6],e[7],e[8],this.l10),v.FromFloatsToRef(e[9],e[10],e[11],this.l11),v.FromFloatsToRef(e[12],e[13],e[14],this.l2_2),v.FromFloatsToRef(e[15],e[16],e[17],this.l2_1),v.FromFloatsToRef(e[18],e[19],e[20],this.l20),v.FromFloatsToRef(e[21],e[22],e[23],this.l21),v.FromFloatsToRef(e[24],e[25],e[26],this.l22),this}static FromArray(e){return new Ir().updateFromArray(e)}static FromPolynomial(e){const t=new Ir;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 On{constructor(){this.x=v.Zero(),this.y=v.Zero(),this.z=v.Zero(),this.xx=v.Zero(),this.yy=v.Zero(),this.zz=v.Zero(),this.xy=v.Zero(),this.yz=v.Zero(),this.zx=v.Zero()}get preScaledHarmonics(){return this._harmonics||(this._harmonics=Ir.FromPolynomial(this)),this._harmonics.preScaled||this._harmonics.preScaleForRendering(),this._harmonics}addAmbient(e){N.Vector3[0].copyFromFloats(e.r,e.g,e.b);const t=N.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),N.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),N.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),this.xx.scaleInPlace(.886277).subtractInPlace(N.Vector3[0]).addInPlace(N.Vector3[1]),this.yy.copyFrom(e.l00),this.yy.scaleInPlace(.886277).subtractInPlace(N.Vector3[0]).subtractInPlace(N.Vector3[1]),this.zz.copyFrom(e.l00),N.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),this.zz.scaleInPlace(.886277).addInPlace(N.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 On().updateFromHarmonics(e)}static FromArray(e){const t=new On;return v.FromArrayToRef(e[0],0,t.x),v.FromArrayToRef(e[1],0,t.y),v.FromArrayToRef(e[2],0,t.z),v.FromArrayToRef(e[3],0,t.xx),v.FromArrayToRef(e[4],0,t.yy),v.FromArrayToRef(e[5],0,t.zz),v.FromArrayToRef(e[6],0,t.yz),v.FromArrayToRef(e[7],0,t.zx),v.FromArrayToRef(e[8],0,t.xy),t}}function D(a,e,t,i){var s=arguments.length,n=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(a,e,t,i);else for(var o=a.length-1;o>=0;o--)(r=a[o])&&(n=(s<3?r(n):s>3?r(e,t,n):r(e,t))||n);return s>3&&n&&Object.defineProperty(e,t,n),n}const rr={},_r={};function $d(a){const e=a.getClassName();return _r[e]||(_r[e]={}),_r[e]}function La(a){const e=a.getClassName();if(rr[e])return rr[e];rr[e]={};const t=rr[e];let i=a,s=e;for(;s;){const n=_r[s];for(const h in n)t[h]=n[h];let r,o=!1;do{if(r=Object.getPrototypeOf(i),!r.getClassName){o=!0;break}if(r.getClassName()!==s)break;i=r}while(r);if(o)break;s=r.getClassName(),i=r}return t}function Di(a,e){return(t,i)=>{const s=$d(t);s[i]||(s[i]={type:a,sourceName:e})}}function Zd(a,e=null){return(t,i)=>{const s=e||"_"+i;Object.defineProperty(t,i,{get:function(){return this[s]},set:function(n){typeof this.equals=="function"&&this.equals(n)||this[s]!==n&&(this[s]=n,t[a].apply(this))},enumerable:!0,configurable:!0})}}function je(a,e=null){return Zd(a,e)}function B(a){return Di(0,a)}function _i(a){return Di(1,a)}function ls(a){return Di(2,a)}function Kn(a){return Di(3,a)}function tc(a){return Di(4,a)}function yi(a){return Di(5,a)}function ic(a){return Di(6,a)}function Qd(a){return Di(7,a)}function p0(a){return Di(8,a)}function Jd(a){return Di(10,a)}function e_(a){return Di(11,a)}function rs(a,e,t,i){const s=t.value;t.value=(...n)=>{let r=s;if(typeof _native<"u"&&_native[e]){const o=_native[e];i?r=(...h)=>i(...h)?o(...h):s(...h):r=o}return a[e]=r,r(...n)}}rs.filter=function(a){return(e,t,i)=>rs(e,t,i,a)};function g0(){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 t_(){return typeof _native<"u"&&_native.XMLHttpRequest?new _native.XMLHttpRequest:new XMLHttpRequest}class Ft{constructor(){this._xhr=t_(),this._requestURL=""}static get IsCustomRequestAvailable(){return Object.keys(Ft.CustomRequestHeaders).length>0||Ft.CustomRequestModifiers.length>0}get requestURL(){return this._requestURL}_injectCustomRequestHeaders(){if(!this._shouldSkipRequestModifications(this._requestURL))for(const e in Ft.CustomRequestHeaders){const t=Ft.CustomRequestHeaders[e];t&&this._xhr.setRequestHeader(e,t)}}_shouldSkipRequestModifications(e){return Ft.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){Ft.CustomRequestHeaders&&this._injectCustomRequestHeaders(),this._xhr.send(e)}open(e,t){for(const i of Ft.CustomRequestModifiers){if(this._shouldSkipRequestModifications(t))return;i(this._xhr,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)}}Ft.CustomRequestHeaders={};Ft.CustomRequestModifiers=new Array;Ft.SkipRequestModificationForBabylonCDN=!0;class Cn{}Cn.FilesToLoad={};class i_{static ExponentialBackoff(e=3,t=500){return(i,s,n)=>s.status!==0||n>=e||i.indexOf("file:")!==-1?-1:Math.pow(2,n)*t}}class hn extends Error{}hn._setPrototypeOf=Object.setPrototypeOf||((a,e)=>(a.__proto__=e,a));const Hs={MeshInvalidPositionsError:0,SceneLoaderError:3e3,LoadFileError:4e3,RequestFileError:4001,ReadFileError:4002};class cs extends hn{constructor(e,t,i){super(e),this.errorCode=t,this.innerError=i,this.name="RuntimeError",hn._setPrototypeOf(this,cs.prototype)}}const sc=a=>{const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let t="",i,s,n,r,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,n=c<u.length?u[c++]:Number.NaN,r=i>>2,o=(i&3)<<4|s>>4,h=(s&15)<<2|n>>6,l=n&63,isNaN(s)?h=l=64:isNaN(n)&&(l=64),t+=e.charAt(r)+e.charAt(o)+e.charAt(h)+e.charAt(l);return t},nc=a=>atob(a),s_=a=>{const e=nc(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};class Bn{static SetImmediate(e){St()&&window.setImmediate?window.setImmediate(e):setTimeout(e,1)}}const rc=new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i);class Er extends cs{constructor(e,t){super(e,Hs.LoadFileError),this.name="LoadFileError",hn._setPrototypeOf(this,Er.prototype),t instanceof Ft?this.request=t:this.file=t}}class Cr extends cs{constructor(e,t){super(e,Hs.RequestFileError),this.request=t,this.name="RequestFileError",hn._setPrototypeOf(this,Cr.prototype)}}class m0 extends cs{constructor(e,t){super(e,Hs.ReadFileError),this.file=t,this.name="ReadFileError",hn._setPrototypeOf(this,m0.prototype)}}const n_=a=>(a=a.replace(/#/gm,"%23"),a),ut={DefaultRetryStrategy:i_.ExponentialBackoff(),BaseUrl:"",CorsBehavior:"anonymous",PreprocessUrl:a=>a,ScriptBaseUrl:"",ScriptPreprocessUrl:a=>a,CleanUrl:n_},v0=(a,e)=>{if(!(a&&a.indexOf("data:")===0)&&ut.CorsBehavior)if(typeof ut.CorsBehavior=="string"||ut.CorsBehavior instanceof String)e.crossOrigin=ut.CorsBehavior;else{const t=ut.CorsBehavior(a);t&&(e.crossOrigin=t)}},b0=(a,e,t,i,s="",n)=>{const r=Ee.LastCreatedEngine;if(typeof HTMLImageElement>"u"&&!(r!=null&&r._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:".concat(s,";base64,")+sc(a):a instanceof Blob?(o=URL.createObjectURL(a),h=!0):(o=ut.CleanUrl(a),o=ut.PreprocessUrl(o));const l=x=>{if(t){const y=o||a.toString();t("Error while trying to load image: ".concat(y.indexOf("http")===0||y.length<=128?y:y.slice(0,128)+"..."),x)}};if(r!=null&&r._features.forceBitmapOverHTMLImageElement)return Ts(o,x=>{r.createImageBitmap(new Blob([x],{type:s}),{premultiplyAlpha:"none",...n}).then(y=>{e(y),h&&URL.revokeObjectURL(o)}).catch(y=>{t&&t("Error while trying to load image: "+a,y)})},void 0,i||void 0,!0,(x,y)=>{l(y)}),null;const c=new Image;v0(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},_=()=>{d(),e(c),h&&c.src&&URL.revokeObjectURL(c.src)},p=x=>{d(),l(x),h&&c.src&&URL.revokeObjectURL(c.src)},g=x=>{if(x.blockedURI!==c.src||x.disposition==="report")return;d();const y=new Error("CSP violation of policy ".concat(x.effectiveDirective," ").concat(x.blockedURI,". Current policy is ").concat(x.originalPolicy));Ee.UseFallbackTexture=!1,l(y),h&&c.src&&URL.revokeObjectURL(c.src),c.src=""};u.push({target:c,name:"load",handler:_}),u.push({target:c,name:"error",handler:p}),u.push({target:document,name:"securitypolicyviolation",handler:g}),f();const m=o.substring(0,5)==="blob:",b=o.substring(0,5)==="data:",I=()=>{m||b||!Ft.IsCustomRequestAvailable?c.src=o:Ts(o,(x,y,R)=>{const E=!s&&R?R:s,C=new Blob([x],{type:E}),S=URL.createObjectURL(C);h=!0,c.src=S},void 0,i||void 0,!0,(x,y)=>{l(y)})},T=()=>{i&&i.loadImage(o,c)};if(!m&&!b&&i&&i.enableTexturesOffline)i.open(T,I);else{if(o.indexOf("file:")!==-1){const x=decodeURIComponent(o.substring(5).toLowerCase());if(Cn.FilesToLoad[x]&&typeof URL<"u"){try{let y;try{y=URL.createObjectURL(Cn.FilesToLoad[x])}catch{y=URL.createObjectURL(Cn.FilesToLoad[x])}c.src=y,h=!0}catch{c.src=""}return c}}I()}return c},Ln=(a,e,t,i,s)=>{const n=new FileReader,r={onCompleteObservable:new Z,abort:()=>n.abort()};return n.onloadend=()=>r.onCompleteObservable.notifyObservers(r),s&&(n.onerror=()=>{s(new m0("Unable to read ".concat(a.name),a))}),n.onload=o=>{e(o.target.result)},t&&(n.onprogress=t),i?n.readAsArrayBuffer(a):n.readAsText(a),r},Ts=(a,e,t,i,s,n,r)=>{if(a.name)return Ln(a,e,t,s,n?c=>{n(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=Cn.FilesToLoad[c];if(u)return Ln(u,e,t,s,n?f=>n(void 0,new Er(f.message,f.file)):void 0)}const{match:h,type:l}=r_(o);if(h){const c={onCompleteObservable:new Z,abort:()=>()=>{}};try{const u=s?T0(o):oc(o);e(u,void 0,l)}catch(u){n?n(void 0,u):U.Error(u.message||"Failed to parse the Data URL")}return Bn.SetImmediate(()=>{c.onCompleteObservable.notifyObservers(c)}),c}return x0(o,(c,u)=>{e(c,u==null?void 0:u.responseURL,u==null?void 0:u.getResponseHeader("content-type"))},t,i,s,n?c=>{n(c.request,new Er(c.message,c.request))}:void 0,r)},x0=(a,e,t,i,s,n,r)=>{a=ut.CleanUrl(a),a=ut.PreprocessUrl(a);const o=ut.BaseUrl+a;let h=!1;const l={onCompleteObservable:new Z,abort:()=>h=!0},c=()=>{let u=new Ft,f=null,d;const _=()=>{u&&(t&&u.removeEventListener("progress",t),d&&u.removeEventListener("readystatechange",d),u.removeEventListener("loadend",p))};let p=()=>{_(),l.onCompleteObservable.notifyObservers(l),l.onCompleteObservable.clear(),t=void 0,d=null,p=null,n=void 0,r=void 0,e=void 0};l.abort=()=>{h=!0,p&&p(),u&&u.readyState!==(XMLHttpRequest.DONE||4)&&u.abort(),f!==null&&(clearTimeout(f),f=null),u=null};const g=b=>{const I=b.message||"Unknown error";n&&u?n(new Cr(I,u)):U.Error(I)},m=b=>{if(u){if(u.open("GET",o),r)try{r(u)}catch(I){g(I);return}s&&(u.responseType="arraybuffer"),t&&u.addEventListener("progress",t),p&&u.addEventListener("loadend",p),d=()=>{if(!(h||!u)&&u.readyState===(XMLHttpRequest.DONE||4)){if(d&&u.removeEventListener("readystatechange",d),u.status>=200&&u.status<300||u.status===0&&(!St()||ac())){try{e&&e(s?u.response:u.responseText,u)}catch(x){g(x)}return}const I=ut.DefaultRetryStrategy;if(I){const x=I(o,u,b);if(x!==-1){_(),u=new Ft,f=setTimeout(()=>m(b+1),x);return}}const T=new Cr("Error status: "+u.status+" "+u.statusText+" - Unable to load "+o,u);n&&n(T)}},u.addEventListener("readystatechange",d),u.send()}};m(0)};if(i&&i.enableSceneOffline){const u=d=>{d&&d.status>400?n&&n(d):c()},f=()=>{i&&i.loadFile(ut.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},ac=()=>typeof location<"u"&&location.protocol==="file:",y0=a=>rc.test(a),r_=a=>{const e=rc.exec(a);return e===null||e.length===0?{match:!1,type:""}:{match:!0,type:e[0].replace("data:","").replace("base64,","")}};function T0(a){return s_(a.split(",")[1])}const oc=a=>nc(a.split(",")[1]),a_=()=>{ae._FileToolsLoadImage=b0,xr.loadFile=Ts,zl.loadFile=Ts};a_();let bn;const o_=(a,e,t,i,s,n,r,o,h,l)=>{bn={DecodeBase64UrlToBinary:a,DecodeBase64UrlToString:e,DefaultRetryStrategy:t.DefaultRetryStrategy,BaseUrl:t.BaseUrl,CorsBehavior:t.CorsBehavior,PreprocessUrl:t.PreprocessUrl,IsBase64DataUrl:i,IsFileURL:s,LoadFile:n,LoadImage:r,ReadFile:o,RequestFile:h,SetCorsBehavior:l},Object.defineProperty(bn,"DefaultRetryStrategy",{get:function(){return t.DefaultRetryStrategy},set:function(c){t.DefaultRetryStrategy=c}}),Object.defineProperty(bn,"BaseUrl",{get:function(){return t.BaseUrl},set:function(c){t.BaseUrl=c}}),Object.defineProperty(bn,"PreprocessUrl",{get:function(){return t.PreprocessUrl},set:function(c){t.PreprocessUrl=c}}),Object.defineProperty(bn,"CorsBehavior",{get:function(){return t.CorsBehavior},set:function(c){t.CorsBehavior=c}})};o_(T0,oc,ut,y0,ac,Ts,b0,Ln,x0,v0);class A0{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==null?void 0: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=hi.Zero(),this._cachedBaseSize=hi.Zero(),this._initialSamplingMode=2,this._texture=A0._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)}releaseInternalTexture(){this._texture&&(this._texture.dispose(),this._texture=null)}dispose(){this._texture&&(this.releaseInternalTexture(),this._engine=null)}}class ws{static Eval(e,t){return e.match(/\([^()]*\)/g)?e=e.replace(/\([^()]*\)/g,i=>(i=i.slice(1,i.length-1),ws._HandleParenthesisContent(i,t))):e=ws._HandleParenthesisContent(e,t),e==="true"?!0:e==="false"?!1:ws.Eval(e,t)}static _HandleParenthesisContent(e,t){t=t||(n=>n==="true");let i;const s=e.split("||");for(const n in s)if(Object.prototype.hasOwnProperty.call(s,n)){let r=ws._SimplifyNegation(s[n].trim());const o=r.split("&&");if(o.length>1)for(let h=0;h<o.length;++h){const l=ws._SimplifyNegation(o[h].trim());if(l!=="true"&&l!=="false"?l[0]==="!"?i=!t(l.substring(1)):i=t(l):i=l==="true",!i){r="false";break}}if(i||r==="true"){i=!0;break}r!=="true"&&r!=="false"?r[0]==="!"?i=!t(r.substring(1)):i=t(r):i=r==="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 ke{static EnableFor(e){e._tags=e._tags||{},e.hasTags=()=>ke.HasTags(e),e.addTags=t=>ke.AddTagsTo(e,t),e.removeTags=t=>ke.RemoveTagsFrom(e,t),e.matchesTagsQuery=t=>ke.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){ke._AddTagTo(e,s)})}static _AddTagTo(e,t){t=t.trim(),!(t===""||t==="true"||t==="false")&&(t.match(/[\s]/)||t.match(/^([!]|([|]|[&]){2})/)||(ke.EnableFor(e),e._tags[t]=!0))}static RemoveTagsFrom(e,t){if(!ke.HasTags(e))return;const i=t.split(" ");for(const s in i)ke._RemoveTagFrom(e,i[s])}static _RemoveTagFrom(e,t){delete e._tags[t]}static MatchesQuery(e,t){return t===void 0?!0:t===""?ke.HasTags(e):ws.Eval(t,i=>ke.HasTags(e)&&e._tags[i])}}const No=function(a,e,t,i={}){const s=a();ke&&ke.HasTags(e)&&ke.AddTagsTo(s,ke.GetTags(e,!0));const n=La(s),r={};for(const o in n){const h=n[o],l=e[o],c=h.type;if(l!=null&&(o!=="uniqueId"||Ae.AllowLoadingUniqueId))switch(c){case 0:case 6:case 11:s[o]=l;break;case 1:i.cloneTexturesOnlyOnce&&r[l.uniqueId]?s[o]=r[l.uniqueId]:(s[o]=t||l.isRenderTarget?l:l.clone(),r[l.uniqueId]=s[o]);break;case 2:case 3:case 4:case 5:case 7:case 10:case 12:s[o]=t?l:l.clone();break}}return s};class Ae{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={}),ke&&(t.tags=ke.GetTags(e));const i=La(e);for(const s in i){const n=i[s],r=n.sourceName||s,o=n.type,h=e[s];if(h!=null&&(s!=="uniqueId"||Ae.AllowLoadingUniqueId))switch(o){case 0:t[r]=h;break;case 1:t[r]=h.serialize();break;case 2:t[r]=h.asArray();break;case 3:t[r]=h.serialize();break;case 4:t[r]=h.asArray();break;case 5:t[r]=h.asArray();break;case 6:t[r]=h.id;break;case 7:t[r]=h.serialize();break;case 8:t[r]=h.asArray();break;case 9:t[r]=h.serialize();break;case 10:t[r]=h.asArray();break;case 11:t[r]=h.id;break;case 12:t[r]=h.asArray();break}}return t}static ParseProperties(e,t,i,s){s||(s="");const n=La(t);for(const r in n){const o=n[r],h=e[o.sourceName||r],l=o.type;if(h!=null&&(r!=="uniqueId"||Ae.AllowLoadingUniqueId)){const c=t;switch(l){case 0:c[r]=h;break;case 1:i&&(c[r]=Ae._TextureParser(h,i,s));break;case 2:c[r]=de.FromArray(h);break;case 3:c[r]=Ae._FresnelParametersParser(h);break;case 4:c[r]=oe.FromArray(h);break;case 5:c[r]=v.FromArray(h);break;case 6:i&&(c[r]=i.getLastMeshById(h));break;case 7:c[r]=Ae._ColorCurvesParser(h);break;case 8:c[r]=H.FromArray(h);break;case 9:c[r]=Ae._ImageProcessingConfigurationParser(h);break;case 10:c[r]=re.FromArray(h);break;case 11:i&&(c[r]=i.getCameraById(h));break;case 12:c[r]=O.FromArray(h);break}}}}static Parse(e,t,i,s=null){const n=e();return ke&&ke.AddTagsTo(n,t.tags),Ae.ParseProperties(t,n,i,s),n}static Clone(e,t,i={}){return No(e,t,!1,i)}static Instanciate(e,t){return No(e,t,!0)}}Ae.AllowLoadingUniqueId=!1;Ae._ImageProcessingConfigurationParser=a=>{throw ye("ImageProcessingConfiguration")};Ae._FresnelParametersParser=a=>{throw ye("FresnelParameters")};Ae._ColorCurvesParser=a=>{throw ye("ColorCurves")};Ae._TextureParser=(a,e,t)=>{throw ye("Texture")};class st extends A0{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){var t;if(this._texture){if(this._texture._gammaSpace===e)return;this._texture._gammaSpace=e}else{if(this._gammaSpace===e)return;this._gammaSpace=e}(t=this.getScene())==null||t.markAllMaterialsAsDirty(1,i=>i.hasTexture(this))}get isRGBD(){return this._texture!=null&&this._texture._isRGBD}set isRGBD(e){var t;e!==this.isRGBD&&(this._texture&&(this._texture._isRGBD=e),(t=this.getScene())==null||t.markAllMaterialsAsDirty(1,i=>i.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=g0()),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=st.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 Z,this._onDisposeObserver=null,this._scene=null,this._uid=null,this._parentContainer=null,this._loadingError=!1,e?st._IsScene(e)?this._scene=e:this._engine=e:this._scene=Ee.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 O.IdentityReadOnly}getReflectionTextureMatrix(){return O.IdentityReadOnly}getRefractionTextureMatrix(){return this.getReflectionTextureMatrix()}isReadyOrNotBlocking(){return!this.isBlocking||this.isReady()||this.loadingError}scale(e){}get canRescale(){return!1}_getFromCache(e,t,i,s,n,r){const o=this._getEngine();if(!o)return null;const h=o._getUseSRGBBuffer(!!n,t),l=o.getLoadedTexturesCache();for(let c=0;c<l.length;c++){const u=l[c];if((n===void 0||h===u._useSRGBBuffer)&&(s===void 0||s===u.invertY)&&u.url===e&&u.generateMipMaps===!t&&(!i||i===u.samplingMode)&&(r===void 0||r===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,n=!1,r=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,n,r,o):c._readTexturePixels(this._texture,h,l,-1,t,i,s,n,r,o)}catch{return null}}_readPixelsSync(e=0,t=0,i=null,s=!0,n=!1){if(!this._texture)return null;const r=this.getSize();let o=r.width,h=r.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,n):l._readTexturePixelsSync(this._texture,o,h,-1,t,i,s,n)}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=Ae.Serialize(this);return Ae.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 n=e[s];if(n.isReady())--i===0&&t();else{const r=n.onLoadObservable;r?r.addOnce(()=>{--i===0&&t()}):--i===0&&t()}}}static _IsScene(e){return e.getClassName()==="Scene"}}st.DEFAULT_ANISOTROPIC_FILTERING_LEVEL=4;D([B()],st.prototype,"uniqueId",void 0);D([B()],st.prototype,"name",void 0);D([B()],st.prototype,"displayName",void 0);D([B()],st.prototype,"metadata",void 0);D([B("hasAlpha")],st.prototype,"_hasAlpha",void 0);D([B("getAlphaFromRGB")],st.prototype,"_getAlphaFromRGB",void 0);D([B()],st.prototype,"level",void 0);D([B("coordinatesIndex")],st.prototype,"_coordinatesIndex",void 0);D([B()],st.prototype,"optimizeUVAllocation",void 0);D([B("coordinatesMode")],st.prototype,"_coordinatesMode",void 0);D([B()],st.prototype,"wrapU",null);D([B()],st.prototype,"wrapV",null);D([B()],st.prototype,"wrapR",void 0);D([B()],st.prototype,"anisotropicFilteringLevel",void 0);D([B()],st.prototype,"isCube",null);D([B()],st.prototype,"is3D",null);D([B()],st.prototype,"is2DArray",null);D([B()],st.prototype,"gammaSpace",null);D([B()],st.prototype,"invertZ",void 0);D([B()],st.prototype,"lodLevelInAlpha",void 0);D([B()],st.prototype,"lodGenerationOffset",null);D([B()],st.prototype,"lodGenerationScale",null);D([B()],st.prototype,"linearSpecularLOD",null);D([_i()],st.prototype,"irradianceTexture",null);D([B()],st.prototype,"isRenderTarget",void 0);we.prototype.createPrefilteredCubeTexture=function(a,e,t,i,s=null,n=null,r,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 On,u._source=9,this.getCaps().textureLOD){s&&s(u);return}const f=3,d=this._gl,_=c.width;if(!_)return;const{DDSTools:p}=await Oe(async()=>{const{DDSTools:m}=await import("./dds-C4nWUSlI.js");return{DDSTools:m}},__vite__mapDeps([1,2,3,4,5,6,7,8,9,10])),g=[];for(let m=0;m<f;m++){const I=1-m/(f-1),T=i,x=Math.log2(_)*t+i,y=T+(x-T)*I,R=Math.round(Math.min(Math.max(y,0),x)),E=new ft(this,2);if(E.type=u.type,E.format=u.format,E.width=Math.pow(2,Math.max(Math.log2(_)-R,0)),E.height=E.width,E.isCube=!0,E._cachedWrapU=0,E._cachedWrapV=0,this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,E,!0),E.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 S=c.info,w=c.data;this._unpackFlipY(S.isCompressed),p.UploadDDSLevels(this,E,w,S,!0,6,R)}else U.Warn("DDS is the only prefiltered cube map supported so far.");this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,null);const C=new st(e);C._isCube=!0,C._texture=E,E.isReady=!0,g.push(C)}u._lodTextureHigh=g[2],u._lodTextureMid=g[1],u._lodTextureLow=g[0],s&&s(u)};return this.createCubeTexture(a,e,null,!1,l,n,r,o,h,t,i)};we.prototype.createUniformBuffer=function(a,e){const t=this._gl.createBuffer();if(!t)throw new Error("Unable to create uniform buffer");const i=new Pn(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};we.prototype.createDynamicUniformBuffer=function(a,e){const t=this._gl.createBuffer();if(!t)throw new Error("Unable to create dynamic uniform buffer");const i=new Pn(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};we.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)};we.prototype.bindUniformBuffer=function(a){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,a?a.underlyingResource:null)};we.prototype.bindUniformBufferBase=function(a,e,t){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,e,a?a.underlyingResource:null)};we.prototype.bindUniformBlock=function(a,e,t){const i=a.program,s=this._gl.getUniformBlockIndex(i,e);s!==4294967295&&this._gl.uniformBlockBinding(i,s,t)};ae.prototype.displayLoadingUI=function(){if(!St())return;const a=this.loadingScreen;a&&a.displayLoadingUI()};ae.prototype.hideLoadingUI=function(){if(!St())return;const a=this._loadingScreen;a&&a.hideLoadingUI()};Object.defineProperty(ae.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&this._renderingCanvas&&(this._loadingScreen=ae.DefaultLoadingScreenFactory(this._renderingCanvas)),this._loadingScreen},set:function(a){this._loadingScreen=a},enumerable:!0,configurable:!0});Object.defineProperty(ae.prototype,"loadingUIText",{set:function(a){this.loadingScreen.loadingUIText=a},enumerable:!0,configurable:!0});Object.defineProperty(ae.prototype,"loadingUIBackgroundColor",{set:function(a){this.loadingScreen.loadingUIBackgroundColor=a},enumerable:!0,configurable:!0});ae.prototype.getInputElement=function(){return this._renderingCanvas};ae.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null};ae.prototype.getInputElementClientRect=function(){return this._renderingCanvas?this.getInputElement().getBoundingClientRect():null};ae.prototype.getAspectRatio=function(a,e=!1){const t=a.viewport;return this.getRenderWidth(e)*t.width/(this.getRenderHeight(e)*t.height)};ae.prototype.getScreenAspectRatio=function(){return this.getRenderWidth(!0)/this.getRenderHeight(!0)};ae.prototype._verifyPointerLock=function(){var a;(a=this._onPointerLockChange)==null||a.call(this)};ae.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}};ae.prototype.getInputElement=function(){return this._renderingCanvas};ae.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc};ae.prototype.setDepthFunction=function(a){this._depthCullingState.depthFunc=a};ae.prototype.setDepthFunctionToGreater=function(){this.setDepthFunction(516)};ae.prototype.setDepthFunctionToGreaterOrEqual=function(){this.setDepthFunction(518)};ae.prototype.setDepthFunctionToLess=function(){this.setDepthFunction(513)};ae.prototype.setDepthFunctionToLessOrEqual=function(){this.setDepthFunction(515)};ae.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask};ae.prototype.setDepthWrite=function(a){this._depthCullingState.depthMask=a};ae.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest};ae.prototype.setStencilBuffer=function(a){this._stencilState.stencilTest=a};ae.prototype.getStencilMask=function(){return this._stencilState.stencilMask};ae.prototype.setStencilMask=function(a){this._stencilState.stencilMask=a};ae.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc};ae.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef};ae.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask};ae.prototype.setStencilFunction=function(a){this._stencilState.stencilFunc=a};ae.prototype.setStencilFunctionReference=function(a){this._stencilState.stencilFuncRef=a};ae.prototype.setStencilFunctionMask=function(a){this._stencilState.stencilFuncMask=a};ae.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail};ae.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail};ae.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass};ae.prototype.setStencilOperationFail=function(a){this._stencilState.stencilOpStencilFail=a};ae.prototype.setStencilOperationDepthFail=function(a){this._stencilState.stencilOpDepthFail=a};ae.prototype.setStencilOperationPass=function(a){this._stencilState.stencilOpStencilDepthPass=a};ae.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()};ae.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)};ae.prototype.setAlphaConstants=function(a,e,t,i){this._alphaState.setAlphaBlendConstants(a,e,t,i)};ae.prototype.getAlphaMode=function(){return this._alphaMode};ae.prototype.getAlphaEquation=function(){return this._alphaEquation};ae.prototype.getRenderPassNames=function(){return this._renderPassNames};ae.prototype.getCurrentRenderPassName=function(){return this._renderPassNames[this.currentRenderPassId]};ae.prototype.createRenderPassId=function(a){const e=++ae._RenderPassIdCounter;return this._renderPassNames[e]=a!=null?a:"NONAME",e};ae.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 n=0;n<s.subMeshes.length;++n)s.subMeshes[n]._removeDrawWrapper(a)}}};function h_(a){!a||!a.setAttribute||(a.setAttribute("touch-action","none"),a.style.touchAction="none",a.style.webkitTapHighlightColor="transparent")}function hc(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||h_(e),!ae.audioEngine&&t.audioEngine&&ae.AudioEngineFactory&&(ae.audioEngine=ae.AudioEngineFactory(a.getRenderingCanvas(),a.getAudioContext(),a.getAudioDestination())),En()&&(a._onFullscreenChange=()=>{a.isFullscreen=!!document.fullscreenElement,a.isFullscreen&&a._pointerLockRequested&&e&&R0(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=ae.OfflineProviderFactory!==void 0,a._deterministicLockstep=!!t.deterministicLockstep,a._lockstepMaxSteps=t.lockstepMaxSteps||0,a._timeStep=t.timeStep||1/60}function lc(a,e){Ee.Instances.length===1&&ae.audioEngine&&(ae.audioEngine.dispose(),ae.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)),En()&&(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 cc(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,n=0;try{n=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:n,descent:n-s}}function uc(a,e,t){return new Promise((s,n)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{a.createImageBitmap(r,t).then(o=>{s(o)})})},r.onerror=()=>{n("Error loading image ".concat(r.src))},r.src=e})}function fc(a,e,t,i){const n=a.createCanvas(t,i).getContext("2d");if(!n)throw new Error("Unable to get 2d context for resizeImageBitmap");return n.drawImage(e,0,0),n.getImageData(0,0,t,i).data}function dc(a){const e=a.requestFullscreen||a.webkitRequestFullscreen;e&&e.call(a)}function _c(){const a=document;document.exitFullscreen?document.exitFullscreen():a.webkitCancelFullScreen&&a.webkitCancelFullScreen()}function R0(a){if(a.requestPointerLock){const e=a.requestPointerLock();e instanceof Promise?e.then(()=>{a.focus()}).catch(()=>{}):a.focus()}}function pc(){document.exitPointerLock&&document.exitPointerLock()}class ui{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){ui.Enabled&&(this._current+=e,t&&this._fetchResult())}beginMonitoring(){ui.Enabled&&(this._startMonitoringTime=bi.Now)}endMonitoring(e=!0){if(!ui.Enabled)return;e&&this.fetchNewFrame();const t=bi.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=bi.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)}}ui.Enabled=!0;ae.AudioEngineFactory=(a,e,t)=>new l_(a,e,t);class l_{get audioContext(){return this._audioContextInitialized||this._initializeAudioContext(),this._audioContext}constructor(e=null,t=null,i=null){if(this._audioContext=null,this._audioContextInitialized=!1,this._muteButton=null,this._audioDestination=null,this.canUseWebAudio=!1,this.WarnedWebAudioUnsupported=!1,this.isMP3supported=!1,this.isOGGsupported=!1,this.unlocked=!1,this.useCustomUnlockedButton=!1,this.onAudioUnlockedObservable=new Z,this.onAudioLockedObservable=new Z,this._tryToRun=!1,this._onResize=()=>{this._moveButtonToTopLeft()},!St())return;typeof window.AudioContext<"u"&&(this.canUseWebAudio=!0);const s=document.createElement("audio");this._hostElement=e,this._audioContext=t,this._audioDestination=i;try{s&&s.canPlayType&&(s.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/,"")||s.canPlayType("audio/mp3").replace(/^no$/,""))&&(this.isMP3supported=!0)}catch{}try{s&&s.canPlayType&&s.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.isOGGsupported=!0)}catch{}}lock(){this._triggerSuspendedState()}unlock(){var e,t;if(((e=this._audioContext)==null?void 0:e.state)==="running"){this._hideMuteButton(),this.unlocked||(this.unlocked=!0,this.onAudioUnlockedObservable.notifyObservers(this));return}this._tryToRun?(t=this._audioContext)==null||t.suspend().then(()=>{this._tryToRun=!1,this._triggerRunningState()}):this._triggerRunningState()}_resumeAudioContextOnStateChange(){var e;(e=this._audioContext)==null||e.addEventListener("statechange",()=>{var t;this.unlocked&&((t=this._audioContext)==null?void 0:t.state)!=="running"&&this._resumeAudioContext()},{once:!0,passive:!0,signal:AbortSignal.timeout(3e3)})}_resumeAudioContext(){var e;return(e=this._audioContext)!=null&&e.resume?this._audioContext.resume():Promise.resolve()}_initializeAudioContext(){try{this.canUseWebAudio&&(this._audioContext||(this._audioContext=new AudioContext),this.masterGain=this._audioContext.createGain(),this.masterGain.gain.value=1,this._audioDestination||(this._audioDestination=this._audioContext.destination),this.masterGain.connect(this._audioDestination),this._audioContextInitialized=!0,this._audioContext.state==="running"&&this._triggerRunningState())}catch(e){this.canUseWebAudio=!1,U.Error("Web Audio: "+e.message)}}_triggerRunningState(){this._tryToRun||(this._tryToRun=!0,this._resumeAudioContext().then(()=>{this._tryToRun=!1,this._muteButton&&this._hideMuteButton(),this.unlocked=!0,this.onAudioUnlockedObservable.notifyObservers(this)}).catch(()=>{this._tryToRun=!1,this.unlocked=!1}))}_triggerSuspendedState(){this.unlocked=!1,this.onAudioLockedObservable.notifyObservers(this),this._displayMuteButton()}_displayMuteButton(){if(this.useCustomUnlockedButton||this._muteButton)return;this._muteButton=document.createElement("BUTTON"),this._muteButton.className="babylonUnmuteIcon",this._muteButton.id="babylonUnmuteIconBtn",this._muteButton.title="Unmute";const t=".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url("+(window.SVGSVGElement?"data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2239%22%20height%3D%2232%22%20viewBox%3D%220%200%2039%2032%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M9.625%2018.938l-0.031%200.016h-4.953q-0.016%200-0.031-0.016v-12.453q0-0.016%200.031-0.016h4.953q0.031%200%200.031%200.016v12.453zM12.125%207.688l8.719-8.703v27.453l-8.719-8.719-0.016-0.047v-9.938zM23.359%207.875l1.406-1.406%204.219%204.203%204.203-4.203%201.422%201.406-4.219%204.219%204.219%204.203-1.484%201.359-4.141-4.156-4.219%204.219-1.406-1.422%204.219-4.203z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E":"https://cdn.babylonjs.com/Assets/audio.png")+"); background-size: 80%; background-repeat:no-repeat; background-position: center; background-position-y: 4px; border: none; outline: none; transition: transform 0.125s ease-out; cursor: pointer; z-index: 9999; } .babylonUnmuteIcon:hover { transform: scale(1.05) } .babylonUnmuteIcon:active { background-color: rgba(51,51,51,1) }",i=document.createElement("style");i.appendChild(document.createTextNode(t)),document.getElementsByTagName("head")[0].appendChild(i),document.body.appendChild(this._muteButton),this._moveButtonToTopLeft(),this._muteButton.addEventListener("touchend",()=>{this._triggerRunningState()},!0),this._muteButton.addEventListener("click",()=>{this.unlock()},!0),window.addEventListener("resize",this._onResize)}_moveButtonToTopLeft(){this._hostElement&&this._muteButton&&(this._muteButton.style.top=this._hostElement.offsetTop+20+"px",this._muteButton.style.left=this._hostElement.offsetLeft+20+"px")}_hideMuteButton(){this._muteButton&&(document.body.removeChild(this._muteButton),this._muteButton=null)}dispose(){this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser&&this._audioContext&&(this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser.dispose(),this.masterGain.disconnect(),this.masterGain.connect(this._audioContext.destination),this._connectedAnalyser=null),this.masterGain.gain.value=1),this.WarnedWebAudioUnsupported=!1,this._hideMuteButton(),window.removeEventListener("resize",this._onResize),this.onAudioUnlockedObservable.clear(),this.onAudioLockedObservable.clear()}getGlobalVolume(){return this.canUseWebAudio&&this._audioContextInitialized?this.masterGain.gain.value:-1}setGlobalVolume(e){this.canUseWebAudio&&this._audioContextInitialized&&(this.masterGain.gain.value=e)}connectToAnalyser(e){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this.canUseWebAudio&&this._audioContextInitialized&&this._audioContext&&(this._connectedAnalyser=e,this.masterGain.disconnect(),this._connectedAnalyser.connectAudioNodes(this.masterGain,this._audioContext.destination))}}class le extends we{static get NpmPackage(){return ae.NpmPackage}static get Version(){return ae.Version}static get Instances(){return Ee.Instances}static get LastCreatedEngine(){return Ee.LastCreatedEngine}static get LastCreatedScene(){return Ee.LastCreatedScene}static DefaultLoadingScreenFactory(e){return ae.DefaultLoadingScreenFactory(e)}get _supportsHardwareTextureRescaling(){return!!le._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){if(super(e,t,i,s),this.customAnimationFrameRequester=null,this._performanceMonitor=new Yl,this._drawCalls=new ui,!!e&&(this._features.supportRenderPasses=!0,i=this._creationOptions,e.getContext)){const n=e;this._sharedInit(n)}}_initGLContext(){super._initGLContext(),this._rescalePostProcess=null}_sharedInit(e){super._sharedInit(e),hc(this,e,this._creationOptions)}resizeImageBitmap(e,t,i){return fc(this,e,t,i)}_createImageBitmapFromSource(e,t){return uc(this,e,t)}switchFullscreen(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)}enterFullscreen(e){this.isFullscreen||(this._pointerLockRequested=e,this._renderingCanvas&&dc(this._renderingCanvas))}exitFullscreen(){this.isFullscreen&&_c()}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 n=this._cachedViewport;return this._cachedViewport=null,this._viewport(e,t,i,s),n}scissorClear(e,t,i,s,n){this.enableScissor(e,t,i,s),this.clear(n,!0,!0,!0),this.disableScissor()}enableScissor(e,t,i,s){const n=this._gl;n.enable(n.SCISSOR_TEST),n.scissor(e,t,i,s)}disableScissor(){const e=this._gl;e.disable(e.SCISSOR_TEST)}_loadFileAsync(e,t,i){return new Promise((s,n)=>{this._loadFile(e,r=>{s(r)},void 0,t,i,(r,o)=>{n(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 cc(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(){if(this._frameHandler=0,!this._contextWasLost){let e=!0;(this.isDisposed||!this.renderEvenInBackground&&this._windowIsBackground)&&(e=!1),e&&(this.beginFrame(),this._renderViews()||this._renderFrame(),this.endFrame())}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&&R0(this._renderingCanvas)}exitPointerlock(){pc()}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,n,r=null){n=n||this._gl,this.onBeforeShaderCompilationObservable.notifyObservers(this);const o=super.createShaderProgram(e,t,i,s,n,r);return this.onAfterShaderCompilationObservable.notifyObservers(this),o}_createShaderProgram(e,t,i,s,n=null){const r=s.createProgram();if(e.program=r,!r)throw new Error("Unable to create program");if(s.attachShader(r,t),s.attachShader(r,i),this.webGLVersion>1&&n){const o=this.createTransformFeedback();this.bindTransformFeedback(o),this.setTranformFeedbackVaryings(r,n),e.transformFeedback=o}return s.linkProgram(r),this.webGLVersion>1&&n&&this.bindTransformFeedback(null),e.context=s,e.vertexShader=t,e.fragmentShader=i,e.isParallelCompiled||this._finalizePipelineContext(e),r}_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,n){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 r=this.createRenderTargetTexture({width:t.width,height:t.height},{generateMipMaps:!1,type:0,samplingMode:2,generateDepthBuffer:!1,generateStencilBuffer:!1});if(!this._rescalePostProcess&&le._RescalePostProcessFactory&&(this._rescalePostProcess=le._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],r,!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(r),r.dispose(),n&&n()},h=this._rescalePostProcess.getEffect();h?h.executeWhenCompiled(o):this._rescalePostProcess.onEffectCreatedObservable.addOnce(l=>{l.executeWhenCompiled(o)})}}wrapWebGLTexture(e,t=!1,i=3,s=0,n=0){const r=new Xl(e,this._gl),o=new ft(this,0,!0);return o._hardwareTexture=r,o.baseWidth=s,o.baseHeight=n,o.width=s,o.height=n,o.isReady=!0,o.useMipMaps=t,this.updateTextureSamplingMode(i,o),o}_uploadImageToTexture(e,t,i=0,s=0){const n=this._gl,r=this._getWebGLTextureType(e.type),o=this._getInternalFormat(e.format),h=this._getRGBABufferInternalSizedFormat(e.type,o),l=e.isCube?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D;this._bindTextureDirectly(l,e,!0),this._unpackFlipY(e.invertY);let c=n.TEXTURE_2D;e.isCube&&(c=n.TEXTURE_CUBE_MAP_POSITIVE_X+i),n.texImage2D(c,s,h,o,r,t),this._bindTextureDirectly(l,null,!0)}updateTextureComparisonFunction(e,t){if(this.webGLVersion===1){U.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 Pn(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((n,r)=>{const o=()=>{const h=s.clientWaitSync(e,t,0);if(h==s.WAIT_FAILED){r();return}if(h==s.TIMEOUT_EXPIRED){setTimeout(o,i);return}n()};o()})}_readPixelsAsync(e,t,i,s,n,r,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,n,r,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(),lc(this,this._renderingCanvas),super.dispose()}}le.ALPHA_DISABLE=0;le.ALPHA_ADD=1;le.ALPHA_COMBINE=2;le.ALPHA_SUBTRACT=3;le.ALPHA_MULTIPLY=4;le.ALPHA_MAXIMIZED=5;le.ALPHA_ONEONE=6;le.ALPHA_PREMULTIPLIED=7;le.ALPHA_PREMULTIPLIED_PORTERDUFF=8;le.ALPHA_INTERPOLATE=9;le.ALPHA_SCREENMODE=10;le.DELAYLOADSTATE_NONE=0;le.DELAYLOADSTATE_LOADED=1;le.DELAYLOADSTATE_LOADING=2;le.DELAYLOADSTATE_NOTLOADED=4;le.NEVER=512;le.ALWAYS=519;le.LESS=513;le.EQUAL=514;le.LEQUAL=515;le.GREATER=516;le.GEQUAL=518;le.NOTEQUAL=517;le.KEEP=7680;le.REPLACE=7681;le.INCR=7682;le.DECR=7683;le.INVERT=5386;le.INCR_WRAP=34055;le.DECR_WRAP=34056;le.TEXTURE_CLAMP_ADDRESSMODE=0;le.TEXTURE_WRAP_ADDRESSMODE=1;le.TEXTURE_MIRROR_ADDRESSMODE=2;le.TEXTUREFORMAT_ALPHA=0;le.TEXTUREFORMAT_LUMINANCE=1;le.TEXTUREFORMAT_LUMINANCE_ALPHA=2;le.TEXTUREFORMAT_RGB=4;le.TEXTUREFORMAT_RGBA=5;le.TEXTUREFORMAT_RED=6;le.TEXTUREFORMAT_R=6;le.TEXTUREFORMAT_R16_UNORM=33322;le.TEXTUREFORMAT_RG16_UNORM=33324;le.TEXTUREFORMAT_RGB16_UNORM=32852;le.TEXTUREFORMAT_RGBA16_UNORM=32859;le.TEXTUREFORMAT_R16_SNORM=36760;le.TEXTUREFORMAT_RG16_SNORM=36761;le.TEXTUREFORMAT_RGB16_SNORM=36762;le.TEXTUREFORMAT_RGBA16_SNORM=36763;le.TEXTUREFORMAT_RG=7;le.TEXTUREFORMAT_RED_INTEGER=8;le.TEXTUREFORMAT_R_INTEGER=8;le.TEXTUREFORMAT_RG_INTEGER=9;le.TEXTUREFORMAT_RGB_INTEGER=10;le.TEXTUREFORMAT_RGBA_INTEGER=11;le.TEXTURETYPE_UNSIGNED_BYTE=0;le.TEXTURETYPE_UNSIGNED_INT=0;le.TEXTURETYPE_FLOAT=1;le.TEXTURETYPE_HALF_FLOAT=2;le.TEXTURETYPE_BYTE=3;le.TEXTURETYPE_SHORT=4;le.TEXTURETYPE_UNSIGNED_SHORT=5;le.TEXTURETYPE_INT=6;le.TEXTURETYPE_UNSIGNED_INTEGER=7;le.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8;le.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9;le.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10;le.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11;le.TEXTURETYPE_UNSIGNED_INT_24_8=12;le.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13;le.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14;le.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15;le.TEXTURE_NEAREST_SAMPLINGMODE=1;le.TEXTURE_BILINEAR_SAMPLINGMODE=2;le.TEXTURE_TRILINEAR_SAMPLINGMODE=3;le.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8;le.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11;le.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3;le.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4;le.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5;le.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6;le.TEXTURE_NEAREST_LINEAR=7;le.TEXTURE_NEAREST_NEAREST=1;le.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9;le.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10;le.TEXTURE_LINEAR_LINEAR=2;le.TEXTURE_LINEAR_NEAREST=12;le.TEXTURE_EXPLICIT_MODE=0;le.TEXTURE_SPHERICAL_MODE=1;le.TEXTURE_PLANAR_MODE=2;le.TEXTURE_CUBIC_MODE=3;le.TEXTURE_PROJECTION_MODE=4;le.TEXTURE_SKYBOX_MODE=5;le.TEXTURE_INVCUBIC_MODE=6;le.TEXTURE_EQUIRECTANGULAR_MODE=7;le.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8;le.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9;le.SCALEMODE_FLOOR=1;le.SCALEMODE_NEAREST=2;le.SCALEMODE_CEILING=3;class Ve{static ComputeNumMipmapLevels(e,t){return ec(Math.max(e,t))+1}static GetTextureTypeFromFormat(e){switch(e){case"r8unorm":case"r8uint":case"rg8unorm":case"rg8uint":case"rgba8unorm":case"rgba8unorm-srgb":case"rgba8uint":case"bgra8unorm":case"bgra8unorm-srgb":case"rgb10a2uint":case"rgb10a2unorm":case"rgb9e5ufloat":case"rg11b10ufloat":case"bc7-rgba-unorm":case"bc7-rgba-unorm-srgb":case"bc6h-rgb-ufloat":case"bc5-rg-unorm":case"bc3-rgba-unorm":case"bc3-rgba-unorm-srgb":case"bc2-rgba-unorm":case"bc2-rgba-unorm-srgb":case"bc4-r-unorm":case"bc1-rgba-unorm":case"bc1-rgba-unorm-srgb":case"etc2-rgb8unorm":case"etc2-rgb8unorm-srgb":case"etc2-rgb8a1unorm":case"etc2-rgb8a1unorm-srgb":case"etc2-rgba8unorm":case"etc2-rgba8unorm-srgb":case"eac-r11unorm":case"eac-rg11unorm":case"astc-4x4-unorm":case"astc-4x4-unorm-srgb":case"astc-5x4-unorm":case"astc-5x4-unorm-srgb":case"astc-5x5-unorm":case"astc-5x5-unorm-srgb":case"astc-6x5-unorm":case"astc-6x5-unorm-srgb":case"astc-6x6-unorm":case"astc-6x6-unorm-srgb":case"astc-8x5-unorm":case"astc-8x5-unorm-srgb":case"astc-8x6-unorm":case"astc-8x6-unorm-srgb":case"astc-8x8-unorm":case"astc-8x8-unorm-srgb":case"astc-10x5-unorm":case"astc-10x5-unorm-srgb":case"astc-10x6-unorm":case"astc-10x6-unorm-srgb":case"astc-10x8-unorm":case"astc-10x8-unorm-srgb":case"astc-10x10-unorm":case"astc-10x10-unorm-srgb":case"astc-12x10-unorm":case"astc-12x10-unorm-srgb":case"astc-12x12-unorm":case"astc-12x12-unorm-srgb":case"stencil8":return 0;case"r8snorm":case"r8sint":case"rg8snorm":case"rg8sint":case"rgba8snorm":case"rgba8sint":case"bc6h-rgb-float":case"bc5-rg-snorm":case"bc4-r-snorm":case"eac-r11snorm":case"eac-rg11snorm":return 3;case"r16uint":case"r16unorm":case"rg16unorm":case"rgba16unorm":case"rg16uint":case"rgba16uint":case"depth16unorm":return 5;case"r16sint":case"r16snorm":case"rg16snorm":case"rgba16snorm":case"rg16sint":case"rgba16sint":return 4;case"r16float":case"rg16float":case"rgba16float":return 2;case"r32uint":case"rg32uint":case"rgba32uint":return 7;case"r32sint":case"rg32sint":case"rgba32sint":return 7;case"r32float":case"rg32float":case"rgba32float":case"depth32float":case"depth32float-stencil8":case"depth24plus":case"depth24plus-stencil8":return 1}return 0}static GetBlockInformationFromFormat(e){switch(e){case"r8unorm":case"r8snorm":case"r8uint":case"r8sint":return{width:1,height:1,length:1};case"r16uint":case"r16sint":case"r16unorm":case"rg16unorm":case"rgba16unorm":case"r16snorm":case"rg16snorm":case"rgba16snorm":case"r16float":case"rg8unorm":case"rg8snorm":case"rg8uint":case"rg8sint":return{width:1,height:1,length:2};case"r32uint":case"r32sint":case"r32float":case"rg16uint":case"rg16sint":case"rg16float":case"rgba8unorm":case"rgba8unorm-srgb":case"rgba8snorm":case"rgba8uint":case"rgba8sint":case"bgra8unorm":case"bgra8unorm-srgb":case"rgb9e5ufloat":case"rgb10a2uint":case"rgb10a2unorm":case"rg11b10ufloat":return{width:1,height:1,length:4};case"rg32uint":case"rg32sint":case"rg32float":case"rgba16uint":case"rgba16sint":case"rgba16float":return{width:1,height:1,length:8};case"rgba32uint":case"rgba32sint":case"rgba32float":return{width:1,height:1,length:16};case"stencil8":throw"No fixed size for Stencil8 format!";case"depth16unorm":return{width:1,height:1,length:2};case"depth24plus":throw"No fixed size for Depth24Plus format!";case"depth24plus-stencil8":throw"No fixed size for Depth24PlusStencil8 format!";case"depth32float":return{width:1,height:1,length:4};case"depth32float-stencil8":return{width:1,height:1,length:5};case"bc7-rgba-unorm":case"bc7-rgba-unorm-srgb":case"bc6h-rgb-ufloat":case"bc6h-rgb-float":case"bc5-rg-unorm":case"bc5-rg-snorm":case"bc3-rgba-unorm":case"bc3-rgba-unorm-srgb":case"bc2-rgba-unorm":case"bc2-rgba-unorm-srgb":return{width:4,height:4,length:16};case"bc4-r-unorm":case"bc4-r-snorm":case"bc1-rgba-unorm":case"bc1-rgba-unorm-srgb":return{width:4,height:4,length:8};case"etc2-rgb8unorm":case"etc2-rgb8unorm-srgb":case"etc2-rgb8a1unorm":case"etc2-rgb8a1unorm-srgb":case"eac-r11unorm":case"eac-r11snorm":return{width:4,height:4,length:8};case"etc2-rgba8unorm":case"etc2-rgba8unorm-srgb":case"eac-rg11unorm":case"eac-rg11snorm":return{width:4,height:4,length:16};case"astc-4x4-unorm":case"astc-4x4-unorm-srgb":return{width:4,height:4,length:16};case"astc-5x4-unorm":case"astc-5x4-unorm-srgb":return{width:5,height:4,length:16};case"astc-5x5-unorm":case"astc-5x5-unorm-srgb":return{width:5,height:5,length:16};case"astc-6x5-unorm":case"astc-6x5-unorm-srgb":return{width:6,height:5,length:16};case"astc-6x6-unorm":case"astc-6x6-unorm-srgb":return{width:6,height:6,length:16};case"astc-8x5-unorm":case"astc-8x5-unorm-srgb":return{width:8,height:5,length:16};case"astc-8x6-unorm":case"astc-8x6-unorm-srgb":return{width:8,height:6,length:16};case"astc-8x8-unorm":case"astc-8x8-unorm-srgb":return{width:8,height:8,length:16};case"astc-10x5-unorm":case"astc-10x5-unorm-srgb":return{width:10,height:5,length:16};case"astc-10x6-unorm":case"astc-10x6-unorm-srgb":return{width:10,height:6,length:16};case"astc-10x8-unorm":case"astc-10x8-unorm-srgb":return{width:10,height:8,length:16};case"astc-10x10-unorm":case"astc-10x10-unorm-srgb":return{width:10,height:10,length:16};case"astc-12x10-unorm":case"astc-12x10-unorm-srgb":return{width:12,height:10,length:16};case"astc-12x12-unorm":case"astc-12x12-unorm-srgb":return{width:12,height:12,length:16}}return{width:1,height:1,length:4}}static IsHardwareTexture(e){return!!e.release}static IsInternalTexture(e){return!!e.dispose}static IsImageBitmap(e){return e.close!==void 0}static IsImageBitmapArray(e){return Array.isArray(e)&&e[0].close!==void 0}static IsCompressedFormat(e){switch(e){case"bc7-rgba-unorm-srgb":case"bc7-rgba-unorm":case"bc6h-rgb-float":case"bc6h-rgb-ufloat":case"bc5-rg-snorm":case"bc5-rg-unorm":case"bc4-r-snorm":case"bc4-r-unorm":case"bc3-rgba-unorm-srgb":case"bc3-rgba-unorm":case"bc2-rgba-unorm-srgb":case"bc2-rgba-unorm":case"bc1-rgba-unorm-srgb":case"bc1-rgba-unorm":case"etc2-rgb8unorm":case"etc2-rgb8unorm-srgb":case"etc2-rgb8a1unorm":case"etc2-rgb8a1unorm-srgb":case"etc2-rgba8unorm":case"etc2-rgba8unorm-srgb":case"eac-r11unorm":case"eac-r11snorm":case"eac-rg11unorm":case"eac-rg11snorm":case"astc-4x4-unorm":case"astc-4x4-unorm-srgb":case"astc-5x4-unorm":case"astc-5x4-unorm-srgb":case"astc-5x5-unorm":case"astc-5x5-unorm-srgb":case"astc-6x5-unorm":case"astc-6x5-unorm-srgb":case"astc-6x6-unorm":case"astc-6x6-unorm-srgb":case"astc-8x5-unorm":case"astc-8x5-unorm-srgb":case"astc-8x6-unorm":case"astc-8x6-unorm-srgb":case"astc-8x8-unorm":case"astc-8x8-unorm-srgb":case"astc-10x5-unorm":case"astc-10x5-unorm-srgb":case"astc-10x6-unorm":case"astc-10x6-unorm-srgb":case"astc-10x8-unorm":case"astc-10x8-unorm-srgb":case"astc-10x10-unorm":case"astc-10x10-unorm-srgb":case"astc-12x10-unorm":case"astc-12x10-unorm-srgb":case"astc-12x12-unorm":case"astc-12x12-unorm-srgb":return!0}return!1}static GetWebGPUTextureFormat(e,t,i=!1){switch(t){case 15:return"depth16unorm";case 16:return"depth24plus";case 13:return"depth24plus-stencil8";case 14:return"depth32float";case 18:return"depth32float-stencil8";case 19:return"stencil8";case 36492:return i?"bc7-rgba-unorm-srgb":"bc7-rgba-unorm";case 36495:return"bc6h-rgb-ufloat";case 36494:return"bc6h-rgb-float";case 33779:return i?"bc3-rgba-unorm-srgb":"bc3-rgba-unorm";case 33778:return i?"bc2-rgba-unorm-srgb":"bc2-rgba-unorm";case 33777:case 33776:return i?"bc1-rgba-unorm-srgb":"bc1-rgba-unorm";case 37808:return i?"astc-4x4-unorm-srgb":"astc-4x4-unorm";case 36196:case 37492:return i?"etc2-rgb8unorm-srgb":"etc2-rgb8unorm";case 37496:return i?"etc2-rgba8unorm-srgb":"etc2-rgba8unorm"}switch(e){case 3:switch(t){case 6:return"r8snorm";case 7:return"rg8snorm";case 4:throw"RGB format not supported in WebGPU";case 8:return"r8sint";case 9:return"rg8sint";case 10:throw"RGB_INTEGER format not supported in WebGPU";case 11:return"rgba8sint";default:return"rgba8snorm"}case 0:switch(t){case 6:return"r8unorm";case 7:return"rg8unorm";case 4:throw"TEXTUREFORMAT_RGB format not supported in WebGPU";case 5:return i?"rgba8unorm-srgb":"rgba8unorm";case 12:return i?"bgra8unorm-srgb":"bgra8unorm";case 8:return"r8uint";case 9:return"rg8uint";case 10:throw"RGB_INTEGER format not supported in WebGPU";case 11:return"rgba8uint";case 0:throw"TEXTUREFORMAT_ALPHA format not supported in WebGPU";case 1:throw"TEXTUREFORMAT_LUMINANCE format not supported in WebGPU";case 2:throw"TEXTUREFORMAT_LUMINANCE_ALPHA format not supported in WebGPU";default:return"rgba8unorm"}case 4:switch(t){case 8:return"r16sint";case 9:return"rg16sint";case 10:throw"TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";case 11:return"rgba16sint";default:return"rgba16sint"}case 5:switch(t){case 8:return"r16uint";case 9:return"rg16uint";case 10:throw"TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";case 11:return"rgba16uint";default:return"rgba16uint"}case 6:switch(t){case 8:return"r32sint";case 9:return"rg32sint";case 10:throw"TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";case 11:return"rgba32sint";default:return"rgba32sint"}case 7:switch(t){case 8:return"r32uint";case 9:return"rg32uint";case 10:throw"TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";case 11:return"rgba32uint";default:return"rgba32uint"}case 1:switch(t){case 6:return"r32float";case 7:return"rg32float";case 4:throw"TEXTUREFORMAT_RGB format not supported in WebGPU";case 5:return"rgba32float";default:return"rgba32float"}case 2:switch(t){case 6:return"r16float";case 7:return"rg16float";case 4:throw"TEXTUREFORMAT_RGB format not supported in WebGPU";case 5:return"rgba16float";default:return"rgba16float"}case 10:throw"TEXTURETYPE_UNSIGNED_SHORT_5_6_5 format not supported in WebGPU";case 13:switch(t){case 5:return"rg11b10ufloat";case 11:throw"TEXTUREFORMAT_RGBA_INTEGER format not supported in WebGPU when type is TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV";default:return"rg11b10ufloat"}case 14:switch(t){case 5:return"rgb9e5ufloat";case 11:throw"TEXTUREFORMAT_RGBA_INTEGER format not supported in WebGPU when type is TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV";default:return"rgb9e5ufloat"}case 8:throw"TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 format not supported in WebGPU";case 9:throw"TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 format not supported in WebGPU";case 11:switch(t){case 5:return"rgb10a2unorm";case 11:return"rgb10a2uint";default:return"rgb10a2unorm"}}return i?"rgba8unorm-srgb":"rgba8unorm"}static GetNumChannelsFromWebGPUTextureFormat(e){switch(e){case"r8unorm":case"r8snorm":case"r8uint":case"r8sint":case"bc4-r-unorm":case"bc4-r-snorm":case"r16uint":case"r16sint":case"depth16unorm":case"r16float":case"r16unorm":case"r16snorm":case"r32uint":case"r32sint":case"r32float":case"depth32float":case"stencil8":case"depth24plus":case"eac-r11unorm":case"eac-r11snorm":return 1;case"rg8unorm":case"rg8snorm":case"rg8uint":case"rg8sint":case"depth32float-stencil8":case"bc5-rg-unorm":case"bc5-rg-snorm":case"rg16uint":case"rg16sint":case"rg16float":case"rg16unorm":case"rg16snorm":case"rg32uint":case"rg32sint":case"rg32float":case"depth24plus-stencil8":case"eac-rg11unorm":case"eac-rg11snorm":return 2;case"rgb9e5ufloat":case"rg11b10ufloat":case"bc6h-rgb-ufloat":case"bc6h-rgb-float":case"etc2-rgb8unorm":case"etc2-rgb8unorm-srgb":return 3;case"rgba8unorm":case"rgba8unorm-srgb":case"rgba8snorm":case"rgba8uint":case"rgba8sint":case"bgra8unorm":case"bgra8unorm-srgb":case"rgba16unorm":case"rgba16snorm":case"rgb10a2uint":case"rgb10a2unorm":case"bc7-rgba-unorm":case"bc7-rgba-unorm-srgb":case"bc3-rgba-unorm":case"bc3-rgba-unorm-srgb":case"bc2-rgba-unorm":case"bc2-rgba-unorm-srgb":case"bc1-rgba-unorm":case"bc1-rgba-unorm-srgb":case"rgba16uint":case"rgba16sint":case"rgba16float":case"rgba32uint":case"rgba32sint":case"rgba32float":case"etc2-rgb8a1unorm":case"etc2-rgb8a1unorm-srgb":case"etc2-rgba8unorm":case"etc2-rgba8unorm-srgb":case"astc-4x4-unorm":case"astc-4x4-unorm-srgb":case"astc-5x4-unorm":case"astc-5x4-unorm-srgb":case"astc-5x5-unorm":case"astc-5x5-unorm-srgb":case"astc-6x5-unorm":case"astc-6x5-unorm-srgb":case"astc-6x6-unorm":case"astc-6x6-unorm-srgb":case"astc-8x5-unorm":case"astc-8x5-unorm-srgb":case"astc-8x6-unorm":case"astc-8x6-unorm-srgb":case"astc-8x8-unorm":case"astc-8x8-unorm-srgb":case"astc-10x5-unorm":case"astc-10x5-unorm-srgb":case"astc-10x6-unorm":case"astc-10x6-unorm-srgb":case"astc-10x8-unorm":case"astc-10x8-unorm-srgb":case"astc-10x10-unorm":case"astc-10x10-unorm-srgb":case"astc-12x10-unorm":case"astc-12x10-unorm-srgb":case"astc-12x12-unorm":case"astc-12x12-unorm-srgb":return 4}throw"Unknown format ".concat(e,"!")}static HasStencilAspect(e){switch(e){case"stencil8":case"depth32float-stencil8":case"depth24plus-stencil8":return!0}return!1}static HasDepthAndStencilAspects(e){switch(e){case"depth32float-stencil8":case"depth24plus-stencil8":return!0}return!1}static GetDepthFormatOnly(e){switch(e){case"depth16unorm":return"depth16unorm";case"depth24plus":return"depth24plus";case"depth24plus-stencil8":return"depth24plus";case"depth32float":return"depth32float";case"depth32float-stencil8":return"depth32float"}return e}static GetSample(e){return e>1?4:1}}class gc{constructor(){this._gpuTimeInFrameId=-1,this.counter=new ui}_addDuration(e,t){e<this._gpuTimeInFrameId||(this._gpuTimeInFrameId!==e?(this.counter._fetchResult(),this.counter.fetchNewFrame(),this.counter.addCount(t,!1),this._gpuTimeInFrameId=e):this.counter.addCount(t,!1))}}class et extends ae{constructor(){super(...arguments),this.dbgShowShaderCode=!1,this.dbgSanityChecks=!0,this.dbgVerboseLogsNumFrames=10,this.dbgLogIfNotDrawWrapper=!0,this.dbgShowEmptyEnableEffectCalls=!0,this.dbgVerboseLogsForFirstFrames=!1,this._currentRenderPass=null,this._snapshotRenderingMode=0,this._timestampIndex=0,this._debugStackRenderPass=[]}get enableGPUTimingMeasurements(){return this._timestampQuery.enable}set enableGPUTimingMeasurements(e){this._timestampQuery.enable!==e&&(this.gpuTimeInFrameForMainPass=e?new gc:void 0,this._timestampQuery.enable=e)}_currentPassIsMainPass(){return this._currentRenderTarget===null}_endCurrentRenderPass(){var t,i,s;if(!this._currentRenderPass)return 0;if(this._debugStackRenderPass.length!==0)for(let n=0;n<this._debugStackRenderPass.length;++n)this._currentRenderPass.popDebugGroup();const e=this._currentPassIsMainPass()?2:1;return!this._snapshotRendering.endRenderPass(this._currentRenderPass)&&!this.compatibilityMode&&(this._bundleList.run(this._currentRenderPass),this._bundleList.reset()),this._currentRenderPass.end(),this._timestampQuery.endPass(this._timestampIndex,this._currentRenderTarget&&this._currentRenderTarget.gpuTimeInFrame?this._currentRenderTarget.gpuTimeInFrame:this.gpuTimeInFrameForMainPass),this._timestampIndex+=2,this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&U.Log("frame #"+this._count+" - "+(e===2?"main":"render target")+" end pass"+(e===1?" - internalTexture.uniqueId="+((i=(t=this._currentRenderTarget)==null?void 0:t.texture)==null?void 0:i.uniqueId):""))),(s=this._debugPopGroup)==null||s.call(this,0),this._currentRenderPass=null,e}_generateMipmaps(e,t){t=t!=null?t:this._renderEncoder;const i=e._hardwareTexture;if(!i)return;t===this._renderEncoder&&this._endCurrentRenderPass();const s=e._hardwareTexture.format,n=Ve.ComputeNumMipmapLevels(e.width,e.height);this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&U.Log("frame #"+this._count+" - generate mipmaps - width="+e.width+", height="+e.height+", isCube="+e.isCube+", command encoder="+(t===this._renderEncoder?"render":"copy"))),e.isCube?this._textureHelper.generateCubeMipmaps(i,s,n,t):this._textureHelper.generateMipmaps(i,s,n,0,e.is3D,t)}}var Uo;(function(a){a.LowPower="low-power",a.HighPerformance="high-performance"})(Uo||(Uo={}));var ko;(function(a){a.DepthClipControl="depth-clip-control",a.Depth32FloatStencil8="depth32float-stencil8",a.TextureCompressionBC="texture-compression-bc",a.TextureCompressionBCSliced3D="texture-compression-bc-sliced-3d",a.TextureCompressionETC2="texture-compression-etc2",a.TextureCompressionASTC="texture-compression-astc",a.TextureCompressionASTCSliced3D="texture-compression-astc-sliced-3d",a.TimestampQuery="timestamp-query",a.IndirectFirstInstance="indirect-first-instance",a.ShaderF16="shader-f16",a.RG11B10UFloatRenderable="rg11b10ufloat-renderable",a.BGRA8UnormStorage="bgra8unorm-storage",a.Float32Filterable="float32-filterable",a.Float32Blendable="float32-blendable",a.ClipDistances="clip-distances",a.DualSourceBlending="dual-source-blending"})(ko||(ko={}));var Vo;(function(a){a.Unmapped="unmapped",a.Pending="pending",a.Mapped="mapped"})(Vo||(Vo={}));var We;(function(a){a[a.MapRead=1]="MapRead",a[a.MapWrite=2]="MapWrite",a[a.CopySrc=4]="CopySrc",a[a.CopyDst=8]="CopyDst",a[a.Index=16]="Index",a[a.Vertex=32]="Vertex",a[a.Uniform=64]="Uniform",a[a.Storage=128]="Storage",a[a.Indirect=256]="Indirect",a[a.QueryResolve=512]="QueryResolve"})(We||(We={}));var Go;(function(a){a[a.Read=1]="Read",a[a.Write=2]="Write"})(Go||(Go={}));var zo;(function(a){a.E1d="1d",a.E2d="2d",a.E3d="3d"})(zo||(zo={}));var Wo;(function(a){a[a.CopySrc=1]="CopySrc",a[a.CopyDst=2]="CopyDst",a[a.TextureBinding=4]="TextureBinding",a[a.StorageBinding=8]="StorageBinding",a[a.RenderAttachment=16]="RenderAttachment"})(Wo||(Wo={}));var Ho;(function(a){a.E1d="1d",a.E2d="2d",a.E2dArray="2d-array",a.Cube="cube",a.CubeArray="cube-array",a.E3d="3d"})(Ho||(Ho={}));var Ko;(function(a){a.All="all",a.StencilOnly="stencil-only",a.DepthOnly="depth-only"})(Ko||(Ko={}));var Xo;(function(a){a.R8Unorm="r8unorm",a.R8Snorm="r8snorm",a.R8Uint="r8uint",a.R8Sint="r8sint",a.R16Uint="r16uint",a.R16Sint="r16sint",a.R16Float="r16float",a.RG8Unorm="rg8unorm",a.RG8Snorm="rg8snorm",a.RG8Uint="rg8uint",a.RG8Sint="rg8sint",a.R16Unorm="r16unorm",a.R16Snorm="r16snorm",a.RG16Unorm="rg16unorm",a.RG16Snorm="rg16snorm",a.RGBA16Unorm="rgba16unorm",a.RGBA16Snorm="rgba16snorm",a.R32Uint="r32uint",a.R32Sint="r32sint",a.R32Float="r32float",a.RG16Uint="rg16uint",a.RG16Sint="rg16sint",a.RG16Float="rg16float",a.RGBA8Unorm="rgba8unorm",a.RGBA8UnormSRGB="rgba8unorm-srgb",a.RGBA8Snorm="rgba8snorm",a.RGBA8Uint="rgba8uint",a.RGBA8Sint="rgba8sint",a.BGRA8Unorm="bgra8unorm",a.BGRA8UnormSRGB="bgra8unorm-srgb",a.RGB9E5UFloat="rgb9e5ufloat",a.RGB10A2UINT="rgb10a2uint",a.RGB10A2Unorm="rgb10a2unorm",a.RG11B10UFloat="rg11b10ufloat",a.RG32Uint="rg32uint",a.RG32Sint="rg32sint",a.RG32Float="rg32float",a.RGBA16Uint="rgba16uint",a.RGBA16Sint="rgba16sint",a.RGBA16Float="rgba16float",a.RGBA32Uint="rgba32uint",a.RGBA32Sint="rgba32sint",a.RGBA32Float="rgba32float",a.Stencil8="stencil8",a.Depth16Unorm="depth16unorm",a.Depth24Plus="depth24plus",a.Depth24PlusStencil8="depth24plus-stencil8",a.Depth32Float="depth32float",a.BC1RGBAUnorm="bc1-rgba-unorm",a.BC1RGBAUnormSRGB="bc1-rgba-unorm-srgb",a.BC2RGBAUnorm="bc2-rgba-unorm",a.BC2RGBAUnormSRGB="bc2-rgba-unorm-srgb",a.BC3RGBAUnorm="bc3-rgba-unorm",a.BC3RGBAUnormSRGB="bc3-rgba-unorm-srgb",a.BC4RUnorm="bc4-r-unorm",a.BC4RSnorm="bc4-r-snorm",a.BC5RGUnorm="bc5-rg-unorm",a.BC5RGSnorm="bc5-rg-snorm",a.BC6HRGBUFloat="bc6h-rgb-ufloat",a.BC6HRGBFloat="bc6h-rgb-float",a.BC7RGBAUnorm="bc7-rgba-unorm",a.BC7RGBAUnormSRGB="bc7-rgba-unorm-srgb",a.ETC2RGB8Unorm="etc2-rgb8unorm",a.ETC2RGB8UnormSRGB="etc2-rgb8unorm-srgb",a.ETC2RGB8A1Unorm="etc2-rgb8a1unorm",a.ETC2RGB8A1UnormSRGB="etc2-rgb8a1unorm-srgb",a.ETC2RGBA8Unorm="etc2-rgba8unorm",a.ETC2RGBA8UnormSRGB="etc2-rgba8unorm-srgb",a.EACR11Unorm="eac-r11unorm",a.EACR11Snorm="eac-r11snorm",a.EACRG11Unorm="eac-rg11unorm",a.EACRG11Snorm="eac-rg11snorm",a.ASTC4x4Unorm="astc-4x4-unorm",a.ASTC4x4UnormSRGB="astc-4x4-unorm-srgb",a.ASTC5x4Unorm="astc-5x4-unorm",a.ASTC5x4UnormSRGB="astc-5x4-unorm-srgb",a.ASTC5x5Unorm="astc-5x5-unorm",a.ASTC5x5UnormSRGB="astc-5x5-unorm-srgb",a.ASTC6x5Unorm="astc-6x5-unorm",a.ASTC6x5UnormSRGB="astc-6x5-unorm-srgb",a.ASTC6x6Unorm="astc-6x6-unorm",a.ASTC6x6UnormSRGB="astc-6x6-unorm-srgb",a.ASTC8x5Unorm="astc-8x5-unorm",a.ASTC8x5UnormSRGB="astc-8x5-unorm-srgb",a.ASTC8x6Unorm="astc-8x6-unorm",a.ASTC8x6UnormSRGB="astc-8x6-unorm-srgb",a.ASTC8x8Unorm="astc-8x8-unorm",a.ASTC8x8UnormSRGB="astc-8x8-unorm-srgb",a.ASTC10x5Unorm="astc-10x5-unorm",a.ASTC10x5UnormSRGB="astc-10x5-unorm-srgb",a.ASTC10x6Unorm="astc-10x6-unorm",a.ASTC10x6UnormSRGB="astc-10x6-unorm-srgb",a.ASTC10x8Unorm="astc-10x8-unorm",a.ASTC10x8UnormSRGB="astc-10x8-unorm-srgb",a.ASTC10x10Unorm="astc-10x10-unorm",a.ASTC10x10UnormSRGB="astc-10x10-unorm-srgb",a.ASTC12x10Unorm="astc-12x10-unorm",a.ASTC12x10UnormSRGB="astc-12x10-unorm-srgb",a.ASTC12x12Unorm="astc-12x12-unorm",a.ASTC12x12UnormSRGB="astc-12x12-unorm-srgb",a.Depth32FloatStencil8="depth32float-stencil8"})(Xo||(Xo={}));var Yo;(function(a){a.ClampToEdge="clamp-to-edge",a.Repeat="repeat",a.MirrorRepeat="mirror-repeat"})(Yo||(Yo={}));var qo;(function(a){a.Nearest="nearest",a.Linear="linear"})(qo||(qo={}));var jo;(function(a){a.Nearest="nearest",a.Linear="linear"})(jo||(jo={}));var $o;(function(a){a.Never="never",a.Less="less",a.Equal="equal",a.LessEqual="less-equal",a.Greater="greater",a.NotEqual="not-equal",a.GreaterEqual="greater-equal",a.Always="always"})($o||($o={}));var Zo;(function(a){a[a.Vertex=1]="Vertex",a[a.Fragment=2]="Fragment",a[a.Compute=4]="Compute"})(Zo||(Zo={}));var Qo;(function(a){a.Uniform="uniform",a.Storage="storage",a.ReadOnlyStorage="read-only-storage"})(Qo||(Qo={}));var Jo;(function(a){a.Filtering="filtering",a.NonFiltering="non-filtering",a.Comparison="comparison"})(Jo||(Jo={}));var eh;(function(a){a.Float="float",a.UnfilterableFloat="unfilterable-float",a.Depth="depth",a.Sint="sint",a.Uint="uint"})(eh||(eh={}));var th;(function(a){a.WriteOnly="write-only",a.ReadOnly="read-only",a.ReadWrite="read-write"})(th||(th={}));var ih;(function(a){a.Error="error",a.Warning="warning",a.Info="info"})(ih||(ih={}));var sh;(function(a){a.Validation="validation",a.Internal="internal"})(sh||(sh={}));var nh;(function(a){a.Auto="auto"})(nh||(nh={}));var rh;(function(a){a.PointList="point-list",a.LineList="line-list",a.LineStrip="line-strip",a.TriangleList="triangle-list",a.TriangleStrip="triangle-strip"})(rh||(rh={}));var ah;(function(a){a.CCW="ccw",a.CW="cw"})(ah||(ah={}));var oh;(function(a){a.None="none",a.Front="front",a.Back="back"})(oh||(oh={}));var hh;(function(a){a[a.Red=1]="Red",a[a.Green=2]="Green",a[a.Blue=4]="Blue",a[a.Alpha=8]="Alpha",a[a.All=15]="All"})(hh||(hh={}));var lh;(function(a){a.Zero="zero",a.One="one",a.Src="src",a.OneMinusSrc="one-minus-src",a.SrcAlpha="src-alpha",a.OneMinusSrcAlpha="one-minus-src-alpha",a.Dst="dst",a.OneMinusDst="one-minus-dst",a.DstAlpha="dst-alpha",a.OneMinusDstAlpha="one-minus-dst-alpha",a.SrcAlphaSaturated="src-alpha-saturated",a.Constant="constant",a.OneMinusConstant="one-minus-constant",a.Src1="src1",a.OneMinusSrc1="one-minus-src1",a.Src1Alpha="src1-alpha",a.OneMinusSrc1Alpha="one-minus-src1-alpha"})(lh||(lh={}));var ch;(function(a){a.Add="add",a.Subtract="subtract",a.ReverseSubtract="reverse-subtract",a.Min="min",a.Max="max"})(ch||(ch={}));var uh;(function(a){a.Keep="keep",a.Zero="zero",a.Replace="replace",a.Invert="invert",a.IncrementClamp="increment-clamp",a.DecrementClamp="decrement-clamp",a.IncrementWrap="increment-wrap",a.DecrementWrap="decrement-wrap"})(uh||(uh={}));var fh;(function(a){a.Uint16="uint16",a.Uint32="uint32"})(fh||(fh={}));var dh;(function(a){a.Uint8x2="uint8x2",a.Uint8x4="uint8x4",a.Sint8x2="sint8x2",a.Sint8x4="sint8x4",a.Unorm8x2="unorm8x2",a.Unorm8x4="unorm8x4",a.Snorm8x2="snorm8x2",a.Snorm8x4="snorm8x4",a.Uint16x2="uint16x2",a.Uint16x4="uint16x4",a.Sint16x2="sint16x2",a.Sint16x4="sint16x4",a.Unorm16x2="unorm16x2",a.Unorm16x4="unorm16x4",a.Snorm16x2="snorm16x2",a.Snorm16x4="snorm16x4",a.Float16x2="float16x2",a.Float16x4="float16x4",a.Float32="float32",a.Float32x2="float32x2",a.Float32x3="float32x3",a.Float32x4="float32x4",a.Uint32="uint32",a.Uint32x2="uint32x2",a.Uint32x3="uint32x3",a.Uint32x4="uint32x4",a.Sint32="sint32",a.Sint32x2="sint32x2",a.Sint32x3="sint32x3",a.Sint32x4="sint32x4",a.UNORM10x10x10x2="unorm10-10-10-2"})(dh||(dh={}));var _h;(function(a){a.Vertex="vertex",a.Instance="instance"})(_h||(_h={}));var ph;(function(a){a.Beginning="beginning",a.End="end"})(ph||(ph={}));var gh;(function(a){a.Beginning="beginning",a.End="end"})(gh||(gh={}));var mh;(function(a){a.Load="load",a.Clear="clear"})(mh||(mh={}));var vh;(function(a){a.Store="store",a.Discard="discard"})(vh||(vh={}));var bh;(function(a){a.Occlusion="occlusion",a.Timestamp="timestamp"})(bh||(bh={}));var xh;(function(a){a.Opaque="opaque",a.Premultiplied="premultiplied"})(xh||(xh={}));var yh;(function(a){a.Standard="standard",a.Extended="extended"})(yh||(yh={}));var Th;(function(a){a.Unknown="unknown",a.Destroyed="destroyed"})(Th||(Th={}));var Ah;(function(a){a.Validation="validation",a.OutOfMemory="out-of-memory",a.Internal="internal"})(Ah||(Ah={}));class ln{get isDisposed(){return this._isDisposed}constructor(e,t,i,s=0,n=!1,r=!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=r,this._divisor=h||1,this._label=l,t instanceof pn?(this._data=null,this._buffer=t):(this._data=t,this._buffer=null),this.byteStride=o?s:s*Float32Array.BYTES_PER_ELEMENT,n||this.create()}createVertexBuffer(e,t,i,s,n,r=!1,o){const h=r?t:t*Float32Array.BYTES_PER_ELEMENT,l=s?r?s:s*Float32Array.BYTES_PER_ELEMENT:this.byteStride;return new A(this._engine,this,e,this._updatable,!0,l,n===void 0?this._instanced:n,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}U.Warn('Missing data for buffer "'.concat(this._label,'" ').concat(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 A{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,n,r,o,h,l,c,u=!1,f=!1,d=1,_=!1){var m,b,I,T,x;this._isDisposed=!1;let p=!1;if(this.engine=e,typeof s=="object"&&s!==null?(p=(m=s.updatable)!=null?m:!1,n=s.postponeInternalCreation,r=s.stride,o=s.instanced,h=s.offset,l=s.size,c=s.type,u=(b=s.normalized)!=null?b:!1,f=(I=s.useBytes)!=null?I:!1,d=(T=s.divisor)!=null?T:1,_=(x=s.takeBufferOwnership)!=null?x:!1,this._label=s.label):p=!!s,t instanceof ln?(this._buffer=t,this._ownsBuffer=_):(this._buffer=new ln(e,t,p,r,n,o,f,d,this._label),this._ownsBuffer=!0),this.uniqueId=A._Counter++,this._kind=i,c===void 0){const y=this.getData();this.type=y?A.GetDataType(y):A.FLOAT}else this.type=c;const g=A.GetTypeByteLength(this.type);f?(this._size=l||(r?r/g:A.DeduceStride(i)),this.byteStride=r||this._buffer.byteStride||this._size*g,this.byteOffset=h||0):(this._size=l||r||A.DeduceStride(i),this.byteStride=r?r*g:this._buffer.byteStride||this._size*g,this.byteOffset=(h||0)*g),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(){var e;(e=this._buffer)==null||e._rebuild()}getKind(){return this._kind}isUpdatable(){return this._buffer.isUpdatable()}getData(){return this._buffer.getData()}getFloatData(e,t){const i=this.getData();return i?A.GetFloatData(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/A.GetTypeByteLength(this.type)}getOffset(){return this.byteOffset/A.GetTypeByteLength(this.type)}getSize(e=!1){return e?this._size*A.GetTypeByteLength(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){A.ForEach(this._buffer.getData(),this.byteOffset,this.byteStride,this._size,this.type,e,this.normalized,t)}_alignBuffer(){}static DeduceStride(e){switch(e){case A.UVKind:case A.UV2Kind:case A.UV3Kind:case A.UV4Kind:case A.UV5Kind:case A.UV6Kind:return 2;case A.NormalKind:case A.PositionKind:return 3;case A.ColorKind:case A.ColorInstanceKind:case A.MatricesIndicesKind:case A.MatricesIndicesExtraKind:case A.MatricesWeightsKind:case A.MatricesWeightsExtraKind:case A.TangentKind:return 4;default:throw new Error("Invalid kind '"+e+"'")}}static GetDataType(e){return e instanceof Int8Array?A.BYTE:e instanceof Uint8Array?A.UNSIGNED_BYTE:e instanceof Int16Array?A.SHORT:e instanceof Uint16Array?A.UNSIGNED_SHORT:e instanceof Int32Array?A.INT:e instanceof Uint32Array?A.UNSIGNED_INT:A.FLOAT}static GetTypeByteLength(e){switch(e){case A.BYTE:case A.UNSIGNED_BYTE:return 1;case A.SHORT:case A.UNSIGNED_SHORT:return 2;case A.INT:case A.UNSIGNED_INT:case A.FLOAT:return 4;default:throw new Error("Invalid type '".concat(e,"'"))}}static ForEach(e,t,i,s,n,r,o,h){if(e instanceof Array){let l=t/4;const c=i/4;for(let u=0;u<r;u+=s){for(let f=0;f<s;f++)h(e[l+f],u+f);l+=c}}else{const l=e instanceof ArrayBuffer?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength),c=A.GetTypeByteLength(n);for(let u=0;u<r;u+=s){let f=t;for(let d=0;d<s;d++){const _=A._GetFloatValue(l,n,f,o);h(_,u+d),f+=c}t+=i}}}static _GetFloatValue(e,t,i,s){switch(t){case A.BYTE:{let n=e.getInt8(i);return s&&(n=Math.max(n/127,-1)),n}case A.UNSIGNED_BYTE:{let n=e.getUint8(i);return s&&(n=n/255),n}case A.SHORT:{let n=e.getInt16(i,!0);return s&&(n=Math.max(n/32767,-1)),n}case A.UNSIGNED_SHORT:{let n=e.getUint16(i,!0);return s&&(n=n/65535),n}case A.INT:return e.getInt32(i,!0);case A.UNSIGNED_INT:return e.getUint32(i,!0);case A.FLOAT:return e.getFloat32(i,!0);default:throw new Error("Invalid component type ".concat(t))}}static GetFloatData(e,t,i,s,n,r,o,h){const l=t*A.GetTypeByteLength(i),c=o*t;if(i!==A.FLOAT||n!==l){const u=new Float32Array(c);return A.ForEach(e,s,n,t,i,c,r,(f,d)=>u[d]=f),u}if(!(e instanceof Array||e instanceof Float32Array)||s!==0||e.length!==c)if(e instanceof Array){const u=s/4;return e.slice(u,u+c)}else{if(e instanceof ArrayBuffer)return new Float32Array(e,s,c);{const u=e.byteOffset+s;if(u&3&&(U.Warn("Float array must be aligned to 4-bytes border"),h=!0),h){const f=new Uint8Array(c*Float32Array.BYTES_PER_ELEMENT),d=new Uint8Array(e.buffer,u,f.length);return f.set(d),new Float32Array(f.buffer)}else return new Float32Array(e.buffer,u,c)}}return h?e.slice():e}}A._Counter=0;A.BYTE=5120;A.UNSIGNED_BYTE=5121;A.SHORT=5122;A.UNSIGNED_SHORT=5123;A.INT=5124;A.UNSIGNED_INT=5125;A.FLOAT=5126;A.PositionKind="position";A.NormalKind="normal";A.TangentKind="tangent";A.UVKind="uv";A.UV2Kind="uv2";A.UV3Kind="uv3";A.UV4Kind="uv4";A.UV5Kind="uv5";A.UV6Kind="uv6";A.ColorKind="color";A.ColorInstanceKind="instanceColor";A.MatricesIndicesKind="matricesIndices";A.MatricesWeightsKind="matricesWeights";A.MatricesIndicesExtraKind="matricesIndicesExtra";A.MatricesWeightsExtraKind="matricesWeightsExtra";const Rh=(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 c_(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 I0{static DeepCopy(e,t,i,s,n=!1){const r=c_(e);for(const o of r){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=Rh(h[c],t,n);t[o].indexOf(u)===-1&&t[o].push(u)}else t[o]=h.slice(0)}else t[o]=Rh(h,t,n);else t[o]=h}catch(c){U.Warn(c.message)}}}}class Sn{static Instantiate(e){if(this.RegisteredExternalClasses&&this.RegisteredExternalClasses[e])return this.RegisteredExternalClasses[e];const t=ys(e);if(t)return t;U.Warn(e+" not found, you may have missed an import.");const i=e.split(".");let s=window||this;for(let n=0,r=i.length;n<r;n++)s=s[i[n]];return typeof s!="function"?null:s}}Sn.RegisteredExternalClasses={};class J{static get BaseUrl(){return ut.BaseUrl}static set BaseUrl(e){ut.BaseUrl=e}static get CleanUrl(){return ut.CleanUrl}static set CleanUrl(e){ut.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){ut.ScriptBaseUrl=e}static get ScriptBaseUrl(){return ut.ScriptBaseUrl}static set ScriptPreprocessUrl(e){ut.ScriptPreprocessUrl=e}static get ScriptPreprocessUrl(){return ut.ScriptPreprocessUrl}static get DefaultRetryStrategy(){return ut.DefaultRetryStrategy}static set DefaultRetryStrategy(e){ut.DefaultRetryStrategy=e}static get CorsBehavior(){return ut.CorsBehavior}static set CorsBehavior(e){ut.CorsBehavior=e}static get UseFallbackTexture(){return Ee.UseFallbackTexture}static set UseFallbackTexture(e){Ee.UseFallbackTexture=e}static get RegisteredExternalClasses(){return Sn.RegisteredExternalClasses}static set RegisteredExternalClasses(e){Sn.RegisteredExternalClasses=e}static get fallbackTexture(){return Ee.FallbackTexture}static set fallbackTexture(e){Ee.FallbackTexture=e}static FetchToRef(e,t,i,s,n,r){const o=Math.abs(e)*i%i|0,h=Math.abs(t)*s%s|0,l=(o+h*i)*4;r.r=n[l]/255,r.g=n[l+1]/255,r.b=n[l+2]/255,r.a=n[l+3]/255}static Mix(e,t,i){return 0}static Instantiate(e){return Sn.Instantiate(e)}static SetImmediate(e){Bn.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),n=this.ToRadians(t);return this.ToDegrees(Math.atan2((1-i)*Math.sin(n)+i*Math.sin(s),(1-i)*Math.cos(n)+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 St()&&!window.PointerEvent?"mouse":"pointer"}static SetCorsBehavior(e,t){v0(e,t)}static SetReferrerPolicyBehavior(e,t){t.referrerPolicy=e}static get PreprocessUrl(){return ut.PreprocessUrl}static set PreprocessUrl(e){ut.PreprocessUrl=e}static LoadImage(e,t,i,s,n,r){return b0(e,t,i,s,n,r)}static LoadFile(e,t,i,s,n,r){return Ts(e,t,i,s,n,r)}static LoadFileAsync(e,t=!0){return new Promise((i,s)=>{Ts(e,n=>{i(n)},void 0,void 0,t,(n,r)=>{s(r)})})}static GetBabylonScriptURL(e,t){if(!e)return"";if(J.ScriptBaseUrl&&e.startsWith(J._DefaultCdnUrl)){const i=J.ScriptBaseUrl[J.ScriptBaseUrl.length-1]==="/"?J.ScriptBaseUrl.substring(0,J.ScriptBaseUrl.length-1):J.ScriptBaseUrl;e=e.replace(J._DefaultCdnUrl,i)}return e=J.ScriptPreprocessUrl(e),t&&(e=J.GetAbsoluteUrl(e)),e}static LoadBabylonScript(e,t,i,s){e=J.GetBabylonScriptURL(e),J.LoadScript(e,t,i)}static LoadBabylonScriptAsync(e){return e=J.GetBabylonScriptURL(e),J.LoadScriptAsync(e)}static LoadScript(e,t,i,s,n=!1){if(typeof importScripts=="function"){try{importScripts(e),t&&t()}catch(h){i==null||i("Unable to load script '".concat(e,"' in worker"),h)}return}else if(!St()){i==null||i("Cannot load script '".concat(e,"' outside of a window or a worker"));return}const r=document.getElementsByTagName("head")[0],o=document.createElement("script");n?(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 '".concat(e,"'"),h)},r.appendChild(o)}static LoadScriptAsync(e,t){return new Promise((i,s)=>{this.LoadScript(e,()=>{i()},(n,r)=>{s(r||new Error(n))},t)})}static ReadFileAsDataURL(e,t,i){const s=new FileReader,n={onCompleteObservable:new Z,abort:()=>s.abort()};return s.onloadend=()=>{n.onCompleteObservable.notifyObservers(n)},s.onload=r=>{t(r.target.result)},s.onprogress=i,s.readAsDataURL(e),n}static ReadFile(e,t,i,s,n){return Ln(e,t,i,s,n)}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){I0.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,n="image/png",r,o){throw ye("DumpTools")}static DumpData(e,t,i,s,n="image/png",r,o=!1,h=!1,l){throw ye("DumpTools")}static DumpDataAsync(e,t,i,s="image/png",n,r=!1,o=!1,h){throw ye("DumpTools")}static _IsOffScreenCanvas(e){return e.convertToBlob!==void 0}static ToBlob(e,t,i="image/png",s){!J._IsOffScreenCanvas(e)&&!e.toBlob&&(e.toBlob=function(n,r,o){setTimeout(()=>{const h=atob(this.toDataURL(r,o).split(",")[1]),l=h.length,c=new Uint8Array(l);for(let u=0;u<l;u++)c[u]=h.charCodeAt(u);n(new Blob([c]))})}),J._IsOffScreenCanvas(e)?e.convertToBlob({type:i,quality:s}).then(n=>t(n)):e.toBlob(function(n){t(n)},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"}J.Download(e,t)}else if(e&&typeof URL<"u"){const i=URL.createObjectURL(e),s=window.open("");if(!s)return;const n=s.document.createElement("img");n.onload=function(){URL.revokeObjectURL(i)},n.src=i,s.document.body.appendChild(n)}}static EncodeScreenshotCanvasData(e,t,i="image/png",s,n){if(typeof s=="string"||!t)this.ToBlob(e,function(r){r&&J.DownloadBlob(r,s),t&&t("")},i,n);else if(t){if(J._IsOffScreenCanvas(e)){e.convertToBlob({type:i,quality:n}).then(o=>{const h=new FileReader;h.readAsDataURL(o),h.onloadend=()=>{const l=h.result;t(l)}});return}const r=e.toDataURL(i,n);t(r)}}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,n="image/png",r=!1,o){throw ye("ScreenshotTools")}static CreateScreenshotAsync(e,t,i,s="image/png",n){throw ye("ScreenshotTools")}static CreateScreenshotUsingRenderTarget(e,t,i,s,n="image/png",r=1,o=!1,h,l=!1,c=!1,u=!0,f,d){throw ye("ScreenshotTools")}static CreateScreenshotUsingRenderTargetAsync(e,t,i,s="image/png",n=1,r=!1,o,h=!1,l=!1,c=!0,u,f){throw ye("ScreenshotTools")}static RandomId(){return g0()}static IsBase64(e){return y0(e)}static DecodeBase64(e){return T0(e)}static get errorsCount(){return U.errorsCount}static Log(e){U.Log(e)}static Warn(e){U.Warn(e)}static Error(e){U.Error(e)}static get LogCache(){return U.LogCache}static ClearLogCache(){U.ClearLogCache()}static set LogLevels(e){U.LogLevels=e}static set PerformanceLogLevel(e){if((e&J.PerformanceUserMarkLogLevel)===J.PerformanceUserMarkLogLevel){J.StartPerformanceCounter=J._StartUserMark,J.EndPerformanceCounter=J._EndUserMark;return}if((e&J.PerformanceConsoleLogLevel)===J.PerformanceConsoleLogLevel){J.StartPerformanceCounter=J._StartPerformanceConsole,J.EndPerformanceCounter=J._EndPerformanceConsole;return}J.StartPerformanceCounter=J._StartPerformanceCounterDisabled,J.EndPerformanceCounter=J._EndPerformanceCounterDisabled}static _StartPerformanceCounterDisabled(e,t){}static _EndPerformanceCounterDisabled(e,t){}static _StartUserMark(e,t=!0){if(!J._Performance){if(!St())return;J._Performance=window.performance}!t||!J._Performance.mark||J._Performance.mark(e+"-Begin")}static _EndUserMark(e,t=!0){!t||!J._Performance.mark||(J._Performance.mark(e+"-End"),J._Performance.measure(e,e+"-Begin",e+"-End"))}static _StartPerformanceConsole(e,t=!0){t&&(J._StartUserMark(e,t),console.time&&console.time(e))}static _EndPerformanceConsole(e,t=!0){t&&(J._EndUserMark(e,t),console.timeEnd(e))}static get Now(){return bi.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 n=t?e:Object.getPrototypeOf(e);i=n.constructor.__bjsclassName__,s=n.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 Qs()?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}}J.UseCustomRequestHeaders=!1;J.CustomRequestHeaders=Ft.CustomRequestHeaders;J.GetDOMTextContent=h0;J._DefaultCdnUrl="https://cdn.babylonjs.com";J.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.")};J.NoneLogLevel=U.NoneLogLevel;J.MessageLogLevel=U.MessageLogLevel;J.WarningLogLevel=U.WarningLogLevel;J.ErrorLogLevel=U.ErrorLogLevel;J.AllLogLevel=U.AllLogLevel;J.IsWindowObjectExist=St;J.PerformanceNoneLogLevel=0;J.PerformanceUserMarkLogLevel=1;J.PerformanceConsoleLogLevel=2;J.StartPerformanceCounter=J._StartPerformanceCounterDisabled;J.EndPerformanceCounter=J._EndPerformanceCounterDisabled;class Sr{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 n=new Sr(e,t,i,s);return n.executeNext(),n}static SyncAsyncForLoop(e,t,i,s,n,r=0){return Sr.Run(Math.ceil(e/t),o=>{n&&n()?o.breakLoop():setTimeout(()=>{for(let h=0;h<t;++h){const l=o.index*t+h;if(l>=e)break;if(i(l),n&&n()){o.breakLoop();break}}o.executeNext()},r)},s)}}J.Mix=Fa;J.IsExponentOfTwo=wn;Ee.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";class fe{constructor(e,t,i,s,n=!1){this._valueCache={},this._engine=e,this._noUBO=!e.supportsUniformBuffers||n,this._dynamic=i,this._name=s!=null?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 n=0;n<s;n++)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 r=(4-t)*i;t=t*i+r}s=[];for(let n=0;n<t;n++)s.push(0)}else{if(t instanceof Array)s=t,t=s.length;else{t=t,s=[];for(let n=0;n<t;n++)s.push(0)}this._fillAlignment(t)}this._uniformSizes[e]=t,this._uniformLocations[e]=this._uniformLocationPointer,this._uniformLocationPointer+=t;for(let n=0;n<t;n++)this._data.push(s[n]);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 n=[t,i,s];this.addUniform(e,n)}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&&(fe._UpdatedUbosInFrame[this._name]||(fe._UpdatedUbosInFrame[this._name]=0),fe._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){U.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 n=0;n<i;n++)this._bufferData[s+n]=t[n];else{let n=!1;for(let r=0;r<i;r++)(i===16&&!this._engine._features.uniformBufferHardCheckMatrix||this._bufferData[s+r]!==Math.fround(t[r]))&&(n=!0,this._createBufferOnWrite&&this._createNewBuffer(),this._bufferData[s+r]=t[r]);this._needSync=this._needSync||n}}updateUniformArray(e,t,i){this._checkNewFrame();const s=this._uniformLocations[e];if(s===void 0){U.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 n=this._uniformArraySizes[e];if(this._dynamic)for(let r=0;r<i;r++)this._bufferData[s+r]=t[r];else{let r=!1,o=0,h=0;for(let l=0;l<i;l++)if(this._bufferData[s+h*4+o]!==J.FloatRound(t[l])&&(r=!0,this._createBufferOnWrite&&this._createNewBuffer(),this._bufferData[s+h*4+o]=t[l]),o++,o===n.strideSize){for(;o<4;o++)this._bufferData[s+h*4+o]=0;o=0,h++}this._needSync=this._needSync||r}}_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++)fe._TempBuffer[i*4]=t[i*3],fe._TempBuffer[i*4+1]=t[i*3+1],fe._TempBuffer[i*4+2]=t[i*3+2],fe._TempBuffer[i*4+3]=0;this.updateUniform(e,fe._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++)fe._TempBuffer[i*4]=t[i*2],fe._TempBuffer[i*4+1]=t[i*2+1],fe._TempBuffer[i*4+2]=0,fe._TempBuffer[i*4+3]=0;this.updateUniform(e,fe._TempBuffer,8)}_updateFloatForEffect(e,t){this._currentEffect.setFloat(e,t)}_updateFloatForUniform(e,t){fe._TempBuffer[0]=t,this.updateUniform(e,fe._TempBuffer,1)}_updateFloat2ForEffect(e,t,i,s=""){this._currentEffect.setFloat2(e+s,t,i)}_updateFloat2ForUniform(e,t,i){fe._TempBuffer[0]=t,fe._TempBuffer[1]=i,this.updateUniform(e,fe._TempBuffer,2)}_updateFloat3ForEffect(e,t,i,s,n=""){this._currentEffect.setFloat3(e+n,t,i,s)}_updateFloat3ForUniform(e,t,i,s){fe._TempBuffer[0]=t,fe._TempBuffer[1]=i,fe._TempBuffer[2]=s,this.updateUniform(e,fe._TempBuffer,3)}_updateFloat4ForEffect(e,t,i,s,n,r=""){this._currentEffect.setFloat4(e+r,t,i,s,n)}_updateFloat4ForUniform(e,t,i,s,n){fe._TempBuffer[0]=t,fe._TempBuffer[1]=i,fe._TempBuffer[2]=s,fe._TempBuffer[3]=n,this.updateUniform(e,fe._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){fe._TempBufferInt32View.set(t),this.updateUniformArray(e,fe._TempBuffer,t.length)}_updateUIntArrayForEffect(e,t){this._currentEffect.setUIntArray(e,t)}_updateUIntArrayForUniform(e,t){fe._TempBufferUInt32View.set(t),this.updateUniformArray(e,fe._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){fe._TempBuffer[0]=t.x,fe._TempBuffer[1]=t.y,fe._TempBuffer[2]=t.z,this.updateUniform(e,fe._TempBuffer,3)}_updateVector4ForEffect(e,t){this._currentEffect.setVector4(e,t)}_updateVector4ForUniform(e,t){fe._TempBuffer[0]=t.x,fe._TempBuffer[1]=t.y,fe._TempBuffer[2]=t.z,fe._TempBuffer[3]=t.w,this.updateUniform(e,fe._TempBuffer,4)}_updateColor3ForEffect(e,t,i=""){this._currentEffect.setColor3(e+i,t)}_updateColor3ForUniform(e,t){fe._TempBuffer[0]=t.r,fe._TempBuffer[1]=t.g,fe._TempBuffer[2]=t.b,this.updateUniform(e,fe._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){fe._TempBuffer[0]=t.r,fe._TempBuffer[1]=t.g,fe._TempBuffer[2]=t.b,fe._TempBuffer[3]=i,this.updateUniform(e,fe._TempBuffer,4)}_updateDirectColor4ForUniform(e,t){fe._TempBuffer[0]=t.r,fe._TempBuffer[1]=t.g,fe._TempBuffer[2]=t.b,fe._TempBuffer[3]=t.a,this.updateUniform(e,fe._TempBuffer,4)}_updateIntForEffect(e,t,i=""){this._currentEffect.setInt(e+i,t)}_updateIntForUniform(e,t){fe._TempBufferInt32View[0]=t,this.updateUniform(e,fe._TempBuffer,1)}_updateInt2ForEffect(e,t,i,s=""){this._currentEffect.setInt2(e+s,t,i)}_updateInt2ForUniform(e,t,i){fe._TempBufferInt32View[0]=t,fe._TempBufferInt32View[1]=i,this.updateUniform(e,fe._TempBuffer,2)}_updateInt3ForEffect(e,t,i,s,n=""){this._currentEffect.setInt3(e+n,t,i,s)}_updateInt3ForUniform(e,t,i,s){fe._TempBufferInt32View[0]=t,fe._TempBufferInt32View[1]=i,fe._TempBufferInt32View[2]=s,this.updateUniform(e,fe._TempBuffer,3)}_updateInt4ForEffect(e,t,i,s,n,r=""){this._currentEffect.setInt4(e+r,t,i,s,n)}_updateInt4ForUniform(e,t,i,s,n){fe._TempBufferInt32View[0]=t,fe._TempBufferInt32View[1]=i,fe._TempBufferInt32View[2]=s,fe._TempBufferInt32View[3]=n,this.updateUniform(e,fe._TempBuffer,4)}_updateUIntForEffect(e,t,i=""){this._currentEffect.setUInt(e+i,t)}_updateUIntForUniform(e,t){fe._TempBufferUInt32View[0]=t,this.updateUniform(e,fe._TempBuffer,1)}_updateUInt2ForEffect(e,t,i,s=""){this._currentEffect.setUInt2(e+s,t,i)}_updateUInt2ForUniform(e,t,i){fe._TempBufferUInt32View[0]=t,fe._TempBufferUInt32View[1]=i,this.updateUniform(e,fe._TempBuffer,2)}_updateUInt3ForEffect(e,t,i,s,n=""){this._currentEffect.setUInt3(e+n,t,i,s)}_updateUInt3ForUniform(e,t,i,s){fe._TempBufferUInt32View[0]=t,fe._TempBufferUInt32View[1]=i,fe._TempBufferUInt32View[2]=s,this.updateUniform(e,fe._TempBuffer,3)}_updateUInt4ForEffect(e,t,i,s,n,r=""){this._currentEffect.setUInt4(e+r,t,i,s,n)}_updateUInt4ForUniform(e,t,i,s,n){fe._TempBufferUInt32View[0]=t,fe._TempBufferUInt32View[1]=i,fe._TempBufferUInt32View[2]=s,fe._TempBufferUInt32View[3]=n,this.updateUniform(e,fe._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,!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)}}fe._UpdatedUbosInFrame={};fe._MAX_UNIFORM_SIZE=256;fe._TempBuffer=new Float32Array(fe._MAX_UNIFORM_SIZE);fe._TempBufferInt32View=new Int32Array(fe._TempBuffer.buffer);fe._TempBufferUInt32View=new Uint32Array(fe._TempBuffer.buffer);class At{constructor(){this.shaderLanguage=0}_addUniformToLeftOverUBO(e,t,i){let s=0;[e,t,s]=this._getArraySize(e,t,i);for(let n=0;n<this._webgpuProcessingContext.leftOverUniforms.length;n++)if(this._webgpuProcessingContext.leftOverUniforms[n].name===e)return;this._webgpuProcessingContext.leftOverUniforms.push({name:e,type:t,length:s})}_buildLeftOverUBO(){if(!this._webgpuProcessingContext.leftOverUniforms.length)return"";const e=At.LeftOvertUBOName;let t=this._webgpuProcessingContext.availableBuffers[e];return t||(t={binding:this._webgpuProcessingContext.getNextFreeUBOBinding()},this._webgpuProcessingContext.availableBuffers[e]=t,this._addBufferBindingDescription(e,t,"uniform",!0),this._addBufferBindingDescription(e,t,"uniform",!1)),this._generateLeftOverUBOCode(e,t)}_collectBindingNames(){for(let e=0;e<this._webgpuProcessingContext.bindGroupLayoutEntries.length;e++){const t=this._webgpuProcessingContext.bindGroupLayoutEntries[e];if(t===void 0){this._webgpuProcessingContext.bindGroupLayoutEntries[e]=[];continue}for(let i=0;i<t.length;i++){const s=this._webgpuProcessingContext.bindGroupLayoutEntries[e][i],n=this._webgpuProcessingContext.bindGroupLayoutEntryInfo[e][s.binding].name,r=this._webgpuProcessingContext.bindGroupLayoutEntryInfo[e][s.binding].nameInArrayOfTexture;s&&(s.texture||s.externalTexture||s.storageTexture?this._webgpuProcessingContext.textureNames.push(r):s.sampler?this._webgpuProcessingContext.samplerNames.push(n):s.buffer&&this._webgpuProcessingContext.bufferNames.push(n))}}}_preCreateBindGroupEntries(){const e=this._webgpuProcessingContext.bindGroupEntries;for(let t=0;t<this._webgpuProcessingContext.bindGroupLayoutEntries.length;t++){const i=this._webgpuProcessingContext.bindGroupLayoutEntries[t],s=[];for(let n=0;n<i.length;n++){const r=this._webgpuProcessingContext.bindGroupLayoutEntries[t][n];r.sampler||r.texture||r.storageTexture||r.externalTexture?s.push({binding:r.binding,resource:void 0}):r.buffer&&s.push({binding:r.binding,resource:{buffer:void 0,offset:0,size:0}})}e[t]=s}}_addTextureBindingDescription(e,t,i,s,n,r){let{groupIndex:o,bindingIndex:h}=t.textures[i];if(this._webgpuProcessingContext.bindGroupLayoutEntries[o]||(this._webgpuProcessingContext.bindGroupLayoutEntries[o]=[],this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o]=[]),!this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o][h]){let l;s===null?l=this._webgpuProcessingContext.bindGroupLayoutEntries[o].push({binding:h,visibility:0,externalTexture:{}}):n?l=this._webgpuProcessingContext.bindGroupLayoutEntries[o].push({binding:h,visibility:0,storageTexture:{access:"write-only",format:n,viewDimension:s}}):l=this._webgpuProcessingContext.bindGroupLayoutEntries[o].push({binding:h,visibility:0,texture:{sampleType:t.sampleType,viewDimension:s,multisampled:!1}});const c=t.isTextureArray?e+i:e;this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o][h]={name:e,index:l-1,nameInArrayOfTexture:c}}h=this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o][h].index,r?this._webgpuProcessingContext.bindGroupLayoutEntries[o][h].visibility|=1:this._webgpuProcessingContext.bindGroupLayoutEntries[o][h].visibility|=2}_addSamplerBindingDescription(e,t,i){let{groupIndex:s,bindingIndex:n}=t.binding;if(this._webgpuProcessingContext.bindGroupLayoutEntries[s]||(this._webgpuProcessingContext.bindGroupLayoutEntries[s]=[],this._webgpuProcessingContext.bindGroupLayoutEntryInfo[s]=[]),!this._webgpuProcessingContext.bindGroupLayoutEntryInfo[s][n]){const r=this._webgpuProcessingContext.bindGroupLayoutEntries[s].push({binding:n,visibility:0,sampler:{type:t.type}});this._webgpuProcessingContext.bindGroupLayoutEntryInfo[s][n]={name:e,index:r-1}}n=this._webgpuProcessingContext.bindGroupLayoutEntryInfo[s][n].index,i?this._webgpuProcessingContext.bindGroupLayoutEntries[s][n].visibility|=1:this._webgpuProcessingContext.bindGroupLayoutEntries[s][n].visibility|=2}_addBufferBindingDescription(e,t,i,s){let{groupIndex:n,bindingIndex:r}=t.binding;if(this._webgpuProcessingContext.bindGroupLayoutEntries[n]||(this._webgpuProcessingContext.bindGroupLayoutEntries[n]=[],this._webgpuProcessingContext.bindGroupLayoutEntryInfo[n]=[]),!this._webgpuProcessingContext.bindGroupLayoutEntryInfo[n][r]){const o=this._webgpuProcessingContext.bindGroupLayoutEntries[n].push({binding:r,visibility:0,buffer:{type:i}});this._webgpuProcessingContext.bindGroupLayoutEntryInfo[n][r]={name:e,index:o-1}}r=this._webgpuProcessingContext.bindGroupLayoutEntryInfo[n][r].index,s?this._webgpuProcessingContext.bindGroupLayoutEntries[n][r].visibility|=1:this._webgpuProcessingContext.bindGroupLayoutEntries[n][r].visibility|=2}}At.LeftOvertUBOName="LeftOver";At.InternalsUBOName="Internals";At.UniformSizes={bool:1,int:1,float:1,vec2:2,ivec2:2,uvec2:2,vec3:3,ivec3:3,uvec3:3,vec4:4,ivec4:4,uvec4:4,mat2:4,mat3:12,mat4:16,i32:1,u32:1,f32:1,mat2x2:4,mat3x3:12,mat4x4:16,mat2x2f:4,mat3x3f:12,mat4x4f:16,vec2i:2,vec3i:3,vec4i:4,vec2u:2,vec3u:3,vec4u:4,vec2f:2,vec3f:3,vec4f:4,vec2h:1,vec3h:2,vec4h:2};At._SamplerFunctionByWebGLSamplerType={sampler2D:"sampler2D",sampler2DArray:"sampler2DArray",sampler2DShadow:"sampler2DShadow",sampler2DArrayShadow:"sampler2DArrayShadow",samplerCube:"samplerCube",sampler3D:"sampler3D"};At._TextureTypeByWebGLSamplerType={sampler2D:"texture2D",sampler2DArray:"texture2DArray",sampler2DShadow:"texture2D",sampler2DArrayShadow:"texture2DArray",samplerCube:"textureCube",samplerCubeArray:"textureCubeArray",sampler3D:"texture3D"};At._GpuTextureViewDimensionByWebGPUTextureType={textureCube:"cube",textureCubeArray:"cube-array",texture2D:"2d",texture2DArray:"2d-array",texture3D:"3d"};At._SamplerTypeByWebGLSamplerType={sampler2DShadow:"samplerShadow",sampler2DArrayShadow:"samplerShadow"};At._IsComparisonSamplerByWebGPUSamplerType={samplerShadow:!0,samplerArrayShadow:!0,sampler:!1};class u_{get isAsync(){return!1}get isReady(){return!!this.stages}constructor(e,t){this.bindGroupLayouts={},this._name="unnamed",this.shaderProcessingContext=e,this._leftOverUniformsByName={},this.engine=t,this.vertexBufferKindToType={}}_handlesSpectorRebuildCallback(){}_fillEffectInformation(e,t,i,s,n,r,o,h){const l=this.engine;l._doNotHandleContextLost&&(e._fragmentSourceCode="",e._vertexSourceCode="");const c=this.shaderProcessingContext.availableTextures;let u;for(u=0;u<n.length;u++){const _=n[u],p=c[n[u]];p==null||p==null?(n.splice(u,1),u--):r[_]=u}for(const _ of l.getAttributes(this,o))h.push(_);this.buildUniformLayout();const f=[],d=[];for(u=0;u<o.length;u++){const _=h[u];_>=0&&(f.push(o[u]),d.push(_))}this.shaderProcessingContext.attributeNamesFromEffect=f,this.shaderProcessingContext.attributeLocationsFromEffect=d}buildUniformLayout(){var e;if(this.shaderProcessingContext.leftOverUniforms.length){(e=this.uniformBuffer)==null||e.dispose(),this.uniformBuffer=new fe(this.engine,void 0,void 0,"leftOver-"+this._name);for(const t of this.shaderProcessingContext.leftOverUniforms){const i=t.type.replace(/^(.*?)(<.*>)?$/,"$1"),s=At.UniformSizes[i];this.uniformBuffer.addUniform(t.name,s,t.length),this._leftOverUniformsByName[t.name]=t.type}this.uniformBuffer.create()}}setEngine(e){this.engine=e}dispose(){this.uniformBuffer&&this.uniformBuffer.dispose()}setInt(e,t){!this.uniformBuffer||!this._leftOverUniformsByName[e]||this.uniformBuffer.updateInt(e,t)}setInt2(e,t,i){!this.uniformBuffer||!this._leftOverUniformsByName[e]||this.uniformBuffer.updateInt2(e,t,i)}setInt3(e,t,i,s){!this.uniformBuffer||!this._leftOverUniformsByName[e]||this.uniformBuffer.updateInt3(e,t,i,s)}setInt4(e,t,i,s,n){!this.uniformBuffer||!this._leftOverUniformsByName[e]||this.uniformBuffer.updateInt4(e,t,i,s,n)}setIntArray(e,t){!this.uniformBuffer||!this._leftOverUniformsByName[e]||this.uniformBuffer.updateIntArray(e,t)}setIntArray2(e,t){this.setIntArray(e,t)}setIntArray3(e,t){this.setIntArray(e,t)}setIntArray4(e,t){this.setIntArray(e,t)}setUInt(e,t){!this.uniformBuffer||!this._leftOverUniformsByName[e]||this.uniformBuffer.updateUInt(e,t)}setUInt2(e,t,i){!this.uniformBuffer||!this._leftOverUniformsByName[e]||this.uniformBuffer.updateUInt2(e,t,i)}setUInt3(e,t,i,s){!this.uniformBuffer||!this._leftOverUniformsByName[e]||this.uniformBuffer.updateUInt3(e,t,i,s)}setUInt4(e,t,i,s,n){!this.uniformBuffer||!this._leftOverUniformsByName[e]||this.uniformBuffer.updateUInt4(e,t,i,s,n)}setUIntArray(e,t){!this.uniformBuffer||!this._leftOverUniformsByName[e]||this.uniformBuffer.updateUIntArray(e,t)}setUIntArray2(e,t){this.setUIntArray(e,t)}setUIntArray3(e,t){this.setUIntArray(e,t)}setUIntArray4(e,t){this.setUIntArray(e,t)}setArray(e,t){!this.uniformBuffer||!this._leftOverUniformsByName[e]||this.uniformBuffer.updateArray(e,t)}setArray2(e,t){this.setArray(e,t)}setArray3(e,t){this.setArray(e,t)}setArray4(e,t){this.setArray(e,t)}setMatrices(e,t){!this.uniformBuffer||!this._leftOverUniformsByName[e]||this.uniformBuffer.updateMatrices(e,t)}setMatrix(e,t){!this.uniformBuffer||!this._leftOverUniformsByName[e]||this.uniformBuffer.updateMatrix(e,t)}setMatrix3x3(e,t){!this.uniformBuffer||!this._leftOverUniformsByName[e]||this.uniformBuffer.updateMatrix3x3(e,t)}setMatrix2x2(e,t){!this.uniformBuffer||!this._leftOverUniformsByName[e]||this.uniformBuffer.updateMatrix2x2(e,t)}setFloat(e,t){!this.uniformBuffer||!this._leftOverUniformsByName[e]||this.uniformBuffer.updateFloat(e,t)}setVector2(e,t){this.setFloat2(e,t.x,t.y)}setFloat2(e,t,i){!this.uniformBuffer||!this._leftOverUniformsByName[e]||this.uniformBuffer.updateFloat2(e,t,i)}setVector3(e,t){this.setFloat3(e,t.x,t.y,t.z)}setFloat3(e,t,i,s){!this.uniformBuffer||!this._leftOverUniformsByName[e]||this.uniformBuffer.updateFloat3(e,t,i,s)}setVector4(e,t){this.setFloat4(e,t.x,t.y,t.z,t.w)}setQuaternion(e,t){this.setFloat4(e,t.x,t.y,t.z,t.w)}setFloat4(e,t,i,s,n){!this.uniformBuffer||!this._leftOverUniformsByName[e]||this.uniformBuffer.updateFloat4(e,t,i,s,n)}setColor3(e,t){this.setFloat3(e,t.r,t.g,t.b)}setColor4(e,t,i){this.setFloat4(e,t.r,t.g,t.b,i)}setDirectColor4(e,t){this.setFloat4(e,t.r,t.g,t.b,t.a)}_getVertexShaderCode(){var e;return(e=this.sources)==null?void 0:e.vertex}_getFragmentShaderCode(){var e;return(e=this.sources)==null?void 0:e.fragment}}const f_=4,d_=65536,Ih={mat2:2,mat3:3,mat4:4,mat2x2:2,mat3x3:3,mat4x4:4};class ni{static get KnownUBOs(){return ni._SimplifiedKnownBindings?ni._SimplifiedKnownUBOs:ni._KnownUBOs}constructor(e,t=!1){this.vertexBufferKindToNumberOfComponents={},this.shaderLanguage=e,this._attributeNextLocation=0,this._varyingNextLocation=0,this.freeGroupIndex=0,this.freeBindingIndex=0,this.availableVaryings={},this.availableAttributes={},this.availableBuffers={},this.availableTextures={},this.availableSamplers={},this.orderedAttributes=[],this.bindGroupLayoutEntries=[],this.bindGroupLayoutEntryInfo=[],this.bindGroupEntries=[],this.bufferNames=[],this.textureNames=[],this.samplerNames=[],this.leftOverUniforms=[],t||this._findStartingGroupBinding()}_findStartingGroupBinding(){const e=ni.KnownUBOs,t=[];for(const i in e){const s=e[i].binding;s.groupIndex!==-1&&(t[s.groupIndex]===void 0?t[s.groupIndex]=s.bindingIndex:t[s.groupIndex]=Math.max(t[s.groupIndex],s.bindingIndex))}this.freeGroupIndex=t.length-1,this.freeGroupIndex===0?(this.freeGroupIndex++,this.freeBindingIndex=0):this.freeBindingIndex=t[t.length-1]+1}getAttributeNextLocation(e,t=0){var s;const i=this._attributeNextLocation;return this._attributeNextLocation+=((s=Ih[e])!=null?s:1)*(t||1),i}getVaryingNextLocation(e,t=0){var s;const i=this._varyingNextLocation;return this._varyingNextLocation+=((s=Ih[e])!=null?s:1)*(t||1),i}getNextFreeUBOBinding(){return this._getNextFreeBinding(1)}_getNextFreeBinding(e){if(this.freeBindingIndex>d_-e&&(this.freeGroupIndex++,this.freeBindingIndex=0),this.freeGroupIndex===f_)throw"Too many textures or UBOs have been declared and it is not supported in WebGPU.";const t={groupIndex:this.freeGroupIndex,bindingIndex:this.freeBindingIndex};return this.freeBindingIndex+=e,t}}ni._SimplifiedKnownBindings=!0;ni._SimplifiedKnownUBOs={Scene:{binding:{groupIndex:0,bindingIndex:0}},Light0:{binding:{groupIndex:-1,bindingIndex:-1}},Light1:{binding:{groupIndex:-1,bindingIndex:-1}},Light2:{binding:{groupIndex:-1,bindingIndex:-1}},Light3:{binding:{groupIndex:-1,bindingIndex:-1}},Light4:{binding:{groupIndex:-1,bindingIndex:-1}},Light5:{binding:{groupIndex:-1,bindingIndex:-1}},Light6:{binding:{groupIndex:-1,bindingIndex:-1}},Light7:{binding:{groupIndex:-1,bindingIndex:-1}},Light8:{binding:{groupIndex:-1,bindingIndex:-1}},Light9:{binding:{groupIndex:-1,bindingIndex:-1}},Light10:{binding:{groupIndex:-1,bindingIndex:-1}},Light11:{binding:{groupIndex:-1,bindingIndex:-1}},Light12:{binding:{groupIndex:-1,bindingIndex:-1}},Light13:{binding:{groupIndex:-1,bindingIndex:-1}},Light14:{binding:{groupIndex:-1,bindingIndex:-1}},Light15:{binding:{groupIndex:-1,bindingIndex:-1}},Light16:{binding:{groupIndex:-1,bindingIndex:-1}},Light17:{binding:{groupIndex:-1,bindingIndex:-1}},Light18:{binding:{groupIndex:-1,bindingIndex:-1}},Light19:{binding:{groupIndex:-1,bindingIndex:-1}},Light20:{binding:{groupIndex:-1,bindingIndex:-1}},Light21:{binding:{groupIndex:-1,bindingIndex:-1}},Light22:{binding:{groupIndex:-1,bindingIndex:-1}},Light23:{binding:{groupIndex:-1,bindingIndex:-1}},Light24:{binding:{groupIndex:-1,bindingIndex:-1}},Light25:{binding:{groupIndex:-1,bindingIndex:-1}},Light26:{binding:{groupIndex:-1,bindingIndex:-1}},Light27:{binding:{groupIndex:-1,bindingIndex:-1}},Light28:{binding:{groupIndex:-1,bindingIndex:-1}},Light29:{binding:{groupIndex:-1,bindingIndex:-1}},Light30:{binding:{groupIndex:-1,bindingIndex:-1}},Light31:{binding:{groupIndex:-1,bindingIndex:-1}},Material:{binding:{groupIndex:-1,bindingIndex:-1}},Mesh:{binding:{groupIndex:-1,bindingIndex:-1}},Internals:{binding:{groupIndex:-1,bindingIndex:-1}}};ni._KnownUBOs={Scene:{binding:{groupIndex:0,bindingIndex:0}},Light0:{binding:{groupIndex:1,bindingIndex:0}},Light1:{binding:{groupIndex:1,bindingIndex:1}},Light2:{binding:{groupIndex:1,bindingIndex:2}},Light3:{binding:{groupIndex:1,bindingIndex:3}},Light4:{binding:{groupIndex:1,bindingIndex:4}},Light5:{binding:{groupIndex:1,bindingIndex:5}},Light6:{binding:{groupIndex:1,bindingIndex:6}},Light7:{binding:{groupIndex:1,bindingIndex:7}},Light8:{binding:{groupIndex:1,bindingIndex:8}},Light9:{binding:{groupIndex:1,bindingIndex:9}},Light10:{binding:{groupIndex:1,bindingIndex:10}},Light11:{binding:{groupIndex:1,bindingIndex:11}},Light12:{binding:{groupIndex:1,bindingIndex:12}},Light13:{binding:{groupIndex:1,bindingIndex:13}},Light14:{binding:{groupIndex:1,bindingIndex:14}},Light15:{binding:{groupIndex:1,bindingIndex:15}},Light16:{binding:{groupIndex:1,bindingIndex:16}},Light17:{binding:{groupIndex:1,bindingIndex:17}},Light18:{binding:{groupIndex:1,bindingIndex:18}},Light19:{binding:{groupIndex:1,bindingIndex:19}},Light20:{binding:{groupIndex:1,bindingIndex:20}},Light21:{binding:{groupIndex:1,bindingIndex:21}},Light22:{binding:{groupIndex:1,bindingIndex:22}},Light23:{binding:{groupIndex:1,bindingIndex:23}},Light24:{binding:{groupIndex:1,bindingIndex:24}},Light25:{binding:{groupIndex:1,bindingIndex:25}},Light26:{binding:{groupIndex:1,bindingIndex:26}},Light27:{binding:{groupIndex:1,bindingIndex:27}},Light28:{binding:{groupIndex:1,bindingIndex:28}},Light29:{binding:{groupIndex:1,bindingIndex:29}},Light30:{binding:{groupIndex:1,bindingIndex:30}},Light31:{binding:{groupIndex:1,bindingIndex:31}},Material:{binding:{groupIndex:2,bindingIndex:0}},Mesh:{binding:{groupIndex:2,bindingIndex:1}},Internals:{binding:{groupIndex:2,bindingIndex:2}}};function ar(a,e,t,i){let s=i,n=0,r="";for(;s<t.length;){const o=t.charAt(s);if(r)o===r?r==='"'||r==="'"?t.charAt(s-1)!=="\\"&&(r=""):r="":r==="*/"&&o==="*"&&s+1<t.length&&(t.charAt(s+1)==="/"&&(r=""),r===""&&s++);else switch(o){case a:n++;break;case e:n--;break;case'"':case"'":case"`":r=o;break;case"/":if(s+1<t.length){const h=t.charAt(s+1);h==="/"?r="\n":h==="*"&&(r="*/")}break}if(s++,n===0)break}return n===0?s-1:-1}function Eh(a,e){for(;e<a.length;){const t=a[e];if(t!==" "&&t!=="\n"&&t!=="\r"&&t!==" "&&t!=="\n"&&t!==" ")break;e++}return e}function va(a){const e=a.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e==95}function Na(a){let e=0,t="",i=!1;const s=[];for(;e<a.length;){const n=a.charAt(e);if(t)n===t?t==='"'||t==="'"?(a.charAt(e-1)!=="\\"&&(t=""),s.push(n)):(t="",i=!1):t==="*/"&&n==="*"&&e+1<a.length?(a.charAt(e+1)==="/"&&(t=""),t===""&&(i=!1,e++)):i||s.push(n);else{switch(n){case'"':case"'":case"`":t=n;break;case"/":if(e+1<a.length){const r=a.charAt(e+1);r==="/"?(t="\n",i=!0):r==="*"&&(t="*/",i=!0)}break}i||s.push(n)}e++}return s.join("")}function __(a,e,t,i){for(;e>=0&&a.charAt(e)!==t&&a.charAt(e)!==i;)e--;return e}function p_(a){return a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ua(a,e,t,i){let s=a.indexOf(e);if(s<0)return a;if(t){for(;s++<a.length&&a.charAt(s)!="{";);if(s<a.length){const n=a.substring(0,s+1),r=a.substring(s+1);a=n+t+r}}if(i){const n=a.lastIndexOf("}");a=a.substring(0,n),a+=i+"\n}"}return a}class g_ extends At{constructor(){super(...arguments),this._missingVaryings=[],this._textureArrayProcessing=[],this._vertexIsGLES3=!1,this._fragmentIsGLES3=!1,this.shaderLanguage=0,this.parseGLES3=!0}_getArraySize(e,t,i){let s=0;const n=e.indexOf("["),r=e.indexOf("]");if(n>0&&r>0){const o=e.substring(n+1,r);s=+o,isNaN(s)&&(s=+i[o.trim()]),e=e.substring(0,n)}return[e,t,s]}initializeShaders(e){this._webgpuProcessingContext=e,this._missingVaryings.length=0,this._textureArrayProcessing.length=0,this.attributeKeywordName=void 0,this.varyingVertexKeywordName=void 0,this.varyingFragmentKeywordName=void 0}preProcessShaderCode(e,t){const i="// Internals UBO\nuniform ".concat(At.InternalsUBOName," {\nfloat yFactor_;\nfloat textureOutputHeight_;\n};\n"),s=e.indexOf("// Internals UBO")!==-1;return t?(this._fragmentIsGLES3=e.indexOf("#version 3")!==-1,this._fragmentIsGLES3&&(this.varyingFragmentKeywordName="in"),s?e:i+"##INJECTCODE##\n"+e):(this._vertexIsGLES3=e.indexOf("#version 3")!==-1,this._vertexIsGLES3&&(this.attributeKeywordName="in",this.varyingVertexKeywordName="out"),s?e:i+e)}varyingCheck(e,t){const i=/(flat\s)?\s*\bout\b/,s=/(flat\s)?\s*\bin\b/,n=/(flat\s)?\s*\bvarying\b/;return(t&&this._fragmentIsGLES3?s:!t&&this._vertexIsGLES3?i:n).test(e)}varyingProcessor(e,t,i){var l;this._preProcessors=i;const s=/\s*(flat)?\s*out\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm,n=/\s*(flat)?\s*in\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm,r=/\s*(flat)?\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm,h=(t&&this._fragmentIsGLES3?n:!t&&this._vertexIsGLES3?s:r).exec(e);if(h!==null){const c=(l=h[1])!=null?l:"",u=h[2],f=h[3];let d;t?(d=this._webgpuProcessingContext.availableVaryings[f],this._missingVaryings[d]="",d===void 0&&U.Warn('Invalid fragment shader: The varying named "'.concat(f,'" is not declared in the vertex shader! This declaration will be ignored.'))):(d=this._webgpuProcessingContext.getVaryingNextLocation(u,this._getArraySize(f,u,i)[2]),this._webgpuProcessingContext.availableVaryings[f]=d,this._missingVaryings[d]="layout(location = ".concat(d,") ").concat(c," in ").concat(u," ").concat(f,";")),e=e.replace(h[0],d===void 0?"":"layout(location = ".concat(d,") ").concat(c," ").concat(t?"in":"out"," ").concat(u," ").concat(f,";"))}return e}attributeProcessor(e,t){this._preProcessors=t;const i=/\s*in\s+(\S+)\s+(\S+)\s*;/gm,s=/\s*attribute\s+(\S+)\s+(\S+)\s*;/gm,r=(this._vertexIsGLES3?i:s).exec(e);if(r!==null){const o=r[1],h=r[2],l=this._webgpuProcessingContext.getAttributeNextLocation(o,this._getArraySize(h,o,t)[2]);this._webgpuProcessingContext.availableAttributes[h]=l,this._webgpuProcessingContext.orderedAttributes[l]=h;const c=this._webgpuProcessingContext.vertexBufferKindToNumberOfComponents[h];if(c!==void 0){const u=c<0?c===-1?"int":"ivec"+-c:c===1?"uint":"uvec"+c,f="_int_".concat(h,"_");e=e.replace(r[0],"layout(location = ".concat(l,") in ").concat(u," ").concat(f,"; ").concat(o," ").concat(h," = ").concat(o,"(").concat(f,");"))}else e=e.replace(r[0],"layout(location = ".concat(l,") in ").concat(o," ").concat(h,";"))}return e}uniformProcessor(e,t,i){var r;this._preProcessors=i;const n=/\s*uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm.exec(e);if(n!==null){let o=n[1],h=n[2];if(o.indexOf("sampler")===0||o.indexOf("sampler")===1){let l=0;[h,o,l]=this._getArraySize(h,o,i);let c=this._webgpuProcessingContext.availableTextures[h];if(!c){c={autoBindSampler:!0,isTextureArray:l>0,isStorageTexture:!1,textures:[],sampleType:"float"};for(let E=0;E<(l||1);++E)c.textures.push(this._webgpuProcessingContext.getNextFreeUBOBinding())}const u=(r=At._SamplerTypeByWebGLSamplerType[o])!=null?r:"sampler",f=!!At._IsComparisonSamplerByWebGPUSamplerType[u],d=f?"comparison":"filtering",_=h+"Sampler";let p=this._webgpuProcessingContext.availableSamplers[_];p||(p={binding:this._webgpuProcessingContext.getNextFreeUBOBinding(),type:d});const g=o.charAt(0)==="u"?"u":o.charAt(0)==="i"?"i":"";g&&(o=o.substring(1));const m=f?"depth":g==="u"?"uint":g==="i"?"sint":"float";c.sampleType=m;const b=l>0,I=p.binding.groupIndex,T=p.binding.bindingIndex,x=At._SamplerFunctionByWebGLSamplerType[o],y=At._TextureTypeByWebGLSamplerType[o],R=At._GpuTextureViewDimensionByWebGPUTextureType[y];if(!b)l=1,e="layout(set = ".concat(I,", binding = ").concat(T,") uniform ").concat(u," ").concat(_,";\n layout(set = ").concat(c.textures[0].groupIndex,", binding = ").concat(c.textures[0].bindingIndex,") uniform ").concat(g).concat(y," ").concat(h,"Texture;\n #define ").concat(h," ").concat(g).concat(x,"(").concat(h,"Texture, ").concat(_,")");else{const E=[];E.push("layout(set = ".concat(I,", binding = ").concat(T,") uniform ").concat(g).concat(u," ").concat(_,";")),e="\n";for(let C=0;C<l;++C){const S=c.textures[C].groupIndex,w=c.textures[C].bindingIndex;E.push("layout(set = ".concat(S,", binding = ").concat(w,") uniform ").concat(y," ").concat(h,"Texture").concat(C,";")),e+="".concat(C>0?"\n":"","#define ").concat(h).concat(C," ").concat(g).concat(x,"(").concat(h,"Texture").concat(C,", ").concat(_,")")}e=E.join("\n")+e,this._textureArrayProcessing.push(h)}this._webgpuProcessingContext.availableTextures[h]=c,this._webgpuProcessingContext.availableSamplers[_]=p,this._addSamplerBindingDescription(_,p,!t);for(let E=0;E<l;++E)this._addTextureBindingDescription(h,c,E,R,null,!t)}else this._addUniformToLeftOverUBO(h,o,i),e=""}return e}uniformBufferProcessor(e,t){const s=/uniform\s+(\w+)/gm.exec(e);if(s!==null){const n=s[1];let r=this._webgpuProcessingContext.availableBuffers[n];if(!r){const o=ni.KnownUBOs[n];let h;o&&o.binding.groupIndex!==-1?h=o.binding:h=this._webgpuProcessingContext.getNextFreeUBOBinding(),r={binding:h},this._webgpuProcessingContext.availableBuffers[n]=r}this._addBufferBindingDescription(n,r,"uniform",!t),e=e.replace("uniform","layout(set = ".concat(r.binding.groupIndex,", binding = ").concat(r.binding.bindingIndex,") uniform"))}return e}postProcessor(e,t,i,s,n){const r=e.search(/#extension.+GL_EXT_draw_buffers.+require/)!==-1,o=/#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(o,""),e=e.replace(/texture2D\s*\(/g,"texture("),i){const h=e.indexOf("gl_FragCoord")>=0,l="\n glFragCoord_ = gl_FragCoord;\n if (yFactor_ == 1.) {\n glFragCoord_.y = textureOutputHeight_ - glFragCoord_.y;\n }\n ",c=h?"vec4 glFragCoord_;\n":"",u=e.search(/layout *\(location *= *0\) *out/g)!==-1;if(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(/gl_FragCoord/g,"glFragCoord_"),!this._fragmentIsGLES3)e=e.replace(/void\s+?main\s*\(/g,(r||u?"":"layout(location = 0) out vec4 glFragColor;\n")+"void main(");else{const f=/^\s*out\s+\S+\s+\S+\s*;/gm.exec(e);f!==null&&(e=e.substring(0,f.index)+"layout(location = 0) "+e.substring(f.index))}e=e.replace(/dFdy/g,"(-yFactor_)*dFdy"),e=e.replace("##INJECTCODE##",c),h&&(e=Ua(e,"void main",l))}else if(e=e.replace(/gl_InstanceID/g,"gl_InstanceIndex"),e=e.replace(/gl_VertexID/g,"gl_VertexIndex"),t.indexOf("#define MULTIVIEW")!==-1)return"#extension GL_OVR_multiview2 : require\nlayout (num_views = 2) in;\n"+e;if(!i){const h=e.lastIndexOf("}");e=e.substring(0,h),e+="gl_Position.y *= yFactor_;\n",e+="}"}return e}_applyTextureArrayProcessing(e,t){const i=new RegExp(t+"\\s*\\[(.+)?\\]","gm");let s=i.exec(e);for(;s!==null;){const n=s[1];let r=+n;this._preProcessors&&isNaN(r)&&(r=+this._preProcessors[n.trim()]),e=e.replace(s[0],t+r),s=i.exec(e)}return e}_generateLeftOverUBOCode(e,t){let i="layout(set = ".concat(t.binding.groupIndex,", binding = ").concat(t.binding.bindingIndex,") uniform ").concat(e," {\n ");for(const s of this._webgpuProcessingContext.leftOverUniforms)s.length>0?i+=" ".concat(s.type," ").concat(s.name,"[").concat(s.length,"];\n"):i+=" ".concat(s.type," ").concat(s.name,";\n");return i+="};\n\n",i}finalizeShaders(e,t){for(let s=0;s<this._textureArrayProcessing.length;++s){const n=this._textureArrayProcessing[s];e=this._applyTextureArrayProcessing(e,n),t=this._applyTextureArrayProcessing(t,n)}for(let s=0;s<this._missingVaryings.length;++s){const n=this._missingVaryings[s];n&&n.length>0&&(t=n+"\n"+t)}const i=this._buildLeftOverUBO();return e=i+e,t=i+t,this._collectBindingNames(),this._preCreateBindGroupEntries(),this._preProcessors=null,this._webgpuProcessingContext.vertexBufferKindToNumberOfComponents={},{vertexCode:e,fragmentCode:t}}}const m_="bakedVertexAnimationDeclaration",v_="#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\nuniform bakedVertexAnimationTime: f32;uniform bakedVertexAnimationTextureSizeInverted: vec2<f32>;uniform bakedVertexAnimationSettings: vec4<f32>;var bakedVertexAnimationTexture : texture_2d<f32>;\n#ifdef INSTANCES\nattribute bakedVertexAnimationSettingsInstanced : vec4<f32>;\n#endif\nfn readMatrixFromRawSamplerVAT(smp : texture_2d<f32>,index : f32,frame : f32)->mat4x4<f32>\n{let offset=i32(index)*4;let frameUV=i32(frame);let m0=textureLoad(smp,vec2<i32>(offset+0,frameUV),0);let m1=textureLoad(smp,vec2<i32>(offset+1,frameUV),0);let m2=textureLoad(smp,vec2<i32>(offset+2,frameUV),0);let m3=textureLoad(smp,vec2<i32>(offset+3,frameUV),0);return mat4x4<f32>(m0,m1,m2,m3);}\n#endif\n";Me.IncludesShadersStoreWGSL[m_]=v_;const b_="bakedVertexAnimation",x_="#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\n{\n#ifdef INSTANCES\nlet VATStartFrame: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.x;let VATEndFrame: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.y;let VATOffsetFrame: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.z;let VATSpeed: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.w;\n#else\nlet VATStartFrame: f32=uniforms.bakedVertexAnimationSettings.x;let VATEndFrame: f32=uniforms.bakedVertexAnimationSettings.y;let VATOffsetFrame: f32=uniforms.bakedVertexAnimationSettings.z;let VATSpeed: f32=uniforms.bakedVertexAnimationSettings.w;\n#endif\nlet totalFrames: f32=VATEndFrame-VATStartFrame+1.0;let time: f32=uniforms.bakedVertexAnimationTime*VATSpeed/totalFrames;let frameCorrection: f32=select(1.0,0.0,time<1.0);let numOfFrames: f32=totalFrames-frameCorrection;var VATFrameNum: f32=fract(time)*numOfFrames;VATFrameNum=(VATFrameNum+VATOffsetFrame) % numOfFrames;VATFrameNum=floor(VATFrameNum);VATFrameNum=VATFrameNum+VATStartFrame+frameCorrection;var VATInfluence : mat4x4<f32>;VATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[0],VATFrameNum)*vertexInputs.matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[1],VATFrameNum)*vertexInputs.matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[2],VATFrameNum)*vertexInputs.matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[3],VATFrameNum)*vertexInputs.matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[0],VATFrameNum)*vertexInputs.matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[1],VATFrameNum)*vertexInputs.matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[2],VATFrameNum)*vertexInputs.matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[3],VATFrameNum)*vertexInputs.matricesWeightsExtra[3];\n#endif\nfinalWorld=finalWorld*VATInfluence;}\n#endif\n";Me.IncludesShadersStoreWGSL[b_]=x_;const y_="instancesDeclaration",T_="#ifdef INSTANCES\nattribute world0 : vec4<f32>;attribute world1 : vec4<f32>;attribute world2 : vec4<f32>;attribute world3 : vec4<f32>;\n#ifdef INSTANCESCOLOR\nattribute instanceColor : vec4<f32>;\n#endif\n#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)\nuniform world : mat4x4<f32>;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nattribute previousWorld0 : vec4<f32>;attribute previousWorld1 : vec4<f32>;attribute previousWorld2 : vec4<f32>;attribute previousWorld3 : vec4<f32>;\n#ifdef THIN_INSTANCES\nuniform previousWorld : mat4x4<f32>;\n#endif\n#endif\n#else\n#if !defined(WORLD_UBO)\nuniform world : mat4x4<f32>;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nuniform previousWorld : mat4x4<f32>;\n#endif\n#endif\n";Me.IncludesShadersStoreWGSL[y_]=T_;const A_="instancesVertex",R_="#ifdef INSTANCES\nvar finalWorld=mat4x4<f32>(vertexInputs.world0,vertexInputs.world1,vertexInputs.world2,vertexInputs.world3);\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nvar finalPreviousWorld=mat4x4<f32>(\nvertexInputs.previousWorld0,vertexInputs.previousWorld1,\nvertexInputs.previousWorld2,vertexInputs.previousWorld3);\n#endif\n#ifdef THIN_INSTANCES\n#if !defined(WORLD_UBO)\nfinalWorld=uniforms.world*finalWorld;\n#else\nfinalWorld=mesh.world*finalWorld;\n#endif\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nfinalPreviousWorld=uniforms.previousWorld*finalPreviousWorld;\n#endif\n#endif\n#else\n#if !defined(WORLD_UBO)\nvar finalWorld=uniforms.world;\n#else\nvar finalWorld=mesh.world;\n#endif\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nvar finalPreviousWorld=uniforms.previousWorld;\n#endif\n#endif\n";Me.IncludesShadersStoreWGSL[A_]=R_;const I_="helperFunctions",E_="const PI: f32=3.1415926535897932384626433832795;const RECIPROCAL_PI: f32=0.3183098861837907;const RECIPROCAL_PI2: f32=0.15915494309189535;const HALF_MIN: f32=5.96046448e-08; \nconst LinearEncodePowerApprox: f32=2.2;const GammaEncodePowerApprox: f32=1.0/LinearEncodePowerApprox;const LuminanceEncodeApprox: vec3<f32>=vec3<f32> (0.2126,0.7152,0.0722);const Epsilon:f32=0.0000001;fn square(x: f32)->f32 {return x*x;}\nfn saturate(x: f32)->f32 {return clamp(x,0.0,1.0);}\nfn saturateVec3(x: vec3f)->vec3f {return clamp(x,vec3f(0.0),vec3f(1.0));}\nfn saturateEps(x: f32)->f32 {return clamp(x,Epsilon,1.0);} \nfn maxEps(x: f32)->f32 {return max(x,Epsilon);}\nfn maxEpsVec3(x: vec3f)->vec3f {return max(x,vec3f(Epsilon));}\nfn absEps(x: f32)->f32 {return abs(x)+Epsilon;}\nfn transposeMat3(inMatrix: mat3x3f)->mat3x3f {let i0: vec3<f32>=inMatrix[0];let i1: vec3<f32>=inMatrix[1];let i2: vec3<f32>=inMatrix[2];let outMatrix:mat3x3f=mat3x3f(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);return outMatrix;}\nfn inverseMat3(inMatrix: mat3x3f)->mat3x3f {let a00: f32=inMatrix[0][0];let a01: f32=inMatrix[0][1];let a02: f32=inMatrix[0][2];let a10: f32=inMatrix[1][0];let a11: f32=inMatrix[1][1];let a12: f32=inMatrix[1][2];let a20: f32=inMatrix[2][0];let a21: f32=inMatrix[2][1];let a22: f32=inMatrix[2][2];let b01: f32=a22*a11-a12*a21;let b11: f32=-a22*a10+a12*a20;let b21: f32=a21*a10-a11*a20;let det: f32=a00*b01+a01*b11+a02*b21;return mat3x3f(b01/det,(-a22*a01+a02*a21)/det,(a12*a01-a02*a11)/det,\nb11/det,(a22*a00-a02*a20)/det,(-a12*a00+a02*a10)/det,\nb21/det,(-a21*a00+a01*a20)/det,(a11*a00-a01*a10)/det);}\n#if USE_EXACT_SRGB_CONVERSIONS\nfn toLinearSpaceExact(color: vec3<f32>)->vec3<f32>\n{let nearZeroSection: vec3<f32>=0.0773993808*color;let remainingSection: vec3<f32>=pow(0.947867299*(color+vec3<f32>(0.055)),vec3<f32>(2.4));return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3<f32>(0.04045)));}\nfn toGammaSpaceExact(color: vec3<f32>)->vec3<f32>\n{let nearZeroSection: vec3<f32>=12.92*color;let remainingSection: vec3<f32>=1.055*pow(color,vec3<f32>(0.41666))-vec3<f32>(0.055);return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3<f32>(0.0031308)));}\n#endif\nfn toLinearSpace(color: f32)->f32\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nvar nearZeroSection=0.0773993808*color;var remainingSection=pow(0.947867299*(color+0.055),2.4);return select(remainingSection,nearZeroSection,color<=0.04045);\n#else\nreturn pow(color,LinearEncodePowerApprox);\n#endif\n}\nfn toLinearSpaceVec3(color: vec3<f32>)->vec3<f32>\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn toLinearSpaceExact(color);\n#else\nreturn pow(color,vec3<f32>(LinearEncodePowerApprox));\n#endif\n}\nfn toLinearSpaceVec4(color: vec4<f32>)->vec4<f32>\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn vec4f(toLinearSpaceExact(color.rgb),color.a);\n#else\nreturn vec4f(pow(color.rgb,vec3f(LinearEncodePowerApprox)),color.a);\n#endif\n}\nfn toGammaSpace(color: vec4<f32>)->vec4<f32>\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn vec4<f32>(toGammaSpaceExact(color.rgb),color.a);\n#else\nreturn vec4<f32>(pow(color.rgb,vec3<f32>(GammaEncodePowerApprox)),color.a);\n#endif\n}\nfn toGammaSpaceVec3(color: vec3<f32>)->vec3<f32>\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn toGammaSpaceExact(color);\n#else\nreturn pow(color,vec3<f32>(GammaEncodePowerApprox));\n#endif\n}\nfn squareVec3(value: vec3<f32>)->vec3<f32>\n{return value*value;}\nfn pow5(value: f32)->f32 {let sq: f32=value*value;return sq*sq*value;}\nfn getLuminance(color: vec3<f32>)->f32\n{return clamp(dot(color,LuminanceEncodeApprox),0.,1.);}\nfn getRand(seed: vec2<f32>)->f32 {return fract(sin(dot(seed.xy ,vec2<f32>(12.9898,78.233)))*43758.5453);}\nfn dither(seed: vec2<f32>,varianceAmount: f32)->f32 {let rand: f32=getRand(seed);let normVariance: f32=varianceAmount/255.0;let dither: f32=mix(-normVariance,normVariance,rand);return dither;}\nconst rgbdMaxRange: f32=255.0;fn toRGBD(color: vec3<f32>)->vec4<f32> {let maxRGB: f32=max(max(color.r,max(color.g,color.b)),Epsilon);var D: f32 =max(rgbdMaxRange/maxRGB,1.);D =clamp(floor(D)/255.0,0.,1.);var rgb: vec3<f32> =color.rgb*D;rgb=toGammaSpaceVec3(rgb);return vec4<f32>(clamp(rgb,vec3<f32>(0.,0.,0.),vec3<f32>(1.,1.,1.)),D); }\nfn fromRGBD(rgbd: vec4<f32>)->vec3<f32> {let rgb=toLinearSpaceVec3(rgbd.rgb);return rgb/rgbd.a;}\nfn parallaxCorrectNormal(vertexPos: vec3<f32>,origVec: vec3<f32>,cubeSize: vec3<f32>,cubePos: vec3<f32>)->vec3<f32> {let invOrigVec: vec3<f32>=vec3<f32>(1.0,1.0,1.0)/origVec;let halfSize: vec3<f32>=cubeSize*0.5;let intersecAtMaxPlane: vec3<f32>=(cubePos+halfSize-vertexPos)*invOrigVec;let intersecAtMinPlane: vec3<f32>=(cubePos-halfSize-vertexPos)*invOrigVec;let largestIntersec: vec3<f32>=max(intersecAtMaxPlane,intersecAtMinPlane);let distance: f32=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);let intersectPositionWS: vec3<f32>=vertexPos+origVec*distance;return intersectPositionWS-cubePos;}\n";Me.IncludesShadersStoreWGSL[I_]=E_;const C_="fresnelFunction",S_="#ifdef FRESNEL\nfn computeFresnelTerm(viewDirection: vec3f,worldNormal: vec3f,bias: f32,power: f32)->f32\n{let fresnelTerm: f32=pow(bias+abs(dot(viewDirection,worldNormal)),power);return clamp(fresnelTerm,0.,1.);}\n#endif\n";Me.IncludesShadersStoreWGSL[C_]=S_;const M_="meshUboDeclaration",P_="struct Mesh {world : mat4x4<f32>,\nvisibility : f32,};var<uniform> mesh : Mesh;\n#define WORLD_UBO\n";Me.IncludesShadersStoreWGSL[M_]=P_;const w_="sceneUboDeclaration",D_="struct Scene {viewProjection : mat4x4<f32>,\n#ifdef MULTIVIEW\nviewProjectionR : mat4x4<f32>,\n#endif \nview : mat4x4<f32>,\nprojection : mat4x4<f32>,\nvEyePosition : vec4<f32>,};var<uniform> scene : Scene;\n";Me.IncludesShadersStoreWGSL[w_]=D_;const F_="decalFragment",O_="#ifdef DECAL\nvar decalTempColor=decalColor.rgb;var decalTempAlpha=decalColor.a;\n#ifdef GAMMADECAL\ndecalTempColor=toLinearSpaceVec3(decalColor.rgb);\n#endif\n#ifdef DECAL_SMOOTHALPHA\ndecalTempAlpha=decalColor.a*decalColor.a;\n#endif\nsurfaceAlbedo=mix(surfaceAlbedo.rgb,decalTempColor,decalTempAlpha);\n#endif\n";Me.IncludesShadersStoreWGSL[F_]=O_;const Ch="fragmentOutputs.fragDepth",B_="uniforms",L_="internals",N_={texture_1d:"1d",texture_2d:"2d",texture_2d_array:"2d-array",texture_3d:"3d",texture_cube:"cube",texture_cube_array:"cube-array",texture_multisampled_2d:"2d",texture_depth_2d:"2d",texture_depth_2d_array:"2d-array",texture_depth_cube:"cube",texture_depth_cube_array:"cube-array",texture_depth_multisampled_2d:"2d",texture_storage_1d:"1d",texture_storage_2d:"2d",texture_storage_2d_array:"2d-array",texture_storage_3d:"3d",texture_external:null};class U_ extends At{constructor(){super(...arguments),this.shaderLanguage=1,this.uniformRegexp=/uniform\s+(\w+)\s*:\s*(.+)\s*;/,this.textureRegexp=/var\s+(\w+)\s*:\s*((array<\s*)?(texture_\w+)\s*(<\s*(.+)\s*>)?\s*(,\s*\w+\s*>\s*)?);/,this.noPrecision=!0,this.pureMode=!1}preProcessor(e,t,i,s,n){for(const r in i){if(r==="__VERSION__")continue;const o=i[r];(!isNaN(parseInt(o))||!isNaN(parseFloat(o)))&&(e="const ".concat(r," = ").concat(o,";\n")+e)}return e}_getArraySize(e,t,i){let s=0;const n=t.lastIndexOf(">");if(t.indexOf("array")>=0&&n>0){let r=n;for(;r>0&&t.charAt(r)!==" "&&t.charAt(r)!==",";)r--;const o=t.substring(r+1,n);for(s=+o,isNaN(s)&&(s=+i[o.trim()]);r>0&&(t.charAt(r)===" "||t.charAt(r)===",");)r--;t=t.substring(t.indexOf("<")+1,r+1)}return[e,t,s]}initializeShaders(e){this._webgpuProcessingContext=e,this._attributesInputWGSL=[],this._attributesWGSL=[],this._attributesConversionCodeWGSL=[],this._hasNonFloatAttribute=!1,this._varyingsWGSL=[],this._varyingNamesWGSL=[],this._stridedUniformArrays=[]}preProcessShaderCode(e){const t=this.pureMode?"":"struct ".concat(At.InternalsUBOName," {\n yFactor_: f32,\n textureOutputHeight_: f32,\n};\nvar<uniform> ").concat(L_," : ").concat(At.InternalsUBOName,";\n");return e.indexOf(t)!==-1?e:t+Na(e)}varyingCheck(e){return/(flat|linear|perspective)?\s*(center|centroid|sample)?\s*\bvarying\b/.test(e)}varyingProcessor(e,t,i){var r,o;const n=/\s*(flat|linear|perspective)?\s*(center|centroid|sample)?\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s*:\s*(.+)\s*;/gm.exec(e);if(n!==null){const h=(r=n[1])!=null?r:"perspective",l=(o=n[2])!=null?o:"center",c=n[4],u=n[3],f=h==="flat"?"@interpolate(".concat(h,")"):"@interpolate(".concat(h,", ").concat(l,")");let d;t?(d=this._webgpuProcessingContext.availableVaryings[u],d===void 0&&U.Warn('Invalid fragment shader: The varying named "'.concat(u,'" is not declared in the vertex shader! This declaration will be ignored.'))):(d=this._webgpuProcessingContext.getVaryingNextLocation(c,this._getArraySize(u,c,i)[2]),this._webgpuProcessingContext.availableVaryings[u]=d,this._varyingsWGSL.push(" @location(".concat(d,") ").concat(f," ").concat(u," : ").concat(c,",")),this._varyingNamesWGSL.push(u)),e=""}return e}attributeProcessor(e,t){const s=/\s*attribute\s+(\S+)\s*:\s*(.+)\s*;/gm.exec(e);if(s!==null){const n=s[2],r=s[1],o=this._webgpuProcessingContext.getAttributeNextLocation(n,this._getArraySize(r,n,t)[2]);this._webgpuProcessingContext.availableAttributes[r]=o,this._webgpuProcessingContext.orderedAttributes[o]=r;const h=this._webgpuProcessingContext.vertexBufferKindToNumberOfComponents[r];if(h!==void 0){const l=h<0?h===-1?"i32":"vec"+-h+"<i32>":h===1?"u32":"vec"+h+"<u32>",c="_int_".concat(r,"_");this._attributesInputWGSL.push("@location(".concat(o,") ").concat(c," : ").concat(l,",")),this._attributesWGSL.push("".concat(r," : ").concat(n,",")),this._attributesConversionCodeWGSL.push("vertexInputs.".concat(r," = ").concat(n,"(vertexInputs_.").concat(c,");")),this._hasNonFloatAttribute=!0}else this._attributesInputWGSL.push("@location(".concat(o,") ").concat(r," : ").concat(n,",")),this._attributesWGSL.push("".concat(r," : ").concat(n,",")),this._attributesConversionCodeWGSL.push("vertexInputs.".concat(r," = vertexInputs_.").concat(r,";"));e=""}return e}uniformProcessor(e,t,i){const s=this.uniformRegexp.exec(e);if(s!==null){const n=s[2],r=s[1];this._addUniformToLeftOverUBO(r,n,i),e=""}return e}textureProcessor(e,t,i){const s=this.textureRegexp.exec(e);if(s!==null){const n=s[1],r=s[2],o=!!s[3],h=s[4],l=h.indexOf("storage")>0,c=s[6],u=l?c.substring(0,c.indexOf(",")).trim():null;let f=o?this._getArraySize(n,r,i)[2]:0,d=this._webgpuProcessingContext.availableTextures[n];if(d)f=d.textures.length;else{d={isTextureArray:f>0,isStorageTexture:l,textures:[],sampleType:"float"},f=f||1;for(let m=0;m<f;++m)d.textures.push(this._webgpuProcessingContext.getNextFreeUBOBinding())}this._webgpuProcessingContext.availableTextures[n]=d;const _=h.indexOf("depth")>0,p=N_[h],g=_?"depth":c==="u32"?"uint":c==="i32"?"sint":"float";if(d.sampleType=g,p===void 0)throw"Can't get the texture dimension corresponding to the texture function \"".concat(h,'"!');for(let m=0;m<f;++m){const{groupIndex:b,bindingIndex:I}=d.textures[m];m===0&&(e="@group(".concat(b,") @binding(").concat(I,") ").concat(e)),this._addTextureBindingDescription(n,d,m,p,u,!t)}}return e}postProcessor(e){const t=/#define (.+?) (.+?)$/gm;let i;for(;(i=t.exec(e))!==null;)e=e.replace(new RegExp(i[1],"g"),i[2]);return e}finalizeShaders(e,t){const i=t.indexOf("fragmentInputs.position")>=0&&!this.pureMode?"\n if (internals.yFactor_ == 1.) {\n fragmentInputs.position.y = internals.textureOutputHeight_ - fragmentInputs.position.y;\n }\n ":"";e=this._processSamplers(e,!0),t=this._processSamplers(t,!1),e=this._processCustomBuffers(e,!0),t=this._processCustomBuffers(t,!1);const s=this._buildLeftOverUBO();e=s+e,t=s+t,e=e.replace(/#define (\w+)\s+(\d+\.?\d*)/g,"const $1 = $2;"),e=e.replace(/#define /g,"//#define "),e=this._processStridedUniformArrays(e);let n="struct VertexInputs {\n @builtin(vertex_index) vertexIndex : u32,\n @builtin(instance_index) instanceIndex : u32,\n";this._attributesInputWGSL.length>0&&(n+=this._attributesInputWGSL.join("\n")),n+="\n};\nvar<private> vertexInputs"+(this._hasNonFloatAttribute?"_":"")+" : VertexInputs;\n",this._hasNonFloatAttribute&&(n+="struct VertexInputs_ {\n vertexIndex : u32, instanceIndex : u32,\n",n+=this._attributesWGSL.join("\n"),n+="\n};\nvar<private> vertexInputs : VertexInputs_;\n");let r="struct FragmentInputs {\n @builtin(position) position : vec4<f32>,\n";this._varyingsWGSL.length>0&&(r+=this._varyingsWGSL.join("\n")),r+="\n};\nvar<private> vertexOutputs : FragmentInputs;\n",e=n+r+e;let o="\n vertexInputs".concat(this._hasNonFloatAttribute?"_":""," = input;\n");this._hasNonFloatAttribute&&(o+="vertexInputs.vertexIndex = vertexInputs_.vertexIndex;\nvertexInputs.instanceIndex = vertexInputs_.instanceIndex;\n",o+=this._attributesConversionCodeWGSL.join("\n"),o+="\n");const h=this.pureMode?" return vertexOutputs;":" vertexOutputs.position.y = vertexOutputs.position.y * internals.yFactor_;\n return vertexOutputs;";let l=e.indexOf("#define DISABLE_UNIFORMITY_ANALYSIS")!==-1;e=(l?"diagnostic(off, derivative_uniformity);\n":"")+"diagnostic(off, chromium.unreachable_code);\n"+Ua(e,"fn main",o,h),t=t.replace(/#define (\w+)\s+(\d+\.?\d*)/g,"const $1 = $2;"),t=t.replace(/#define /g,"//#define "),t=this._processStridedUniformArrays(t),this.pureMode||(t=t.replace(/dpdy/g,"(-internals.yFactor_)*dpdy"));let c="struct FragmentInputs {\n @builtin(position) position : vec4<f32>,\n @builtin(front_facing) frontFacing : bool,\n";this._varyingsWGSL.length>0&&(c+=this._varyingsWGSL.join("\n")),c+="\n};\nvar<private> fragmentInputs : FragmentInputs;\n";let u="struct FragmentOutputs {\n";const f="fragmentOutputs\\.fragData";let d=t.match(new RegExp(f+"0","g")),_=0;if(d){u+=" @location(".concat(_,") fragData0 : vec4<f32>,\n"),_++;for(let T=1;T<8;T++)d=t.match(new RegExp(f+T,"g")),d&&(u+=" @location(".concat(_,") fragData").concat(_," : vec4<f32>,\n"),_++);t.indexOf("MRT_AND_COLOR")!==-1&&(u+=" @location(".concat(_,") color : vec4<f32>,\n"),_++)}const p=/oitDepthSampler/;d=t.match(p),d&&(u+=" @location(".concat(_++,") depth : vec2<f32>,\n"),u+=" @location(".concat(_++,") frontColor : vec4<f32>,\n"),u+=" @location(".concat(_++,") backColor : vec4<f32>,\n")),_===0&&(u+=" @location(0) color : vec4<f32>,\n",_++);let g=!1,m=0;for(;!g&&(m=t.indexOf(Ch,m),!(m<0));){const T=m;for(g=!0;m>1&&t.charAt(m)!=="\n";){if(t.charAt(m)==="/"&&t.charAt(m-1)==="/"){g=!1;break}m--}m=T+Ch.length}g&&(u+=" @builtin(frag_depth) fragDepth: f32,\n"),u+="};\nvar<private> fragmentOutputs : FragmentOutputs;\n",t=c+u+t;const b=" fragmentInputs = input;\n "+i,I=" return fragmentOutputs;";return l=t.indexOf("#define DISABLE_UNIFORMITY_ANALYSIS")!==-1,t=(l?"diagnostic(off, derivative_uniformity);\n":"")+"diagnostic(off, chromium.unreachable_code);\n"+Ua(t,"fn main",b,I),this._collectBindingNames(),this._preCreateBindGroupEntries(),this._webgpuProcessingContext.vertexBufferKindToNumberOfComponents={},{vertexCode:e,fragmentCode:t}}_generateLeftOverUBOCode(e,t){let i="",s="struct ".concat(e," {\n");for(const n of this._webgpuProcessingContext.leftOverUniforms){const r=n.type.replace(/^(.*?)(<.*>)?$/,"$1"),o=At.UniformSizes[r];if(n.length>0)if(o<=2){const h="".concat(e,"_").concat(this._stridedUniformArrays.length,"_strided_arr");i+="struct ".concat(h," {\n @size(16)\n el: ").concat(r,",\n }"),this._stridedUniformArrays.push(n.name),s+=" @align(16) ".concat(n.name," : array<").concat(h,", ").concat(n.length,">,\n")}else s+=" ".concat(n.name," : array<").concat(n.type,", ").concat(n.length,">,\n");else s+=" ".concat(n.name," : ").concat(n.type,",\n")}return s+="};\n",s="".concat(i,"\n").concat(s),s+="@group(".concat(t.binding.groupIndex,") @binding(").concat(t.binding.bindingIndex,") var<uniform> ").concat(B_," : ").concat(e,";\n"),s}_processSamplers(e,t){const i=/var\s+(\w+Sampler)\s*:\s*(sampler|sampler_comparison)\s*;/gm;for(;;){const s=i.exec(e);if(s===null)break;const n=s[1],r=s[2],o=n.length-7,h=n.lastIndexOf("Sampler")===o?n.substring(0,o):null,l=r==="sampler_comparison"?"comparison":"filtering";if(h){const _=this._webgpuProcessingContext.availableTextures[h];_&&(_.autoBindSampler=!0)}let c=this._webgpuProcessingContext.availableSamplers[n];c||(c={binding:this._webgpuProcessingContext.getNextFreeUBOBinding(),type:l},this._webgpuProcessingContext.availableSamplers[n]=c),this._addSamplerBindingDescription(n,c,t);const u=e.substring(0,s.index),f="@group(".concat(c.binding.groupIndex,") @binding(").concat(c.binding.bindingIndex,") "),d=e.substring(s.index);e=u+f+d,i.lastIndex+=f.length}return e}_processCustomBuffers(e,t){var s;const i=/var<\s*(uniform|storage)\s*(,\s*(read|read_write)\s*)?>\s+(\S+)\s*:\s*(\S+)\s*;/gm;for(;;){const n=i.exec(e);if(n===null)break;const r=n[1],o=n[3];let h=n[4];const l=n[5];let c=this._webgpuProcessingContext.availableBuffers[h];if(!c){const g=r==="uniform"?ni.KnownUBOs[l]:null;let m;g?(h=l,m=g.binding,m.groupIndex===-1&&(m=(s=this._webgpuProcessingContext.availableBuffers[h])==null?void 0:s.binding,m||(m=this._webgpuProcessingContext.getNextFreeUBOBinding()))):m=this._webgpuProcessingContext.getNextFreeUBOBinding(),c={binding:m},this._webgpuProcessingContext.availableBuffers[h]=c}this._addBufferBindingDescription(h,this._webgpuProcessingContext.availableBuffers[h],o==="read_write"?"storage":r==="storage"?"read-only-storage":"uniform",t);const u=c.binding.groupIndex,f=c.binding.bindingIndex,d=e.substring(0,n.index),_="@group(".concat(u,") @binding(").concat(f,") "),p=e.substring(n.index);e=d+_+p,i.lastIndex+=_.length}return e}_processStridedUniformArrays(e){for(const t of this._stridedUniformArrays)e=e.replace(new RegExp("".concat(t,"\\s*\\[(.*?)\\]"),"g"),"".concat(t,"[$1].el"));return e}}class pr{get underlyingResource(){return this._webgpuTexture}getMSAATexture(e){var t,i;return(i=(t=this._webgpuMSAATexture)==null?void 0:t[e])!=null?i:null}setMSAATexture(e,t){this._webgpuMSAATexture||(this._webgpuMSAATexture=[]),this._webgpuMSAATexture[t]=e}releaseMSAATexture(e){if(this._webgpuMSAATexture)if(e!==void 0)this._engine._textureHelper.releaseTexture(this._webgpuMSAATexture[e]),delete this._webgpuMSAATexture[e];else{for(const t of this._webgpuMSAATexture)this._engine._textureHelper.releaseTexture(t);this._webgpuMSAATexture=null}}constructor(e,t=null){this._engine=e,this._originalFormatIsRGB=!1,this.format="rgba8unorm",this.textureUsages=0,this.textureAdditionalUsages=0,this._webgpuTexture=t,this._webgpuMSAATexture=null,this.view=null,this.viewForWriting=null}set(e){this._webgpuTexture=e}setUsage(e,t,i,s,n,r,o,h){let l="2d",c=1;s?(l=i?"cube-array":"cube",c=6*(h||1)):n?(l="3d",c=1):i&&(l="2d-array",c=h);const u=Ve.GetDepthFormatOnly(this.format),f=Ve.HasDepthAndStencilAspects(this.format)?"depth-only":"all";this.createView({label:"TextureView".concat(n?"3D":s?"Cube":"2D").concat(i?"_Array"+c:"","_").concat(r,"x").concat(o,"_").concat(t?"wmips":"womips","_").concat(this.format,"_").concat(l),format:u,dimension:l,mipLevelCount:t?ec(Math.max(r,o))+1:1,baseArrayLayer:0,baseMipLevel:0,arrayLayerCount:c,aspect:f})}createView(e,t=!1){if(this.view=this._webgpuTexture.createView(e),t&&e){const i=e.mipLevelCount;e.mipLevelCount=1,this.viewForWriting=this._webgpuTexture.createView(e),e.mipLevelCount=i}}reset(){this._webgpuTexture=null,this._webgpuMSAATexture=null,this.view=null,this.viewForWriting=null}release(){var e,t;(e=this._webgpuTexture)==null||e.destroy(),this.releaseMSAATexture(),(t=this._copyInvertYTempTexture)==null||t.destroy(),this.reset()}}const k_="\n const pos = array<vec2<f32>, 4>( vec2f(-1.0f, 1.0f), vec2f(1.0f, 1.0f), vec2f(-1.0f, -1.0f), vec2f(1.0f, -1.0f));\n const tex = array<vec2<f32>, 4>( vec2f(0.0f, 0.0f), vec2f(1.0f, 0.0f), vec2f(0.0f, 1.0f), vec2f(1.0f, 1.0f));\n\n varying vTex: vec2f;\n\n @vertex\n fn main(input : VertexInputs) -> FragmentInputs {\n vertexOutputs.vTex = tex[input.vertexIndex];\n vertexOutputs.position = vec4f(pos[input.vertexIndex], 0.0, 1.0);\n }\n ",V_="\n var imgSampler: sampler;\n var img: texture_2d<f32>;\n\n varying vTex: vec2f;\n\n @fragment\n fn main(input: FragmentInputs) -> FragmentOutputs {\n fragmentOutputs.color = textureSample(img, imgSampler, input.vTex);\n }\n ",mc="\n const pos = array<vec2<f32>, 4>( vec2f(-1.0f, 1.0f), vec2f(1.0f, 1.0f), vec2f(-1.0f, -1.0f), vec2f(1.0f, -1.0f));\n const tex = array<vec2<f32>, 4>( vec2f(0.0f, 0.0f), vec2f(1.0f, 0.0f), vec2f(0.0f, 1.0f), vec2f(1.0f, 1.0f));\n\n var img: texture_2d<f32>;\n\n #ifdef INVERTY\n varying vTextureSize: vec2f;\n #endif\n\n @vertex\n fn main(input : VertexInputs) -> FragmentInputs {\n #ifdef INVERTY\n vertexOutputs.vTextureSize = vec2f(textureDimensions(img, 0));\n #endif\n vertexOutputs.position = vec4f(pos[input.vertexIndex], 0.0, 1.0);\n }\n ",G_="\n var img: texture_2d<f32>;\n\n #ifdef INVERTY\n varying vTextureSize: vec2f;\n #endif\n\n @fragment\n fn main(input: FragmentInputs) -> FragmentOutputs {\n #ifdef INVERTY\n var color: vec4f = textureLoad(img, vec2i(i32(input.position.x), i32(input.vTextureSize.y - input.position.y)), 0);\n #else\n var color: vec4f = textureLoad(img, vec2i(input.position.xy), 0);\n #endif\n #ifdef PREMULTIPLYALPHA\n fragmentOutputs.color = vec4f(color.rgb * color.a, color.a);\n #endif\n fragmentOutputs.color = color;\n }\n ",z_=mc,W_="\n var img: texture_2d<f32>;\n uniform ofstX: f32;\n uniform ofstY: f32;\n uniform width: f32;\n uniform height: f32;\n\n #ifdef INVERTY\n varying vTextureSize: vec2f;\n #endif\n\n @fragment\n fn main(input: FragmentInputs) -> FragmentOutputs {\n if (input.position.x < uniforms.ofstX || input.position.x >= uniforms.ofstX + uniforms.width) {\n discard;\n }\n if (input.position.y < uniforms.ofstY || input.position.y >= uniforms.ofstY + uniforms.height) {\n discard;\n }\n #ifdef INVERTY\n var color: vec4f = textureLoad(img, vec2i(i32(input.position.x), i32(uniforms.ofstY + uniforms.height - (input.position.y - uniforms.ofstY))), 0);\n #else\n var color: vec4f = textureLoad(img, vec2i(input.position.xy), 0);\n #endif\n #ifdef PREMULTIPLYALPHA\n color = vec4f(color.rgb * color.a, color.a);\n #endif\n fragmentOutputs.color = color;\n }\n ",H_="\n const pos = array<vec2<f32>, 4>( vec2f(-1.0f, 1.0f), vec2f(1.0f, 1.0f), vec2f(-1.0f, -1.0f), vec2f(1.0f, -1.0f));\n\n @vertex\n fn main(input : VertexInputs) -> FragmentInputs {\n vertexOutputs.position = vec4f(pos[input.vertexIndex], 0.0, 1.0);\n }\n ",K_="\n uniform color: vec4f;\n\n\n @fragment\n fn main(input: FragmentInputs) -> FragmentOutputs {\n fragmentOutputs.color = uniforms.color;\n }\n ",X_="\n struct VertexOutput {\n @builtin(position) Position : vec4<f32>,\n @location(0) fragUV : vec2<f32>\n }\n\n @vertex\n fn main(\n @builtin(vertex_index) VertexIndex : u32\n ) -> VertexOutput {\n var pos = array<vec2<f32>, 4>(\n vec2(-1.0, 1.0),\n vec2( 1.0, 1.0),\n vec2(-1.0, -1.0),\n vec2( 1.0, -1.0)\n );\n var tex = array<vec2<f32>, 4>(\n vec2(0.0, 0.0),\n vec2(1.0, 0.0),\n vec2(0.0, 1.0),\n vec2(1.0, 1.0)\n );\n\n var output: VertexOutput;\n\n output.Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);\n output.fragUV = tex[VertexIndex];\n\n return output;\n }\n ",Y_="\n @group(0) @binding(0) var videoSampler: sampler;\n @group(0) @binding(1) var videoTexture: texture_external;\n\n @fragment\n fn main(\n @location(0) fragUV: vec2<f32>\n ) -> @location(0) vec4<f32> {\n return textureSampleBaseClampToEdge(videoTexture, videoSampler, fragUV);\n }\n ",q_="\n @group(0) @binding(0) var videoSampler: sampler;\n @group(0) @binding(1) var videoTexture: texture_external;\n\n @fragment\n fn main(\n @location(0) fragUV: vec2<f32>\n ) -> @location(0) vec4<f32> {\n return textureSampleBaseClampToEdge(videoTexture, videoSampler, vec2<f32>(fragUV.x, 1.0 - fragUV.y));\n }\n ";var gi;(function(a){a[a.MipMap=0]="MipMap",a[a.InvertYPremultiplyAlpha=1]="InvertYPremultiplyAlpha",a[a.Clear=2]="Clear",a[a.InvertYPremultiplyAlphaWithOfst=3]="InvertYPremultiplyAlphaWithOfst"})(gi||(gi={}));var en;(function(a){a[a.DontInvertY=0]="DontInvertY",a[a.InvertY=1]="InvertY"})(en||(en={}));const Sh=[{vertex:k_,fragment:V_},{vertex:mc,fragment:G_},{vertex:H_,fragment:K_},{vertex:z_,fragment:W_}],Vi={"":0,r8unorm:1,r8uint:2,r8sint:3,r16uint:4,r16sint:5,r16float:6,rg8unorm:7,rg8uint:8,rg8sint:9,r32uint:10,r32sint:11,r32float:12,rg16uint:13,rg16sint:14,rg16float:15,rgba8unorm:16,"rgba8unorm-srgb":17,rgba8uint:18,rgba8sint:19,bgra8unorm:20,"bgra8unorm-srgb":21,rgb10a2uint:22,rgb10a2unorm:23,rg32uint:24,rg32sint:25,rg32float:26,rgba16uint:27,rgba16sint:28,rgba16float:29,rgba32uint:30,rgba32sint:31,rgba32float:32,stencil8:33,depth16unorm:34,depth24plus:35,"depth24plus-stencil8":36,depth32float:37,"depth32float-stencil8":38,r16unorm:39,rg16unorm:40,rgba16unorm:41,r16snorm:42,rg16snorm:43,rgba16snorm:44};class j_{constructor(e,t,i,s){if(this._pipelines={},this._compiledShaders=[],this._videoPipelines={},this._videoCompiledShaders=[],this._deferredReleaseTextures=[],this._engine=e,this._device=t,this._bufferManager=i,s.indexOf("rg11b10ufloat-renderable")!==-1){const n=Object.keys(Vi);Vi.rg11b10ufloat=Vi[n[n.length-1]]+1}this._mipmapSampler=t.createSampler({minFilter:"linear"}),this._videoSampler=t.createSampler({minFilter:"linear"}),this._ubCopyWithOfst=this._bufferManager.createBuffer(4*4,We.Uniform|We.CopyDst,"UBCopyWithOffset").underlyingResource,this._getPipeline("rgba8unorm"),this._getVideoPipeline("rgba8unorm")}_getPipeline(e,t=gi.MipMap,i){const s=t===gi.MipMap?1:t===gi.InvertYPremultiplyAlpha?((i.invertY?1:0)<<1)+((i.premultiplyAlpha?1:0)<<2):t===gi.Clear?8:t===gi.InvertYPremultiplyAlphaWithOfst?((i.invertY?1:0)<<4)+((i.premultiplyAlpha?1:0)<<5):0;this._pipelines[e]||(this._pipelines[e]=[]);let n=this._pipelines[e][s];if(!n){let r="";(t===gi.InvertYPremultiplyAlpha||t===gi.InvertYPremultiplyAlphaWithOfst)&&(i.invertY&&(r+="#define INVERTY\n"),i.premultiplyAlpha&&(r+="#define PREMULTIPLYALPHA\n"));let o=this._compiledShaders[s];if(!o){let l=Sh[t].vertex,c=Sh[t].fragment;const u={defines:r.split("\n"),indexParameters:null,isFragment:!1,shouldUseHighPrecisionShader:!0,processor:this._engine._getShaderProcessor(1),supportsUniformBuffers:!0,shadersRepository:"",includesShadersStore:{},version:(this._engine.version*100).toString(),platformName:this._engine.shaderPlatformName,processingContext:this._engine._getShaderProcessingContext(1,!0),isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer};f0(u),u.processor.pureMode=!0,Tr(l,u,p=>{l=p},this._engine),u.isFragment=!0,Tr(c,u,p=>{c=p},this._engine);const f=d0(l,c,u);u.processor.pureMode=!1;const d=this._device.createShaderModule({code:f.vertexCode}),_=this._device.createShaderModule({code:f.fragmentCode});o=this._compiledShaders[s]=[d,_]}const h=this._device.createRenderPipeline({layout:"auto",vertex:{module:o[0],entryPoint:"main"},fragment:{module:o[1],entryPoint:"main",targets:[{format:e}]},primitive:{topology:"triangle-strip",stripIndexFormat:"uint16"}});n=this._pipelines[e][s]=[h,h.getBindGroupLayout(0)]}return n}_getVideoPipeline(e,t=en.DontInvertY){const i=t===en.InvertY?1:0;this._videoPipelines[e]||(this._videoPipelines[e]=[]);let s=this._videoPipelines[e][i];if(!s){let n=this._videoCompiledShaders[i];if(!n){const o=this._device.createShaderModule({code:X_}),h=this._device.createShaderModule({code:i===0?Y_:q_});n=this._videoCompiledShaders[i]=[o,h]}const r=this._device.createRenderPipeline({label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_CopyVideoToTexture_").concat(e,"_").concat(i===0?"DontInvertY":"InvertY"),layout:"auto",vertex:{module:n[0],entryPoint:"main"},fragment:{module:n[1],entryPoint:"main",targets:[{format:e}]},primitive:{topology:"triangle-strip",stripIndexFormat:"uint16"}});s=this._videoPipelines[e][i]=[r,r.getBindGroupLayout(0)]}return s}setCommandEncoder(e){this._commandEncoderForCreation=e}copyVideoToTexture(e,t,i,s=!1,n){var _,p;const r=n===void 0,[o,h]=this._getVideoPipeline(i,s?en.InvertY:en.DontInvertY);r&&(n=this._device.createCommandEncoder({})),(_=n.pushDebugGroup)==null||_.call(n,"copy video to texture - invertY=".concat(s));const l=t._hardwareTexture,c={label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_copyVideoToTexture_").concat(i,"_").concat(s?"InvertY":"DontInvertY").concat(t.label?"_"+t.label:""),colorAttachments:[{view:l.underlyingResource.createView({format:i,dimension:"2d",mipLevelCount:1,baseArrayLayer:0,baseMipLevel:0,arrayLayerCount:1,aspect:"all"}),loadOp:"load",storeOp:"store"}]},u=n.beginRenderPass(c),f={layout:h,entries:[{binding:0,resource:this._videoSampler},{binding:1,resource:this._device.importExternalTexture({source:e.underlyingResource})}]},d=this._device.createBindGroup(f);u.setPipeline(o),u.setBindGroup(0,d),u.draw(4,1,0,0),u.end(),(p=n.popDebugGroup)==null||p.call(n),r&&(this._device.queue.submit([n.finish()]),n=null)}invertYPreMultiplyAlpha(e,t,i,s,n=!1,r=!1,o=0,h=0,l=1,c=0,u=0,f=0,d=0,_,p){var S,w,P,G;const g=f!==0,m=_===void 0,[b,I]=this._getPipeline(s,g?gi.InvertYPremultiplyAlphaWithOfst:gi.InvertYPremultiplyAlpha,{invertY:n,premultiplyAlpha:r});o=Math.max(o,0),m&&(_=this._device.createCommandEncoder({})),(S=_.pushDebugGroup)==null||S.call(_,"internal process texture - invertY=".concat(n," premultiplyAlpha=").concat(r));let T;if(Ve.IsHardwareTexture(e)?(T=e.underlyingResource,n&&!r&&l===1&&o===0||(e=void 0)):(T=e,e=void 0),!T)return;g&&this._bufferManager.setRawData(this._ubCopyWithOfst,0,new Float32Array([c,u,f,d]),0,4*4);const x=e,y=(w=x==null?void 0:x._copyInvertYTempTexture)!=null?w:this.createTexture({width:t,height:i,layers:1},!1,!1,!1,!1,!1,s,1,_,21,void 0,"TempTextureForCopyWithInvertY"),R=(P=x==null?void 0:x._copyInvertYRenderPassDescr)!=null?P:{label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_invertYPreMultiplyAlpha_").concat(s,"_").concat(n?"InvertY":"DontInvertY","_").concat(r?"PremultiplyAlpha":"DontPremultiplyAlpha"),colorAttachments:[{view:y.createView({format:s,dimension:"2d",baseMipLevel:0,mipLevelCount:1,arrayLayerCount:1,baseArrayLayer:0}),loadOp:"load",storeOp:"store"}]},E=_.beginRenderPass(R);let C=g?x==null?void 0:x._copyInvertYBindGroupWithOfst:x==null?void 0:x._copyInvertYBindGroup;if(!C){const L={layout:I,entries:[{binding:0,resource:T.createView({format:s,dimension:"2d",baseMipLevel:h,mipLevelCount:1,arrayLayerCount:l,baseArrayLayer:o})}]};g&&L.entries.push({binding:1,resource:{buffer:this._ubCopyWithOfst}}),C=this._device.createBindGroup(L)}E.setPipeline(b),E.setBindGroup(0,C),E.draw(4,1,0,0),E.end(),_.copyTextureToTexture({texture:y},{texture:T,mipLevel:h,origin:{x:0,y:0,z:o}},{width:t,height:i,depthOrArrayLayers:1}),x?(x._copyInvertYTempTexture=y,x._copyInvertYRenderPassDescr=R,g?x._copyInvertYBindGroupWithOfst=C:x._copyInvertYBindGroup=C):this._deferredReleaseTextures.push([y,null]),(G=_.popDebugGroup)==null||G.call(_),m&&(this._device.queue.submit([_.finish()]),_=null)}copyWithInvertY(e,t,i,s){var c,u;const n=s===void 0,[r,o]=this._getPipeline(t,gi.InvertYPremultiplyAlpha,{invertY:!0,premultiplyAlpha:!1});n&&(s=this._device.createCommandEncoder({})),(c=s.pushDebugGroup)==null||c.call(s,"internal copy texture with invertY");const h=s.beginRenderPass(i),l=this._device.createBindGroup({layout:o,entries:[{binding:0,resource:e}]});h.setPipeline(r),h.setBindGroup(0,l),h.draw(4,1,0,0),h.end(),(u=s.popDebugGroup)==null||u.call(s),n&&(this._device.queue.submit([s.finish()]),s=null)}createTexture(e,t=!1,i=!1,s=!1,n=!1,r=!1,o="rgba8unorm",h=1,l,c=-1,u=0,f){h=Ve.GetSample(h);const d=e.layers||1,_={width:e.width,height:e.height,depthOrArrayLayers:d},p=Vi[o]?16:0,g=Ve.IsCompressedFormat(o),m=t?Ve.ComputeNumMipmapLevels(e.width,e.height):1,b=c>=0?c:7;u|=t&&!g?1|p:0,!g&&!r&&(u|=p|2);const I=this._device.createTexture({label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_Texture").concat(r?"3D":"2D","_").concat(f?f+"_":"").concat(_.width,"x").concat(_.height,"x").concat(_.depthOrArrayLayers,"_").concat(t?"wmips":"womips","_").concat(o,"_samples").concat(h),size:_,dimension:r?"3d":"2d",format:o,usage:b|u,sampleCount:h,mipLevelCount:m});return Ve.IsImageBitmap(e)&&(this.updateTexture(e,I,e.width,e.height,d,o,0,0,s,n,0,0),t&&i&&this.generateMipmaps(I,o,m,0,r,l)),I}createCubeTexture(e,t=!1,i=!1,s=!1,n=!1,r="rgba8unorm",o=1,h,l=-1,c=0,u){o=Ve.GetSample(o);const f=Ve.IsImageBitmapArray(e)?e[0].width:e.width,d=Ve.IsImageBitmapArray(e)?e[0].height:e.height,_=Vi[r]?16:0,p=Ve.IsCompressedFormat(r),g=t?Ve.ComputeNumMipmapLevels(f,d):1,m=l>=0?l:7;c|=t&&!p?1|_:0,p||(c|=_|2);const b=this._device.createTexture({label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_TextureCube_").concat(u?u+"_":"").concat(f,"x").concat(d,"x6_").concat(t?"wmips":"womips","_").concat(r,"_samples").concat(o),size:{width:f,height:d,depthOrArrayLayers:6},dimension:"2d",format:r,usage:m|c,sampleCount:o,mipLevelCount:g});return Ve.IsImageBitmapArray(e)&&(this.updateCubeTextures(e,b,f,d,r,s,n,0,0),t&&i&&this.generateCubeMipmaps(b,r,g,h)),b}generateCubeMipmaps(e,t,i,s){var r,o;const n=s===void 0;n&&(s=this._device.createCommandEncoder({})),(r=s.pushDebugGroup)==null||r.call(s,"create cube mipmaps - ".concat(i," levels"));for(let h=0;h<6;++h)this.generateMipmaps(e,t,i,h,!1,s);(o=s.popDebugGroup)==null||o.call(s),n&&(this._device.queue.submit([s.finish()]),s=null)}generateMipmaps(e,t,i,s=0,n=!1,r){var f,d,_,p,g,m;const o=r===void 0,[h,l]=this._getPipeline(t);s=Math.max(s,0),o&&(r=this._device.createCommandEncoder({})),(f=r.pushDebugGroup)==null||f.call(r,"create mipmaps for face #".concat(s," - ").concat(i," levels"));let c;if(Ve.IsHardwareTexture(e)?(c=e.underlyingResource,e._mipmapGenRenderPassDescr=e._mipmapGenRenderPassDescr||[],e._mipmapGenBindGroup=e._mipmapGenBindGroup||[]):(c=e,e=void 0),!c)return;const u=e;for(let b=1;b<i;++b){const I=(_=(d=u==null?void 0:u._mipmapGenRenderPassDescr[s])==null?void 0:d[b-1])!=null?_:{label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_generateMipmaps_").concat(t,"_faceIndex").concat(s,"_level").concat(b),colorAttachments:[{view:c.createView({format:t,dimension:n?"3d":"2d",baseMipLevel:b,mipLevelCount:1,arrayLayerCount:1,baseArrayLayer:s}),loadOp:"load",storeOp:"store"}]};u&&(u._mipmapGenRenderPassDescr[s]=u._mipmapGenRenderPassDescr[s]||[],u._mipmapGenRenderPassDescr[s][b-1]=I);const T=r.beginRenderPass(I),x=(g=(p=u==null?void 0:u._mipmapGenBindGroup[s])==null?void 0:p[b-1])!=null?g:this._device.createBindGroup({layout:l,entries:[{binding:0,resource:c.createView({format:t,dimension:n?"3d":"2d",baseMipLevel:b-1,mipLevelCount:1,arrayLayerCount:1,baseArrayLayer:s})},{binding:1,resource:this._mipmapSampler}]});u&&(u._mipmapGenBindGroup[s]=u._mipmapGenBindGroup[s]||[],u._mipmapGenBindGroup[s][b-1]=x),T.setPipeline(h),T.setBindGroup(0,x),T.draw(4,1,0,0),T.end()}(m=r.popDebugGroup)==null||m.call(r),o&&(this._device.queue.submit([r.finish()]),r=null)}createGPUTextureForInternalTexture(e,t,i,s,n,r){var f,d;e._hardwareTexture||(e._hardwareTexture=new pr(this._engine)),t===void 0&&(t=e.width),i===void 0&&(i=e.height),s===void 0&&(s=e.depth);const o=e._hardwareTexture,h=((n!=null?n:0)&1)!==0;o.format=Ve.GetWebGPUTextureFormat(e.type,e.format,e._useSRGBBuffer),o.textureUsages=e._source===5||e.source===6?21:e._source===12?20:-1,o.textureAdditionalUsages=h?8:0;const l=e.generateMipMaps,c=s||1;let u;if(e._maxLodLevel!==null?u=e._maxLodLevel:u=l?Ve.ComputeNumMipmapLevels(t,i):1,e.isCube){const _=this.createCubeTexture({width:t,height:i},e.generateMipMaps,e.generateMipMaps,e.invertY,!1,o.format,1,this._commandEncoderForCreation,o.textureUsages,o.textureAdditionalUsages,e.label);o.set(_);const p=e.is3D?1:c,g=Ve.GetDepthFormatOnly(o.format),m=Ve.HasDepthAndStencilAspects(o.format)?"depth-only":"all",b=e.is2DArray?"cube-array":"cube";o.createView({label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_TextureViewCube").concat(e.is2DArray?"_Array"+p:"","_").concat(t,"x").concat(i,"_").concat(l?"wmips":"womips","_").concat(g,"_").concat(b,"_").concat(m,"_").concat((f=e.label)!=null?f:"noname"),format:g,dimension:b,mipLevelCount:u,baseArrayLayer:0,baseMipLevel:0,arrayLayerCount:6,aspect:m},h)}else{const _=this.createTexture({width:t,height:i,layers:c},e.generateMipMaps,e.generateMipMaps,e.invertY,!1,e.is3D,o.format,1,this._commandEncoderForCreation,o.textureUsages,o.textureAdditionalUsages,e.label);o.set(_);const p=e.is3D?1:c,g=Ve.GetDepthFormatOnly(o.format),m=Ve.HasDepthAndStencilAspects(o.format)?"depth-only":"all",b=e.is2DArray?"2d-array":e.is3D?"3d":"2d";o.createView({label:"BabylonWebGPUDevice".concat(this._engine.uniqueId,"_TextureView").concat(e.is3D?"3D":"2D").concat(e.is2DArray?"_Array"+p:"","_").concat(t,"x").concat(i).concat(e.is3D?"x"+c:"","_").concat(l?"wmips":"womips","_").concat(g,"_").concat(b,"_").concat(m,"_").concat((d=e.label)!=null?d:"noname"),format:g,dimension:b,mipLevelCount:u,baseArrayLayer:0,baseMipLevel:0,arrayLayerCount:p,aspect:m},h)}return e.width=e.baseWidth=t,e.height=e.baseHeight=i,e.depth=e.baseDepth=s,r||this.createMSAATexture(e,e.samples),o}createMSAATexture(e,t,i=!0,s=0){const n=e._hardwareTexture;if(i&&(n==null||n.releaseMSAATexture()),!n||(t!=null?t:1)<=1)return;const r=e.width,o=e.height,h=this.createTexture({width:r,height:o,layers:1},!1,!1,!1,!1,!1,n.format,t,this._commandEncoderForCreation,16,0,e.label?"MSAA_"+e.label:"MSAA");n.setMSAATexture(h,s)}updateCubeTextures(e,t,i,s,n,r=!1,o=!1,h=0,l=0){const c=[0,3,1,4,2,5];for(let u=0;u<c.length;++u){const f=e[c[u]];this.updateTexture(f,t,i,s,1,n,u,0,r,o,h,l)}}updateTexture(e,t,i,s,n,r,o=0,h=0,l=!1,c=!1,u=0,f=0,d){const _=Ve.IsInternalTexture(t)?t._hardwareTexture.underlyingResource:t,p=Ve.GetBlockInformationFromFormat(r),g=Ve.IsInternalTexture(t)?t._hardwareTexture:t,m={texture:_,origin:{x:u,y:f,z:Math.max(o,0)},mipLevel:h,premultipliedAlpha:c},b={width:Math.ceil(i/p.width)*p.width,height:Math.ceil(s/p.height)*p.height,depthOrArrayLayers:n||1};if(e.byteLength!==void 0){e=e;const I=Math.ceil(i/p.width)*p.length;if(Math.ceil(I/256)*256===I){const x=this._device.createCommandEncoder({}),y=this._bufferManager.createRawBuffer(e.byteLength,We.MapWrite|We.CopySrc,!0,"TempBufferForUpdateTexture"+(_?"_"+_.label:"")),R=y.getMappedRange();new Uint8Array(R).set(e),y.unmap(),x.copyBufferToTexture({buffer:y,offset:0,bytesPerRow:I,rowsPerImage:s},m,b),this._device.queue.submit([x.finish()]),this._bufferManager.releaseBuffer(y)}else this._device.queue.writeTexture(m,e,{offset:0,bytesPerRow:I,rowsPerImage:s},b);if(l||c)if(Ve.IsInternalTexture(t)){const x=u===0&&f===0&&i===t.width&&s===t.height;this.invertYPreMultiplyAlpha(g,t.width,t.height,r,l,c,o,h,n||1,u,f,x?0:i,x?0:s,void 0,d)}else throw"updateTexture: Can't process the texture data because a GPUTexture was provided instead of an InternalTexture!"}else if(e=e,l)if(m.premultipliedAlpha=!1,Ve.IsInternalTexture(t)&&u===0&&f===0&&i===t.width&&s===t.height)this._device.queue.copyExternalImageToTexture({source:e},m,b),this.invertYPreMultiplyAlpha(g,i,s,r,l,c,o,h,n||1,0,0,0,0,void 0,d);else{const I=this._device.createCommandEncoder({}),T=this.createTexture({width:i,height:s,layers:1},!1,!1,!1,!1,!1,r,1,I,5,void 0,"TempTextureForUpdateTexture");this._deferredReleaseTextures.push([T,null]),b.depthOrArrayLayers=1,this._device.queue.copyExternalImageToTexture({source:e},{texture:T},b),b.depthOrArrayLayers=n||1,this.invertYPreMultiplyAlpha(T,i,s,r,l,c,o,h,n||1,0,0,0,0,I,d),I.copyTextureToTexture({texture:T},m,b),this._device.queue.submit([I.finish()])}else this._device.queue.copyExternalImageToTexture({source:e},m,b)}readPixels(e,t,i,s,n,r,o=0,h=0,l=null,c=!1){const u=Ve.GetBlockInformationFromFormat(r),f=Math.ceil(s/u.width)*u.length,d=Math.ceil(f/256)*256,_=d*n,p=this._bufferManager.createRawBuffer(_,We.MapRead|We.CopyDst,void 0,"TempBufferForReadPixels"+(e.label?"_"+e.label:"")),g=this._device.createCommandEncoder({});return g.copyTextureToBuffer({texture:e,mipLevel:h,origin:{x:t,y:i,z:Math.max(o,0)}},{buffer:p,offset:0,bytesPerRow:d},{width:s,height:n,depthOrArrayLayers:1}),this._device.queue.submit([g.finish()]),this._bufferManager.readDataFromBuffer(p,_,s,n,f,d,Ve.GetTextureTypeFromFormat(r),0,l,!0,c)}releaseTexture(e){if(Ve.IsInternalTexture(e)){const t=e._hardwareTexture,i=e._irradianceTexture;this._deferredReleaseTextures.push([t,i])}else this._deferredReleaseTextures.push([e,null])}destroyDeferredTextures(){for(let e=0;e<this._deferredReleaseTextures.length;++e){const[t,i]=this._deferredReleaseTextures[e];t&&(Ve.IsHardwareTexture(t)?t.release():t.destroy()),i==null||i.dispose()}this._deferredReleaseTextures.length=0}}class $_ extends pn{set buffer(e){this._buffer=e}constructor(e,t=0){super(),this.engineId=-1,this.capacity=t,e&&(this._buffer=e)}get underlyingResource(){return this._buffer}}function vc(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 n=document.createElement("canvas");n.width=i,n.height=s;const r=n.getContext("2d");if(!r)return null;const o=r.createImageData(i,s);if(o.data.set(a),r.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(n,0,0),l.toDataURL("image/png")):null}return n.toDataURL("image/png")}function Z_(a,e=0,t=0){const i=a.getInternalTexture();if(!i)return null;const s=a._readPixelsSync(e,t);return s?vc(s,a.getSize(),i.invertY):null}async function Q_(a,e=0,t=0){const i=a.getInternalTexture();if(!i)return null;const s=await a.readPixels(e,t);return s?vc(s,a.getSize(),i.invertY):null}class ie extends st{static _CreateVideoTexture(e,t,i,s=!1,n=!1,r=ie.TRILINEAR_SAMPLINGMODE,o={},h,l=5){throw ye("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,n=ie.TRILINEAR_SAMPLINGMODE,r=null,o=null,h=null,l=!1,c,u,f,d,_){var R,E,C,S,w,P,G,L,W,K,ce;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 Z,this._isBlocking=!0,this.name=e||"",this.url=e;let p,g=!1,m=null,b=!0;typeof i=="object"&&i!==null?(p=(R=i.noMipmap)!=null?R:!1,s=(E=i.invertY)!=null?E:!0,n=(C=i.samplingMode)!=null?C:ie.TRILINEAR_SAMPLINGMODE,r=(S=i.onLoad)!=null?S:null,o=(w=i.onError)!=null?w:null,h=(P=i.buffer)!=null?P:null,l=(G=i.deleteBuffer)!=null?G:!1,c=i.format,u=i.mimeType,f=i.loaderOptions,d=i.creationFlags,g=(L=i.useSRGBBuffer)!=null?L:!1,m=(W=i.internalTexture)!=null?W:null,b=(K=i.gammaSpace)!=null?K:b,_=(ce=i.forcedExtension)!=null?ce:_):p=!!i,this._gammaSpace=b,this._noMipmap=p,this._invertY=s===void 0?!0:s,this._initialSamplingMode=n,this._buffer=h,this._deleteBuffer=l,this._mimeType=u,this._loaderOptions=f,this._creationFlags=d,this._useSRGBBuffer=g,this._forcedExtension=_,c&&(this._format=c);const I=this.getScene(),T=this._getEngine();if(!T)return;T.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),r&&r(),!this.isBlocking&&I&&I.resetCachedMaterial()},y=($,z)=>{this._loadingError=!0,this._errorObject={message:$,exception:z},o&&o($,z),ie.OnTextureLoadErrorObservable.notifyObservers(this)};if(!this.url&&!m){this._delayedOnLoad=x,this._delayedOnError=y;return}if(this._texture=m!=null?m:this._getFromCache(this.url,p,n,this._invertY,g,this.isCube),this._texture)if(this._texture.isReady)Bn.SetImmediate(()=>x());else{const $=this._texture.onLoadedObservable.add(x);this._texture.onErrorObservable.add(z=>{var k;y(z.message,z.exception),(k=this._texture)==null||k.onLoadedObservable.remove($)})}else if(!I||!I.useDelayedTextureLoading){try{this._texture=T.createTexture(this.url,p,this._invertY,I,n,x,y,this._buffer,void 0,this._format,this._forcedExtension,u,f,d,g)}catch($){throw y("error loading",$),$}l&&(this._buffer=null)}else this.delayLoadState=4,this._delayedOnLoad=x,this._delayedOnError=y}updateURL(e,t=null,i,s){this.url&&(this.releaseInternalTexture(),this.getScene().markAllMaterialsAsDirty(1,n=>n.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?Bn.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,v.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=O.Zero(),this._rowGenerationMatrix=new O,this._t0=v.Zero(),this._t1=v.Zero(),this._t2=v.Zero()),O.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this.homogeneousRotationInUVTransform?(O.TranslationToRef(-this._cachedURotationCenter,-this._cachedVRotationCenter,-this._cachedWRotationCenter,N.Matrix[0]),O.TranslationToRef(this._cachedURotationCenter,this._cachedVRotationCenter,this._cachedWRotationCenter,N.Matrix[1]),O.ScalingToRef(this._cachedUScale,this._cachedVScale,0,N.Matrix[2]),O.TranslationToRef(this._cachedUOffset,this._cachedVOffset,0,N.Matrix[3]),N.Matrix[0].multiplyToRef(this._rowGenerationMatrix,this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(N.Matrix[1],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(N.Matrix[2],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(N.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),O.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===ie.PROJECTION_MODE){if(this._cachedReflectionProjectionMatrixId===e.getProjectionMatrix().updateFlag)return this._cachedReflectionTextureMatrix}else return this._cachedReflectionTextureMatrix;this._cachedReflectionTextureMatrix||(this._cachedReflectionTextureMatrix=O.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=O.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 ie.PLANAR_MODE:{O.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 ie.PROJECTION_MODE:{O.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:O.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 Ae.Clone(()=>new ie(this._texture?this._texture.url:null,this.getScene(),e),this)}serialize(){var i,s;const e=this.name;ie.SerializeBuffers||this.name.startsWith("data:")&&(this.name=""),this.name.startsWith("data:")&&this.url===this.name&&(this.url="");const t=super.serialize(ie._SerializeInternalTextureUniqueId);return t?((ie.SerializeBuffers||ie.ForceSerializeBuffers)&&(typeof this._buffer=="string"&&this._buffer.substring(0,5)==="data:"?(t.base64String=this._buffer,t.name=t.name.replace("data:","")):this.url&&this.url.startsWith("data:")&&this._buffer instanceof Uint8Array?t.base64String="data:image/png;base64,"+sc(this._buffer):(ie.ForceSerializeBuffers||this.url&&this.url.startsWith("blob:")||this._forceSerialize)&&(t.base64String=!this._engine||this._engine._features.supportSyncTextureRead?Z_(this):Q_(this))),t.invertY=this._invertY,t.samplingMode=this.samplingMode,t._creationFlags=this._creationFlags,t._useSRGBBuffer=this._useSRGBBuffer,ie._SerializeInternalTextureUniqueId&&(t.internalTextureUniqueId=(i=this._texture)==null?void 0:i.uniqueId),t.internalTextureLabel=(s=this._texture)==null?void 0:s.label,t.noMipmap=this._noMipmap,this.name=e,t):null}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=Sn.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 ie._CubeTextureParser(e,t,i);const s=e.internalTextureUniqueId!==void 0;if(!e.name&&!e.isRenderTarget&&!s)return null;let n;if(s){const h=t.getEngine().getLoadedTexturesCache();for(const l of h)if(l.uniqueId===e.internalTextureUniqueId){n=l;break}}const r=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=ys("BABYLON.Animation");u&&h.animations.push(u.Parse(c))}h&&h._texture&&(s&&!n&&h._texture._setUniqueId(e.internalTextureUniqueId),h._texture.label=e.internalTextureLabel)};return Ae.Parse(()=>{var l,c,u;let h=!0;if(e.noMipmap&&(h=!1),e.mirrorPlane){const f=ie._CreateMirror(e.name,e.renderTargetSize,t,h);return f._waitingRenderList=e.renderList,f.mirrorPlane=Xt.FromArray(e.mirrorPlane),r(f),f}else if(e.isRenderTarget){let f=null;if(e.isCube){if(t.reflectionProbes)for(let d=0;d<t.reflectionProbes.length;d++){const _=t.reflectionProbes[d];if(_.name===e.name)return _.cubeTexture}}else f=ie._CreateRenderTargetTexture(e.name,e.renderTargetSize,t,h,(l=e._creationFlags)!=null?l:0),f._waitingRenderList=e.renderList;return r(f),f}else if(e.isVideo){const f=ie._CreateVideoTexture(i+(e.url||e.name),i+(e.src||e.url),t,h,e.invertY,e.samplingMode,e.settings||{});return r(f),f}else{let f;if(e.base64String&&!n)f=ie.CreateFromBase64String(e.base64String,e.base64String,t,!h,e.invertY,e.samplingMode,()=>{r(f)},(c=e._creationFlags)!=null?c:0,(u=e._useSRGBBuffer)!=null?u:!1),f.name=e.name;else{let d;e.name&&(e.name.indexOf("://")>0||e.name.startsWith("data:"))?d=e.name:d=i+e.name,e.url&&(e.url.startsWith("data:")||ie.UseSerializedUrlIfAny)&&(d=e.url);const _={noMipmap:!h,invertY:e.invertY,samplingMode:e.samplingMode,onLoad:()=>{r(f)},internalTexture:n};f=new ie(d,t,_)}return f}},e,t)}static CreateFromBase64String(e,t,i,s,n,r=ie.TRILINEAR_SAMPLINGMODE,o=null,h=null,l=5,c,u){return new ie("data:"+t,i,s,n,r,o,h,e,!1,l,void 0,void 0,c,u)}static LoadFromDataString(e,t,i,s=!1,n,r=!0,o=ie.TRILINEAR_SAMPLINGMODE,h=null,l=null,c=5,u,f){return e.substring(0,5)!=="data:"&&(e="data:"+e),new ie(e,i,n,r,o,h,l,t,s,c,void 0,void 0,u,f)}}ie.SerializeBuffers=!0;ie.ForceSerializeBuffers=!1;ie.OnTextureLoadErrorObservable=new Z;ie._SerializeInternalTextureUniqueId=!1;ie._CubeTextureParser=(a,e,t)=>{throw ye("CubeTexture")};ie._CreateMirror=(a,e,t,i)=>{throw ye("MirrorTexture")};ie._CreateRenderTargetTexture=(a,e,t,i,s)=>{throw ye("RenderTargetTexture")};ie.NEAREST_SAMPLINGMODE=1;ie.NEAREST_NEAREST_MIPLINEAR=8;ie.BILINEAR_SAMPLINGMODE=2;ie.LINEAR_LINEAR_MIPNEAREST=11;ie.TRILINEAR_SAMPLINGMODE=3;ie.LINEAR_LINEAR_MIPLINEAR=3;ie.NEAREST_NEAREST_MIPNEAREST=4;ie.NEAREST_LINEAR_MIPNEAREST=5;ie.NEAREST_LINEAR_MIPLINEAR=6;ie.NEAREST_LINEAR=7;ie.NEAREST_NEAREST=1;ie.LINEAR_NEAREST_MIPNEAREST=9;ie.LINEAR_NEAREST_MIPLINEAR=10;ie.LINEAR_LINEAR=2;ie.LINEAR_NEAREST=12;ie.EXPLICIT_MODE=0;ie.SPHERICAL_MODE=1;ie.PLANAR_MODE=2;ie.CUBIC_MODE=3;ie.PROJECTION_MODE=4;ie.SKYBOX_MODE=5;ie.INVCUBIC_MODE=6;ie.EQUIRECTANGULAR_MODE=7;ie.FIXED_EQUIRECTANGULAR_MODE=8;ie.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9;ie.CLAMP_ADDRESSMODE=0;ie.WRAP_ADDRESSMODE=1;ie.MIRROR_ADDRESSMODE=2;ie.UseSerializedUrlIfAny=!1;D([B()],ie.prototype,"url",void 0);D([B()],ie.prototype,"uOffset",void 0);D([B()],ie.prototype,"vOffset",void 0);D([B()],ie.prototype,"uScale",void 0);D([B()],ie.prototype,"vScale",void 0);D([B()],ie.prototype,"uAng",void 0);D([B()],ie.prototype,"vAng",void 0);D([B()],ie.prototype,"wAng",void 0);D([B()],ie.prototype,"uRotationCenter",void 0);D([B()],ie.prototype,"vRotationCenter",void 0);D([B()],ie.prototype,"wRotationCenter",void 0);D([B()],ie.prototype,"homogeneousRotationInUVTransform",void 0);D([B()],ie.prototype,"isBlocking",null);vt("BABYLON.Texture",ie);Ae._TextureParser=ie.Parse;class ka{constructor(e){this._vertexBuffers={},this.onBeforeRenderObservable=new Z,this._scene=e}_prepareBuffers(){if(this._vertexBuffers[A.PositionKind])return;const e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffers[A.PositionKind]=new A(this._scene.getEngine(),e,A.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[A.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,n=0,r=!1){var h;const o=this._scene.getEngine();for(let l=0;l<e.length;l++){l<e.length-1?e[l+1].activate(this._scene.activeCamera,t==null?void 0:t.texture):(t?o.bindFramebuffer(t,s,void 0,void 0,i,n):r||o.restoreDefaultFramebuffer(),(h=o._debugInsertMarker)==null||h.call(o,"post process ".concat(e[l].name," output")));const c=e[l],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)}_finalizeFrame(e,t,i,s,n=!1){var h;const r=this._scene.activeCamera;if(!r||(this.onBeforeRenderObservable.notifyObservers(this),s=s||r._postProcesses.filter(l=>l!=null),s.length===0||!this._scene.postProcessesEnabled))return;const o=this._scene.getEngine();for(let l=0,c=s.length;l<c;l++){const u=s[l];if(l<c-1?u._outputTexture=s[l+1].activate(r,t==null?void 0:t.texture):(t?(o.bindFramebuffer(t,i,void 0,void 0,n),u._outputTexture=t):(o.restoreDefaultFramebuffer(),u._outputTexture=null),(h=o._debugInsertMarker)==null||h.call(o,"post process ".concat(s[l].name," output"))),e)break;const f=u.apply();f&&(u.onBeforeRenderObservable.notifyObservers(f),this._prepareBuffers(),o.bindBuffers(this._vertexBuffers,this._indexBuffer,f),o.drawElementsType(0,0,6),u.onAfterRenderObservable.notifyObservers(f))}o.setDepthBuffer(!0),o.setDepthWrite(!0),o.setAlphaMode(0)}dispose(){const e=this._vertexBuffers[A.PositionKind];e&&(e.dispose(),this._vertexBuffers[A.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null)}}class Ut{constructor(e){this.length=0,this.data=new Array(e),this._id=Ut._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}}Ut._GlobalId=0;class Ms extends Ut{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 Ei{set opaqueSortCompareFn(e){e?this._opaqueSortCompareFn=e:this._opaqueSortCompareFn=Ei.PainterSortCompare,this._renderOpaque=this._renderOpaqueSorted}set alphaTestSortCompareFn(e){e?this._alphaTestSortCompareFn=e:this._alphaTestSortCompareFn=Ei.PainterSortCompare,this._renderAlphaTest=this._renderAlphaTestSorted}set transparentSortCompareFn(e){e?this._transparentSortCompareFn=e:this._transparentSortCompareFn=Ei.defaultTransparentSortCompare,this._renderTransparent=this._renderTransparentSorted}constructor(e,t,i=null,s=null,n=null){this.index=e,this._opaqueSubMeshes=new Ut(256),this._transparentSubMeshes=new Ut(256),this._alphaTestSubMeshes=new Ut(256),this._depthOnlySubMeshes=new Ut(256),this._particleSystems=new Ut(256),this._spriteManagers=new Ut(256),this._empty=!0,this._edgesRenderers=new Ms(16),this._scene=t,this.opaqueSortCompareFn=i,this.alphaTestSortCompareFn=s,this.transparentSortCompareFn=n}render(e,t,i,s){if(e){e(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);return}const n=this._scene.getEngine();this._depthOnlySubMeshes.length!==0&&(n.setColorWrite(!1),this._renderAlphaTest(this._depthOnlySubMeshes),n.setColorWrite(!0)),this._opaqueSubMeshes.length!==0&&this._renderOpaque(this._opaqueSubMeshes),this._alphaTestSubMeshes.length!==0&&this._renderAlphaTest(this._alphaTestSubMeshes);const r=n.getStencilBuffer();if(n.setStencilBuffer(!1),t&&this._renderSprites(),i&&this._renderParticles(s),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),this._transparentSubMeshes.length!==0||this._scene.useOrderIndependentTransparency){if(n.setStencilBuffer(r),this._scene.useOrderIndependentTransparency){const o=this._scene.depthPeelingRenderer.render(this._transparentSubMeshes);o.length&&this._renderTransparent(o)}else this._renderTransparent(this._transparentSubMeshes);n.setAlphaMode(0)}if(n.setStencilBuffer(!1),this._edgesRenderers.length){for(let o=0;o<this._edgesRenderers.length;o++)this._edgesRenderers.data[o].render();n.setAlphaMode(0)}n.setStencilBuffer(r)}_renderOpaqueSorted(e){Ei._RenderSorted(e,this._opaqueSortCompareFn,this._scene.activeCamera,!1)}_renderAlphaTestSorted(e){Ei._RenderSorted(e,this._alphaTestSortCompareFn,this._scene.activeCamera,!1)}_renderTransparentSorted(e){Ei._RenderSorted(e,this._transparentSortCompareFn,this._scene.activeCamera,!0)}static _RenderSorted(e,t,i,s){let n=0,r;const o=i?i.globalPosition:Ei._ZeroVector;if(s)for(;n<e.length;n++)r=e.data[n],r._alphaIndex=r.getMesh().alphaIndex,r._distanceToCamera=v.Distance(r.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(n=0;n<h.length;n++)if(r=h[n],!(l._activeMeshesFrozenButKeepClipping&&!r.isInFrustum(l._frustumPlanes))){if(s){const c=r.getMaterial();if(c&&c.needDepthPrePass){const u=c.getScene().getEngine();u.setColorWrite(!1),u.setAlphaMode(0),r.render(!1),u.setColorWrite(!0)}}r.render(s)}}static defaultTransparentSortCompare(e,t){return e._alphaIndex>t._alphaIndex?1:e._alphaIndex<t._alphaIndex?-1:Ei.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.needAlphaTesting()?(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 n=s.emitter;(!n.position||!e||e.indexOf(n)!==-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)}}Ei._ZeroVector=v.Zero();class J_{}class Lt{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 J_,this._maintainStateBetweenFrames=!1,this._scene=e;for(let t=Lt.MIN_RENDERINGGROUPS;t<Lt.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 n=this._renderingGroupInfo;if(n.scene=this._scene,n.camera=this._scene.activeCamera,this._scene.spriteManagers&&s)for(let r=0;r<this._scene.spriteManagers.length;r++){const o=this._scene.spriteManagers[r];this.dispatchSprites(o)}for(let r=Lt.MIN_RENDERINGGROUPS;r<Lt.MAX_RENDERINGGROUPS;r++){this._depthStencilBufferAlreadyCleaned=r===Lt.MIN_RENDERINGGROUPS;const o=this._renderingGroups[r];if(!o||o._empty)continue;const h=1<<r;if(n.renderingGroupId=r,this._scene.onBeforeRenderingGroupObservable.notifyObservers(n,h),Lt.AUTOCLEAR){const l=this._useSceneAutoClearSetup?this._scene.getAutoClearDepthStencilSetup(r):this._autoClearDepthStencil[r];l&&l.autoClear&&this._clearDepthStencilBuffer(l.depth,l.stencil)}for(const l of this._scene._beforeRenderingGroupDrawStage)l.action(r);o.render(e,s,i,t);for(const l of this._scene._afterRenderingGroupDrawStage)l.action(r);this._scene.onAfterRenderingGroupObservable.notifyObservers(n,h)}}reset(){if(!this.maintainStateBetweenFrames)for(let e=Lt.MIN_RENDERINGGROUPS;e<Lt.MAX_RENDERINGGROUPS;e++){const t=this._renderingGroups[e];t&&t.prepare()}}resetSprites(){if(!this.maintainStateBetweenFrames)for(let e=Lt.MIN_RENDERINGGROUPS;e<Lt.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=Lt.MIN_RENDERINGGROUPS;e<Lt.MAX_RENDERINGGROUPS;e++){const t=this._renderingGroups[e];t&&t.dispose()}}_prepareRenderingGroup(e){this._renderingGroups[e]===void 0&&(this._renderingGroups[e]=new Ei(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 n=this._renderingGroups[e];n.opaqueSortCompareFn=this._customOpaqueSortCompareFn[e],n.alphaTestSortCompareFn=this._customAlphaTestSortCompareFn[e],n.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]}}Lt.MAX_RENDERINGGROUPS=4;Lt.MIN_RENDERINGGROUPS=0;Lt.AUTOCLEAR=!0;class Pi{get renderList(){return this._renderList}set renderList(e){this._renderList!==e&&(this._unObserveRenderList&&(this._unObserveRenderList(),this._unObserveRenderList=null),e&&(this._unObserveRenderList=Ql(e,this._renderListHasChanged)),this._renderList=e)}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 n=0;n<this.options.numPasses;++n)i[s].setMaterialForRenderPass(this._renderPassIds[n],t!==void 0?Array.isArray(t)?t[n]:t:void 0)}constructor(e,t,i){this._unObserveRenderList=null,this._renderListHasChanged=(s,n)=>{const r=this._renderList?this._renderList.length:0;(n===0&&r>0||r===0)&&this._scene.meshes.forEach(o=>{o._markSubMeshesAsLightDirty()})},this.particleSystemList=null,this.getCustomRenderList=null,this.renderParticles=!0,this.renderSprites=!1,this.forceLayerMaskCheck=!1,this.onBeforeRenderObservable=new Z,this.onAfterRenderObservable=new Z,this.onBeforeRenderingManagerRenderObservable=new Z,this.onAfterRenderingManagerRenderObservable=new Z,this.onFastPathRenderObservable=new Z,this._currentRefreshId=-1,this._refreshRate=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 Lt(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("ObjectRenderer - ".concat(this.name,"#").concat(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)}}}initRender(e,t){var n;const i=this._scene.getEngine(),s=(n=this.activeCamera)!=null?n: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;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(),n=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=n}_checkReadiness(){const e=this._scene,t=e.getEngine(),i=t.currentRenderPassId;let s=!0;e.getViewMatrix()||e.updateTransformMatrix();const n=this.options.numPasses;for(let o=0;o<n&&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._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),n>1&&(e.incrementRenderId(),e.resetCachedMaterial())}const r=this.particleSystemList||e.particleSystems;for(const o of r)o.isReady()||(s=!1);return t.currentRenderPassId=i,s}_prepareRenderingManager(e,t,i){const s=this._scene,n=s.activeCamera;this._renderingManager.reset();const r=s.getRenderId();for(let h=0;h<t;h++){const l=e[h];if(l&&!l.isBlocked){if(this.customIsReadyFunction){if(!this.customIsReadyFunction(l,this.refreshRate,!1)){this.resetRefreshCounter();continue}}else if(!l.isReady(this.refreshRate===0)){this.resetRefreshCounter();continue}if(!l._internalAbstractMeshDataInfo._currentLODIsUpToDate&&n&&(l._internalAbstractMeshDataInfo._currentLOD=s.customLODSelector?s.customLODSelector(l,n):l.getLOD(n),l._internalAbstractMeshDataInfo._currentLODIsUpToDate=!0),!l._internalAbstractMeshDataInfo._currentLOD)continue;let c=l._internalAbstractMeshDataInfo._currentLOD;c!==l&&c.billboardMode!==0&&c.computeWorldMatrix(),c._preActivateForIntermediateRendering(r);let u;if(i&&n?u=(l.layerMask&n.layerMask)===0:u=!1,l.isEnabled()&&l.isVisible&&l.subMeshes&&!u){if(c!==l&&c._activate(r,!0),l._activate(r,!0)&&l.subMeshes.length){l.isAnInstance?l._internalAbstractMeshDataInfo._actAsRegularMesh&&(c=l):c._internalAbstractMeshDataInfo._onlyForInstancesIntermediate=!1,c._internalAbstractMeshDataInfo._isActiveIntermediate=!0,s._prepareSkeleton(c);for(let f=0;f<c.subMeshes.length;f++){const d=c.subMeshes[f];this._renderingManager.dispatch(d,c)}}l._postActivate()}}}const o=this.particleSystemList||s.particleSystems;for(let h=0;h<o.length;h++){const l=o[h],c=l.emitter;!l.isStarted()||!c||c.position&&!c.isEnabled()||this._renderingManager.dispatchParticles(l)}}setRenderingOrder(e,t=null,i=null,s=null){this._renderingManager.setRenderingOrder(e,t,i,s)}setRenderingAutoClearDepthStencil(e,t){this._renderingManager.setRenderingAutoClearDepthStencil(e,t),this._renderingManager._useSceneAutoClearSetup=!1}clone(){const e=new Pi(this.name,this._scene,this.options);return this.renderList&&(e.renderList=this.renderList.slice(0)),e}dispose(){this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderingManagerRenderObservable.clear(),this.onAfterRenderingManagerRenderObservable.clear(),this.onFastPathRenderObservable.clear(),this._releaseRenderPassId(),this.renderList=null}_rebuild(){this.refreshRate===Pi.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=Pi.REFRESHRATE_RENDER_ONCE)}freeRenderingGroups(){this._renderingManager&&this._renderingManager.freeRenderingGroups()}}Pi.REFRESHRATE_RENDER_ONCE=0;Pi.REFRESHRATE_RENDER_ONEVERYFRAME=1;Pi.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2;Et.prototype.setDepthStencilTexture=function(a,e){this._engine.setDepthStencilTexture(this._samplers[a],this._uniforms[a],e,a)};class us extends ie{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 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(){var e,t;return(t=(e=this._renderTarget)==null?void 0:e.isMulti)!=null?t:!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(){var e,t;return(t=(e=this._renderTarget)==null?void 0:e._depthStencilTexture)!=null?t:null}constructor(e,t,i,s=!1,n=!0,r=0,o=!1,h=ie.TRILINEAR_SAMPLINGMODE,l=!0,c=!1,u=!1,f=5,d=!1,_,p,g=!1,m=!1){var x,y,R,E,C,S,w;let b,I=!0;if(typeof s=="object"){const P=s;s=!!P.generateMipMaps,n=(x=P.doNotChangeAspectRatio)!=null?x:!0,r=(y=P.type)!=null?y:0,o=!!P.isCube,h=(R=P.samplingMode)!=null?R:ie.TRILINEAR_SAMPLINGMODE,l=(E=P.generateDepthBuffer)!=null?E:!0,c=!!P.generateStencilBuffer,u=!!P.isMulti,f=(C=P.format)!=null?C:5,d=!!P.delayAllocation,_=P.samples,p=P.creationFlags,g=!!P.noColorAttachment,m=!!P.useSRGBBuffer,b=P.colorAttachment,I=(S=P.gammaSpace)!=null?S:I}if(super(null,i,!s,void 0,h,void 0,void 0,void 0,void 0,f),this.ignoreCameraViewport=!1,this.onBeforeBindObservable=new Z,this.onAfterUnbindObservable=new Z,this.onClearObservable=new Z,this.onResizeObservable=new Z,this._cleared=!1,this.skipInitialClear=!1,this._samples=1,this._canRescale=!0,this._renderTarget=null,this.boundingBoxPosition=v.Zero(),this._dumpToolsLoading=!1,i=this.getScene(),!i)return;const T=this.getScene().getEngine();this._gammaSpace=I,this._coordinatesMode=ie.PROJECTION_MODE,this.name=e,this.isRenderTarget=!0,this._initialSizeParameter=t,this._processSizeParameter(t),this._objectRenderer=new Pi(e,i,{numPasses:o?6:this.getRenderLayers()||1,doNotChangeAspectRatio:n}),this._objectRenderer.onBeforeRenderingManagerRenderObservable.add(()=>{for(const P of this._scene._beforeRenderTargetClearStage)P.action(this,this._currentFaceIndex,this._currentLayer);this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(T):this.skipInitialClear||T.clear(this.clearColor||this._scene.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||this._scene.updateTransformMatrix(!0);for(const P of this._scene._beforeRenderTargetDrawStage)P.action(this,this._currentFaceIndex,this._currentLayer)}),this._objectRenderer.onAfterRenderingManagerRenderObservable.add(()=>{var G,L,W,K;for(const ce of this._scene._afterRenderTargetDrawStage)ce.action(this,this._currentFaceIndex,this._currentLayer);const P=(L=(G=this._texture)==null?void 0:G.generateMipMaps)!=null?L:!1;this._texture&&(this._texture.generateMipMaps=!1),this._postProcessManager?this._postProcessManager._finalizeFrame(!1,(W=this._renderTarget)!=null?W:void 0,this._currentFaceIndex,this._postProcesses,this.ignoreCameraViewport):this._currentUseCameraPostProcess&&this._scene.postProcessManager._finalizeFrame(!1,(K=this._renderTarget)!=null?K:void 0,this._currentFaceIndex);for(const ce of this._scene._afterRenderTargetPostProcessStage)ce.action(this,this._currentFaceIndex,this._currentLayer);this._texture&&(this._texture.generateMipMaps=P),this._doNotChangeAspectRatio||this._scene.updateTransformMatrix(!0),this._currentDumpForDebug&&(this._dumpTools?this._dumpTools.DumpFramebuffer(this.getRenderWidth(),this.getRenderHeight(),T):U.Error("dumpTools module is still being loaded. To speed up the process import dump tools directly in your project"))}),this._objectRenderer.onFastPathRenderObservable.add(()=>{this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(T):this.skipInitialClear||T.clear(this.clearColor||this._scene.clearColor,!0,!0,!0)}),this._resizeObserver=T.onResizeObservable.add(()=>{}),this._generateMipMaps=!!s,this._doNotChangeAspectRatio=n,!u&&(this._renderTargetOptions={generateMipMaps:s,type:r,format:(w=this._format)!=null?w:void 0,samplingMode:this.samplingMode,generateDepthBuffer:l,generateStencilBuffer:c,samples:_,creationFlags:p,noColorAttachment:g,useSRGBBuffer:m,colorAttachment:b,label:this.name},this.samplingMode===ie.NEAREST_SAMPLINGMODE&&(this.wrapU=ie.CLAMP_ADDRESSMODE,this.wrapV=ie.CLAMP_ADDRESSMODE),d||(o?(this._renderTarget=i.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions),this.coordinatesMode=ie.INVCUBIC_MODE,this._textureMatrix=O.Identity()):this._renderTarget=i.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this._texture=this._renderTarget.texture,_!==void 0&&(this.samples=_)))}createDepthStencilTexture(e=0,t=!0,i=!1,s=1,n=14,r){var o;(o=this._renderTarget)==null||o.createDepthStencilTexture(e,t,i,s,n,r)}_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(){var e,t;return(t=(e=this._renderTarget)==null?void 0:e.samples)!=null?t: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 ka(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){var s;const t=this.isCube;(s=this._renderTarget)==null||s.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,Oe(()=>Promise.resolve().then(()=>qg),void 0).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.finishRender()}}_bestReflectionRenderTargetDimension(e,t){const s=e*t,n=Ul(s+128*128/(128+s));return Math.min(u0(e),n)}_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){var o,h;const n=this.getScene();if(!n)return;const r=n.getEngine();this._currentFaceIndex=e,this._currentLayer=s,this._currentUseCameraPostProcess=t,this._currentDumpForDebug=i,this._prepareFrame(n,e,s,t),(o=r._debugPushGroup)==null||o.call(r,"render to face #".concat(e," layer #").concat(s),2),this._objectRenderer.render(e+s,!0),(h=r._debugPopGroup)==null||h.call(r,2),this._unbindFrameBuffer(r,e),this._texture&&this.isCube&&e===5&&r.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 us(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(){var e;(e=this._renderTarget)==null||e.dispose(!0)}releaseInternalTexture(){var e;(e=this._renderTarget)==null||e.releaseTextures(),this._texture=null}dispose(){var i;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.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 s of e.cameras)t=s.customRenderTargets.indexOf(this),t>=0&&s.customRenderTargets.splice(t,1);(i=this._renderTarget)==null||i.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}}us.REFRESHRATE_RENDER_ONCE=Pi.REFRESHRATE_RENDER_ONCE;us.REFRESHRATE_RENDER_ONEVERYFRAME=Pi.REFRESHRATE_RENDER_ONEVERYFRAME;us.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=Pi.REFRESHRATE_RENDER_ONEVERYTWOFRAMES;ie._CreateRenderTargetTexture=(a,e,t,i,s)=>new us(a,e,t,i);class Xn{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){var s;this.effect=e,t!==void 0&&(this.defines=t),i&&((s=this.drawContext)==null||s.reset())}dispose(e=!1){var t;if(this.effect){const i=this.effect;e?i.dispose():Bn.SetImmediate(()=>{i.getEngine().onEndFrameObservable.addOnce(()=>{i.dispose()})}),this.effect=null}(t=this.drawContext)==null||t.dispose()}}const bc="postprocessVertexShader",xc="attribute vec2 position;uniform vec2 scale;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvUV=(position*madd+madd)*scale;gl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";Me.ShadersStore[bc]=xc;const ep={name:bc,shader:xc},yc=Object.freeze(Object.defineProperty({__proto__:null,postprocessVertexShader:ep},Symbol.toStringTag,{value:"Module"})),ba={positions:[1,1,-1,1,-1,-1,1,-1],indices:[0,1,2,0,2,3]};class tp{constructor(e,t=ba){var n,r;this._fullscreenViewport=new on(0,0,1,1);const i=(n=t.positions)!=null?n:ba.positions,s=(r=t.indices)!=null?r:ba.indices;this.engine=e,this._vertexBuffers={[A.PositionKind]:new A(e,i,A.PositionKind,!1,!1,2)},this._indexBuffer=e.createIndexBuffer(s),this._onContextRestoredObserver=e.onContextRestoredObservable.add(()=>{this._indexBuffer=e.createIndexBuffer(s);for(const o in this._vertexBuffers)this._vertexBuffers[o]._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[A.PositionKind];e&&(e.dispose(),delete this._vertexBuffers[A.PositionKind]),this._indexBuffer&&this.engine._releaseBuffer(this._indexBuffer),this._onContextRestoredObserver&&(this.engine.onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)}}class Kt{static RegisterShaderCodeProcessing(e,t){if(!t){delete Kt._CustomShaderCodeProcessing[e!=null?e:""];return}Kt._CustomShaderCodeProcessing[e!=null?e:""]=t}static _GetShaderCodeProcessing(e){var t;return(t=Kt._CustomShaderCodeProcessing[e])!=null?t:Kt._CustomShaderCodeProcessing[""]}get name(){return this.options.name}set name(e){this.options.name=e}isReady(){var e,t;return(t=(e=this._drawWrapper.effect)==null?void 0:e.isReady())!=null?t:!1}get drawWrapper(){return this._drawWrapper}get effect(){return this._drawWrapper.effect}set effect(e){this._drawWrapper.effect=e}constructor(e){var i;this.alphaMode=0,this.onEffectCreatedObservable=new Z(void 0,!0),this.onApplyObservable=new Z,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:(i=e.useAsPostProcess)!=null?i:!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 Xn(this.options.engine),this._webGPUReady=this.options.shaderLanguage===1;const t=Array.isArray(this.options.defines)?this.options.defines.join("\n"):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([Oe(()=>import("./postprocess.vertex-DvFhjUjz.js"),__vite__mapDeps([17,3,4,5,6,7,8,9,10]))])):t.push(Promise.all([Oe(()=>Promise.resolve().then(()=>yc),void 0)])))}_postConstructor(e,t=null,i,s){this._importPromises.length=0,s&&this._importPromises.push(...s);const n=this.options.engine.isWebGPU&&!Kt.ForceGLSL;this._gatherImports(n,this._importPromises),i!==void 0&&i(n,this._importPromises),n&&this._webGPUReady&&(this.options.shaderLanguage=1),e||this.updateEffect(t)}updateEffect(e=null,t=null,i=null,s,n,r,o,h){var f,d;const l=Kt._GetShaderCodeProcessing(this.name);if(l!=null&&l.defineCustomBindings){const _=(f=t==null?void 0:t.slice())!=null?f:[];_.push(...this.options.uniforms);const p=(d=i==null?void 0:i.slice())!=null?d:[];p.push(...this.options.samplers),e=l.defineCustomBindings(this.name,e,_,p),t=_,i=p}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==null||c(),await this.options.extraInitializationsAsync}:u=c,this.options.useShaderStore?this._drawWrapper.effect=this.options.engine.createEffect({vertex:o!=null?o:this._shaderPath.vertex,fragment:h!=null?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:n!=null?n:this.options.onCompiled,onError:r!=null?r:null,indexParameters:s||this.options.indexParameters,processCodeAfterIncludes:l!=null&&l.processCodeAfterIncludes?(_,p)=>l.processCodeAfterIncludes(this.name,_,p):null,processFinalCode:l!=null&&l.processFinalCode?(_,p)=>l.processFinalCode(this.name,_,p):null,shaderLanguage:this.options.shaderLanguage,extraInitializationsAsync:u},this.options.engine):this._drawWrapper.effect=new Et(this._shaderPath,this.options.attributeNames,t||this.options.uniforms,i||this.options.samplerNames,this.options.engine,e,void 0,n||this.options.onCompiled,void 0,void 0,void 0,this.options.shaderLanguage,u),this.onEffectCreatedObservable.notifyObservers(this._drawWrapper.effect)}bind(){var e,t;this.options.useAsPostProcess&&(this.options.engine.setAlphaMode(this.alphaMode),this.drawWrapper.effect.setFloat2("scale",1,1)),(t=(e=Kt._GetShaderCodeProcessing(this.name))==null?void 0:e.bindCustomBindings)==null||t.call(e,this.name,this._drawWrapper.effect)}dispose(e=!1){this._onContextRestoredObserver&&(this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null),this.onEffectCreatedObservable.clear(),this.effect.dispose()}}Kt.ForceGLSL=!1;Kt._CustomShaderCodeProcessing={};ae.prototype.setTextureFromPostProcess=function(a,e,t){var s;let i=null;e&&(e._forcedOutputTexture?i=e._forcedOutputTexture:e._textures.data[e._currentRenderTextureInd]&&(i=e._textures.data[e._currentRenderTextureInd])),this._bindTexture(a,(s=i==null?void 0:i.texture)!=null?s:null,t)};ae.prototype.setTextureFromPostProcessOutput=function(a,e,t){var i,s;this._bindTexture(a,(s=(i=e==null?void 0:e._outputTexture)==null?void 0:i.texture)!=null?s:null,t)};Et.prototype.setTextureFromPostProcess=function(a,e){this._engine.setTextureFromPostProcess(this._samplers[a],e,a)};Et.prototype.setTextureFromPostProcessOutput=function(a,e){this._engine.setTextureFromPostProcessOutput(this._samplers[a],e,a)};class mt{static get ForceGLSL(){return Kt.ForceGLSL}static set ForceGLSL(e){Kt.ForceGLSL=e}static RegisterShaderCodeProcessing(e,t){Kt.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,n,r,o=1,h,l,c=null,u=0,f="postprocess",d,_=!1,p=5,g,m){var y,R,E,C,S,w,P,G,L,W,K,ce;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 Ut(2),this._textureCache=[],this._currentRenderTextureInd=0,this._scaleRatio=new oe(1,1),this._texelSize=oe.Zero(),this.onActivateObservable=new Z,this.onSizeChangedObservable=new Z,this.onApplyObservable=new Z,this.onBeforeRenderObservable=new Z,this.onAfterRenderObservable=new Z;let b=1,I=null,T;if(i&&!Array.isArray(i)){const $=i;i=(y=$.uniforms)!=null?y:null,s=(R=$.samplers)!=null?R:null,b=(E=$.size)!=null?E:1,r=(C=$.camera)!=null?C:null,o=(S=$.samplingMode)!=null?S:1,h=$.engine,l=$.reusable,c=Array.isArray($.defines)?$.defines.join("\n"):(w=$.defines)!=null?w:null,u=(P=$.textureType)!=null?P:0,f=(G=$.vertexUrl)!=null?G:"postprocess",d=$.indexParameters,_=(L=$.blockCompilation)!=null?L:!1,p=(W=$.textureFormat)!=null?W:5,g=(K=$.shaderLanguage)!=null?K:0,I=(ce=$.uniformBuffers)!=null?ce:null,m=$.extraInitializations,T=$.effectWrapper}else n&&(typeof n=="number"?b=n:b={width:n.width,height:n.height});const x=!!T;if(this._effectWrapper=T!=null?T:new Kt({name:e,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:t,engine:h||(r==null?void 0:r.getScene().getEngine()),uniforms:i,samplers:s,uniformBuffers:I,defines:c,vertexUrl:f,indexParameters:d,blockCompilation:!0,shaderLanguage:g,extraInitializations:void 0}),this.name=e,this.onEffectCreatedObservable=this._effectWrapper.onEffectCreatedObservable,r!=null?(this._camera=r,this._scene=r.getScene(),r.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=b,this.renderTargetSamplingMode=o||1,this._reusable=l||!1,this._textureType=u,this._textureFormat=p,this._shaderLanguage=g||0,this._samplers=s||[],this._samplers.indexOf("textureSampler")===-1&&this._samplers.push("textureSampler"),this._fragmentUrl=t,this._vertexUrl=f,this._parameters=i||[],this._parameters.indexOf("scale")===-1&&this._parameters.push("scale"),this._uniformBuffers=I||[],this._indexParameters=d,!x){this._webGPUReady=this._shaderLanguage===1;const $=[];this._gatherImports(this._engine.isWebGPU&&!mt.ForceGLSL,$),this._effectWrapper._webGPUReady=this._webGPUReady,this._effectWrapper._postConstructor(_,c,m,$)}}_gatherImports(e=!1,t){e&&this._webGPUReady?t.push(Promise.all([Oe(()=>import("./postprocess.vertex-DvFhjUjz.js"),__vite__mapDeps([17,3,4,5,6,7,8,9,10]))])):t.push(Promise.all([Oe(()=>Promise.resolve().then(()=>yc),void 0)]))}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 Ut(2)),this._shareOutputWithPostProcess=null}updateEffect(e=null,t=null,i=null,s,n,r,o,h){this._effectWrapper.updateEffect(e,t,i,s,n,r,o,h),this._postProcessDefines=Array.isArray(this._effectWrapper.options.defines)?this._effectWrapper.options.defines.join("\n"):this._effectWrapper.options.defines}isReusable(){return this._reusable}markTextureDirty(){this.width=-1}_createRenderTargetTexture(e,t,i=0){for(let n=0;n<this._textureCache.length;n++)if(this._textureCache[n].texture.width===e.width&&this._textureCache[n].texture.height===e.height&&this._textureCache[n].postProcessChannel===i&&this._textureCache[n].texture._generateDepthBuffer===t.generateDepthBuffer&&this._textureCache[n].texture.samples===t.samples)return this._textureCache[n].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,n=!1){this._textures.length>0&&this._textures.reset(),this.width=e,this.height=t;let r=null;if(i){for(let l=0;l<i._postProcesses.length;l++)if(i._postProcesses[l]!==null){r=i._postProcesses[l];break}}const o={width:this.width,height:this.height},h={generateMipMaps:s,generateDepthBuffer:n||r===this,generateStencilBuffer:(n||r===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){var d,_;e=e||this._camera;const s=e.getScene(),n=s.getEngine(),r=n.getCaps().maxTextureSize,o=(t?t.width:this._engine.getRenderWidth(!0))*this._options|0,h=(t?t.height:this._engine.getRenderHeight(!0))*this._options|0;let l=this._options.width||o,c=this._options.height||h;const u=this.renderTargetSamplingMode!==7&&this.renderTargetSamplingMode!==1&&this.renderTargetSamplingMode!==2;let f=null;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this.adaptScaleToCurrentViewport){const p=n.currentViewport;p&&(l*=p.width,c*=p.height)}(u||this.alwaysForcePOT)&&(this._options.width||(l=n.needPOTTextures?fi(l,r,this.scaleMode):l),this._options.height||(c=n.needPOTTextures?fi(c,r,this.scaleMode):c)),(this.width!==l||this.height!==c||!(f=this._getTarget()))&&this.resize(l,c,e,u,i),this._textures.forEach(p=>{p.samples!==this.samples&&this._engine.updateRenderTargetTextureSampleCount(p,this.samples)}),this._flushTextureCache(),this._renderId++}return f||(f=this._getTarget()),this.enablePixelPerfectMode?(this._scaleRatio.copyFromFloats(o/l,h/c),this._engine.bindFramebuffer(f,0,o,h,this.forceFullscreenViewport)):(this._scaleRatio.copyFromFloats(1,1),this._engine.bindFramebuffer(f,0,void 0,void 0,this.forceFullscreenViewport)),(_=(d=this._engine)._debugInsertMarker)==null||_.call(d,"post process ".concat(this.name," input")),this.onActivateObservable.notifyObservers(e),this.autoClear&&(this.alphaMode===0||this.forceAutoClearInAlphaMode)&&this._engine.clear(this.clearColor?this.clearColor:s.clearColor,s._allowPostProcessClearColor,!0,!0),this._reusable&&(this._currentRenderTextureInd=(this._currentRenderTextureInd+1)%2),f}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);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==null?void 0:e.texture),this._effectWrapper.drawWrapper.effect.setVector2("scale",this._scaleRatio),this.onApplyObservable.notifyObservers(this._effectWrapper.drawWrapper.effect),this._effectWrapper.bind(),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._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),!!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=Ae.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=mt.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=ys(e.customType);if(!s||!s._Parse)return null;const n=t?t.getCameraById(e.cameraId):null;return s._Parse(e,n,t,i)}static _Parse(e,t,i,s){return Ae.Parse(()=>new mt(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)}}D([B()],mt.prototype,"uniqueId",void 0);D([B()],mt.prototype,"name",null);D([B()],mt.prototype,"width",void 0);D([B()],mt.prototype,"height",void 0);D([B()],mt.prototype,"renderTargetSamplingMode",void 0);D([p0()],mt.prototype,"clearColor",void 0);D([B()],mt.prototype,"autoClear",void 0);D([B()],mt.prototype,"forceAutoClearInAlphaMode",void 0);D([B()],mt.prototype,"alphaMode",null);D([B()],mt.prototype,"alphaConstants",void 0);D([B()],mt.prototype,"enablePixelPerfectMode",void 0);D([B()],mt.prototype,"forceFullscreenViewport",void 0);D([B()],mt.prototype,"scaleMode",void 0);D([B()],mt.prototype,"alwaysForcePOT",void 0);D([B("samples")],mt.prototype,"_samples",void 0);D([B()],mt.prototype,"adaptScaleToCurrentViewport",void 0);vt("BABYLON.PostProcess",mt);class Yn extends mt{getClassName(){return"PassPostProcess"}constructor(e,t,i=null,s,n,r,o=0,h=!1){super(e,"pass",null,null,t,i,s,n,r,void 0,o,void 0,null,h)}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([Oe(()=>import("./pass.fragment-CM2j9WLA.js"),__vite__mapDeps([18,3,4,5,6,7,8,9,10]))]))):t.push(Promise.all([Oe(()=>import("./pass.fragment-BkcfUm5b.js"),__vite__mapDeps([19,3,4,5,6,7,8,9,10]))])),super._gatherImports(e,t)}static _Parse(e,t,i,s){return Ae.Parse(()=>new Yn(e.name,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable),e,i,s)}}vt("BABYLON.PassPostProcess",Yn);ae._RescalePostProcessFactory=a=>new Yn("rescale",1,null,2,a,!1,0);function ip(a,e,t,i,s,n,r,o){const h=e.getEngine();return e.isReady=!1,s=s!=null?s:e.samplingMode,i=i!=null?i:e.type,n=n!=null?n:e.format,r=r!=null?r:e.width,o=o!=null?o:e.height,i===-1&&(i=0),new Promise(l=>{const c=new mt("postprocess",a,null,null,1,null,s,h,!1,void 0,i,void 0,null,!1,n);c.externalTextureSamplerBinding=!0;const u=h.createRenderTargetTexture({width:r,height:o},{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:s,type:i,format:n});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 or,Mh;function rx(a){or||(or=new Float32Array(1),Mh=new Int32Array(or.buffer)),or[0]=a;const e=Mh[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 sp(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 Mr{static _IsGPUBuffer(e){return e.underlyingResource===void 0}static _FlagsToString(e,t=""){let i=t;for(let s=0;s<=9;++s)e&1<<s&&(i&&(i+="_"),i+=We[1<<s]);return i}constructor(e,t){this._deferredReleaseBuffers=[],this._engine=e,this._device=t}createRawBuffer(e,t,i=!1,s){const n=e.byteLength!==void 0?e.byteLength+3&-4:e+3&-4,r={label:"BabylonWebGPUDevice"+this._engine.uniqueId+"_"+Mr._FlagsToString(t,s!=null?s:"Buffer")+"_size"+n,mappedAtCreation:i,size:n,usage:t};return this._device.createBuffer(r)}createBuffer(e,t,i){const s=e.byteLength!==void 0,n=new $_,r="DataBufferUniqueId="+n.uniqueId;return n.buffer=this.createRawBuffer(e,t,void 0,i?r+"-"+i:r),n.references=1,n.capacity=s?e.byteLength:e,n.engineId=this._engine.uniqueId,s&&this.setSubData(n,0,e),n}setRawData(e,t,i,s,n){this._device.queue.writeBuffer(e,t,i.buffer,s,n)}setSubData(e,t,i,s=0,n=0){const r=e.underlyingResource;n=n||i.byteLength,n=Math.min(n,e.capacity-t);let o=i.byteOffset+s,h=o+n;const l=n+3&-4;if(l!==n){const f=new Uint8Array(i.buffer.slice(o,h));i=new Uint8Array(l),i.set(f),s=0,o=0,h=l,n=l}const c=1024*1024*15;let u=0;for(;h-(o+u)>c;)this._device.queue.writeBuffer(r,t+u,i.buffer,o+u,c),u+=c;this._device.queue.writeBuffer(r,t+u,i.buffer,o+u,n-u)}_getHalfFloatAsFloatRGBAArrayBuffer(e,t,i){i||(i=new Float32Array(e));const s=new Uint16Array(t);for(;e--;)i[e]=sp(s[e]);return i}readDataFromBuffer(e,t,i,s,n,r,o=0,h=0,l=null,c=!0,u=!1){const f=o===1?2:o===2?1:0,d=this._engine.uniqueId;return new Promise((_,p)=>{e.mapAsync(1,h,t).then(()=>{const g=e.getMappedRange(h,t);let m=l;if(u)m===null?m=Pa(o,t,!0,g):m=Pa(o,m.buffer,void 0,g);else if(m===null)switch(f){case 0:m=new Uint8Array(t),m.set(new Uint8Array(g));break;case 1:m=this._getHalfFloatAsFloatRGBAArrayBuffer(t/2,g);break;case 2:m=new Float32Array(t/4),m.set(new Float32Array(g));break}else switch(f){case 0:m=new Uint8Array(m.buffer),m.set(new Uint8Array(g));break;case 1:m=this._getHalfFloatAsFloatRGBAArrayBuffer(t/2,g,l);break;case 2:m=new Float32Array(m.buffer),m.set(new Float32Array(g));break}if(n!==r){f===1&&!u&&(n*=2,r*=2);const b=new Uint8Array(m.buffer);let I=n,T=0;for(let x=1;x<s;++x){T=x*r;for(let y=0;y<n;++y)b[I++]=b[T++]}f!==0&&!u?m=new Float32Array(b.buffer,0,I/4):m=new Uint8Array(b.buffer,0,I)}e.unmap(),c&&this.releaseBuffer(e),_(m)},g=>{this._engine.isDisposed||this._engine.uniqueId!==d?_(new Uint8Array):p(g)})})}releaseBuffer(e){return Mr._IsGPUBuffer(e)?(this._deferredReleaseBuffers.push(e),!0):(e.references--,e.references===0?(this._deferredReleaseBuffers.push(e.underlyingResource),!0):!1)}destroyDeferredBuffers(){for(let e=0;e<this._deferredReleaseBuffers.length;++e)this._deferredReleaseBuffers[e].destroy();this._deferredReleaseBuffers.length=0}}const np=[0,0,3,7,0,2,6,2,4,1,5,3,1],rp=[0,64,32,96,16,80,48,112,8],ap=[0,128,128,0,0,0,0,128,0,0,0,0,128];class Fs{constructor(e){this._samplers={},this._device=e,this.disabled=!1}static GetSamplerHashCode(e){var s,n,r;const t=e._cachedAnisotropicFilteringLevel?e._cachedAnisotropicFilteringLevel:1;return np[e.samplingMode]+rp[(e._comparisonFunction||514)-512+1]+ap[e.samplingMode]+(((s=e._cachedWrapU)!=null?s:1)<<8)+(((n=e._cachedWrapV)!=null?n:1)<<10)+(((r=e._cachedWrapR)!=null?r:1)<<12)+((e.useMipMaps?1:0)<<14)+(t<<15)}static _GetSamplerFilterDescriptor(e,t){let i,s,n,r,o;const h=e.useMipMaps;switch(e.samplingMode){case 11:i="linear",s="linear",n="nearest",h||(r=o=0);break;case 3:case 3:i="linear",s="linear",h?n="linear":(n="nearest",r=o=0);break;case 8:i="nearest",s="nearest",h?n="linear":(n="nearest",r=o=0);break;case 4:i="nearest",s="nearest",n="nearest",h||(r=o=0);break;case 5:i="nearest",s="linear",n="nearest",h||(r=o=0);break;case 6:i="nearest",s="linear",h?n="linear":(n="nearest",r=o=0);break;case 7:i="nearest",s="linear",n="nearest",r=o=0;break;case 1:case 1:i="nearest",s="nearest",n="nearest",r=o=0;break;case 9:i="linear",s="nearest",n="nearest",h||(r=o=0);break;case 10:i="linear",s="nearest",h?n="linear":(n="nearest",r=o=0);break;case 2:case 2:i="linear",s="linear",n="nearest",r=o=0;break;case 12:i="linear",s="nearest",n="nearest",r=o=0;break;default:i="nearest",s="nearest",n="nearest",r=o=0;break}return t>1&&(r!==0||o!==0)&&n!=="nearest"?{magFilter:"linear",minFilter:"linear",mipmapFilter:"linear",anisotropyEnabled:!0}:{magFilter:i,minFilter:s,mipmapFilter:n,lodMinClamp:r,lodMaxClamp:o}}static _GetWrappingMode(e){switch(e){case 1:return"repeat";case 0:return"clamp-to-edge";case 2:return"mirror-repeat"}return"repeat"}static _GetSamplerWrappingDescriptor(e){return{addressModeU:this._GetWrappingMode(e._cachedWrapU),addressModeV:this._GetWrappingMode(e._cachedWrapV),addressModeW:this._GetWrappingMode(e._cachedWrapR)}}static _GetSamplerDescriptor(e,t){const i=e.useMipMaps&&e._cachedAnisotropicFilteringLevel?e._cachedAnisotropicFilteringLevel:1,s=this._GetSamplerFilterDescriptor(e,i);return{label:t,...s,...this._GetSamplerWrappingDescriptor(e),compare:e._comparisonFunction?Fs.GetCompareFunction(e._comparisonFunction):void 0,maxAnisotropy:s.anisotropyEnabled?i:1}}static GetCompareFunction(e){switch(e){case 519:return"always";case 514:return"equal";case 516:return"greater";case 518:return"greater-equal";case 513:return"less";case 515:return"less-equal";case 512:return"never";case 517:return"not-equal";default:return"less"}}getSampler(e,t=!1,i=0,s){if(this.disabled)return this._device.createSampler(Fs._GetSamplerDescriptor(e,s));t?i=0:i===0&&(i=Fs.GetSamplerHashCode(e));let n=t?void 0:this._samplers[i];return n||(n=this._device.createSampler(Fs._GetSamplerDescriptor(e,s)),t||(this._samplers[i]=n)),n}}const op={[A.PositionKind]:!0,[A.NormalKind]:!0,[A.TangentKind]:!0,[A.UVKind]:!0,[A.UV2Kind]:!0,[A.UV3Kind]:!0,[A.UV4Kind]:!0,[A.UV5Kind]:!0,[A.UV6Kind]:!0,[A.ColorKind]:!0,[A.ColorInstanceKind]:!0,[A.MatricesIndicesKind]:!0,[A.MatricesWeightsKind]:!0,[A.MatricesIndicesExtraKind]:!0,[A.MatricesWeightsExtraKind]:!0};function hp(a){switch(a){case A.BYTE:case A.SHORT:case A.INT:case A.FLOAT:return!0;case A.UNSIGNED_BYTE:case A.UNSIGNED_SHORT:case A.UNSIGNED_INT:return!1;default:throw new Error("Invalid type '".concat(a,"'"))}}function lp(a,e){const t=e.getEngine(),i=e._pipelineContext;if(!(i!=null&&i.vertexBufferKindToType))return;let s=null;for(const n in a){const r=a[n];if(!r||!op[n])continue;const o=r.normalized?A.FLOAT:r.type,h=i.vertexBufferKindToType[n];(o!==A.FLOAT&&h===void 0||h!==void 0&&h!==o)&&(s||(s=t._getShaderProcessingContext(e.shaderLanguage,!1)),i.vertexBufferKindToType[n]=o,o!==A.FLOAT&&(s.vertexBufferKindToNumberOfComponents[n]=A.DeduceStride(n),hp(o)&&(s.vertexBufferKindToNumberOfComponents[n]*=-1)))}if(s){const n=t._caps.parallelShaderCompile;t._caps.parallelShaderCompile=void 0,e._processShaderCodeAsync(null,t._features._checkNonFloatVertexBuffersDontRecreatePipelineContext,s),t._caps.parallelShaderCompile=n}}var dt;(function(a){a[a.StencilReadMask=0]="StencilReadMask",a[a.StencilWriteMask=1]="StencilWriteMask",a[a.DepthBias=2]="DepthBias",a[a.DepthBiasSlopeScale=3]="DepthBiasSlopeScale",a[a.DepthStencilState=4]="DepthStencilState",a[a.MRTAttachments1=5]="MRTAttachments1",a[a.MRTAttachments2=6]="MRTAttachments2",a[a.RasterizationState=7]="RasterizationState",a[a.ColorStates=8]="ColorStates",a[a.ShaderStage=9]="ShaderStage",a[a.TextureStage=10]="TextureStage",a[a.VertexState=11]="VertexState",a[a.NumStates=12]="NumStates"})(dt||(dt={}));const hr={0:1,1:2,768:3,769:4,770:5,771:6,772:7,773:8,774:9,775:10,776:11,32769:12,32770:13,32771:12,32772:13},Ys={0:0,7680:1,7681:2,7682:3,7683:4,5386:5,34055:6,34056:7};class rt{constructor(e,t){this.mrtTextureCount=0,this._device=e,this._useTextureStage=!0,this._states=new Array(30),this._statesLength=0,this._stateDirtyLowestIndex=0,this._emptyVertexBuffer=t,this._mrtFormats=[],this._parameter={token:void 0,pipeline:null},this.disabled=!1,this.vertexBuffers=[],this._kMaxVertexBufferStride=e.limits.maxVertexBufferArrayStride||2048,this.reset()}reset(){this._isDirty=!0,this.vertexBuffers.length=0,this.setAlphaToCoverage(!1),this.resetDepthCullingState(),this.setClampDepth(!1),this.setDepthBias(0),this._webgpuColorFormat=["bgra8unorm"],this.setColorFormat("bgra8unorm"),this.setMRT([]),this.setAlphaBlendEnabled(!1),this.setAlphaBlendFactors([null,null,null,null],[null,null]),this.setWriteMask(15),this.setDepthStencilFormat("depth24plus-stencil8"),this.setStencilEnabled(!1),this.resetStencilState(),this.setBuffers(null,null,null),this._setTextureState(0)}get colorFormats(){return this._mrtAttachments1>0?this._mrtFormats:this._webgpuColorFormat}getRenderPipeline(e,t,i,s=0){if(i=Ve.GetSample(i),this.disabled){const r=rt._GetTopology(e);return this._setVertexState(t),this._setTextureState(s),this._parameter.pipeline=this._createRenderPipeline(t,r,i),rt.NumCacheMiss++,rt._NumPipelineCreationCurrentFrame++,this._parameter.pipeline}if(this._setShaderStage(t.uniqueId),this._setRasterizationState(e,i),this._setColorStates(),this._setDepthStencilState(),this._setVertexState(t),this._setTextureState(s),this.lastStateDirtyLowestIndex=this._stateDirtyLowestIndex,!this._isDirty&&this._parameter.pipeline)return this._stateDirtyLowestIndex=this._statesLength,rt.NumCacheHitWithoutHash++,this._parameter.pipeline;if(this._getRenderPipeline(this._parameter),this._isDirty=!1,this._stateDirtyLowestIndex=this._statesLength,this._parameter.pipeline)return rt.NumCacheHitWithHash++,this._parameter.pipeline;const n=rt._GetTopology(e);return this._parameter.pipeline=this._createRenderPipeline(t,n,i),this._setRenderPipeline(this._parameter),rt.NumCacheMiss++,rt._NumPipelineCreationCurrentFrame++,this._parameter.pipeline}endFrame(){rt.NumPipelineCreationLastFrame=rt._NumPipelineCreationCurrentFrame,rt._NumPipelineCreationCurrentFrame=0}setAlphaToCoverage(e){this._alphaToCoverageEnabled=e}setFrontFace(e){this._frontFace=e}setCullEnabled(e){this._cullEnabled=e}setCullFace(e){this._cullFace=e}setClampDepth(e){this._clampDepth=e}resetDepthCullingState(){this.setDepthCullingState(!1,2,1,0,0,!0,!0,519)}setDepthCullingState(e,t,i,s,n,r,o,h){this._depthWriteEnabled=o,this._depthTestEnabled=r,this._depthCompare=(h!=null?h:519)-512,this._cullFace=i,this._cullEnabled=e,this._frontFace=t,this.setDepthBiasSlopeScale(s),this.setDepthBias(n)}setDepthBias(e){this._depthBias!==e&&(this._depthBias=e,this._states[dt.DepthBias]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,dt.DepthBias))}setDepthBiasSlopeScale(e){this._depthBiasSlopeScale!==e&&(this._depthBiasSlopeScale=e,this._states[dt.DepthBiasSlopeScale]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,dt.DepthBiasSlopeScale))}setColorFormat(e){this._webgpuColorFormat[0]=e,this._colorFormat=Vi[e!=null?e:""]}setMRTAttachments(e){this.mrtAttachments=e;let t=0;for(let i=0;i<e.length;++i)e[i]!==0&&(t+=1<<i);this._mrtEnabledMask!==t&&(this._mrtEnabledMask=t,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,dt.MRTAttachments1))}setMRT(e,t){var o,h;if(t=t!=null?t:e.length,t>10)throw"Can't handle more than 10 attachments for a MRT in cache render pipeline!";this.mrtTextureArray=e,this.mrtTextureCount=t,this._mrtEnabledMask=65535;const i=[0,0];let s=0,n=0,r=0;for(let l=0;l<t;++l){const c=e[l],u=c==null?void 0:c._hardwareTexture;this._mrtFormats[r]=(o=u==null?void 0:u.format)!=null?o:this._webgpuColorFormat[0],i[s]+=Vi[(h=this._mrtFormats[r])!=null?h:""]<<n,n+=6,r++,n>=32&&(n=0,s++)}this._mrtFormats.length=r,(this._mrtAttachments1!==i[0]||this._mrtAttachments2!==i[1])&&(this._mrtAttachments1=i[0],this._mrtAttachments2=i[1],this._states[dt.MRTAttachments1]=i[0],this._states[dt.MRTAttachments2]=i[1],this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,dt.MRTAttachments1))}setAlphaBlendEnabled(e){this._alphaBlendEnabled=e}setAlphaBlendFactors(e,t){this._alphaBlendFuncParams=e,this._alphaBlendEqParams=t}setWriteMask(e){this._writeMask=e}setDepthStencilFormat(e){this._webgpuDepthStencilFormat=e,this._depthStencilFormat=e===void 0?0:Vi[e]}setDepthTestEnabled(e){this._depthTestEnabled=e}setDepthWriteEnabled(e){this._depthWriteEnabled=e}setDepthCompare(e){this._depthCompare=(e!=null?e:519)-512}setStencilEnabled(e){this._stencilEnabled=e}setStencilCompare(e){this._stencilFrontCompare=(e!=null?e:519)-512}setStencilDepthFailOp(e){this._stencilFrontDepthFailOp=e===null?1:Ys[e]}setStencilPassOp(e){this._stencilFrontPassOp=e===null?2:Ys[e]}setStencilFailOp(e){this._stencilFrontFailOp=e===null?1:Ys[e]}setStencilReadMask(e){this._stencilReadMask!==e&&(this._stencilReadMask=e,this._states[dt.StencilReadMask]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,dt.StencilReadMask))}setStencilWriteMask(e){this._stencilWriteMask!==e&&(this._stencilWriteMask=e,this._states[dt.StencilWriteMask]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,dt.StencilWriteMask))}resetStencilState(){this.setStencilState(!1,519,7680,7681,7680,255,255)}setStencilState(e,t,i,s,n,r,o){this._stencilEnabled=e,this._stencilFrontCompare=(t!=null?t:519)-512,this._stencilFrontDepthFailOp=i===null?1:Ys[i],this._stencilFrontPassOp=s===null?2:Ys[s],this._stencilFrontFailOp=n===null?1:Ys[n],this.setStencilReadMask(r),this.setStencilWriteMask(o)}setBuffers(e,t,i){this._vertexBuffers=e,this._overrideVertexBuffers=i,this._indexBuffer=t}static _GetTopology(e){switch(e){case 0:return"triangle-list";case 2:return"point-list";case 1:return"line-list";case 3:return"point-list";case 4:return"line-list";case 5:throw"LineLoop is an unsupported fillmode in WebGPU";case 6:return"line-strip";case 7:return"triangle-strip";case 8:throw"TriangleFan is an unsupported fillmode in WebGPU";default:return"triangle-list"}}static _GetAphaBlendOperation(e){switch(e){case 32774:return"add";case 32778:return"subtract";case 32779:return"reverse-subtract";case 32775:return"min";case 32776:return"max";default:return"add"}}static _GetAphaBlendFactor(e){switch(e){case 0:return"zero";case 1:return"one";case 768:return"src";case 769:return"one-minus-src";case 770:return"src-alpha";case 771:return"one-minus-src-alpha";case 772:return"dst-alpha";case 773:return"one-minus-dst-alpha";case 774:return"dst";case 775:return"one-minus-dst";case 776:return"src-alpha-saturated";case 32769:return"constant";case 32770:return"one-minus-constant";case 32771:return"constant";case 32772:return"one-minus-constant";case 35065:return"src1";case 35066:return"one-minus-src1";case 34185:return"src1-alpha";case 35067:return"one-minus-src1-alpha";default:return"one"}}static _GetCompareFunction(e){switch(e){case 0:return"never";case 1:return"less";case 2:return"equal";case 3:return"less-equal";case 4:return"greater";case 5:return"not-equal";case 6:return"greater-equal";case 7:return"always"}return"never"}static _GetStencilOpFunction(e){switch(e){case 0:return"zero";case 1:return"keep";case 2:return"replace";case 3:return"increment-clamp";case 4:return"decrement-clamp";case 5:return"invert";case 6:return"increment-wrap";case 7:return"decrement-wrap"}return"keep"}static _GetVertexInputDescriptorFormat(e){const t=e.type,i=e.normalized,s=e.getSize();switch(t){case A.BYTE:switch(s){case 1:case 2:return i?"snorm8x2":"sint8x2";case 3:case 4:return i?"snorm8x4":"sint8x4"}break;case A.UNSIGNED_BYTE:switch(s){case 1:case 2:return i?"unorm8x2":"uint8x2";case 3:case 4:return i?"unorm8x4":"uint8x4"}break;case A.SHORT:switch(s){case 1:case 2:return i?"snorm16x2":"sint16x2";case 3:case 4:return i?"snorm16x4":"sint16x4"}break;case A.UNSIGNED_SHORT:switch(s){case 1:case 2:return i?"unorm16x2":"uint16x2";case 3:case 4:return i?"unorm16x4":"uint16x4"}break;case A.INT:switch(s){case 1:return"sint32";case 2:return"sint32x2";case 3:return"sint32x3";case 4:return"sint32x4"}break;case A.UNSIGNED_INT:switch(s){case 1:return"uint32";case 2:return"uint32x2";case 3:return"uint32x3";case 4:return"uint32x4"}break;case A.FLOAT:switch(s){case 1:return"float32";case 2:return"float32x2";case 3:return"float32x3";case 4:return"float32x4"}break}throw new Error("Invalid Format '".concat(e.getKind(),"' - type=").concat(t,", normalized=").concat(i,", size=").concat(s))}_getAphaBlendState(){return this._alphaBlendEnabled?{srcFactor:rt._GetAphaBlendFactor(this._alphaBlendFuncParams[2]),dstFactor:rt._GetAphaBlendFactor(this._alphaBlendFuncParams[3]),operation:rt._GetAphaBlendOperation(this._alphaBlendEqParams[1])}:null}_getColorBlendState(){return this._alphaBlendEnabled?{srcFactor:rt._GetAphaBlendFactor(this._alphaBlendFuncParams[0]),dstFactor:rt._GetAphaBlendFactor(this._alphaBlendFuncParams[1]),operation:rt._GetAphaBlendOperation(this._alphaBlendEqParams[0])}:null}_setShaderStage(e){this._shaderId!==e&&(this._shaderId=e,this._states[dt.ShaderStage]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,dt.ShaderStage))}_setRasterizationState(e,t){const i=this._frontFace,s=this._cullEnabled?this._cullFace:0,n=this._clampDepth?1:0,r=this._alphaToCoverageEnabled?1:0,o=i-1+(s<<1)+(n<<3)+(r<<4)+(e<<5)+(t<<8);this._rasterizationState!==o&&(this._rasterizationState=o,this._states[dt.RasterizationState]=this._rasterizationState,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,dt.RasterizationState))}_setColorStates(){let e=((this._writeMask?1:0)<<22)+(this._colorFormat<<23)+((this._depthWriteEnabled?1:0)<<29);this._alphaBlendEnabled&&(e+=((this._alphaBlendFuncParams[0]===null?2:hr[this._alphaBlendFuncParams[0]])<<0)+((this._alphaBlendFuncParams[1]===null?2:hr[this._alphaBlendFuncParams[1]])<<4)+((this._alphaBlendFuncParams[2]===null?2:hr[this._alphaBlendFuncParams[2]])<<8)+((this._alphaBlendFuncParams[3]===null?2:hr[this._alphaBlendFuncParams[3]])<<12)+((this._alphaBlendEqParams[0]===null?1:this._alphaBlendEqParams[0]-32773)<<16)+((this._alphaBlendEqParams[1]===null?1:this._alphaBlendEqParams[1]-32773)<<19)),e!==this._colorStates&&(this._colorStates=e,this._states[dt.ColorStates]=this._colorStates,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,dt.ColorStates))}_setDepthStencilState(){const e=this._stencilEnabled?this._stencilFrontCompare+(this._stencilFrontDepthFailOp<<3)+(this._stencilFrontPassOp<<6)+(this._stencilFrontFailOp<<9):591,t=this._depthStencilFormat+((this._depthTestEnabled?this._depthCompare:7)<<6)+(e<<10);this._depthStencilState!==t&&(this._depthStencilState=t,this._states[dt.DepthStencilState]=this._depthStencilState,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,dt.DepthStencilState))}_setVertexState(e){var l,c;const t=this._statesLength;let i=dt.VertexState;const s=e._pipelineContext,n=s.shaderProcessingContext.attributeNamesFromEffect,r=s.shaderProcessingContext.attributeLocationsFromEffect;let o,h=0;for(let u=0;u<n.length;u++){const f=r[u];let d=(l=this._overrideVertexBuffers&&this._overrideVertexBuffers[n[u]])!=null?l:this._vertexBuffers[n[u]];d||(d=this._emptyVertexBuffer);const _=(c=d.effectiveBuffer)==null?void 0:c.underlyingResource;if(d._validOffsetRange===void 0){const g=d.effectiveByteOffset,m=d.getSize(!0),b=d.effectiveByteStride;d._validOffsetRange=g+m<=this._kMaxVertexBufferStride&&b===0||b!==0&&g+m<=b}o&&o===_&&d._validOffsetRange||(this.vertexBuffers[h++]=d,o=d._validOffsetRange?_:null);const p=d.hashCode+(f<<7);this._isDirty=this._isDirty||this._states[i]!==p,this._states[i++]=p}this.vertexBuffers.length=h,this._statesLength=i,this._isDirty=this._isDirty||i!==t,this._isDirty&&(this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,dt.VertexState))}_setTextureState(e){this._textureState!==e&&(this._textureState=e,this._states[dt.TextureStage]=this._textureState,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,dt.TextureStage))}_createPipelineLayout(e){if(this._useTextureStage)return this._createPipelineLayoutWithTextureStage(e);const t=[],i=e.shaderProcessingContext.bindGroupLayoutEntries;for(let s=0;s<i.length;s++){const n=i[s];t[s]=this._device.createBindGroupLayout({entries:n})}return e.bindGroupLayouts[0]=t,this._device.createPipelineLayout({bindGroupLayouts:t})}_createPipelineLayoutWithTextureStage(e){var r;const t=e.shaderProcessingContext,i=t.bindGroupLayoutEntries;let s=1;for(let o=0;o<i.length;o++){const h=i[o];for(let l=0;l<h.length;l++){const c=i[o][l];if(c.texture){const u=t.bindGroupLayoutEntryInfo[o][c.binding].name,f=t.availableTextures[u],d=f.autoBindSampler?t.availableSamplers[u+"Sampler"]:null;let _=f.sampleType,p=(r=d==null?void 0:d.type)!=null?r:"filtering";if(this._textureState&s&&_!=="depth"&&(f.autoBindSampler&&(p="non-filtering"),_="unfilterable-float"),c.texture.sampleType=_,d){const g=t.bindGroupLayoutEntryInfo[d.binding.groupIndex][d.binding.bindingIndex].index;i[d.binding.groupIndex][g].sampler.type=p}s=s<<1}}}const n=[];for(let o=0;o<i.length;++o)n[o]=this._device.createBindGroupLayout({entries:i[o]});return e.bindGroupLayouts[this._textureState]=n,this._device.createPipelineLayout({bindGroupLayouts:n})}_getVertexInputDescriptor(e){var h,l;const t=[],i=e._pipelineContext,s=i.shaderProcessingContext.attributeNamesFromEffect,n=i.shaderProcessingContext.attributeLocationsFromEffect;let r,o;for(let c=0;c<s.length;c++){const u=n[c];let f=(h=this._overrideVertexBuffers&&this._overrideVertexBuffers[s[c]])!=null?h:this._vertexBuffers[s[c]];f||(f=this._emptyVertexBuffer);let d=(l=f.effectiveBuffer)==null?void 0:l.underlyingResource,_=f.effectiveByteOffset;const p=!f._validOffsetRange;if(!(r&&o&&r===d)||p){const g={arrayStride:f.effectiveByteStride,stepMode:f.getIsInstanced()?"instance":"vertex",attributes:[]};t.push(g),o=g.attributes,p&&(_=0,d=null)}o.push({shaderLocation:u,offset:_,format:rt._GetVertexInputDescriptorFormat(f)}),r=d}return t}_createRenderPipeline(e,t,i){var _,p,g;const s=e._pipelineContext,n=this._getVertexInputDescriptor(e),r=this._createPipelineLayout(s),o=[],h=this._getAphaBlendState(),l=this._getColorBlendState();if(this._vertexBuffers&&lp(this._vertexBuffers,e),this._mrtAttachments1>0)for(let m=0;m<this._mrtFormats.length;++m){const b=this._mrtFormats[m];if(b){const I={format:b,writeMask:this._mrtEnabledMask&1<<m?this._writeMask:0};h&&l&&(I.blend={alpha:h,color:l}),o.push(I)}else o.push(null)}else if(this._webgpuColorFormat[0]){const m={format:this._webgpuColorFormat[0],writeMask:this._writeMask};h&&l&&(m.blend={alpha:h,color:l}),o.push(m)}else o.push(null);const c={compare:rt._GetCompareFunction(this._stencilEnabled?this._stencilFrontCompare:7),depthFailOp:rt._GetStencilOpFunction(this._stencilEnabled?this._stencilFrontDepthFailOp:1),failOp:rt._GetStencilOpFunction(this._stencilEnabled?this._stencilFrontFailOp:1),passOp:rt._GetStencilOpFunction(this._stencilEnabled?this._stencilFrontPassOp:1)},u=t==="triangle-list"||t==="triangle-strip";let f;(t==="line-strip"||t==="triangle-strip")&&(f=!this._indexBuffer||this._indexBuffer.is32Bits?"uint32":"uint16");const d=this._webgpuDepthStencilFormat?Ve.HasStencilAspect(this._webgpuDepthStencilFormat):!1;return this._device.createRenderPipeline({label:"RenderPipeline_".concat((p=(_=o[0])==null?void 0:_.format)!=null?p:"nooutput","_").concat((g=this._webgpuDepthStencilFormat)!=null?g:"nodepth","_samples").concat(i,"_textureState").concat(this._textureState),layout:r,vertex:{module:s.stages.vertexStage.module,entryPoint:s.stages.vertexStage.entryPoint,buffers:n},primitive:{topology:t,stripIndexFormat:f,frontFace:this._frontFace===1?"ccw":"cw",cullMode:this._cullEnabled?this._cullFace===2?"front":"back":"none"},fragment:s.stages.fragmentStage?{module:s.stages.fragmentStage.module,entryPoint:s.stages.fragmentStage.entryPoint,targets:o}:void 0,multisample:{count:i},depthStencil:this._webgpuDepthStencilFormat===void 0?void 0:{depthWriteEnabled:this._depthWriteEnabled,depthCompare:this._depthTestEnabled?rt._GetCompareFunction(this._depthCompare):"always",format:this._webgpuDepthStencilFormat,stencilFront:this._stencilEnabled&&d?c:void 0,stencilBack:this._stencilEnabled&&d?c:void 0,stencilReadMask:this._stencilEnabled&&d?this._stencilReadMask:void 0,stencilWriteMask:this._stencilEnabled&&d?this._stencilWriteMask:void 0,depthBias:this._depthBias,depthBiasClamp:u?this._depthBiasClamp:0,depthBiasSlopeScale:u?this._depthBiasSlopeScale:0}})}}rt.NumCacheHitWithoutHash=0;rt.NumCacheHitWithHash=0;rt.NumCacheMiss=0;rt.NumPipelineCreationLastFrame=0;rt._NumPipelineCreationCurrentFrame=0;class Va{constructor(){this.values={}}count(){let e=0,t=this.pipeline?1:0;for(const i in this.values){const s=this.values[i],[n,r]=s.count();e+=n,t+=r,e++}return[e,t]}}class Ci extends rt{static GetNodeCounts(){const e=Ci._Cache.count();return{nodeCount:e[0],pipelineCount:e[1]}}static _GetPipelines(e,t,i,s){if(e.pipeline){const n=i.slice();n.length=s,t.push(n)}for(const n in e.values){const r=e.values[n];i[s]=parseInt(n),Ci._GetPipelines(r,t,i,s+1)}}static GetPipelines(){const e=[];return Ci._GetPipelines(Ci._Cache,e,[],0),e}static ResetCache(){Ci._Cache=new Va}reset(){this._nodeStack=[],this._nodeStack[0]=Ci._Cache,super.reset()}_getRenderPipeline(e){let t=this._nodeStack[this._stateDirtyLowestIndex];for(let i=this._stateDirtyLowestIndex;i<this._statesLength;++i){let s=t.values[this._states[i]];s||(s=new Va,t.values[this._states[i]]=s),t=s,this._nodeStack[i+1]=t}e.token=t,e.pipeline=t.pipeline}_setRenderPipeline(e){e.token.pipeline=e.pipeline}}Ci._Cache=new Va;class cp extends Hl{constructor(e){super(!1),this._cache=e,this.reset()}get func(){return this._func}set func(e){this._func!==e&&(this._func=e,this._cache.setStencilCompare(e))}get funcMask(){return this._funcMask}set funcMask(e){this._funcMask!==e&&(this._funcMask=e,this._cache.setStencilReadMask(e))}get opStencilFail(){return this._opStencilFail}set opStencilFail(e){this._opStencilFail!==e&&(this._opStencilFail=e,this._cache.setStencilFailOp(e))}get opDepthFail(){return this._opDepthFail}set opDepthFail(e){this._opDepthFail!==e&&(this._opDepthFail=e,this._cache.setStencilDepthFailOp(e))}get opStencilDepthPass(){return this._opStencilDepthPass}set opStencilDepthPass(e){this._opStencilDepthPass!==e&&(this._opStencilDepthPass=e,this._cache.setStencilPassOp(e))}get mask(){return this._mask}set mask(e){this._mask!==e&&(this._mask=e,this._cache.setStencilWriteMask(e))}get enabled(){return this._enabled}set enabled(e){this._enabled!==e&&(this._enabled=e,this._cache.setStencilEnabled(e))}reset(){super.reset(),this._cache.resetStencilState()}apply(){var t;const e=(t=this.stencilMaterial)==null?void 0:t.enabled;this.enabled=e?this.stencilMaterial.enabled:this.stencilGlobal.enabled,this.enabled&&(this.func=e?this.stencilMaterial.func:this.stencilGlobal.func,this.funcRef=e?this.stencilMaterial.funcRef:this.stencilGlobal.funcRef,this.funcMask=e?this.stencilMaterial.funcMask:this.stencilGlobal.funcMask,this.opStencilFail=e?this.stencilMaterial.opStencilFail:this.stencilGlobal.opStencilFail,this.opDepthFail=e?this.stencilMaterial.opDepthFail:this.stencilGlobal.opDepthFail,this.opStencilDepthPass=e?this.stencilMaterial.opStencilDepthPass:this.stencilGlobal.opStencilDepthPass,this.mask=e?this.stencilMaterial.mask:this.stencilGlobal.mask)}}class up extends Wl{constructor(e){super(!1),this._cache=e,this.reset()}get zOffset(){return this._zOffset}set zOffset(e){this._zOffset!==e&&(this._zOffset=e,this._isZOffsetDirty=!0,this._cache.setDepthBiasSlopeScale(e))}get zOffsetUnits(){return this._zOffsetUnits}set zOffsetUnits(e){this._zOffsetUnits!==e&&(this._zOffsetUnits=e,this._isZOffsetDirty=!0,this._cache.setDepthBias(e))}get cullFace(){return this._cullFace}set cullFace(e){this._cullFace!==e&&(this._cullFace=e,this._isCullFaceDirty=!0,this._cache.setCullFace(e!=null?e:1))}get cull(){return this._cull}set cull(e){this._cull!==e&&(this._cull=e,this._isCullDirty=!0,this._cache.setCullEnabled(!!e))}get depthFunc(){return this._depthFunc}set depthFunc(e){this._depthFunc!==e&&(this._depthFunc=e,this._isDepthFuncDirty=!0,this._cache.setDepthCompare(e))}get depthMask(){return this._depthMask}set depthMask(e){this._depthMask!==e&&(this._depthMask=e,this._isDepthMaskDirty=!0,this._cache.setDepthWriteEnabled(e))}get depthTest(){return this._depthTest}set depthTest(e){this._depthTest!==e&&(this._depthTest=e,this._isDepthTestDirty=!0,this._cache.setDepthTestEnabled(e))}get frontFace(){return this._frontFace}set frontFace(e){this._frontFace!==e&&(this._frontFace=e,this._isFrontFaceDirty=!0,this._cache.setFrontFace(e!=null?e:2))}reset(){super.reset(),this._cache.resetDepthCullingState()}apply(){}}class Tc{static IsExternalTexture(e){return e.underlyingResource!==void 0}getClassName(){return"ExternalTexture"}get underlyingResource(){return this._video}constructor(e){this.useMipMaps=!1,this.type=16,this.format=4294967295,this._video=e,this.uniqueId=ft._Counter++}isReady(){return this._video.readyState>=this._video.HAVE_CURRENT_DATA}dispose(){}}class zr{get forceBindGroupCreation(){return this._numExternalTextures>0}get hasFloatOrDepthTextures(){return this._numFloatOrDepthTextures>0}constructor(){this.uniqueId=zr._Counter++,this.updateId=0,this.textureState=0,this.reset()}reset(){this.samplers={},this.textures={},this.isDirty=!0,this._numFloatOrDepthTextures=0,this._numExternalTextures=0}setSampler(e,t){let i=this.samplers[e],s=-1;i?s=i.hashCode:this.samplers[e]=i={sampler:t,hashCode:0},i.sampler=t,i.hashCode=t?Fs.GetSamplerHashCode(t):0;const n=s!==i.hashCode;n&&this.updateId++,this.isDirty||(this.isDirty=n)}setTexture(e,t){var r,o,h;let i=this.textures[e],s=-1;i?s=(o=(r=i.texture)==null?void 0:r.uniqueId)!=null?o:-1:this.textures[e]=i={texture:t,isFloatOrDepthTexture:!1,isExternalTexture:!1},i.isExternalTexture&&this._numExternalTextures--,i.isFloatOrDepthTexture&&this._numFloatOrDepthTextures--,t?(i.isFloatOrDepthTexture=t.type===1||t.format>=13&&t.format<=18,i.isExternalTexture=Tc.IsExternalTexture(t),i.isFloatOrDepthTexture&&this._numFloatOrDepthTextures++,i.isExternalTexture&&this._numExternalTextures++):(i.isFloatOrDepthTexture=!1,i.isExternalTexture=!1),i.texture=t;const n=s!==((h=t==null?void 0:t.uniqueId)!=null?h:-1);n&&this.updateId++,this.isDirty||(this.isDirty=n)}}zr._Counter=0;class Wr{isDirty(e){return this._isDirty||this._materialContextUpdateId!==e}resetIsDirty(e){this._isDirty=!1,this._materialContextUpdateId=e}get useInstancing(){return this._useInstancing}set useInstancing(e){this._useInstancing!==e&&(e?(this.indirectDrawBuffer=this._bufferManager.createRawBuffer(20,We.CopyDst|We.Indirect|We.Storage,void 0,"IndirectDrawBuffer"),this._indirectDrawData=new Uint32Array(5),this._indirectDrawData[3]=0,this._indirectDrawData[4]=0):(this.indirectDrawBuffer&&this._bufferManager.releaseBuffer(this.indirectDrawBuffer),this.indirectDrawBuffer=void 0,this._indirectDrawData=void 0),this._useInstancing=e,this._currentInstanceCount=-1)}constructor(e){this._bufferManager=e,this.uniqueId=Wr._Counter++,this._useInstancing=!1,this._currentInstanceCount=0,this.reset()}reset(){this.buffers={},this._isDirty=!0,this._materialContextUpdateId=0,this.fastBundle=void 0,this.bindGroups=void 0}setBuffer(e,t){var i;this._isDirty||(this._isDirty=(t==null?void 0:t.uniqueId)!==((i=this.buffers[e])==null?void 0:i.uniqueId)),this.buffers[e]=t}setIndirectData(e,t,i){t===this._currentInstanceCount||!this.indirectDrawBuffer||!this._indirectDrawData||(this._currentInstanceCount=t,this._indirectDrawData[0]=e,this._indirectDrawData[1]=t,this._indirectDrawData[2]=i,this._bufferManager.setRawData(this.indirectDrawBuffer,0,this._indirectDrawData,0,20))}dispose(){this.indirectDrawBuffer&&(this._bufferManager.releaseBuffer(this.indirectDrawBuffer),this.indirectDrawBuffer=void 0,this._indirectDrawData=void 0),this.fastBundle=void 0,this.bindGroups=void 0,this.buffers=void 0}}Wr._Counter=0;const fp=1<<20,dp=2**35;class Tn{constructor(){this.values={}}}class qe{static get Statistics(){return{totalCreated:qe.NumBindGroupsCreatedTotal,lastFrameCreated:qe.NumBindGroupsCreatedLastFrame,lookupLastFrame:qe.NumBindGroupsLookupLastFrame,noLookupLastFrame:qe.NumBindGroupsNoLookupLastFrame}}static ResetCache(){qe._Cache=new Tn,qe.NumBindGroupsCreatedTotal=0,qe.NumBindGroupsCreatedLastFrame=0,qe.NumBindGroupsLookupLastFrame=0,qe.NumBindGroupsNoLookupLastFrame=0,qe._NumBindGroupsCreatedCurrentFrame=0,qe._NumBindGroupsLookupCurrentFrame=0,qe._NumBindGroupsNoLookupCurrentFrame=0}constructor(e,t,i){this.disabled=!1,this._device=e,this._cacheSampler=t,this._engine=i}endFrame(){qe.NumBindGroupsCreatedLastFrame=qe._NumBindGroupsCreatedCurrentFrame,qe.NumBindGroupsLookupLastFrame=qe._NumBindGroupsLookupCurrentFrame,qe.NumBindGroupsNoLookupLastFrame=qe._NumBindGroupsNoLookupCurrentFrame,qe._NumBindGroupsCreatedCurrentFrame=0,qe._NumBindGroupsLookupCurrentFrame=0,qe._NumBindGroupsNoLookupCurrentFrame=0}getBindGroups(e,t,i){var h,l,c,u,f,d,_,p,g,m;let s,n=qe._Cache;const r=this.disabled||i.forceBindGroupCreation;if(!r){if(!t.isDirty(i.updateId)&&!i.isDirty)return qe._NumBindGroupsNoLookupCurrentFrame++,t.bindGroups;for(const b of e.shaderProcessingContext.bufferNames){const I=((l=(h=t.buffers[b])==null?void 0:h.uniqueId)!=null?l:0)+fp;let T=n.values[I];T||(T=new Tn,n.values[I]=T),n=T}for(const b of e.shaderProcessingContext.samplerNames){const I=(u=(c=i.samplers[b])==null?void 0:c.hashCode)!=null?u:0;let T=n.values[I];T||(T=new Tn,n.values[I]=T),n=T}for(const b of e.shaderProcessingContext.textureNames){const I=((_=(d=(f=i.textures[b])==null?void 0:f.texture)==null?void 0:d.uniqueId)!=null?_:0)+dp;let T=n.values[I];T||(T=new Tn,n.values[I]=T),n=T}s=n.bindGroups}if(t.resetIsDirty(i.updateId),i.isDirty=!1,s)return t.bindGroups=s,qe._NumBindGroupsLookupCurrentFrame++,s;s=[],t.bindGroups=s,r||(n.bindGroups=s),qe.NumBindGroupsCreatedTotal++,qe._NumBindGroupsCreatedCurrentFrame++;const o=e.bindGroupLayouts[i.textureState];for(let b=0;b<e.shaderProcessingContext.bindGroupLayoutEntries.length;b++){const I=e.shaderProcessingContext.bindGroupLayoutEntries[b],T=e.shaderProcessingContext.bindGroupEntries[b];for(let y=0;y<I.length;y++){const R=e.shaderProcessingContext.bindGroupLayoutEntries[b][y],E=e.shaderProcessingContext.bindGroupLayoutEntryInfo[b][R.binding],C=(p=E.nameInArrayOfTexture)!=null?p:E.name;if(R.sampler){const S=i.samplers[C];if(S){const w=S.sampler;if(!w){this._engine.dbgSanityChecks&&U.Error("Trying to bind a null sampler! entry=".concat(JSON.stringify(R),", name=").concat(C,", bindingInfo=").concat(JSON.stringify(S,(P,G)=>P==="texture"?"<no dump>":G),", materialContext.uniqueId=").concat(i.uniqueId),50);continue}T[y].resource=this._cacheSampler.getSampler(w,!1,S.hashCode,w.label)}else U.Error('Sampler "'.concat(C,'" could not be bound. entry=').concat(JSON.stringify(R),", materialContext=").concat(JSON.stringify(i,(w,P)=>w==="texture"||w==="sampler"?"<no dump>":P)),50)}else if(R.texture||R.storageTexture){const S=i.textures[C];if(S){if(this._engine.dbgSanityChecks&&S.texture===null){U.Error("Trying to bind a null texture! entry=".concat(JSON.stringify(R),", bindingInfo=").concat(JSON.stringify(S,(P,G)=>P==="texture"?"<no dump>":G),", materialContext.uniqueId=").concat(i.uniqueId),50);continue}const w=S.texture._hardwareTexture;if(this._engine.dbgSanityChecks&&(!w||R.texture&&!w.view||R.storageTexture&&!w.viewForWriting)){U.Error("Trying to bind a null gpu texture or view! entry=".concat(JSON.stringify(R),", name=").concat(C,", bindingInfo=").concat(JSON.stringify(S,(P,G)=>P==="texture"?"<no dump>":G),", isReady=").concat((g=S.texture)==null?void 0:g.isReady,", materialContext.uniqueId=").concat(i.uniqueId),50);continue}T[y].resource=R.storageTexture?w.viewForWriting:w.view}else U.Error('Texture "'.concat(C,'" could not be bound. entry=').concat(JSON.stringify(R),", materialContext=").concat(JSON.stringify(i,(w,P)=>w==="texture"||w==="sampler"?"<no dump>":P)),50)}else if(R.externalTexture){const S=i.textures[C];if(S){if(this._engine.dbgSanityChecks&&S.texture===null){U.Error("Trying to bind a null external texture! entry=".concat(JSON.stringify(R),", name=").concat(C,", bindingInfo=").concat(JSON.stringify(S,(P,G)=>P==="texture"?"<no dump>":G),", materialContext.uniqueId=").concat(i.uniqueId),50);continue}const w=S.texture.underlyingResource;if(this._engine.dbgSanityChecks&&!w){U.Error("Trying to bind a null gpu external texture! entry=".concat(JSON.stringify(R),", name=").concat(C,", bindingInfo=").concat(JSON.stringify(S,(P,G)=>P==="texture"?"<no dump>":G),", isReady=").concat((m=S.texture)==null?void 0:m.isReady,", materialContext.uniqueId=").concat(i.uniqueId),50);continue}T[y].resource=this._device.importExternalTexture({source:w})}else U.Error('Texture "'.concat(C,'" could not be bound. entry=').concat(JSON.stringify(R),", materialContext=").concat(JSON.stringify(i,(w,P)=>w==="texture"||w==="sampler"?"<no dump>":P)),50)}else if(R.buffer){const S=t.buffers[C];if(S){const w=S.underlyingResource;T[y].resource.buffer=w,T[y].resource.size=S.capacity}else U.Error("Can't find buffer \"".concat(C,'". entry=').concat(JSON.stringify(R),", buffers=").concat(JSON.stringify(t.buffers),", drawContext.uniqueId=").concat(t.uniqueId),50)}}const x=o[b];s[b]=this._device.createBindGroup({layout:x,entries:T})}return s}}qe.NumBindGroupsCreatedTotal=0;qe.NumBindGroupsCreatedLastFrame=0;qe.NumBindGroupsLookupLastFrame=0;qe.NumBindGroupsNoLookupLastFrame=0;qe._Cache=new Tn;qe._NumBindGroupsCreatedCurrentFrame=0;qe._NumBindGroupsLookupCurrentFrame=0;qe._NumBindGroupsNoLookupCurrentFrame=0;const _p="clearQuadVertexShader",pp="uniform depthValue: f32;const pos=array(\nvec2f(-1.0,1.0),\nvec2f(1.0,1.0),\nvec2f(-1.0,-1.0),\nvec2f(1.0,-1.0)\n);\n#define CUSTOM_VERTEX_DEFINITIONS\n@vertex\nfn main(input : VertexInputs)->FragmentInputs {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvertexOutputs.position=vec4f(pos[input.vertexIndex],uniforms.depthValue,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}\n";Me.ShadersStoreWGSL[_p]=pp;const gp="clearQuadPixelShader",mp="uniform color: vec4f;@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=uniforms.color;}\n";Me.ShadersStoreWGSL[gp]=mp;class vp{setDepthStencilFormat(e){this._depthTextureFormat=e,this._cacheRenderPipeline.setDepthStencilFormat(e)}setColorFormat(e){this._cacheRenderPipeline.setColorFormat(e)}setMRTAttachments(e,t,i){this._cacheRenderPipeline.setMRT(t,i),this._cacheRenderPipeline.setMRTAttachments(e)}constructor(e,t,i){this._bindGroups={},this._bundleCache={},this._keyTemp=[],this._device=e,this._engine=t,this._cacheRenderPipeline=new Ci(this._device,i),this._cacheRenderPipeline.setDepthTestEnabled(!1),this._cacheRenderPipeline.setStencilReadMask(255),this._effect=t.createEffect("clearQuad",[],["color","depthValue"],void 0,void 0,void 0,void 0,void 0,void 0,1)}clear(e,t,i,s,n=1){var g,m;let r,o=null,h;const l=!!this._engine._currentRenderTarget;if(e)r=e;else{let b=0;this._keyTemp.length=0;for(let T=0;T<this._cacheRenderPipeline.colorFormats.length;++T)this._keyTemp[b++]=Vi[(g=this._cacheRenderPipeline.colorFormats[T])!=null?g:""];const I=Vi[(m=this._depthTextureFormat)!=null?m:0];if(this._keyTemp[b]=(t?t.r+t.g*256+t.b*256*256+t.a*256*256*256:0)+(i?2**32:0)+(s?2**33:0)+(this._engine.useReverseDepthBuffer?2**34:0)+(l?2**35:0)+(n>1?2**36:0)+I*2**37,h=this._keyTemp.join("_"),o=this._bundleCache[h],o)return o;r=this._device.createRenderBundleEncoder({label:"clearQuadRenderBundle",colorFormats:this._cacheRenderPipeline.colorFormats,depthStencilFormat:this._depthTextureFormat,sampleCount:Ve.GetSample(n)})}this._cacheRenderPipeline.setDepthWriteEnabled(!!i),this._cacheRenderPipeline.setStencilEnabled(!!s&&!!this._depthTextureFormat&&Ve.HasStencilAspect(this._depthTextureFormat)),this._cacheRenderPipeline.setStencilWriteMask(s?255:0),this._cacheRenderPipeline.setStencilCompare(s?519:512),this._cacheRenderPipeline.setStencilPassOp(s?7681:7680),this._cacheRenderPipeline.setWriteMask(t?15:0);const c=this._cacheRenderPipeline.getRenderPipeline(7,this._effect,n),u=this._effect._pipelineContext;t&&this._effect.setDirectColor4("color",t),this._effect.setFloat("depthValue",this._engine.useReverseDepthBuffer?this._engine._clearReverseDepthValue:this._engine._clearDepthValue),u.uniformBuffer.update();const f=l?this._engine._ubInvertY:this._engine._ubDontInvertY,d=u.uniformBuffer.getBuffer(),_=d.uniqueId+"-"+f.uniqueId;let p=this._bindGroups[_];if(!p){const b=u.bindGroupLayouts[0];p=this._bindGroups[_]=[],p.push(this._device.createBindGroup({label:"clearQuadBindGroup0-".concat(_),layout:b[0],entries:[]})),ni._SimplifiedKnownBindings||p.push(this._device.createBindGroup({label:"clearQuadBindGroup1-".concat(_),layout:b[1],entries:[]})),p.push(this._device.createBindGroup({label:"clearQuadBindGroup".concat(ni._SimplifiedKnownBindings?1:2,"-").concat(_),layout:b[ni._SimplifiedKnownBindings?1:2],entries:[{binding:0,resource:{buffer:f.underlyingResource,size:f.capacity}},{binding:1,resource:{buffer:d.underlyingResource,size:d.capacity}}]}))}r.setPipeline(c);for(let b=0;b<p.length;++b)r.setBindGroup(b,p[b]);return r.draw(4,1,0,0),e||(o=r.finish(),this._bundleCache[h]=o),o}}class E0{constructor(e,t,i,s){this.x=Math.floor(e),this.y=Math.floor(t),this.w=Math.floor(i),this.h=Math.floor(s)}run(e){e.setViewport(this.x,this.y,this.w,this.h,0,1)}clone(){return new E0(this.x,this.y,this.w,this.h)}}class C0{constructor(e,t,i,s){this.x=e,this.y=t,this.w=i,this.h=s}run(e){e.setScissorRect(this.x,this.y,this.w,this.h)}clone(){return new C0(this.x,this.y,this.w,this.h)}}class Pr{constructor(e){this.ref=e}run(e){e.setStencilReference(this.ref)}clone(){return new Pr(this.ref)}}class S0{constructor(e){this.color=e}run(e){e.setBlendConstant(this.color)}clone(){return new S0(this.color)}}class M0{constructor(e){this.query=e}run(e){e.beginOcclusionQuery(this.query)}clone(){return new M0(this.query)}}class P0{constructor(){}run(e){e.endOcclusionQuery()}clone(){return new P0}}class w0{constructor(){this.bundles=[]}run(e){e.executeBundles(this.bundles)}clone(){const e=new w0;return e.bundles=this.bundles,e}}class D0{constructor(e){this.numDrawCalls=0,this._device=e,this._list=new Array(10),this._listLength=0}addBundle(e){if(!this._currentItemIsBundle){const t=new w0;this._list[this._listLength++]=t,this._currentBundleList=t.bundles,this._currentItemIsBundle=!0}e&&this._currentBundleList.push(e)}_finishBundle(){this._currentItemIsBundle&&this._bundleEncoder&&(this._currentBundleList.push(this._bundleEncoder.finish()),this._bundleEncoder=void 0,this._currentItemIsBundle=!1)}addItem(e){this._finishBundle(),this._list[this._listLength++]=e,this._currentItemIsBundle=!1}getBundleEncoder(e,t,i){return this._currentItemIsBundle||(this.addBundle(),this._bundleEncoder=this._device.createRenderBundleEncoder({colorFormats:e,depthStencilFormat:t,sampleCount:Ve.GetSample(i)})),this._bundleEncoder}close(){this._finishBundle()}run(e){this.close();for(let t=0;t<this._listLength;++t)this._list[t].run(e)}reset(){this._listLength=0,this._currentItemIsBundle=!1,this.numDrawCalls=0}clone(){this.close();const e=new D0(this._device);e._list=new Array(this._listLength),e._listLength=this._listLength,e.numDrawCalls=this.numDrawCalls;for(let t=0;t<this._listLength;++t)e._list[t]=this._list[t].clone();return e}}class Ac{get querySet(){return this._querySet}constructor(e,t,i,s,n,r=!0,o){this._dstBuffers=[],this._engine=e,this._device=s,this._bufferManager=n,this._count=t,this._canUseMultipleBuffers=r,this._querySet=s.createQuerySet({label:o!=null?o:"QuerySet",type:i,count:t}),this._queryBuffer=n.createRawBuffer(8*t,We.QueryResolve|We.CopySrc,void 0,"QueryBuffer"),r||this._dstBuffers.push(this._bufferManager.createRawBuffer(8*this._count,We.MapRead|We.CopyDst,void 0,"QueryBufferNoMultipleBuffers"))}_getBuffer(e,t){if(!this._canUseMultipleBuffers&&this._dstBuffers.length===0)return null;const i=this._device.createCommandEncoder();let s;return this._dstBuffers.length===0?s=this._bufferManager.createRawBuffer(8*this._count,We.MapRead|We.CopyDst,void 0,"QueryBufferAdditionalBuffer"):(s=this._dstBuffers[this._dstBuffers.length-1],this._dstBuffers.length--),i.resolveQuerySet(this._querySet,e,t,this._queryBuffer,0),i.copyBufferToBuffer(this._queryBuffer,0,s,0,8*t),this._device.queue.submit([i.finish()]),s}async readValues(e=0,t=1){const i=this._getBuffer(e,t);if(i===null)return null;const s=this._engine.uniqueId;return i.mapAsync(1).then(()=>{const n=new BigUint64Array(i.getMappedRange()).slice();return i.unmap(),this._dstBuffers[this._dstBuffers.length]=i,n},n=>{if(this._engine.isDisposed||this._engine.uniqueId!==s)return null;throw n})}async readValue(e=0){const t=this._getBuffer(e,1);if(t===null)return null;const i=this._engine.uniqueId;return t.mapAsync(1).then(()=>{const s=new BigUint64Array(t.getMappedRange()),n=Number(s[0]);return t.unmap(),this._dstBuffers[this._dstBuffers.length]=t,n},s=>{if(this._engine.isDisposed||this._engine.uniqueId!==i)return 0;throw s})}async readTwoValuesAndSubtract(e=0){const t=this._getBuffer(e,2);if(t===null)return null;const i=this._engine.uniqueId;return t.mapAsync(1).then(()=>{const s=new BigUint64Array(t.getMappedRange()),n=Number(s[1]-s[0]);return t.unmap(),this._dstBuffers[this._dstBuffers.length]=t,n},s=>{if(this._engine.isDisposed||this._engine.uniqueId!==i)return 0;throw s})}dispose(){this._querySet.destroy(),this._bufferManager.releaseBuffer(this._queryBuffer);for(let e=0;e<this._dstBuffers.length;++e)this._bufferManager.releaseBuffer(this._dstBuffers[e])}}class bp{get gpuFrameTimeCounter(){return this._gpuFrameTimeCounter}constructor(e,t,i){this._enabled=!1,this._gpuFrameTimeCounter=new ui,this._measureDurationState=0,this._engine=e,this._device=t,this._bufferManager=i}get enable(){return this._enabled}set enable(e){if(this._enabled!==e)if(this._enabled=e,this._measureDurationState=0,e)try{this._measureDuration=new xp(this._engine,this._device,this._bufferManager,2e3,"QuerySet_TimestampQuery")}catch(t){this._enabled=!1,U.Error("Could not create a WebGPUDurationMeasure!\nError: "+t.message+"\nMake sure timestamp query is supported and enabled in your browser.");return}else this._measureDuration.dispose()}startFrame(e){this._enabled&&this._measureDurationState===0&&(this._measureDuration.start(e),this._measureDurationState=1)}endFrame(e){this._measureDurationState===1&&(this._measureDurationState=2,this._measureDuration.stop(e).then(t=>{t!==null&&t>=0&&(this._gpuFrameTimeCounter.fetchNewFrame(),this._gpuFrameTimeCounter.addCount(t,!0)),this._measureDurationState=0}))}startPass(e,t){this._enabled?this._measureDuration.startPass(e,t):e.timestampWrites=void 0}endPass(e,t){if(!this._enabled||!t)return;const i=this._engine.frameId;this._measureDuration.stopPass(e).then(s=>{t._addDuration(i,s!==null&&s>0?s:0)})}dispose(){var e;(e=this._measureDuration)==null||e.dispose()}}class xp{constructor(e,t,i,s=2,n){this._count=s,this._querySet=new Ac(e,s,"timestamp",t,i,!0,n)}start(e){var t;(t=e.writeTimestamp)==null||t.call(e,this._querySet.querySet,0)}async stop(e){var t;return(t=e.writeTimestamp)==null||t.call(e,this._querySet.querySet,1),e.writeTimestamp?this._querySet.readTwoValuesAndSubtract(0):0}startPass(e,t){if(t+3>this._count)throw new Error("WebGPUDurationMeasure: index out of range ("+t+")");e.timestampWrites={querySet:this._querySet.querySet,beginningOfPassWriteIndex:t+2,endOfPassWriteIndex:t+3}}async stopPass(e){return this._querySet.readTwoValuesAndSubtract(e+2)}dispose(){this._querySet.dispose()}}class yp{get querySet(){return this._querySet.querySet}get hasQueries(){return this._currentTotalIndices!==this._availableIndices.length}canBeginQuery(e){if(this._frameQuerySetIsDirty===this._engine.frameId||this._queryFrameId[e]===this._engine.frameId)return!1;const t=this._engine._getCurrentRenderPassWrapper().renderPassDescriptor.occlusionQuerySet!==void 0;return t&&(this._queryFrameId[e]=this._engine.frameId),t}constructor(e,t,i,s=50,n=100){this._availableIndices=[],this._frameQuerySetIsDirty=-1,this._queryFrameId=[],this._engine=e,this._device=t,this._bufferManager=i,this._frameLastBuffer=-1,this._currentTotalIndices=0,this._countIncrement=n,this._allocateNewIndices(s)}createQuery(){this._availableIndices.length===0&&this._allocateNewIndices();const e=this._availableIndices[this._availableIndices.length-1];return this._availableIndices.length--,e}deleteQuery(e){this._availableIndices[this._availableIndices.length]=e}isQueryResultAvailable(e){return this._retrieveQueryBuffer(),!!this._lastBuffer&&e<this._lastBuffer.length}getQueryResult(e){var t,i;return Number((i=(t=this._lastBuffer)==null?void 0:t[e])!=null?i:-1)}_retrieveQueryBuffer(){this._lastBuffer&&this._frameLastBuffer===this._engine.frameId||this._frameLastBuffer!==this._engine.frameId&&(this._frameLastBuffer=this._engine.frameId,this._querySet.readValues(0,this._currentTotalIndices).then(e=>{this._lastBuffer=e}))}_allocateNewIndices(e){e=e!=null?e:this._countIncrement,this._delayQuerySetDispose();for(let t=0;t<e;++t)this._availableIndices.push(this._currentTotalIndices+t);this._currentTotalIndices+=e,this._querySet=new Ac(this._engine,this._currentTotalIndices,"occlusion",this._device,this._bufferManager,!1,"QuerySet_OcclusionQuery_count_"+this._currentTotalIndices),this._frameQuerySetIsDirty=this._engine.frameId}_delayQuerySetDispose(){const e=this._querySet;e&&setTimeout(()=>e.dispose,1e3)}dispose(){var e;(e=this._querySet)==null||e.dispose(),this._availableIndices.length=0}}class Hr{get code(){return this._sourceCode}constructor(e,t=20){this.debug=!1,this._sourceCode=e,this._numMaxIterations=t,this._functionDescr=[],this.inlineToken="#define inline"}processCode(){this.debug&&U.Log("Start inlining process (code size=".concat(this._sourceCode.length,")...")),this._collectFunctions(),this._processInlining(this._numMaxIterations),this.debug&&U.Log("End of inlining process.")}_collectFunctions(){let e=0;for(;e<this._sourceCode.length;){const t=this._sourceCode.indexOf(this.inlineToken,e);if(t<0)break;const i=this._sourceCode.indexOf("(",t+this.inlineToken.length);if(i<0){this.debug&&U.Warn("Could not find the opening parenthesis after the token. startIndex=".concat(e)),e=t+this.inlineToken.length;continue}const s=Hr._RegexpFindFunctionNameAndType.exec(this._sourceCode.substring(t+this.inlineToken.length,i));if(!s){this.debug&&U.Warn("Could not extract the name/type of the function from: ".concat(this._sourceCode.substring(t+this.inlineToken.length,i))),e=t+this.inlineToken.length;continue}const[n,r]=[s[3],s[4]],o=ar("(",")",this._sourceCode,i);if(o<0){this.debug&&U.Warn("Could not extract the parameters the function '".concat(r,"' (type=").concat(n,"). funcParamsStartIndex=").concat(i)),e=t+this.inlineToken.length;continue}const h=this._sourceCode.substring(i+1,o),l=Eh(this._sourceCode,o+1);if(l===this._sourceCode.length){this.debug&&U.Warn("Could not extract the body of the function '".concat(r,"' (type=").concat(n,"). funcParamsEndIndex=").concat(o)),e=t+this.inlineToken.length;continue}const c=ar("{","}",this._sourceCode,l);if(c<0){this.debug&&U.Warn("Could not extract the body of the function '".concat(r,"' (type=").concat(n,"). funcBodyStartIndex=").concat(l)),e=t+this.inlineToken.length;continue}const u=this._sourceCode.substring(l,c+1),f=Na(h).split(","),d=[];for(let g=0;g<f.length;++g){const m=f[g].trim(),b=m.lastIndexOf(" ");b>=0&&d.push(m.substring(b+1))}n!=="void"&&d.push("return"),this._functionDescr.push({name:r,type:n,parameters:d,body:u,callIndex:0}),e=c+1;const _=t>0?this._sourceCode.substring(0,t):"",p=c+1<this._sourceCode.length-1?this._sourceCode.substring(c+1):"";this._sourceCode=_+p,e-=c+1-t}this.debug&&U.Log("Collect functions: ".concat(this._functionDescr.length," functions found. functionDescr=").concat(this._functionDescr))}_processInlining(e=20){for(;e-->=0&&this._replaceFunctionCallsByCode(););return this.debug&&U.Log("numMaxIterations is ".concat(e," after inlining process")),e>=0}_replaceFunctionCallsByCode(){let e=!1;for(const t of this._functionDescr){const{name:i,type:s,parameters:n,body:r}=t;let o=0;for(;o<this._sourceCode.length;){const h=this._sourceCode.indexOf(i,o);if(h<0)break;if(h===0||va(this._sourceCode.charAt(h-1))){o=h+i.length;continue}const l=Eh(this._sourceCode,h+i.length);if(l===this._sourceCode.length||this._sourceCode.charAt(l)!=="("){o=h+i.length;continue}const c=ar("(",")",this._sourceCode,l);if(c<0){this.debug&&U.Warn("Could not extract the parameters of the function call. Function '".concat(i,"' (type=").concat(s,"). callParamsStartIndex=").concat(l)),o=h+i.length;continue}const u=this._sourceCode.substring(l+1,c),d=(I=>{const T=[];let x=0,y=0;for(;x<I.length;){if(I.charAt(x)==="("){const R=ar("(",")",I,x);if(R<0)return null;x=R}else I.charAt(x)===","&&(T.push(I.substring(y,x)),y=x+1);x++}return y<x&&T.push(I.substring(y,x)),T})(Na(u));if(d===null){this.debug&&U.Warn("Invalid function call: can't extract the parameters of the function call. Function '".concat(i,"' (type=").concat(s,"). callParamsStartIndex=").concat(l,", callParams=")+u),o=h+i.length;continue}const _=[];for(let I=0;I<d.length;++I){const T=d[I].trim();_.push(T)}const p=s!=="void"?i+"_"+t.callIndex++:null;if(p&&_.push(p+" ="),_.length!==n.length){this.debug&&U.Warn("Invalid function call: not the same number of parameters for the call than the number expected by the function. Function '".concat(i,"' (type=").concat(s,"). function parameters=").concat(n,", call parameters=").concat(_)),o=h+i.length;continue}o=c+1;const g=this._replaceNames(r,n,_);let m=h>0?this._sourceCode.substring(0,h):"";const b=c+1<this._sourceCode.length-1?this._sourceCode.substring(c+1):"";if(p){const I=__(this._sourceCode,h-1,"\n","{");m=this._sourceCode.substring(0,I+1);const T=this._sourceCode.substring(I+1,h);this._sourceCode=m+s+" "+p+";\n"+g+"\n"+T+p+b,this.debug&&U.Log("Replace function call by code. Function '".concat(i,"' (type=").concat(s,"). injectDeclarationIndex=").concat(I,", call parameters=").concat(_))}else this._sourceCode=m+g+b,o+=g.length-(c+1-h),this.debug&&U.Log("Replace function call by code. Function '".concat(i,"' (type=").concat(s,"). functionCallIndex=").concat(h,", call parameters=").concat(_));e=!0}}return e}_replaceNames(e,t,i){for(let s=0;s<t.length;++s){const n=new RegExp(p_(t[s]),"g"),r=t[s].length,o=i[s];e=e.replace(n,(h,...l)=>{const c=l[0];return va(e.charAt(c-1))||va(e.charAt(c+r))?t[s]:o})}return e}}Hr._RegexpFindFunctionNameAndType=/((\s+?)(\w+)\s+(\w+)\s*?)$/;class ei{async initTwgsl(e){if(!ei._Twgsl)return e=e||{},e={...ei._TWgslDefaultOptions,...e},e.twgsl?(ei._Twgsl=e.twgsl,Promise.resolve()):(e.jsPath&&e.wasmPath&&await J.LoadBabylonScriptAsync(e.jsPath),self.twgsl?(ei._Twgsl=await self.twgsl(J.GetBabylonScriptURL(e.wasmPath)),Promise.resolve()):Promise.reject("twgsl is not available."))}convertSpirV2WGSL(e,t=!1){const i=ei._Twgsl.convertSpirV2WGSL(e,ei.DisableUniformityAnalysis||t);return ei.ShowWGSLShaderCode&&(U.Log(i),U.Log("***********************************************")),ei.DisableUniformityAnalysis||t?"diagnostic(off, derivative_uniformity);\n"+i:i}}ei._TWgslDefaultOptions={jsPath:"".concat(J._DefaultCdnUrl,"/twgsl/twgsl.js"),wasmPath:"".concat(J._DefaultCdnUrl,"/twgsl/twgsl.wasm")};ei.ShowWGSLShaderCode=!1;ei.DisableUniformityAnalysis=!1;ei._Twgsl=null;class Tp{constructor(e,t,i){this._record=!1,this._play=!1,this._playBundleListIndex=0,this._allBundleLists=[],this._enabled=!1,this._engine=e,this._mode=t,this._bundleList=i}get enabled(){return this._enabled}get play(){return this._play}get record(){return this._record}set enabled(e){this._allBundleLists.length=0,this._record=this._enabled=e,this._play=!1,e&&(this._modeSaved=this._mode,this._mode=0)}get mode(){return this._mode}set mode(e){this._record?this._modeSaved=e:this._mode=e}endRenderPass(e){if(!this._record&&!this._play)return!1;let t;if(this._record)t=this._bundleList.clone(),this._allBundleLists.push(t),this._bundleList.reset();else{if(this._playBundleListIndex>=this._allBundleLists.length)throw new Error("Invalid playBundleListIndex! Your snapshot is no longer valid for the current frame, you should recreate a new one. playBundleListIndex=".concat(this._playBundleListIndex,", allBundleLists.length=").concat(this._allBundleLists.length,"}"));t=this._allBundleLists[this._playBundleListIndex++]}return t.run(e),this._mode===1&&this._engine._reportDrawCall(t.numDrawCalls),!0}endFrame(){this._record&&(this._record=!1,this._play=!0,this._mode=this._modeSaved),this._playBundleListIndex=0}reset(){this._record&&(this._mode=this._modeSaved),this.enabled=!1,this.enabled=!0}}const xn=(()=>{const a=new Uint8Array(4),e=new Uint32Array(a.buffer);return!!((e[0]=1)&a[0])})();Object.defineProperty(A.prototype,"effectiveByteStride",{get:function(){return this._alignedBuffer&&this._alignedBuffer.byteStride||this.byteStride},enumerable:!0,configurable:!0});Object.defineProperty(A.prototype,"effectiveByteOffset",{get:function(){return this._alignedBuffer?0:this.byteOffset},enumerable:!0,configurable:!0});Object.defineProperty(A.prototype,"effectiveBuffer",{get:function(){return this._alignedBuffer&&this._alignedBuffer.getBuffer()||this._buffer.getBuffer()},enumerable:!0,configurable:!0});A.prototype._rebuild=function(){var a,e;(a=this._buffer)==null||a._rebuild(),(e=this._alignedBuffer)==null||e._rebuild()};A.prototype.dispose=function(){var a;this._ownsBuffer&&this._buffer.dispose(),(a=this._alignedBuffer)==null||a.dispose(),this._alignedBuffer=void 0,this._isDisposed=!0};A.prototype.getWrapperBuffer=function(){return this._alignedBuffer||this._buffer};A.prototype._alignBuffer=function(){var u,f;const a=this._buffer.getData();if(!this.engine._features.forceVertexBufferStrideAndOffsetMultiple4Bytes||this.byteStride%4===0&&this.byteOffset%4===0||!a)return;const e=A.GetTypeByteLength(this.type),t=this.byteStride+3&-4,i=t/e,s=this._maxVerticesCount,r=s*t/e;let o;if(Array.isArray(a)){const d=new Float32Array(a);o=new DataView(d.buffer,d.byteOffset,d.byteLength)}else a instanceof ArrayBuffer?o=new DataView(a,0,a.byteLength):o=new DataView(a.buffer,a.byteOffset,a.byteLength);let h;this.type===A.BYTE?h=new Int8Array(r):this.type===A.UNSIGNED_BYTE?h=new Uint8Array(r):this.type===A.SHORT?h=new Int16Array(r):this.type===A.UNSIGNED_SHORT?h=new Uint16Array(r):this.type===A.INT?h=new Int32Array(r):this.type===A.UNSIGNED_INT?h=new Uint32Array(r):h=new Float32Array(r);const l=this.getSize();let c=this.byteOffset;for(let d=0;d<s;++d){for(let _=0;_<l;++_)switch(this.type){case A.BYTE:h[d*i+_]=o.getInt8(c+_);break;case A.UNSIGNED_BYTE:h[d*i+_]=o.getUint8(c+_);break;case A.SHORT:h[d*i+_]=o.getInt16(c+_*2,xn);break;case A.UNSIGNED_SHORT:h[d*i+_]=o.getUint16(c+_*2,xn);break;case A.INT:h[d*i+_]=o.getInt32(c+_*4,xn);break;case A.UNSIGNED_INT:h[d*i+_]=o.getUint32(c+_*4,xn);break;case A.FLOAT:h[d*i+_]=o.getFloat32(c+_*4,xn);break}c+=this.byteStride}(u=this._alignedBuffer)==null||u.dispose(),this._alignedBuffer=new ln(this.engine,h,!1,t,!1,this.getIsInstanced(),!0,this.instanceDivisor,((f=this._label)!=null?f:"VertexBuffer")+"_aligned")};class Ap extends Tc{constructor(e){super(e)}}et.prototype.setAlphaMode=function(a,e=!1){if(this._alphaMode===a&&(a===0&&!this._alphaState.alphaBlend||a!==0&&this._alphaState.alphaBlend)){if(!e){const t=a===0;this.depthCullingState.depthMask!==t&&(this.setDepthWrite(t),this._cacheRenderPipeline.setDepthWriteEnabled(t))}return}switch(a){case 0:this._alphaState.alphaBlend=!1;break;case 7:this._alphaState.setAlphaBlendFunctionParameters(1,771,1,1),this._alphaState.alphaBlend=!0;break;case 8:this._alphaState.setAlphaBlendFunctionParameters(1,771,1,771),this._alphaState.alphaBlend=!0;break;case 2:this._alphaState.setAlphaBlendFunctionParameters(770,771,1,1),this._alphaState.alphaBlend=!0;break;case 6:this._alphaState.setAlphaBlendFunctionParameters(1,1,0,1),this._alphaState.alphaBlend=!0;break;case 1:this._alphaState.setAlphaBlendFunctionParameters(770,1,0,1),this._alphaState.alphaBlend=!0;break;case 3:this._alphaState.setAlphaBlendFunctionParameters(0,769,1,1),this._alphaState.alphaBlend=!0;break;case 4:this._alphaState.setAlphaBlendFunctionParameters(774,0,1,1),this._alphaState.alphaBlend=!0;break;case 5:this._alphaState.setAlphaBlendFunctionParameters(770,769,1,1),this._alphaState.alphaBlend=!0;break;case 9:this._alphaState.setAlphaBlendFunctionParameters(32769,32770,32771,32772),this._alphaState.alphaBlend=!0;break;case 10:this._alphaState.setAlphaBlendFunctionParameters(1,769,1,771),this._alphaState.alphaBlend=!0;break;case 11:this._alphaState.setAlphaBlendFunctionParameters(1,1,1,1),this._alphaState.alphaBlend=!0;break;case 12:this._alphaState.setAlphaBlendFunctionParameters(772,1,0,0),this._alphaState.alphaBlend=!0;break;case 13:this._alphaState.setAlphaBlendFunctionParameters(775,769,773,771),this._alphaState.alphaBlend=!0;break;case 14:this._alphaState.setAlphaBlendFunctionParameters(1,771,1,771),this._alphaState.alphaBlend=!0;break;case 15:this._alphaState.setAlphaBlendFunctionParameters(1,1,1,0),this._alphaState.alphaBlend=!0;break;case 16:this._alphaState.setAlphaBlendFunctionParameters(775,769,0,1),this._alphaState.alphaBlend=!0;break;case 17:this._alphaState.setAlphaBlendFunctionParameters(770,771,1,771),this._alphaState.alphaBlend=!0;break}e||(this.setDepthWrite(a===0),this._cacheRenderPipeline.setDepthWriteEnabled(a===0)),this._alphaMode=a,this._cacheRenderPipeline.setAlphaBlendEnabled(this._alphaState.alphaBlend),this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters,this._alphaState._blendEquationParameters)};et.prototype.setAlphaEquation=function(a){ae.prototype.setAlphaEquation.call(this,a),this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters,this._alphaState._blendEquationParameters)};et.prototype.createRawTexture=function(a,e,t,i,s,n,r,o=null,h=0,l=0,c=!1){const u=new ft(this,3);return u.baseWidth=e,u.baseHeight=t,u.width=e,u.height=t,u.format=i,u.generateMipMaps=s,u.samplingMode=r,u.invertY=n,u._compression=o,u.type=h,u._creationFlags=l,u._useSRGBBuffer=c,this._doNotHandleContextLost||(u._bufferView=a),this._textureHelper.createGPUTextureForInternalTexture(u,e,t,void 0,l),this.updateRawTexture(u,a,i,n,o,h,c),this._internalTexturesCache.push(u),u};et.prototype.updateRawTexture=function(a,e,t,i,s=null,n=0,r=!1){if(a){if(this._doNotHandleContextLost||(a._bufferView=e,a.invertY=i,a._compression=s,a._useSRGBBuffer=r),e){const o=a._hardwareTexture;t===4&&(e=qn(e,a.width,a.height,n));const l=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);this._textureHelper.updateTexture(l,a,a.width,a.height,a.depth,o.format,0,0,i,!1,0,0),a.generateMipMaps&&this._generateMipmaps(a,this._uploadEncoder)}a.isReady=!0}};et.prototype.createRawCubeTexture=function(a,e,t,i,s,n,r,o=null){const h=new ft(this,8);if(i===1&&!this._caps.textureFloatLinearFiltering?(s=!1,r=1,U.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):i===2&&!this._caps.textureHalfFloatLinearFiltering?(s=!1,r=1,U.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):i===1&&!this._caps.textureFloatRender?(s=!1,U.Warn("Render to float textures is not supported. Mipmap generation forced to false.")):i===2&&!this._caps.colorBufferFloat&&(s=!1,U.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")),h.isCube=!0,h._originalFormat=t,h.format=t===4?5:t,h.type=i,h.generateMipMaps=s,h.width=e,h.height=e,h.samplingMode=r,this._doNotHandleContextLost||(h._bufferViewArray=a),h.invertY=n,h._compression=o,h._cachedWrapU=0,h._cachedWrapV=0,this._textureHelper.createGPUTextureForInternalTexture(h),t===4){const l=h._hardwareTexture;l._originalFormatIsRGB=!0}return a&&this.updateRawCubeTexture(h,a,t,i,n,o),h.isReady=!0,h};et.prototype.updateRawCubeTexture=function(a,e,t,i,s,n=null){a._bufferViewArray=e,a.invertY=s,a._compression=n;const r=a._hardwareTexture,o=r._originalFormatIsRGB,h=[0,2,4,1,3,5],l=[];for(let c=0;c<e.length;++c){let u=e[h[c]];o&&(u=qn(u,a.width,a.height,i)),l.push(new Uint8Array(u.buffer,u.byteOffset,u.byteLength))}this._textureHelper.updateCubeTextures(l,r.underlyingResource,a.width,a.height,r.format,s,!1,0,0),a.generateMipMaps&&this._generateMipmaps(a,this._uploadEncoder),a.isReady=!0};et.prototype.createRawCubeTextureFromUrl=function(a,e,t,i,s,n,r,o,h=null,l=null,c=3,u=!1){const f=this.createRawCubeTexture(null,t,i,s,!n,u,c,null);e==null||e.addPendingData(f),f.url=a,f.isReady=!1,this._internalTexturesCache.push(f);const d=(p,g)=>{e==null||e.removePendingData(f),l&&p&&l(p.status+" "+p.statusText,g)},_=p=>{const g=f.width,m=r(p);if(m){if(o){const b=i===4,I=o(m),T=f._hardwareTexture,x=[0,1,2,3,4,5];for(let y=0;y<I.length;y++){const R=g>>y,E=[];for(let C=0;C<6;C++){let S=I[y][x[C]];b&&(S=qn(S,R,R,s)),E.push(new Uint8Array(S.buffer,S.byteOffset,S.byteLength))}this._textureHelper.updateCubeTextures(E,T.underlyingResource,R,R,T.format,u,!1,0,0)}}else this.updateRawCubeTexture(f,m,i,s,u);f.isReady=!0,e==null||e.removePendingData(f),h&&h()}};return this._loadFile(a,p=>{_(p)},void 0,e==null?void 0:e.offlineProvider,!0,d),f};et.prototype.createRawTexture3D=function(a,e,t,i,s,n,r,o,h=null,l=0,c=0){const f=new ft(this,10);return f.baseWidth=e,f.baseHeight=t,f.baseDepth=i,f.width=e,f.height=t,f.depth=i,f.format=s,f.type=l,f.generateMipMaps=n,f.samplingMode=o,f.is3D=!0,f._creationFlags=c,this._doNotHandleContextLost||(f._bufferView=a),this._textureHelper.createGPUTextureForInternalTexture(f,e,t,void 0,c),this.updateRawTexture3D(f,a,s,r,h,l),this._internalTexturesCache.push(f),f};et.prototype.updateRawTexture3D=function(a,e,t,i,s=null,n=0){if(this._doNotHandleContextLost||(a._bufferView=e,a.format=t,a.invertY=i,a._compression=s),e){const r=a._hardwareTexture;t===4&&(e=qn(e,a.width,a.height,n));const h=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);this._textureHelper.updateTexture(h,a,a.width,a.height,a.depth,r.format,0,0,i,!1,0,0),a.generateMipMaps&&this._generateMipmaps(a,this._uploadEncoder)}a.isReady=!0};et.prototype.createRawTexture2DArray=function(a,e,t,i,s,n,r,o,h=null,l=0,c=0){const f=new ft(this,11);return f.baseWidth=e,f.baseHeight=t,f.baseDepth=i,f.width=e,f.height=t,f.depth=i,f.format=s,f.type=l,f.generateMipMaps=n,f.samplingMode=o,f.is2DArray=!0,f._creationFlags=c,this._doNotHandleContextLost||(f._bufferView=a),this._textureHelper.createGPUTextureForInternalTexture(f,e,t,i,c),this.updateRawTexture2DArray(f,a,s,r,h,l),this._internalTexturesCache.push(f),f};et.prototype.updateRawTexture2DArray=function(a,e,t,i,s=null,n=0){if(this._doNotHandleContextLost||(a._bufferView=e,a.format=t,a.invertY=i,a._compression=s),e){const r=a._hardwareTexture;t===4&&(e=qn(e,a.width,a.height,n));const h=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);this._textureHelper.updateTexture(h,a,a.width,a.height,a.depth,r.format,0,0,i,!1,0,0),a.generateMipMaps&&this._generateMipmaps(a,this._uploadEncoder)}a.isReady=!0};function qn(a,e,t,i){let s,n=1;i===1?s=new Float32Array(e*t*4):i===2?(s=new Uint16Array(e*t*4),n=15360):i===7?s=new Uint32Array(e*t*4):s=new Uint8Array(e*t*4);for(let r=0;r<e;r++)for(let o=0;o<t;o++){const h=(o*e+r)*3,l=(o*e+r)*4;s[l+0]=a[h+0],s[l+1]=a[h+1],s[l+2]=a[h+2],s[l+3]=n}return s}et.prototype._readTexturePixels=function(a,e,t,i=-1,s=0,n=null,r=!0,o=!1,h=0,l=0){const c=a._hardwareTexture;return r&&this.flushFramebuffer(),this._textureHelper.readPixels(c.underlyingResource,h,l,e,t,c.format,i,s,n,o)};et.prototype._readTexturePixelsSync=function(){throw"_readTexturePixelsSync is unsupported in WebGPU!"};et.prototype._createDepthStencilCubeTexture=function(a,e){const t=new ft(this,e.generateStencil?12:14);t.isCube=!0,t.label=e.label;const i={bilinearFiltering:!1,comparisonFunction:0,samples:1,depthTextureFormat:e.generateStencil?13:14,...e};t.format=i.depthTextureFormat,this._setupDepthStencilTexture(t,a,i.bilinearFiltering,i.comparisonFunction,i.samples),this._textureHelper.createGPUTextureForInternalTexture(t);const s=t._hardwareTexture;return t.type=Ve.GetTextureTypeFromFormat(s.format),this._internalTexturesCache.push(t),t};et.prototype.createCubeTexture=function(a,e,t,i,s=null,n=null,r,o=null,h=!1,l=0,c=0,u=null,f,d=!1,_=null){return this.createCubeTextureBase(a,e,t,!!i,s,n,r,o,h,l,c,u,null,(p,g)=>{const m=g,b=m[0].width,I=b;this._setCubeMapTextureParams(p,!i),p.format=r!=null?r:-1;const T=this._textureHelper.createGPUTextureForInternalTexture(p,b,I);this._textureHelper.updateCubeTextures(m,T.underlyingResource,b,I,T.format,!1,!1,0,0),i||this._generateMipmaps(p,this._uploadEncoder),p.isReady=!0,p.onLoadedObservable.notifyObservers(p),p.onLoadedObservable.clear(),s&&s()},!!d,_)};et.prototype._setCubeMapTextureParams=function(a,e,t){a.samplingMode=e?3:2,a._cachedWrapU=0,a._cachedWrapV=0,t&&(a._maxLodLevel=t)};et.prototype.generateMipMapsForCubemap=function(a){var e;a.generateMipMaps&&((e=a._hardwareTexture)!=null&&e.underlyingResource||this._textureHelper.createGPUTextureForInternalTexture(a),this._generateMipmaps(a))};class Rp extends Zl{constructor(e,t,i,s,n){super(e,t,i,s,n),s.enableGPUTimingMeasurements&&(this.gpuTimeInFrame=new gc)}}et.prototype._createHardwareRenderTargetWrapper=function(a,e,t){const i=new Rp(a,e,t,this);return this._renderTargetWrapperCache.push(i),i};et.prototype.createRenderTargetTexture=function(a,e){var n,r,o,h,l;const t=this._createHardwareRenderTargetWrapper(!1,!1,a),i={};e!==void 0&&typeof e=="object"?(i.generateMipMaps=e.generateMipMaps,i.generateDepthBuffer=e.generateDepthBuffer===void 0?!0:e.generateDepthBuffer,i.generateStencilBuffer=i.generateDepthBuffer&&e.generateStencilBuffer,i.samplingMode=e.samplingMode===void 0?3:e.samplingMode,i.creationFlags=(n=e.creationFlags)!=null?n:0,i.noColorAttachment=!!e.noColorAttachment,i.colorAttachment=e.colorAttachment,i.samples=e.samples,i.label=e.label,i.format=e.format,i.type=e.type):(i.generateMipMaps=e,i.generateDepthBuffer=!0,i.generateStencilBuffer=!1,i.samplingMode=3,i.creationFlags=0,i.noColorAttachment=!1);const s=i.colorAttachment||(i.noColorAttachment?null:this._createInternalTexture(a,i,!0,5));return t.label=(r=i.label)!=null?r:"RenderTargetWrapper",t._samples=(l=(h=(o=i.colorAttachment)==null?void 0:o.samples)!=null?h:i.samples)!=null?l:1,t._generateDepthBuffer=i.generateDepthBuffer,t._generateStencilBuffer=!!i.generateStencilBuffer,t.setTextures(s),(t._generateDepthBuffer||t._generateStencilBuffer)&&t.createDepthStencilTexture(0,!1,t._generateStencilBuffer,t.samples,i.generateStencilBuffer?13:14,i.label?i.label+"-DepthStencil":void 0),s&&!i.colorAttachment&&(e!==void 0&&typeof e=="object"&&e.createMipMaps&&!i.generateMipMaps&&(s.generateMipMaps=!0),this._textureHelper.createGPUTextureForInternalTexture(s,void 0,void 0,void 0,i.creationFlags),e!==void 0&&typeof e=="object"&&e.createMipMaps&&!i.generateMipMaps&&(s.generateMipMaps=!1)),t};et.prototype._createDepthStencilTexture=function(a,e,t){const i={bilinearFiltering:!1,comparisonFunction:0,samples:1,depthTextureFormat:e.generateStencil?13:14,...e},s=i.depthTextureFormat===17||i.depthTextureFormat===13||i.depthTextureFormat===18;t._depthStencilTextureWithStencil=s;const n=new ft(this,s?12:14);return n.label=e.label,n.format=i.depthTextureFormat,n.type=id(n.format),this._setupDepthStencilTexture(n,a,i.bilinearFiltering,i.comparisonFunction,i.samples),this._textureHelper.createGPUTextureForInternalTexture(n),this._internalTexturesCache.push(n),n};et.prototype._setupDepthStencilTexture=function(a,e,t,i,s=1){var l,c;const n=(l=e.width)!=null?l:e,r=(c=e.height)!=null?c:e,o=e.layers||0,h=e.depth||0;a.baseWidth=n,a.baseHeight=r,a.width=n,a.height=r,a.is2DArray=o>0,a.is3D=h>0,a.depth=o||h,a.isReady=!0,a.samples=s,a.generateMipMaps=!1,a.samplingMode=t?2:1,a.type=1,a._comparisonFunction=i,a._cachedWrapU=0,a._cachedWrapV=0};et.prototype.updateRenderTargetTextureSampleCount=function(a,e){return!a||!a.texture||a.samples===e||(e=Math.min(e,this.getCaps().maxMSAASamples),this._textureHelper.createMSAATexture(a.texture,e),a._depthStencilTexture&&(this._textureHelper.createMSAATexture(a._depthStencilTexture,e),a._depthStencilTexture.samples=e),a._samples=e,a.texture.samples=e),e};et.prototype.setDepthStencilTexture=function(a,e,t,i){!t||!t.depthStencilTexture?this._setTexture(a,null,void 0,void 0,i):this._setTexture(a,t,!1,!0,i)};et.prototype.createRenderTargetCubeTexture=function(a,e){var n;const t=this._createHardwareRenderTargetWrapper(!1,!0,a),i={generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:0,samplingMode:3,format:5,samples:1,...e};i.generateStencilBuffer=i.generateDepthBuffer&&i.generateStencilBuffer,t.label=(n=i.label)!=null?n:"RenderTargetWrapper",t._generateDepthBuffer=i.generateDepthBuffer,t._generateStencilBuffer=i.generateStencilBuffer;const s=new ft(this,5);return s.width=a,s.height=a,s.depth=0,s.isReady=!0,s.isCube=!0,s.samples=i.samples,s.generateMipMaps=i.generateMipMaps,s.samplingMode=i.samplingMode,s.type=i.type,s.format=i.format,this._internalTexturesCache.push(s),t.setTextures(s),(t._generateDepthBuffer||t._generateStencilBuffer)&&t.createDepthStencilTexture(0,i.samplingMode===void 0||i.samplingMode===2||i.samplingMode===2||i.samplingMode===3||i.samplingMode===3||i.samplingMode===5||i.samplingMode===6||i.samplingMode===7||i.samplingMode===11,t._generateStencilBuffer,t.samples),e&&e.createMipMaps&&!i.generateMipMaps&&(s.generateMipMaps=!0),this._textureHelper.createGPUTextureForInternalTexture(s),e&&e.createMipMaps&&!i.generateMipMaps&&(s.generateMipMaps=!1),t};function Ga(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 Ip(a=25){let e;return(t,i,s)=>{const n=performance.now();e===void 0||n-e>a?(e=n,setTimeout(()=>{Ga(t,i,s)},0)):Ga(t,i,s)}}function Rc(a,e,t,i,s){const n=()=>{let r;const o=h=>{h.done?t(h.value):r===void 0?r=!0:n()};do r=void 0,e(a,o,i),r===void 0&&(r=!1);while(r)};n()}function F0(a,e){let t;return Rc(a,Ga,i=>t=i,i=>{throw i}),t}function Ep(a,e,t){return new Promise((i,s)=>{Rc(a,e,i,s)})}function Cp(a,e){return(...t)=>F0(a(...t))}class za{constructor(e,t,i){this.bu=e,this.bv=t,this.distance=i,this.faceId=0,this.subMeshId=0}}class is{constructor(e,t,i){this.vectors=zi(8,v.Zero),this.center=v.Zero(),this.centerWorld=v.Zero(),this.extendSize=v.Zero(),this.extendSizeWorld=v.Zero(),this.directions=zi(3,v.Zero),this.vectorsWorld=zi(8,v.Zero),this.minimumWorld=v.Zero(),this.maximumWorld=v.Zero(),this.minimum=v.Zero(),this.maximum=v.Zero(),this._drawWrapperFront=null,this._drawWrapperBack=null,this.reConstruct(e,t,i)}reConstruct(e,t,i){const s=e.x,n=e.y,r=e.z,o=t.x,h=t.y,l=t.z,c=this.vectors;this.minimum.copyFromFloats(s,n,r),this.maximum.copyFromFloats(o,h,l),c[0].copyFromFloats(s,n,r),c[1].copyFromFloats(o,h,l),c[2].copyFromFloats(o,n,r),c[3].copyFromFloats(s,h,r),c[4].copyFromFloats(s,n,l),c[5].copyFromFloats(o,h,r),c[6].copyFromFloats(s,h,l),c[7].copyFromFloats(o,n,l),t.addToRef(e,this.center).scaleInPlace(.5),t.subtractToRef(e,this.extendSize).scaleInPlace(.5),this._worldMatrix=i||O.IdentityReadOnly,this._update(this._worldMatrix)}scale(e){const t=is._TmpVector3,i=this.maximum.subtractToRef(this.minimum,t[0]),s=i.length();i.normalizeFromLength(s);const n=s*e,r=i.scaleInPlace(n*.5),o=this.center.subtractToRef(r,t[1]),h=this.center.addToRef(r,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,n=this.vectorsWorld,r=this.vectors;if(e.isIdentity()){t.copyFrom(this.minimum),i.copyFrom(this.maximum);for(let o=0;o<8;++o)n[o].copyFrom(r[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=n[o];v.TransformCoordinatesToRef(r[o],e,h),t.minimizeInPlace(h),i.maximizeInPlace(h)}i.subtractToRef(t,this.extendSizeWorld).scaleInPlace(.5),i.addToRef(t,this.centerWorld).scaleInPlace(.5)}v.FromArrayToRef(e.m,0,s[0]),v.FromArrayToRef(e.m,4,s[1]),v.FromArrayToRef(e.m,8,s[2]),this._worldMatrix=e}isInFrustum(e){return is.IsInFrustum(this.vectorsWorld,e)}isCompletelyInFrustum(e){return is.IsCompletelyInFrustum(this.vectorsWorld,e)}intersectsPoint(e){const t=this.minimumWorld,i=this.maximumWorld,s=t.x,n=t.y,r=t.z,o=i.x,h=i.y,l=i.z,c=e.x,u=e.y,f=e.z,d=-.001;return!(o-c<d||d>c-s||h-u<d||d>u-n||l-f<d||d>f-r)}intersectsSphere(e){return is.IntersectsSphere(this.minimumWorld,this.maximumWorld,e.centerWorld,e.radiusWorld)}intersectsMinMax(e,t){const i=this.minimumWorld,s=this.maximumWorld,n=i.x,r=i.y,o=i.z,h=s.x,l=s.y,c=s.z,u=e.x,f=e.y,d=e.z,_=t.x,p=t.y,g=t.z;return!(h<u||n>_||l<f||r>p||c<d||o>g)}dispose(){var e,t;(e=this._drawWrapperFront)==null||e.dispose(),(t=this._drawWrapperBack)==null||t.dispose()}static Intersects(e,t){return e.intersectsMinMax(t.minimumWorld,t.maximumWorld)}static IntersectsSphere(e,t,i,s){const n=is._TmpVector3[0];return v.ClampToRef(i,e,t,n),v.DistanceSquared(i,n)<=s*s}static IsCompletelyInFrustum(e,t){for(let i=0;i<6;++i){const s=t[i];for(let n=0;n<8;++n)if(s.dotCoordinate(e[n])<0)return!1}return!0}static IsInFrustum(e,t){for(let i=0;i<6;++i){let s=!0;const n=t[i];for(let r=0;r<8;++r)if(n.dotCoordinate(e[r])>=0){s=!1;break}if(s)return!1}return!0}}is._TmpVector3=zi(3,v.Zero);class Ls{constructor(e,t,i){this.center=v.Zero(),this.centerWorld=v.Zero(),this.minimum=v.Zero(),this.maximum=v.Zero(),this.reConstruct(e,t,i)}reConstruct(e,t,i){this.minimum.copyFrom(e),this.maximum.copyFrom(t);const s=v.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=s*.5,this._update(i||O.IdentityReadOnly)}scale(e){const t=this.radius*e,i=Ls._TmpVector3,s=i[0].setAll(t),n=this.center.subtractToRef(s,i[1]),r=this.center.addToRef(s,i[2]);return this.reConstruct(n,r,this._worldMatrix),this}getWorldMatrix(){return this._worldMatrix}_update(e){if(e.isIdentity())this.centerWorld.copyFrom(this.center),this.radiusWorld=this.radius;else{v.TransformCoordinatesToRef(this.center,e,this.centerWorld);const t=Ls._TmpVector3[0];v.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=v.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorld<t)}static Intersects(e,t){const i=v.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 Ls(this._TmpVector3[0],this._TmpVector3[2]);return i?s._worldMatrix=i:s._worldMatrix=O.Identity(),s}}Ls._TmpVector3=zi(3,v.Zero);const xa={min:0,max:0},ya={min:0,max:0},Ph=(a,e,t)=>{const i=v.Dot(e.centerWorld,a),s=Math.abs(v.Dot(e.directions[0],a))*e.extendSize.x,n=Math.abs(v.Dot(e.directions[1],a))*e.extendSize.y,r=Math.abs(v.Dot(e.directions[2],a))*e.extendSize.z,o=s+n+r;t.min=i-o,t.max=i+o},qt=(a,e,t)=>(Ph(a,e,xa),Ph(a,t,ya),!(xa.min>ya.max||ya.min>xa.max));class ri{constructor(e,t,i){this._isLocked=!1,this.boundingBox=new is(e,t,i),this.boundingSphere=new Ls(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=ri._TmpVector3[0].copyFrom(e).subtractInPlace(t),s=ri._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=v.Minimize(this.minimum,e),i=v.Maximize(this.maximum,e);return this.reConstruct(t,i,this.boundingBox.getWorldMatrix()),this}encapsulateBoundingInfo(e){const t=N.Matrix[0];this.boundingBox.getWorldMatrix().invertToRef(t);const i=N.Vector3[0];return v.TransformCoordinatesToRef(e.boundingBox.minimumWorld,t,i),this.encapsulate(i),v.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,ri._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(!Ls.Intersects(this.boundingSphere,e.boundingSphere)||!is.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;const i=this.boundingBox,s=e.boundingBox;return!(!qt(i.directions[0],i,s)||!qt(i.directions[1],i,s)||!qt(i.directions[2],i,s)||!qt(s.directions[0],i,s)||!qt(s.directions[1],i,s)||!qt(s.directions[2],i,s)||!qt(v.Cross(i.directions[0],s.directions[0]),i,s)||!qt(v.Cross(i.directions[0],s.directions[1]),i,s)||!qt(v.Cross(i.directions[0],s.directions[2]),i,s)||!qt(v.Cross(i.directions[1],s.directions[0]),i,s)||!qt(v.Cross(i.directions[1],s.directions[1]),i,s)||!qt(v.Cross(i.directions[1],s.directions[2]),i,s)||!qt(v.Cross(i.directions[2],s.directions[0]),i,s)||!qt(v.Cross(i.directions[2],s.directions[1]),i,s)||!qt(v.Cross(i.directions[2],s.directions[2]),i,s))}}ri._TmpVector3=zi(2,v.Zero);class Kr{static extractMinAndMaxIndexed(e,t,i,s,n,r){for(let o=i;o<i+s;o++){const h=t[o]*3,l=e[h],c=e[h+1],u=e[h+2];n.minimizeInPlaceFromFloats(l,c,u),r.maximizeInPlaceFromFloats(l,c,u)}}static extractMinAndMax(e,t,i,s,n,r){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];n.minimizeInPlaceFromFloats(l,c,u),r.maximizeInPlaceFromFloats(l,c,u)}}}D([rs.filter((...[a,e])=>!Array.isArray(a)&&!Array.isArray(e))],Kr,"extractMinAndMaxIndexed",null);D([rs.filter((...[a])=>!Array.isArray(a))],Kr,"extractMinAndMax",null);function Sp(a,e,t,i,s=null){const n=new v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r=new v(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return Kr.extractMinAndMaxIndexed(a,e,t,i,n,r),s&&(n.x-=n.x*s.x+s.y,n.y-=n.y*s.x+s.y,n.z-=n.z*s.x+s.y,r.x+=r.x*s.x+s.y,r.y+=r.y*s.x+s.y,r.z+=r.z*s.x+s.y),{minimum:n,maximum:r}}function Ic(a,e,t,i=null,s){const n=new v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r=new v(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return s||(s=3),Kr.extractMinAndMax(a,e,t,s,n,r),i&&(n.x-=n.x*i.x+i.y,n.y-=n.y*i.x+i.y,n.z-=n.z*i.x+i.y,r.x+=r.x*i.x+i.y,r.y+=r.y*i.x+i.y,r.z+=r.z*i.x+i.y),{minimum:n,maximum:r}}class vi{get materialDefines(){var e;return this._mainDrawWrapperOverride?this._mainDrawWrapperOverride.defines:(e=this._getDrawWrapper())==null?void 0:e.defines}set materialDefines(e){var i;const t=(i=this._mainDrawWrapperOverride)!=null?i:this._getDrawWrapper(void 0,!0);t.defines=e}_getDrawWrapper(e,t=!1){e=e!=null?e:this._engine.currentRenderPassId;let i=this._drawWrappers[e];return!i&&t&&(this._drawWrappers[e]=i=new Xn(this._mesh.getScene().getEngine())),i}_removeDrawWrapper(e,t=!0,i=!1){var s;t&&((s=this._drawWrappers[e])==null||s.dispose(i)),this._drawWrappers[e]=void 0}get effect(){var e,t;return this._mainDrawWrapperOverride?this._mainDrawWrapperOverride.effect:(t=(e=this._getDrawWrapper())==null?void 0:e.effect)!=null?t:null}get _drawWrapper(){var e;return(e=this._mainDrawWrapperOverride)!=null?e:this._getDrawWrapper(void 0,!0)}get _drawWrapperOverride(){return this._mainDrawWrapperOverride}_setMainDrawWrapperOverride(e){this._mainDrawWrapperOverride=e}setEffect(e,t=null,i,s=!0){const n=this._drawWrapper;n.setEffect(e,t,s),i!==void 0&&(n.materialContext=i),e||(n.defines=null,n.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==null||i.dispose(t);this._drawWrappers=[]}static AddToMesh(e,t,i,s,n,r,o,h=!0){return new vi(e,t,i,s,n,r,o,h)}constructor(e,t,i,s,n,r,o,h=!0,l=!0){this.materialIndex=e,this.verticesStart=t,this.verticesCount=i,this.indexStart=s,this.indexCount=n,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=r,this._renderingMesh=o||r,l&&r.subMeshes.push(this),this._engine=this._mesh.getScene().getEngine(),this.resetDrawCache(),this._trianglePlanes=[],this._id=r.subMeshes.length-1,h&&(this.refreshBoundingInfo(),r.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){var i;const t=(i=this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId))!=null?i:this._renderingMesh.material;if(t){if(this._isMultiMaterial(t)){const s=t.getSubMaterial(this.materialIndex);return this._currentMaterial!==s&&(this._currentMaterial=s,this.resetDrawCache()),s}}else return e?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(A.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=Sp(e,t,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new ri(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=[];for(let s=this.indexStart;s<this.indexStart+this.indexCount;s+=3)i.push(e[s],e[s+1],e[s+1],e[s+2],e[s+2],e[s]);this._linesIndexBuffer=t.createIndexBuffer(i),this._linesIndexCount=i.length}return this._linesIndexBuffer}canIntersects(e){const t=this.getBoundingInfo();return t?e.intersectsBox(t.boundingBox):!1}intersects(e,t,i,s,n){const r=this.getMaterial();if(!r)return null;let o=3,h=!1;switch(r.fillMode){case 3:case 5:case 6:case 8:return null;case 7:o=1,h=!0;break}return r.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,n):this._intersectTriangles(e,t,i,o,h,s,n)}_intersectLines(e,t,i,s,n){let r=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)&&(n||!r||c<r.distance)&&(r=new za(null,null,c),r.faceId=o/2,n))break}return r}_intersectUnIndexedLines(e,t,i,s,n){let r=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)&&(n||!r||c<r.distance)&&(r=new za(null,null,c),r.faceId=o/2,n))break}return r}_intersectTriangles(e,t,i,s,n,r,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(n&&d===4294967295){c+=2;continue}const _=t[u],p=t[f],g=t[d];if(!_||!p||!g||o&&!o(_,p,g,e,u,f,d))continue;const m=e.intersectsTriangle(_,p,g);if(m){if(m.distance<0)continue;if((r||!h||m.distance<h.distance)&&(h=m,h.faceId=l,r))break}}return h}_intersectUnIndexedTriangles(e,t,i,s,n){let r=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(n&&!n(h,l,c,e,-1,-1,-1))continue;const u=e.intersectsTriangle(h,l,c);if(u){if(u.distance<0)continue;if((s||!r||u.distance<r.distance)&&(r=u,r.faceId=o/3,s))break}}return r}_rebuild(){this._linesIndexBuffer&&(this._linesIndexBuffer=null)}clone(e,t){const i=new vi(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 ri(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,n,r=!0){let o=Number.MAX_VALUE,h=-Number.MAX_VALUE;const c=(n||s).getIndices();for(let u=t;u<t+i;u++){const f=c[u];f<o&&(o=f),f>h&&(h=f)}return new vi(e,o,h-o+1,t,i,s,n,r)}}class Ta{}class j{constructor(){this.uniqueId=0,this.metadata={},this._applyTo=Cp(this._applyToCoroutine.bind(this)),this.uniqueId=j._UniqueIDGenerator,j._UniqueIDGenerator++}set(e,t){switch(e.length||U.Warn("Setting vertex data kind '".concat(t,"' with an empty array")),t){case A.PositionKind:this.positions=e;break;case A.NormalKind:this.normals=e;break;case A.TangentKind:this.tangents=e;break;case A.UVKind:this.uvs=e;break;case A.UV2Kind:this.uvs2=e;break;case A.UV3Kind:this.uvs3=e;break;case A.UV4Kind:this.uvs4=e;break;case A.UV5Kind:this.uvs5=e;break;case A.UV6Kind:this.uvs6=e;break;case A.ColorKind:this.colors=e;break;case A.MatricesIndicesKind:this.matricesIndices=e;break;case A.MatricesWeightsKind:this.matricesWeights=e;break;case A.MatricesIndicesExtraKind:this.matricesIndicesExtra=e;break;case A.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(A.PositionKind,this.positions,t),i&&(yield)),this.normals&&(e.setVerticesData(A.NormalKind,this.normals,t),i&&(yield)),this.tangents&&(e.setVerticesData(A.TangentKind,this.tangents,t),i&&(yield)),this.uvs&&(e.setVerticesData(A.UVKind,this.uvs,t),i&&(yield)),this.uvs2&&(e.setVerticesData(A.UV2Kind,this.uvs2,t),i&&(yield)),this.uvs3&&(e.setVerticesData(A.UV3Kind,this.uvs3,t),i&&(yield)),this.uvs4&&(e.setVerticesData(A.UV4Kind,this.uvs4,t),i&&(yield)),this.uvs5&&(e.setVerticesData(A.UV5Kind,this.uvs5,t),i&&(yield)),this.uvs6&&(e.setVerticesData(A.UV6Kind,this.uvs6,t),i&&(yield)),this.colors&&(e.setVerticesData(A.ColorKind,this.colors,t),this.hasVertexAlpha&&e.hasVertexAlpha!==void 0&&(e.hasVertexAlpha=!0),i&&(yield)),this.matricesIndices&&(e.setVerticesData(A.MatricesIndicesKind,this.matricesIndices,t),i&&(yield)),this.matricesWeights&&(e.setVerticesData(A.MatricesWeightsKind,this.matricesWeights,t),i&&(yield)),this.matricesIndicesExtra&&(e.setVerticesData(A.MatricesIndicesExtraKind,this.matricesIndicesExtra,t),i&&(yield)),this.matricesWeightsExtra&&(e.setVerticesData(A.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 n of this.materialInfos)new vi(n.materialIndex,n.verticesStart,n.verticesCount,n.indexStart,n.indexCount,s)}return this}_update(e,t,i){return this.positions&&e.updateVerticesData(A.PositionKind,this.positions,t,i),this.normals&&e.updateVerticesData(A.NormalKind,this.normals,t,i),this.tangents&&e.updateVerticesData(A.TangentKind,this.tangents,t,i),this.uvs&&e.updateVerticesData(A.UVKind,this.uvs,t,i),this.uvs2&&e.updateVerticesData(A.UV2Kind,this.uvs2,t,i),this.uvs3&&e.updateVerticesData(A.UV3Kind,this.uvs3,t,i),this.uvs4&&e.updateVerticesData(A.UV4Kind,this.uvs4,t,i),this.uvs5&&e.updateVerticesData(A.UV5Kind,this.uvs5,t,i),this.uvs6&&e.updateVerticesData(A.UV6Kind,this.uvs6,t,i),this.colors&&e.updateVerticesData(A.ColorKind,this.colors,t,i),this.matricesIndices&&e.updateVerticesData(A.MatricesIndicesKind,this.matricesIndices,t,i),this.matricesWeights&&e.updateVerticesData(A.MatricesWeightsKind,this.matricesWeights,t,i),this.matricesIndicesExtra&&e.updateVerticesData(A.MatricesIndicesExtraKind,this.matricesIndicesExtra,t,i),this.matricesWeightsExtra&&e.updateVerticesData(A.MatricesWeightsExtraKind,this.matricesWeightsExtra,t,i),this.indices&&e.setIndices(this.indices,null),this}static _TransformVector3Coordinates(e,t,i=0,s=e.length){const n=N.Vector3[0],r=N.Vector3[1];for(let o=i;o<i+s;o+=3)v.FromArrayToRef(e,o,n),v.TransformCoordinatesToRef(n,t,r),e[o]=r.x,e[o+1]=r.y,e[o+2]=r.z}static _TransformVector3Normals(e,t,i=0,s=e.length){const n=N.Vector3[0],r=N.Vector3[1];for(let o=i;o<i+s;o+=3)v.FromArrayToRef(e,o,n),v.TransformNormalToRef(n,t,r),e[o]=r.x,e[o+1]=r.y,e[o+2]=r.z}static _TransformVector4Normals(e,t,i=0,s=e.length){const n=N.Vector4[0],r=N.Vector4[1];for(let o=i;o<i+s;o+=4)Pe.FromArrayToRef(e,o,n),Pe.TransformNormalToRef(n,t,r),e[o]=r.x,e[o+1]=r.y,e[o+2]=r.z,e[o+3]=r.w}static _FlipFaces(e,t=0,i=e.length){for(let s=t;s<t+i;s+=3){const n=e[s+1];e[s+1]=e[s+2],e[s+2]=n}}transform(e){const t=e.determinant()<0;return this.positions&&j._TransformVector3Coordinates(this.positions,e),this.normals&&j._TransformVector3Normals(this.normals,e),this.tangents&&j._TransformVector4Normals(this.tangents,e),t&&this.indices&&j._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 j;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 n=t.indexStart;n<t.indexStart+t.indexCount;n++)i.indices.push(this.indices[n]-t.verticesStart)}const s=new Ta;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,n=!1){const r=Array.isArray(e)?e.map(o=>({vertexData:o})):[{vertexData:e}];return F0(this._mergeCoroutine(void 0,r,t,!1,i,s,n))}*_mergeCoroutine(e,t,i=!1,s,n,r=!1,o=!1){var d,_,p,g;this._validate();let h=t.map(m=>m.vertexData),l=this;if(o)for(const m of h)m&&(m._validate(),!this.normals&&m.normals&&(this.normals=new Float32Array(this.positions.length)),!this.tangents&&m.tangents&&(this.tangents=new Float32Array(this.positions.length/3*4)),!this.uvs&&m.uvs&&(this.uvs=new Float32Array(this.positions.length/3*2)),!this.uvs2&&m.uvs2&&(this.uvs2=new Float32Array(this.positions.length/3*2)),!this.uvs3&&m.uvs3&&(this.uvs3=new Float32Array(this.positions.length/3*2)),!this.uvs4&&m.uvs4&&(this.uvs4=new Float32Array(this.positions.length/3*2)),!this.uvs5&&m.uvs5&&(this.uvs5=new Float32Array(this.positions.length/3*2)),!this.uvs6&&m.uvs6&&(this.uvs6=new Float32Array(this.positions.length/3*2)),!this.colors&&m.colors&&(this.colors=new Float32Array(this.positions.length/3*4),this.colors.fill(1)),!this.matricesIndices&&m.matricesIndices&&(this.matricesIndices=new Float32Array(this.positions.length/3*4)),!this.matricesWeights&&m.matricesWeights&&(this.matricesWeights=new Float32Array(this.positions.length/3*4)),!this.matricesIndicesExtra&&m.matricesIndicesExtra&&(this.matricesIndicesExtra=new Float32Array(this.positions.length/3*4)),!this.matricesWeightsExtra&&m.matricesWeightsExtra&&(this.matricesWeightsExtra=new Float32Array(this.positions.length/3*4)));for(const m of h)if(m){if(o)this.normals&&!m.normals&&(m.normals=new Float32Array(m.positions.length)),this.tangents&&!m.tangents&&(m.tangents=new Float32Array(m.positions.length/3*4)),this.uvs&&!m.uvs&&(m.uvs=new Float32Array(m.positions.length/3*2)),this.uvs2&&!m.uvs2&&(m.uvs2=new Float32Array(m.positions.length/3*2)),this.uvs3&&!m.uvs3&&(m.uvs3=new Float32Array(m.positions.length/3*2)),this.uvs4&&!m.uvs4&&(m.uvs4=new Float32Array(m.positions.length/3*2)),this.uvs5&&!m.uvs5&&(m.uvs5=new Float32Array(m.positions.length/3*2)),this.uvs6&&!m.uvs6&&(m.uvs6=new Float32Array(m.positions.length/3*2)),this.colors&&!m.colors&&(m.colors=new Float32Array(m.positions.length/3*4),m.colors.fill(1)),this.matricesIndices&&!m.matricesIndices&&(m.matricesIndices=new Float32Array(m.positions.length/3*4)),this.matricesWeights&&!m.matricesWeights&&(m.matricesWeights=new Float32Array(m.positions.length/3*4)),this.matricesIndicesExtra&&!m.matricesIndicesExtra&&(m.matricesIndicesExtra=new Float32Array(m.positions.length/3*4)),this.matricesWeightsExtra&&!m.matricesWeightsExtra&&(m.matricesWeightsExtra=new Float32Array(m.positions.length/3*4));else if(m._validate(),!this.normals!=!m.normals||!this.tangents!=!m.tangents||!this.uvs!=!m.uvs||!this.uvs2!=!m.uvs2||!this.uvs3!=!m.uvs3||!this.uvs4!=!m.uvs4||!this.uvs5!=!m.uvs5||!this.uvs6!=!m.uvs6||!this.colors!=!m.colors||!this.matricesIndices!=!m.matricesIndices||!this.matricesWeights!=!m.matricesWeights||!this.matricesIndicesExtra!=!m.matricesIndicesExtra||!this.matricesWeightsExtra!=!m.matricesWeightsExtra)throw new Error("Cannot merge vertex data that do not have the same set of attributes")}if(r){let m=0,b=0,I=0;const T=[];let x=null;const y=[];for(const E of this.splitBasedOnMaterialID())y.push({vertexData:E,transform:e});for(const E of t)if(E.vertexData)for(const C of E.vertexData.splitBasedOnMaterialID())y.push({vertexData:C,transform:E.transform});y.sort((E,C)=>{const S=E.vertexData.materialInfos?E.vertexData.materialInfos[0].materialIndex:0,w=C.vertexData.materialInfos?C.vertexData.materialInfos[0].materialIndex:0;return S>w?1:S===w?0:-1});for(const E of y){const C=E.vertexData;if(C.materialInfos?m=C.materialInfos[0].materialIndex:m=0,x&&x.materialIndex===m)x.indexCount+=C.indices.length,x.verticesCount+=C.positions.length/3;else{const S=new Ta;S.materialIndex=m,S.indexStart=b,S.indexCount=C.indices.length,S.verticesStart=I,S.verticesCount=C.positions.length/3,T.push(S),x=S}b+=C.indices.length,I+=C.positions.length/3}const R=y.splice(0,1)[0];l=R.vertexData,e=R.transform,h=y.map(E=>E.vertexData),t=y,this.materialInfos=T}const c=h.reduce((m,b)=>{var I,T;return m+((T=(I=b.indices)==null?void 0:I.length)!=null?T:0)},(_=(d=l.indices)==null?void 0:d.length)!=null?_:0);let f=n||h.some(m=>m.indices===l.indices)?(p=l.indices)==null?void 0:p.slice():l.indices;if(c>0){let m=(g=f==null?void 0:f.length)!=null?g:0;if(f||(f=new Array(c)),f.length!==c){if(Array.isArray(f))f.length=c;else{const I=i||f instanceof Uint32Array?new Uint32Array(c):new Uint16Array(c);I.set(f),f=I}e&&e.determinant()<0&&j._FlipFaces(f,0,m)}let b=l.positions?l.positions.length/3:0;for(const{vertexData:I,transform:T}of t)if(I.indices){for(let x=0;x<I.indices.length;x++)f[m+x]=I.indices[x]+b;T&&T.determinant()<0&&j._FlipFaces(f,m,I.indices.length),b+=I.positions.length/3,m+=I.indices.length,s&&(yield)}}return this.indices=f,this.positions=j._MergeElement(A.PositionKind,l.positions,e,t.map(m=>[m.vertexData.positions,m.transform])),s&&(yield),l.normals&&(this.normals=j._MergeElement(A.NormalKind,l.normals,e,t.map(m=>[m.vertexData.normals,m.transform])),s&&(yield)),l.tangents&&(this.tangents=j._MergeElement(A.TangentKind,l.tangents,e,t.map(m=>[m.vertexData.tangents,m.transform])),s&&(yield)),l.uvs&&(this.uvs=j._MergeElement(A.UVKind,l.uvs,e,t.map(m=>[m.vertexData.uvs,m.transform])),s&&(yield)),l.uvs2&&(this.uvs2=j._MergeElement(A.UV2Kind,l.uvs2,e,t.map(m=>[m.vertexData.uvs2,m.transform])),s&&(yield)),l.uvs3&&(this.uvs3=j._MergeElement(A.UV3Kind,l.uvs3,e,t.map(m=>[m.vertexData.uvs3,m.transform])),s&&(yield)),l.uvs4&&(this.uvs4=j._MergeElement(A.UV4Kind,l.uvs4,e,t.map(m=>[m.vertexData.uvs4,m.transform])),s&&(yield)),l.uvs5&&(this.uvs5=j._MergeElement(A.UV5Kind,l.uvs5,e,t.map(m=>[m.vertexData.uvs5,m.transform])),s&&(yield)),l.uvs6&&(this.uvs6=j._MergeElement(A.UV6Kind,l.uvs6,e,t.map(m=>[m.vertexData.uvs6,m.transform])),s&&(yield)),l.colors&&(this.colors=j._MergeElement(A.ColorKind,l.colors,e,t.map(m=>[m.vertexData.colors,m.transform])),(l.hasVertexAlpha!==void 0||t.some(m=>m.vertexData.hasVertexAlpha!==void 0))&&(this.hasVertexAlpha=l.hasVertexAlpha||t.some(m=>m.vertexData.hasVertexAlpha)),s&&(yield)),l.matricesIndices&&(this.matricesIndices=j._MergeElement(A.MatricesIndicesKind,l.matricesIndices,e,t.map(m=>[m.vertexData.matricesIndices,m.transform])),s&&(yield)),l.matricesWeights&&(this.matricesWeights=j._MergeElement(A.MatricesWeightsKind,l.matricesWeights,e,t.map(m=>[m.vertexData.matricesWeights,m.transform])),s&&(yield)),l.matricesIndicesExtra&&(this.matricesIndicesExtra=j._MergeElement(A.MatricesIndicesExtraKind,l.matricesIndicesExtra,e,t.map(m=>[m.vertexData.matricesIndicesExtra,m.transform])),s&&(yield)),l.matricesWeightsExtra&&(this.matricesWeightsExtra=j._MergeElement(A.MatricesWeightsExtraKind,l.matricesWeightsExtra,e,t.map(m=>[m.vertexData.matricesWeightsExtra,m.transform]))),this}static _MergeElement(e,t,i,s){const n=s.filter(h=>h[0]!==null&&h[0]!==void 0);if(!t&&n.length==0)return t;if(!t)return this._MergeElement(e,n[0][0],n[0][1],n.slice(1));const r=n.reduce((h,l)=>h+l[0].length,t.length),o=e===A.PositionKind?j._TransformVector3Coordinates:e===A.NormalKind?j._TransformVector3Normals:e===A.TangentKind?j._TransformVector4Normals:()=>{};if(t instanceof Float32Array){const h=new Float32Array(r);h.set(t),i&&o(h,i,0,t.length);let l=t.length;for(const[c,u]of n)h.set(c,l),u&&o(h,u,l,c.length),l+=c.length;return h}else{const h=new Array(r);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 n){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 cs("Positions are required",Hs.MeshInvalidPositionsError);const e=(s,n)=>{const r=A.DeduceStride(s);if(n.length%r!==0)throw new Error("The "+s+"s array count must be a multiple of "+r);return n.length/r},t=e(A.PositionKind,this.positions),i=(s,n)=>{const r=e(s,n);if(r!==t)throw new Error("The "+s+"s element count ("+r+") does not match the positions count ("+t+")")};this.normals&&i(A.NormalKind,this.normals),this.tangents&&i(A.TangentKind,this.tangents),this.uvs&&i(A.UVKind,this.uvs),this.uvs2&&i(A.UV2Kind,this.uvs2),this.uvs3&&i(A.UV3Kind,this.uvs3),this.uvs4&&i(A.UV4Kind,this.uvs4),this.uvs5&&i(A.UV5Kind,this.uvs5),this.uvs6&&i(A.UV6Kind,this.uvs6),this.colors&&i(A.ColorKind,this.colors),this.matricesIndices&&i(A.MatricesIndicesKind,this.matricesIndices),this.matricesWeights&&i(A.MatricesWeightsKind,this.matricesWeights),this.matricesIndicesExtra&&i(A.MatricesIndicesExtraKind,this.matricesIndicesExtra),this.matricesWeightsExtra&&i(A.MatricesWeightsExtraKind,this.matricesWeightsExtra)}clone(){const e=this.serialize();return j.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=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 j._ExtractFrom(e,t,i)}static ExtractFromGeometry(e,t,i){return j._ExtractFrom(e,t,i)}static _ExtractFrom(e,t,i){const s=new j;if(e.isVerticesDataPresent(A.PositionKind)&&(s.positions=e.getVerticesData(A.PositionKind,t,i)),e.isVerticesDataPresent(A.NormalKind)&&(s.normals=e.getVerticesData(A.NormalKind,t,i)),e.isVerticesDataPresent(A.TangentKind)&&(s.tangents=e.getVerticesData(A.TangentKind,t,i)),e.isVerticesDataPresent(A.UVKind)&&(s.uvs=e.getVerticesData(A.UVKind,t,i)),e.isVerticesDataPresent(A.UV2Kind)&&(s.uvs2=e.getVerticesData(A.UV2Kind,t,i)),e.isVerticesDataPresent(A.UV3Kind)&&(s.uvs3=e.getVerticesData(A.UV3Kind,t,i)),e.isVerticesDataPresent(A.UV4Kind)&&(s.uvs4=e.getVerticesData(A.UV4Kind,t,i)),e.isVerticesDataPresent(A.UV5Kind)&&(s.uvs5=e.getVerticesData(A.UV5Kind,t,i)),e.isVerticesDataPresent(A.UV6Kind)&&(s.uvs6=e.getVerticesData(A.UV6Kind,t,i)),e.isVerticesDataPresent(A.ColorKind)){const n=e.geometry||e,r=n.getVertexBuffer(A.ColorKind),o=n.getVerticesData(A.ColorKind,t,i);if(r.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(r.getSize()===4)s.colors=o;else throw new Error("Unexpected number of color components: ".concat(r.getSize()))}return e.isVerticesDataPresent(A.MatricesIndicesKind)&&(s.matricesIndices=e.getVerticesData(A.MatricesIndicesKind,t,i)),e.isVerticesDataPresent(A.MatricesWeightsKind)&&(s.matricesWeights=e.getVerticesData(A.MatricesWeightsKind,t,i)),e.isVerticesDataPresent(A.MatricesIndicesExtraKind)&&(s.matricesIndicesExtra=e.getVerticesData(A.MatricesIndicesExtraKind,t,i)),e.isVerticesDataPresent(A.MatricesWeightsExtraKind)&&(s.matricesWeightsExtra=e.getVerticesData(A.MatricesWeightsExtraKind,t,i)),s.indices=e.getIndices(t,i),s}static CreateRibbon(e){throw ye("ribbonBuilder")}static CreateBox(e){throw ye("boxBuilder")}static CreateTiledBox(e){throw ye("tiledBoxBuilder")}static CreateTiledPlane(e){throw ye("tiledPlaneBuilder")}static CreateSphere(e){throw ye("sphereBuilder")}static CreateCylinder(e){throw ye("cylinderBuilder")}static CreateTorus(e){throw ye("torusBuilder")}static CreateLineSystem(e){throw ye("linesBuilder")}static CreateDashedLines(e){throw ye("linesBuilder")}static CreateGround(e){throw ye("groundBuilder")}static CreateTiledGround(e){throw ye("groundBuilder")}static CreateGroundFromHeightMap(e){throw ye("groundBuilder")}static CreatePlane(e){throw ye("planeBuilder")}static CreateDisc(e){throw ye("discBuilder")}static CreatePolygon(e,t,i,s,n,r,o){throw ye("polygonBuilder")}static CreateIcoSphere(e){throw ye("icoSphereBuilder")}static CreatePolyhedron(e){throw ye("polyhedronBuilder")}static CreateCapsule(e={orientation:v.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6}){throw ye("capsuleBuilder")}static CreateTorusKnot(e){throw ye("torusKnotBuilder")}static ComputeNormals(e,t,i,s){let n=0,r=0,o=0,h=0,l=0,c=0,u=0,f=0,d=0,_=0,p=0,g=0,m=0,b=0,I=0,T=0,x=0,y=0,R=0,E=0,C=!1,S=!1,w=!1,P=!1,G=1,L=0,W=null;s&&(C=!!s.facetNormals,S=!!s.facetPositions,w=!!s.facetPartitioning,G=s.useRightHandedSystem===!0?-1:1,L=s.ratio||0,P=!!s.depthSort,W=s.distanceTo,P&&W===void 0&&(W=v.Zero()));let K=0,ce=0,$=0,z=0;for(w&&s&&s.bbSize&&(K=s.subDiv.X*L/s.bbSize.x,ce=s.subDiv.Y*L/s.bbSize.y,$=s.subDiv.Z*L/s.bbSize.z,z=s.subDiv.max*s.subDiv.max,s.facetPartitioning.length=0),n=0;n<e.length;n++)i[n]=0;const k=t.length/3|0;for(n=0;n<k;n++){if(g=t[n*3]*3,m=g+1,b=g+2,I=t[n*3+1]*3,T=I+1,x=I+2,y=t[n*3+2]*3,R=y+1,E=y+2,r=e[g]-e[I],o=e[m]-e[T],h=e[b]-e[x],l=e[y]-e[I],c=e[R]-e[T],u=e[E]-e[x],f=G*(o*u-h*c),d=G*(h*l-r*u),_=G*(r*c-o*l),p=Math.sqrt(f*f+d*d+_*_),p=p===0?1:p,f/=p,d/=p,_/=p,C&&s&&(s.facetNormals[n].x=f,s.facetNormals[n].y=d,s.facetNormals[n].z=_),S&&s&&(s.facetPositions[n].x=(e[g]+e[I]+e[y])/3,s.facetPositions[n].y=(e[m]+e[T]+e[R])/3,s.facetPositions[n].z=(e[b]+e[x]+e[E])/3),w&&s){const M=Math.floor((s.facetPositions[n].x-s.bInfo.minimum.x*L)*K),V=Math.floor((s.facetPositions[n].y-s.bInfo.minimum.y*L)*ce),q=Math.floor((s.facetPositions[n].z-s.bInfo.minimum.z*L)*$),he=Math.floor((e[g]-s.bInfo.minimum.x*L)*K),pe=Math.floor((e[m]-s.bInfo.minimum.y*L)*ce),se=Math.floor((e[b]-s.bInfo.minimum.z*L)*$),ue=Math.floor((e[I]-s.bInfo.minimum.x*L)*K),me=Math.floor((e[T]-s.bInfo.minimum.y*L)*ce),ne=Math.floor((e[x]-s.bInfo.minimum.z*L)*$),Ie=Math.floor((e[y]-s.bInfo.minimum.x*L)*K),Se=Math.floor((e[R]-s.bInfo.minimum.y*L)*ce),Q=Math.floor((e[E]-s.bInfo.minimum.z*L)*$),be=he+s.subDiv.max*pe+z*se,Be=ue+s.subDiv.max*me+z*ne,ze=Ie+s.subDiv.max*Se+z*Q,Ke=M+s.subDiv.max*V+z*q;s.facetPartitioning[Ke]=s.facetPartitioning[Ke]?s.facetPartitioning[Ke]:new Array,s.facetPartitioning[be]=s.facetPartitioning[be]?s.facetPartitioning[be]:new Array,s.facetPartitioning[Be]=s.facetPartitioning[Be]?s.facetPartitioning[Be]:new Array,s.facetPartitioning[ze]=s.facetPartitioning[ze]?s.facetPartitioning[ze]:new Array,s.facetPartitioning[be].push(n),Be!=be&&s.facetPartitioning[Be].push(n),ze==Be||ze==be||s.facetPartitioning[ze].push(n),Ke==be||Ke==Be||Ke==ze||s.facetPartitioning[Ke].push(n)}if(P&&s&&s.facetPositions){const M=s.depthSortedFacets[n];M.ind=n*3,M.sqDistance=v.DistanceSquared(s.facetPositions[n],W)}i[g]+=f,i[m]+=d,i[b]+=_,i[I]+=f,i[T]+=d,i[x]+=_,i[y]+=f,i[R]+=d,i[E]+=_}for(n=0;n<i.length/3;n++)f=i[n*3],d=i[n*3+1],_=i[n*3+2],p=Math.sqrt(f*f+d*d+_*_),p=p===0?1:p,f/=p,d/=p,_/=p,i[n*3]=f,i[n*3+1]=d,i[n*3+2]=_}static _ComputeSides(e,t,i,s,n,r,o){const h=i.length,l=s.length;let c,u;switch(e=e||j.DEFAULTSIDE,e){case j.FRONTSIDE:break;case j.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 j.DOUBLESIDE:{const f=t.length,d=f/3;for(let g=0;g<f;g++)t[f+g]=t[g];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 _=n.length;let p=0;for(p=0;p<_;p++)n[p+_]=n[p];for(r=r||new Pe(0,0,1,1),o=o||new Pe(0,0,1,1),p=0,c=0;c<_/2;c++)n[p]=r.x+(r.z-r.x)*n[p],n[p+1]=r.y+(r.w-r.y)*n[p+1],n[p+_]=o.x+(o.z-o.x)*n[p+_],n[p+_+1]=o.y+(o.w-o.y)*n[p+_+1],p+=2;break}}}static Parse(e){const t=new j,i=e.positions;i&&t.set(i,A.PositionKind);const s=e.normals;s&&t.set(s,A.NormalKind);const n=e.tangents;n&&t.set(n,A.TangentKind);const r=e.uvs;r&&t.set(r,A.UVKind);const o=e.uvs2;o&&t.set(o,A.UV2Kind);const h=e.uvs3;h&&t.set(h,A.UV3Kind);const l=e.uvs4;l&&t.set(l,A.UV4Kind);const c=e.uvs5;c&&t.set(c,A.UV5Kind);const u=e.uvs6;u&&t.set(u,A.UV6Kind);const f=e.colors;f&&(t.set(H.CheckColors4(f,i.length/3),A.ColorKind),e.hasVertexAlpha!==void 0&&(t.hasVertexAlpha=e.hasVertexAlpha));const d=e.matricesIndices;d&&t.set(d,A.MatricesIndicesKind);const _=e.matricesWeights;_&&t.set(_,A.MatricesWeightsKind);const p=e.indices;p&&(t.indices=p);const g=e.materialInfos;if(g){t.materialInfos=[];for(const m of g){const b=new Ta;b.indexCount=m.indexCount,b.indexStart=m.indexStart,b.verticesCount=m.verticesCount,b.verticesStart=m.verticesStart,b.materialIndex=m.materialIndex,t.materialInfos.push(b)}}return t}static ImportVertexData(e,t){const i=j.Parse(e);t.setAllVerticesData(i,e.updatable)}}j.FRONTSIDE=0;j.BACKSIDE=1;j.DOUBLESIDE=2;j.DEFAULTSIDE=0;j._UniqueIDGenerator=0;D([rs.filter((...[a])=>!Array.isArray(a))],j,"_TransformVector3Coordinates",null);D([rs.filter((...[a])=>!Array.isArray(a))],j,"_TransformVector3Normals",null);D([rs.filter((...[a])=>!Array.isArray(a))],j,"_TransformVector4Normals",null);D([rs.filter((...[a])=>!Array.isArray(a))],j,"_FlipFaces",null);class Mp{constructor(){this._doNotSerialize=!1,this._isDisposed=!1,this._sceneRootNodesIndex=-1,this._isEnabled=!0,this._isParentEnabled=!0,this._isReady=!0,this._onEnabledStateChangedObservable=new Z,this._onClonedObservable=new Z}}class bt{static AddNodeConstructor(e,t){this._NodeConstructors[e]=t}static Construct(e,t,i,s){const n=this._NodeConstructors[e];return n?n(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 Mp,this.state="",this.metadata=null,this.reservedDataStore=null,this._accessibilityTag=null,this.onAccessibilityTagChangedObservable=new Z,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=O.Identity(),this._worldMatrixDeterminant=0,this._worldMatrixDeterminantIsDirty=!0,this._animationPropertiesOverride=null,this._isNode=!0,this.onDisposeObservable=new Z,this._onDisposeObserver=null,this._behaviors=new Array,this.name=e,this.id=e,this._scene=t||Ee.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 n=this._children[s];(!i||i(n))&&e.push(n),t||n._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]=bt._AnimationRangeFactory(e,t,i);for(let s=0,n=this.animations.length;s<n;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=Ae.Clone(()=>new bt(e,this.getScene()),this);if(t&&(s.parent=t),!i){const n=this.getDescendants(!0);for(let r=0;r<n.length;r++){const o=n[r];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 n=this.getAnimationRange(e);return n?this._scene.beginAnimation(this,n.from,n.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=O.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 n=t.ranges[s];e.createAnimationRange(n.name,n.from,n.to)}}getHierarchyBoundingVectors(e=!0,t=null){this.getScene().incrementRenderId(),this.computeWorldMatrix(!0);let i,s;const n=this;if(n.getBoundingInfo&&n.subMeshes){const r=n.getBoundingInfo();i=r.boundingBox.minimumWorld.clone(),s=r.boundingBox.maximumWorld.clone()}else i=new v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s=new v(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);if(e){const r=this.getDescendants(!1);for(const o of r){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;v.CheckExtends(u,i,s),v.CheckExtends(f,i,s)}}return{min:i,max:s}}}bt._AnimationRangeFactory=(a,e,t)=>{throw ye("AnimationRange")};bt._NodeConstructors={};D([B()],bt.prototype,"name",void 0);D([B()],bt.prototype,"id",void 0);D([B()],bt.prototype,"uniqueId",void 0);D([B()],bt.prototype,"state",void 0);D([B()],bt.prototype,"metadata",void 0);const Pp=O.Compose(v.One(),re.FromEulerAngles(0,Math.PI,0),v.Zero());class Te extends bt{get billboardMode(){return this._billboardMode}set billboardMode(e){this._billboardMode!==e&&(this._billboardMode=e,this._cache.useBillboardPosition=(this._billboardMode&Te.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!==Te.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 v(0,0,1),this._up=new v(0,1,0),this._right=new v(1,0,0),this._position=v.Zero(),this._rotation=v.Zero(),this._rotationQuaternion=null,this._scaling=v.One(),this._transformToBoneReferal=null,this._isAbsoluteSynced=!1,this._billboardMode=Te.BILLBOARDMODE_NONE,this._preserveParentRotationForBillboard=!1,this.scalingDeterminant=1,this._infiniteDistance=!1,this.ignoreNonUniformScaling=!1,this.reIntegrateRotationIntoRotationQuaternion=!1,this._poseMatrix=null,this._localMatrix=O.Zero(),this._usePivotMatrix=!1,this._absolutePosition=v.Zero(),this._absoluteScaling=v.Zero(),this._absoluteRotationQuaternion=re.Identity(),this._pivotMatrix=O.Identity(),this._postMultiplyPivotMatrix=!1,this._isWorldMatrixFrozen=!1,this._indexInSceneTransformNodesArray=-1,this.onAfterWorldMatrixUpdateObservable=new Z,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 v.TransformNormalFromFloatsToRef(0,0,this.getScene().useRightHandedSystem?-1:1,this.getWorldMatrix(),this._forward),this._forward.normalize()}get up(){return v.TransformNormalFromFloatsToRef(0,1,0,this.getWorldMatrix(),this._up),this._up.normalize()}get right(){return v.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=O.Identity()),this._poseMatrix}_isSynchronized(){const e=this._cache;return!(this._billboardMode!==e.billboardMode||this._billboardMode!==Te.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=O.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 n of this.getChildTransformNodes(!0))n.instantiateHierarchy(s,t,i);return s}freezeWorldMatrix(e=null,t=!1){return e?t?(this._rotation.setAll(0),this._rotationQuaternion=this._rotationQuaternion||re.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 n=N.Matrix[0];this.parent.getWorldMatrix().invertToRef(n),v.TransformCoordinatesFromFloatsToRef(t,i,s,n,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=v.TransformNormal(e,this._localMatrix),this}getPositionExpressedInLocalSpace(){this.computeWorldMatrix();const e=N.Matrix[0];return this._localMatrix.invertToRef(e),v.TransformNormal(this.position,e)}locallyTranslate(e){return this.computeWorldMatrix(!0),this.position=v.TransformCoordinates(e,this._localMatrix),this}lookAt(e,t=0,i=0,s=0,n=0){const r=Te._LookAtVectorCache,o=n===0?this.position:this.getAbsolutePosition();if(e.subtractToRef(o,r),this.setDirection(r,t,i,s),n===1&&this.parent)if(this.rotationQuaternion){const h=N.Matrix[0];this.rotationQuaternion.toRotationMatrix(h);const l=N.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(l),l.invert(),h.multiplyToRef(l,h),this.rotationQuaternion.fromRotationMatrix(h)}else{const h=N.Quaternion[0];re.FromEulerVectorToRef(this.rotation,h);const l=N.Matrix[0];h.toRotationMatrix(l);const c=N.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=v.Zero();return this.getDirectionToRef(e,t),t}getDirectionToRef(e,t){return v.TransformNormalToRef(e,this.getWorldMatrix(),t),this}setDirection(e,t=0,i=0,s=0){const n=-Math.atan2(e.z,e.x)+Math.PI/2,r=Math.sqrt(e.x*e.x+e.z*e.z),o=-Math.atan2(e.y,r);return this.rotationQuaternion?re.RotationYawPitchRollToRef(n+t,o+i,s,this.rotationQuaternion):(this.rotation.x=o+i,this.rotation.y=n+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=N.Matrix[0];i.invertToRef(s),e=v.TransformCoordinates(e,s)}return this.setPivotMatrix(O.Translation(-e.x,-e.y,-e.z),!0)}getPivotPoint(){const e=v.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=v.Zero();return this.getAbsolutePivotPointToRef(e),e}getAbsolutePivotPointToRef(e){return this.getPivotPointToRef(e),v.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=N.Quaternion[0],n=N.Vector3[0],r=N.Vector3[1],o=N.Matrix[1];O.IdentityToRef(o);const h=N.Matrix[0];this.computeWorldMatrix(!0);let l=this.rotationQuaternion;return l||(l=Te._TmpRotation,re.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,l)),O.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(r,s,n,t?this:void 0),this.rotationQuaternion?this.rotationQuaternion.copyFrom(s):s.toEulerAnglesToRef(this.rotation),this.scaling.copyFrom(r),this.position.copyFrom(n),this.parent=e,i&&this.setPivotMatrix(O.Identity()),this}addChild(e,t=!1){return e.setParent(this,t),this}removeChild(e,t=!1){return 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=re.RotationAxisToRef(e,t,Te._RotationAxisCache),this.rotationQuaternion.multiplyToRef(s,this.rotationQuaternion);else{if(this.parent){const n=this.parent.getWorldMatrix(),r=N.Matrix[0];n.invertToRef(r),e=v.TransformNormal(e,r),n.determinant()<0&&(t*=-1)}s=re.RotationAxisToRef(e,t,Te._RotationAxisCache),s.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}return this}rotateAround(e,t,i){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=re.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.setAll(0));const s=N.Vector3[0],n=N.Vector3[1],r=N.Vector3[2],o=N.Quaternion[0],h=N.Matrix[0],l=N.Matrix[1],c=N.Matrix[2],u=N.Matrix[3];return e.subtractToRef(this.position,s),O.TranslationToRef(s.x,s.y,s.z,h),O.TranslationToRef(-s.x,-s.y,-s.z,l),O.RotationAxisToRef(t,i,c),l.multiplyToRef(c,u),u.multiplyToRef(h,u),u.decompose(n,o,r),this.position.addInPlace(r),o.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion),this}translate(e,t,i){const s=e.scale(t);if(!i||i===0){const n=this.getPositionExpressedInLocalSpace().add(s);this.setPositionWithLocalVector(n)}else this.setAbsolutePosition(this.getAbsolutePosition().add(s));return this}addRotation(e,t,i){let s;this.rotationQuaternion?s=this.rotationQuaternion:(s=N.Quaternion[1],re.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,s));const n=N.Quaternion[0];return re.RotationYawPitchRollToRef(t,e,i,n),s.multiplyInPlace(n),this.rotationQuaternion||s.toEulerAnglesToRef(this.rotation),this}_getEffectiveParent(){return this.parent}isWorldMatrixCameraDependent(){return this._infiniteDistance&&!this.parent||this._billboardMode!==Te.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 n=this._getEffectiveParent(),r=Te._TmpScaling;let o=this._position;if(this._infiniteDistance&&!this.parent&&t){const l=t.getWorldMatrix(),c=new v(l.m[12],l.m[13],l.m[14]);o=Te._TmpTranslation,o.copyFromFloats(this._position.x+c.x,this._position.y+c.y,this._position.z+c.z)}r.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(re.RotationYawPitchRoll(this._rotation.y,this._rotation.x,this._rotation.z)),this._rotation.copyFromFloats(0,0,0))):(h=Te._TmpRotation,re.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,h)),this._usePivotMatrix){const l=N.Matrix[1];O.ScalingToRef(r.x,r.y,r.z,l);const c=N.Matrix[0];h.toRotationMatrix(c),this._pivotMatrix.multiplyToRef(l,N.Matrix[4]),N.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 O.ComposeToRef(r,h,o,this._localMatrix);if(n&&n.getWorldMatrix){if(e&&n.computeWorldMatrix(e),s.useBillboardPath){if(this._transformToBoneReferal){const f=this.parent;f.getSkeleton().prepare(),f.getFinalMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),N.Matrix[7])}else N.Matrix[7].copyFrom(n.getWorldMatrix());const l=N.Vector3[5],c=N.Vector3[6],u=N.Quaternion[0];N.Matrix[7].decompose(c,u,l),O.ScalingToRef(c.x,c.y,c.z,N.Matrix[7]),N.Matrix[7].setTranslation(l),Te.BillboardUseParentOrientation&&(this._position.applyRotationQuaternionToRef(u,l),this._localMatrix.setTranslation(l)),this._localMatrix.multiplyToRef(N.Matrix[7],this._worldMatrix)}else if(this._transformToBoneReferal){const l=this.parent;l.getSkeleton().prepare(),this._localMatrix.multiplyToRef(l.getFinalMatrix(),N.Matrix[6]),N.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),this._worldMatrix)}else this._localMatrix.multiplyToRef(n.getWorldMatrix(),this._worldMatrix);this._markSyncedWithParent()}else this._worldMatrix.copyFrom(this._localMatrix);if(s.useBillboardPath&&t&&this.billboardMode&&!s.useBillboardPosition){const l=N.Vector3[0];if(this._worldMatrix.getTranslationToRef(l),N.Matrix[1].copyFrom(t.getViewMatrix()),this._scene.useRightHandedSystem&&N.Matrix[1].multiplyToRef(Pp,N.Matrix[1]),N.Matrix[1].setTranslationFromFloats(0,0,0),N.Matrix[1].invertToRef(N.Matrix[0]),(this.billboardMode&Te.BILLBOARDMODE_ALL)!==Te.BILLBOARDMODE_ALL){N.Matrix[0].decompose(void 0,N.Quaternion[0],void 0);const c=N.Vector3[1];N.Quaternion[0].toEulerAnglesToRef(c),(this.billboardMode&Te.BILLBOARDMODE_X)!==Te.BILLBOARDMODE_X&&(c.x=0),(this.billboardMode&Te.BILLBOARDMODE_Y)!==Te.BILLBOARDMODE_Y&&(c.y=0),(this.billboardMode&Te.BILLBOARDMODE_Z)!==Te.BILLBOARDMODE_Z&&(c.z=0),O.RotationYawPitchRollToRef(c.y,c.x,c.z,N.Matrix[0])}this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(N.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(N.Vector3[0])}else if(s.useBillboardPath&&t&&s.useBillboardPosition){const l=N.Vector3[0];this._worldMatrix.getTranslationToRef(l);const c=t.globalPosition;this._worldMatrix.invertToRef(N.Matrix[1]);const u=N.Vector3[1];v.TransformCoordinatesToRef(c,N.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),_=-Math.atan2(u.y,d);if(re.RotationYawPitchRollToRef(f,_,0,N.Quaternion[0]),(this.billboardMode&Te.BILLBOARDMODE_ALL)!==Te.BILLBOARDMODE_ALL){const p=N.Vector3[1];N.Quaternion[0].toEulerAnglesToRef(p),(this.billboardMode&Te.BILLBOARDMODE_X)!==Te.BILLBOARDMODE_X&&(p.x=0),(this.billboardMode&Te.BILLBOARDMODE_Y)!==Te.BILLBOARDMODE_Y&&(p.y=0),(this.billboardMode&Te.BILLBOARDMODE_Z)!==Te.BILLBOARDMODE_Z&&(p.z=0),O.RotationYawPitchRollToRef(p.y,p.x,p.z,N.Matrix[0])}else O.FromQuaternionToRef(N.Quaternion[0],N.Matrix[0]);this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(N.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(N.Vector3[0])}return this.ignoreNonUniformScaling?this._updateNonUniformScalingState(!1):this._scaling.isNonUniformWithinEpsilon(1e-6)?this._updateNonUniformScalingState(!0):n&&n._nonUniformScaling?this._updateNonUniformScalingState(n._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=O.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 n=N.Matrix[0];s._localMatrix.multiplyToRef(this._localMatrix,n);const r=N.Quaternion[0];n.decompose(s.scaling,r,s.position),s.rotationQuaternion?s.rotationQuaternion.copyFrom(r):r.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=re.Identity()),this._worldMatrix=O.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),v.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=Ae.Clone(()=>new Te(e,this.getScene()),this);if(s.name=e,s.id=e,t&&(s.parent=t),!i){const n=this.getDescendants(!0);for(let r=0;r<n.length;r++){const o=n[r];o.clone&&o.clone(e+"."+o.name,s)}}return s}serialize(e){const t=Ae.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(),Ae.AppendSerializedAnimations(this,t),t.ranges=this.serializeAnimationRanges(),t}static Parse(e,t,i){const s=Ae.Parse(()=>new Te(e.name,t),e,t,i);if(e.localMatrix?s.setPreTransformMatrix(O.FromArray(e.localMatrix)):e.pivotMatrix&&s.setPivotMatrix(O.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 n=0;n<e.animations.length;n++){const r=e.animations[n],o=ys("BABYLON.Animation");o&&s.animations.push(o.Parse(r))}bt.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 Te),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,n=null;t&&(this.rotationQuaternion?(n=this.rotationQuaternion.clone(),this.rotationQuaternion.copyFromFloats(0,0,0,1)):this.rotation&&(s=this.rotation.clone(),this.rotation.copyFromFloats(0,0,0)));const r=this.getHierarchyBoundingVectors(e,i),o=r.max.subtract(r.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&&n?this.rotationQuaternion.copyFrom(n):this.rotation&&s&&this.rotation.copyFrom(s)),this}_syncAbsoluteScalingAndRotation(){this._isAbsoluteSynced||(this._worldMatrix.decompose(this._absoluteScaling,this._absoluteRotationQuaternion),this._isAbsoluteSynced=!0)}}Te.BILLBOARDMODE_NONE=0;Te.BILLBOARDMODE_X=1;Te.BILLBOARDMODE_Y=2;Te.BILLBOARDMODE_Z=4;Te.BILLBOARDMODE_ALL=7;Te.BILLBOARDMODE_USE_POSITION=128;Te.BillboardUseParentOrientation=!1;Te._TmpRotation=re.Zero();Te._TmpScaling=v.Zero();Te._TmpTranslation=v.Zero();Te._LookAtVectorCache=new v(0,0,0);Te._RotationAxisCache=new re;D([yi("position")],Te.prototype,"_position",void 0);D([yi("rotation")],Te.prototype,"_rotation",void 0);D([Jd("rotationQuaternion")],Te.prototype,"_rotationQuaternion",void 0);D([yi("scaling")],Te.prototype,"_scaling",void 0);D([B("billboardMode")],Te.prototype,"_billboardMode",void 0);D([B()],Te.prototype,"scalingDeterminant",void 0);D([B("infiniteDistance")],Te.prototype,"_infiniteDistance",void 0);D([B()],Te.prototype,"ignoreNonUniformScaling",void 0);D([B()],Te.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(A.NormalKind))return null;let i=this.pickedMesh.getIndices();(i==null?void 0:i.length)===0&&(i=null);let s;const n=N.Vector3[0],r=N.Vector3[1],o=N.Vector3[2];if(t){const l=this.pickedMesh.getVerticesData(A.NormalKind);let c=i?v.FromArrayToRef(l,i[this.faceId*3]*3,n):n.copyFromFloats(l[this.faceId*3*3],l[this.faceId*3*3+1],l[this.faceId*3*3+2]),u=i?v.FromArrayToRef(l,i[this.faceId*3+1]*3,r):r.copyFromFloats(l[(this.faceId*3+1)*3],l[(this.faceId*3+1)*3+1],l[(this.faceId*3+1)*3+2]),f=i?v.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 v(c.x+u.x+f.x,c.y+u.y+f.y,c.z+u.z+f.z)}else{const l=this.pickedMesh.getVerticesData(A.PositionKind),c=i?v.FromArrayToRef(l,i[this.faceId*3]*3,n):n.copyFromFloats(l[this.faceId*3*3],l[this.faceId*3*3+1],l[this.faceId*3*3+2]),u=i?v.FromArrayToRef(l,i[this.faceId*3+1]*3,r):r.copyFromFloats(l[(this.faceId*3+1)*3],l[(this.faceId*3+1)*3+1],l[(this.faceId*3+1)*3+2]),f=i?v.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),_=f.subtract(u);s=v.Cross(d,_)}const h=(l,c)=>{let u=l.getWorldMatrix();l.nonUniformScaling&&(N.Matrix[0].copyFrom(u),u=N.Matrix[0],u.setTranslationFromFloats(0,0,0),u.invert(),u.transposeToRef(N.Matrix[1]),u=N.Matrix[1]),v.TransformNormalToRef(c,u,c)};if(e&&h(this.pickedMesh,s),this.ray){const l=N.Vector3[0].copyFrom(s);e||h(this.pickedMesh,l),v.Dot(l,this.ray.direction)>0&&s.negateInPlace()}return s.normalize(),s}getTextureCoordinates(e=A.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=oe.FromArray(i,t[this.faceId*3]*2),n=oe.FromArray(i,t[this.faceId*3+1]*2),r=oe.FromArray(i,t[this.faceId*3+2]*2);return s=s.scale(this.bu),n=n.scale(this.bv),r=r.scale(1-this.bu-this.bv),new oe(s.x+n.x+r.x,s.y+n.y+r.y)}}class wp{constructor(){this._checkCollisions=!1,this._collisionMask=-1,this._collisionGroup=-1,this._surroundingMeshes=null,this._collider=null,this._oldPositionForCollisions=new v(0,0,0),this._diffPositionForCollisions=new v(0,0,0),this._collisionResponse=!0}}function Dp(a,e,t){let i=null;switch(e){case A.PositionKind:i=s=>s.getPositions();break;case A.NormalKind:i=s=>s.getNormals();break;case A.TangentKind:i=s=>s.getTangents();break;case A.UVKind:i=s=>s.getUVs();break;default:return}for(let s=0;s<a.length;s++){let n=a[s];for(let r=0;r<t.numTargets;r++){const o=t.getTarget(r),h=o.influence;if(h!==0){const l=i(o);l&&(n+=(l[s]-a[s])*h)}}a[s]=n}}function Fp(a,e,t,i,s,n,r){const o=N.Vector3[0],h=N.Matrix[0],l=N.Matrix[1],c=e===A.NormalKind?v.TransformNormalFromFloatsToRef:v.TransformCoordinatesFromFloatsToRef;for(let u=0,f=0;u<a.length;u+=3,f+=4){h.reset();let d,_;for(d=0;d<4;d++)_=s[f+d],_>0&&(O.FromFloat32ArrayToRefScaled(t,Math.floor(i[f+d]*16),_,l),h.addToSelf(l));if(n&&r)for(d=0;d<4;d++)_=r[f+d],_>0&&(O.FromFloat32ArrayToRefScaled(t,Math.floor(n[f+d]*16),_,l),h.addToSelf(l));c(a[u],a[u+1],a[u+2],h,o),o.toArray(a,u)}}class Op{constructor(){this.facetNb=0,this.partitioningSubdivisions=10,this.partitioningBBoxRatio=1.01,this.facetDataEnabled=!1,this.facetParameters={},this.bbSize=v.Zero(),this.subDiv={max:1,X:1,Y:1,Z:1},this.facetDepthSort=!1,this.facetDepthSortEnabled=!1}}class Bp{constructor(){this._hasVertexAlpha=!1,this._useVertexColors=!0,this._numBoneInfluencers=4,this._applyFog=!0,this._receiveShadows=!1,this._facetData=new Op,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=null,this._currentLODIsUpToDate=!1,this._collisionRetryCount=3,this._morphTargetManager=null,this._renderingGroupId=0,this._bakedVertexAnimationManager=null,this._material=null,this._positions=null,this._pointerOverDisableMeshTesting=!1,this._meshCollisionData=new wp,this._enableDistantPicking=!1,this._rawBoundingInfo=null,this._sideOrientationHint=!1,this._inheritVisibility=!1}}class Qe extends Te{static get BILLBOARDMODE_NONE(){return Te.BILLBOARDMODE_NONE}static get BILLBOARDMODE_X(){return Te.BILLBOARDMODE_X}static get BILLBOARDMODE_Y(){return Te.BILLBOARDMODE_Y}static get BILLBOARDMODE_Z(){return Te.BILLBOARDMODE_Z}static get BILLBOARDMODE_ALL(){return Te.BILLBOARDMODE_ALL}static get BILLBOARDMODE_USE_POSITION(){return Te.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){var t;return(t=this._internalAbstractMeshDataInfo._materialForRenderPass)==null?void 0:t[e]}setMaterialForRenderPass(e,t){this.resetDrawCache(e),this._internalAbstractMeshDataInfo._materialForRenderPass||(this._internalAbstractMeshDataInfo._materialForRenderPass=[]),this._internalAbstractMeshDataInfo._materialForRenderPass[e]=t}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 Bp,this._waitingMaterialId=null,this._waitingMorphTargetManagerId=null,this.cullingStrategy=Qe.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,this.onCollideObservable=new Z,this.onCollisionPositionChangeObservable=new Z,this.onMaterialChangedObservable=new Z,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=de.Red(),this.outlineWidth=.02,this.overlayColor=de.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 v(.5,1,.5),this.ellipsoidOffset=new v(0,0,0),this.edgesWidth=1,this.edgesColor=new H(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 Z,this._onCollisionPositionChange=(i,s,n=null)=>{s.subtractToRef(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length()>ae.CollisionsEpsilon&&this.position.addInPlace(this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),n&&this.onCollideObservable.notifyObservers(n),this.onCollisionPositionChangeObservable.notifyObservers(this.position)},t=this.getScene(),t.addMesh(this),this._resyncLightSources(),this._uniformBuffer=new fe(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!==Te.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(){var e;return(e=this.rawBoundingInfo)!=null?e:this.getBoundingInfo()}setBoundingInfo(e){return this._boundingInfo=e,this}get hasBoundingInfo(){return this._boundingInfo!==null}buildBoundingInfo(e,t,i){return this._boundingInfo=new ri(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(A.MatricesIndicesKind)&&this.isVerticesDataPresent(A.MatricesWeightsKind)}_preActivate(){}_preActivateForIntermediateRendering(e){}_activate(e,t){return this._renderId=e,!0}_postActivate(){}_freeze(){}_unFreeze(){}getWorldMatrix(){return this._masterMesh&&this.billboardMode===Te.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 O;(this.rotationQuaternion?this.rotationQuaternion:re.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(s);const r=v.Zero(),o=this.definedFacingForward?-1:1;return v.TransformCoordinatesFromFloatsToRef(e*o,t,i*o,s,r),r}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 v(e*s,t,i*s)}_refreshBoundingInfo(e,t){if(e){const i=Ic(e,0,this.getTotalVertices(),t);this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new ri(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 ri(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,n,r,o){Fp(e,t,i,s,n,r,o)}_getData(e,t,i=A.PositionKind){const s=e.cache,n=r=>{if(s){const o=s._vertexData||(s._vertexData={});return o[r]||this.copyVerticesData(r,o),o[r]}return this.getVerticesData(r)};if(t||(t=n(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&&Dp(t,i,this.morphTargetManager),e.applySkeleton&&this.skeleton){const r=n(A.MatricesIndicesKind),o=n(A.MatricesWeightsKind);if(o&&r){const h=this.numBoneInfluencers>4,l=h?n(A.MatricesIndicesExtraKind):null,c=h?n(A.MatricesWeightsExtraKind):null,u=this.skeleton.getTransformMatrices(this);Qe._ApplySkeleton(t,i,u,r,o,l,c)}}if(e.updatePositionsArray!==!1&&i===A.PositionKind){const r=this._internalAbstractMeshDataInfo._positions||[],o=r.length;if(r.length=t.length/3,o<r.length)for(let h=o;h<r.length;h++)r[h]=new v;for(let h=0,l=0;h<r.length;h++,l+=3)r[h].copyFromFloats(t[l],t[l+1],t[l+2]);this._internalAbstractMeshDataInfo._positions=r}return t}getNormalsData(e=!1,t=!1){return this._getData({applySkeleton:e,applyMorph:t,updatePositionsArray:!1},null,A.NormalKind)}getPositionData(e=!1,t=!1,i=null){return this._getData({applySkeleton:e,applyMorph:t,updatePositionsArray:!1},i,A.PositionKind)}_updateBoundingInfo(){return this._boundingInfo?this._boundingInfo.update(this.worldMatrixFromCache):this._boundingInfo=new ri(v.Zero(),v.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(),n=e.getBoundingInfo();if(s.intersects(n,t))return!0;if(i){for(const r of this.getChildMeshes())if(r.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){var s;if(this._generatePointsArray(),!this._positions)return this;if(!e._lastColliderWorldVertices||!e._lastColliderTransformMatrix.equals(t)){e._lastColliderTransformMatrix=t.clone(),e._lastColliderWorldVertices=[],e._trianglePlanes=[];const n=e.verticesStart,r=e.verticesStart+e.verticesCount;for(let o=n;o<r;o++)e._lastColliderWorldVertices.push(v.TransformCoordinates(this._positions[o],t))}return i._collide(e._trianglePlanes,e._lastColliderWorldVertices,this.getIndices(),e.indexStart,e.indexStart+e.indexCount,e.verticesStart,!!e.getMaterial(),this,this._shouldConvertRHS(),((s=e.getMaterial())==null?void 0:s.fillMode)===7),this}_processCollisionsForSubMeshes(e,t){const i=this._scene.getCollidingSubMeshCandidates(this,e),s=i.length;for(let n=0;n<s;n++){const r=i.data[n];s>1&&!r._checkCollision(e)||this._collideForSubMesh(r,t,e)}return this}_shouldConvertRHS(){return!1}_checkCollision(e){if(!this.getBoundingInfo()._checkCollision(e))return this;const t=N.Matrix[0],i=N.Matrix[1];return O.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,n,r=!1){const o=new as,h=this.getClassName(),l=h==="InstancedLinesMesh"||h==="LinesMesh"||h==="GreasedLineMesh"?this.intersectionThreshold:0,c=this.getBoundingInfo();if(!this.subMeshes||!r&&(!e.intersectsSphere(c.boundingSphere,l)||!e.intersectsBox(c.boundingBox,l)))return o;if(s)return o.hit=!r,o.pickedMesh=r?null:this,o.distance=r?0:v.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 _=!1;for(let p=0;p<d;p++){const m=f.data[p].getMaterial();if(m&&(m.fillMode==7||m.fillMode==0||m.fillMode==1||m.fillMode==2||m.fillMode==4)){_=!0;break}}if(!_)return o.hit=!0,o.pickedMesh=this,o.distance=v.Distance(e.origin,c.boundingSphere.center),o.subMeshId=-1,o;for(let p=0;p<d;p++){const g=f.data[p];if(d>1&&!r&&!g.canIntersects(e))continue;const m=g.intersects(e,this._positions,this.getIndices(),t,i);if(m&&(t||!u||m.distance<u.distance)&&(u=m,u.subMeshId=p,t))break}if(u){const p=n!=null?n:this.getWorldMatrix(),g=N.Vector3[0],m=N.Vector3[1];v.TransformCoordinatesToRef(e.origin,p,g),e.direction.scaleToRef(u.distance,m);const I=v.TransformNormal(m,p).addInPlace(g);return o.hit=!0,o.distance=v.Distance(g,I),o.pickedPoint=I,o.pickedMesh=this,o.bu=u.bu||0,o.bv=u.bv||0,o.subMeshFaceId=u.faceId,o.faceId=u.faceId+f.data[u.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 r=s.getEngine();if(this._occlusionQuery!==null&&(this.isOcclusionQueryInProgress=!1,r.deleteQuery(this._occlusionQuery),this._occlusionQuery=null),r.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]=v.Zero(),e.facetPositions[t]=v.Zero();return e.facetDataEnabled=!0,this}updateFacetData(){const e=this._internalAbstractMeshDataInfo._facetData;e.facetDataEnabled||this._initFacetData();const t=this.getVerticesData(A.PositionKind),i=this.getIndices(),s=this.getVerticesData(A.NormalKind),n=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:v.Zero()}e.depthSortedFacets=[];for(let o=0;o<e.facetNb;o++){const h={ind:o*3,sqDistance:0};e.depthSortedFacets.push(h)}e.invertedMatrix=O.Identity(),e.facetDepthSortOrigin=v.Zero()}e.bbSize.x=n.maximum.x-n.minimum.x>Le?n.maximum.x-n.minimum.x:Le,e.bbSize.y=n.maximum.y-n.minimum.y>Le?n.maximum.y-n.minimum.y:Le,e.bbSize.z=n.maximum.z-n.minimum.z>Le?n.maximum.z-n.minimum.z:Le;let r=e.bbSize.x>e.bbSize.y?e.bbSize.x:e.bbSize.y;if(r=r>e.bbSize.z?r:e.bbSize.z,e.subDiv.max=e.partitioningSubdivisions,e.subDiv.X=Math.floor(e.subDiv.max*e.bbSize.x/r),e.subDiv.Y=Math.floor(e.subDiv.max*e.bbSize.y/r),e.subDiv.Z=Math.floor(e.subDiv.max*e.bbSize.z/r),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=n,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),v.TransformCoordinatesToRef(e.facetDepthSortFrom,e.invertedMatrix,e.facetDepthSortOrigin),e.facetParameters.distanceTo=e.facetDepthSortOrigin),e.facetParameters.depthSortedFacets=e.depthSortedFacets,s&&j.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=v.Zero();return this.getFacetPositionToRef(e,t),t}getFacetPositionToRef(e,t){const i=this.getFacetLocalPositions()[e],s=this.getWorldMatrix();return v.TransformCoordinatesToRef(i,s,t),this}getFacetNormal(e){const t=v.Zero();return this.getFacetNormalToRef(e,t),t}getFacetNormalToRef(e,t){const i=this.getFacetLocalNormals()[e];return v.TransformNormalToRef(i,this.getWorldMatrix(),t),this}getFacetsAtLocalCoordinates(e,t,i){const s=this.getBoundingInfo(),n=this._internalAbstractMeshDataInfo._facetData,r=Math.floor((e-s.minimum.x*n.partitioningBBoxRatio)*n.subDiv.X*n.partitioningBBoxRatio/n.bbSize.x),o=Math.floor((t-s.minimum.y*n.partitioningBBoxRatio)*n.subDiv.Y*n.partitioningBBoxRatio/n.bbSize.y),h=Math.floor((i-s.minimum.z*n.partitioningBBoxRatio)*n.subDiv.Z*n.partitioningBBoxRatio/n.bbSize.z);return r<0||r>n.subDiv.max||o<0||o>n.subDiv.max||h<0||h>n.subDiv.max?null:n.facetPartitioning[r+n.subDiv.max*o+n.subDiv.max*n.subDiv.max*h]}getClosestFacetAtCoordinates(e,t,i,s,n=!1,r=!0){const o=this.getWorldMatrix(),h=N.Matrix[5];o.invertToRef(h);const l=N.Vector3[8];v.TransformCoordinatesFromFloatsToRef(e,t,i,h,l);const c=this.getClosestFacetAtLocalCoordinates(l.x,l.y,l.z,s,n,r);return s&&v.TransformCoordinatesFromFloatsToRef(s.x,s.y,s.z,o,s),c}getClosestFacetAtLocalCoordinates(e,t,i,s,n=!1,r=!0){let o=null,h=0,l=0,c=0,u=0,f=0,d=0,_=0,p=0;const g=this.getFacetLocalPositions(),m=this.getFacetLocalNormals(),b=this.getFacetsAtLocalCoordinates(e,t,i);if(!b)return null;let I=Number.MAX_VALUE,T=I,x,y,R;for(let E=0;E<b.length;E++)x=b[E],y=m[x],R=g[x],u=(e-R.x)*y.x+(t-R.y)*y.y+(i-R.z)*y.z,(!n||n&&r&&u>=0||n&&!r&&u<=0)&&(u=y.x*R.x+y.y*R.y+y.z*R.z,f=-(y.x*e+y.y*t+y.z*i-u)/(y.x*y.x+y.y*y.y+y.z*y.z),d=e+y.x*f,_=t+y.y*f,p=i+y.z*f,h=d-e,l=_-t,c=p-i,T=h*h+l*l+c*c,T<I&&(I=T,o=x,s&&(s.x=d,s.y=_,s.z=p)));return o}getFacetDataParameters(){return this._internalAbstractMeshDataInfo._facetData.facetParameters}disableFacetData(){const e=this._internalAbstractMeshDataInfo._facetData;return e.facetDataEnabled&&(e.facetDataEnabled=!1,e.facetPositions=[],e.facetNormals=[],e.facetPartitioning=new Array,e.facetParameters={},e.depthSortedIndices=new Uint32Array(0)),this}updateIndices(e,t,i=!1){return this}createNormals(e){const t=this.getVerticesData(A.PositionKind),i=this.getIndices();let s;return this.isVerticesDataPresent(A.NormalKind)?s=this.getVerticesData(A.NormalKind):s=[],j.ComputeNormals(t,i,s,{useRightHandedSystem:this.getScene().useRightHandedSystem}),this.setVerticesData(A.NormalKind,s,e),this}alignWithNormal(e,t){t||(t=Gt.Y);const i=N.Vector3[0],s=N.Vector3[1];return v.CrossToRef(t,e,s),v.CrossToRef(e,s,i),this.rotationQuaternion?re.RotationQuaternionFromAxisToRef(i,e,s,this.rotationQuaternion):v.RotationFromAxisToRef(i,e,s,this.rotation),this}_checkOcclusionQuery(){return!1}disableEdgesRendering(){throw ye("EdgesRenderer")}enableEdgesRendering(e,t,i){throw ye("EdgesRenderer")}getConnectedParticleSystems(){return this._scene.particleSystems.filter(e=>e.emitter===this)}}Qe.OCCLUSION_TYPE_NONE=0;Qe.OCCLUSION_TYPE_OPTIMISTIC=1;Qe.OCCLUSION_TYPE_STRICT=2;Qe.OCCLUSION_ALGORITHM_TYPE_ACCURATE=0;Qe.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE=1;Qe.CULLINGSTRATEGY_STANDARD=0;Qe.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1;Qe.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2;Qe.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3;D([rs.filter((...[a,e,t,i,s])=>!Array.isArray(a)&&!Array.isArray(e)&&!Array.isArray(t)&&!Array.isArray(i)&&!Array.isArray(s))],Qe,"_ApplySkeleton",null);vt("BABYLON.AbstractMesh",Qe);class Lp{constructor(){this.occlusionInternalRetryCounter=0,this.isOcclusionQueryInProgress=!1,this.isOccluded=!1,this.occlusionRetryCount=-1,this.occlusionType=Qe.OCCLUSION_TYPE_NONE,this.occlusionQueryAlgorithmType=Qe.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE,this.forceRenderingWhenOccluded=!1}}ae.prototype.getGPUFrameTimeCounter=function(){return null};ae.prototype.captureGPUFrameTime=function(a){};ae.prototype.createQuery=function(){return null};ae.prototype.deleteQuery=function(a){return this};ae.prototype.isQueryResultAvailable=function(a){return!1};ae.prototype.getQueryResult=function(a){return 0};ae.prototype.beginOcclusionQuery=function(a,e){return!1};ae.prototype.endOcclusionQuery=function(a){return this};Object.defineProperty(Qe.prototype,"isOcclusionQueryInProgress",{get:function(){return this._occlusionDataStorage.isOcclusionQueryInProgress},set:function(a){this._occlusionDataStorage.isOcclusionQueryInProgress=a},enumerable:!1,configurable:!0});Object.defineProperty(Qe.prototype,"_occlusionDataStorage",{get:function(){return this.__occlusionDataStorage||(this.__occlusionDataStorage=new Lp),this.__occlusionDataStorage},enumerable:!1,configurable:!0});Object.defineProperty(Qe.prototype,"isOccluded",{get:function(){return this._occlusionDataStorage.isOccluded},set:function(a){this._occlusionDataStorage.isOccluded=a},enumerable:!0,configurable:!0});Object.defineProperty(Qe.prototype,"occlusionQueryAlgorithmType",{get:function(){return this._occlusionDataStorage.occlusionQueryAlgorithmType},set:function(a){this._occlusionDataStorage.occlusionQueryAlgorithmType=a},enumerable:!0,configurable:!0});Object.defineProperty(Qe.prototype,"occlusionType",{get:function(){return this._occlusionDataStorage.occlusionType},set:function(a){this._occlusionDataStorage.occlusionType=a},enumerable:!0,configurable:!0});Object.defineProperty(Qe.prototype,"occlusionRetryCount",{get:function(){return this._occlusionDataStorage.occlusionRetryCount},set:function(a){this._occlusionDataStorage.occlusionRetryCount=a},enumerable:!0,configurable:!0});Object.defineProperty(Qe.prototype,"forceRenderingWhenOccluded",{get:function(){return this._occlusionDataStorage.forceRenderingWhenOccluded},set:function(a){this._occlusionDataStorage.forceRenderingWhenOccluded=a},enumerable:!0,configurable:!0});Qe.prototype._checkOcclusionQuery=function(){const a=this._occlusionDataStorage;if(a.occlusionType===Qe.OCCLUSION_TYPE_NONE)return a.isOccluded=!1,!1;const e=this.getEngine();if(!e.getCaps().supportOcclusionQuery||!e.isQueryResultAvailable)return a.isOccluded=!1,!1;if(this.isOcclusionQueryInProgress&&this._occlusionQuery!==null&&this._occlusionQuery!==void 0)if(e.isQueryResultAvailable(this._occlusionQuery)){const s=e.getQueryResult(this._occlusionQuery);a.isOcclusionQueryInProgress=!1,a.occlusionInternalRetryCounter=0,a.isOccluded=!(s>0)}else if(a.occlusionInternalRetryCounter++,a.occlusionRetryCount!==-1&&a.occlusionInternalRetryCounter>a.occlusionRetryCount)a.isOcclusionQueryInProgress=!1,a.occlusionInternalRetryCounter=0,a.isOccluded=a.occlusionType===Qe.OCCLUSION_TYPE_OPTIMISTIC?!1:a.isOccluded;else return a.occlusionType===Qe.OCCLUSION_TYPE_OPTIMISTIC?!1:a.isOccluded;const t=this.getScene();if(t.getBoundingBoxRenderer){const i=t.getBoundingBoxRenderer();this._occlusionQuery===null&&(this._occlusionQuery=e.createQuery()),this._occlusionQuery&&e.beginOcclusionQuery(a.occlusionQueryAlgorithmType,this._occlusionQuery)&&(i.renderOcclusionBoundingBox(this),e.endOcclusionQuery(a.occlusionQueryAlgorithmType),this._occlusionDataStorage.isOcclusionQueryInProgress=!0)}return a.isOccluded};et.prototype.getGPUFrameTimeCounter=function(){return this._timestampQuery.gpuFrameTimeCounter};et.prototype.captureGPUFrameTime=function(a){this._timestampQuery.enable=a&&!!this._caps.timerQuery};et.prototype.createQuery=function(){return this._occlusionQuery.createQuery()};et.prototype.deleteQuery=function(a){return this._occlusionQuery.deleteQuery(a),this};et.prototype.isQueryResultAvailable=function(a){return this._occlusionQuery.isQueryResultAvailable(a)};et.prototype.getQueryResult=function(a){return this._occlusionQuery.getQueryResult(a)};et.prototype.beginOcclusionQuery=function(a,e){var t;if(this.compatibilityMode){if(this._occlusionQuery.canBeginQuery(e))return(t=this._currentRenderPass)==null||t.beginOcclusionQuery(e),!0}else return this._bundleList.addItem(new M0(e)),!0;return!1};et.prototype.endOcclusionQuery=function(){var a;return this.compatibilityMode?(a=this._currentRenderPass)==null||a.endOcclusionQuery():this._bundleList.addItem(new P0),this};const wh={label:"TextureView_SwapChain_ResolveTarget",dimension:"2d",format:void 0,mipLevelCount:1,arrayLayerCount:1},Dh={label:"TextureView_SwapChain",dimension:"2d",format:void 0,mipLevelCount:1,arrayLayerCount:1},Np=new H;class Ye extends et{get snapshotRenderingMode(){return this._snapshotRendering.mode}set snapshotRenderingMode(e){this._snapshotRendering.mode=e}snapshotRenderingReset(){this._snapshotRendering.reset()}get snapshotRendering(){return this._snapshotRendering.enabled}set snapshotRendering(e){this._snapshotRendering.enabled=e}get disableCacheSamplers(){return this._cacheSampler?this._cacheSampler.disabled:!1}set disableCacheSamplers(e){this._cacheSampler&&(this._cacheSampler.disabled=e)}get disableCacheRenderPipelines(){return this._cacheRenderPipeline?this._cacheRenderPipeline.disabled:!1}set disableCacheRenderPipelines(e){this._cacheRenderPipeline&&(this._cacheRenderPipeline.disabled=e)}get disableCacheBindGroups(){return this._cacheBindGroups?this._cacheBindGroups.disabled:!1}set disableCacheBindGroups(e){this._cacheBindGroups&&(this._cacheBindGroups.disabled=e)}areAllEffectsReady(){return!0}getFontOffset(e){return cc(e)}static get IsSupportedAsync(){return navigator.gpu?navigator.gpu.requestAdapter().then(e=>!!e,()=>!1).catch(()=>!1):Promise.resolve(!1)}static get IsSupported(){return U.Warn("You must call IsSupportedAsync for WebGPU!"),!1}get supportsUniformBuffers(){return!0}get supportedExtensions(){return this._adapterSupportedExtensions}get enabledExtensions(){return this._deviceEnabledExtensions}get supportedLimits(){return this._adapterSupportedLimits}get currentLimits(){return this._deviceLimits}get description(){return this.name+this.version}get version(){return 1}getInfo(){return{vendor:this._adapterInfo.vendor||"unknown vendor",renderer:this._adapterInfo.architecture||"unknown renderer",version:this._adapterInfo.description||"unknown version"}}get compatibilityMode(){return this._compatibilityMode}set compatibilityMode(e){this._compatibilityMode=e}get currentSampleCount(){return this._currentRenderTarget?this._currentRenderTarget.samples:this._mainPassSampleCount}static CreateAsync(e,t={}){const i=new Ye(e,t);return new Promise(s=>{i.initAsync(t.glslangOptions,t.twgslOptions).then(()=>s(i))})}constructor(e,t={}){var i,s;if(super((i=t.antialias)!=null?i:!0,t),this.uniqueId=-1,this._uploadEncoderDescriptor={label:"upload"},this._renderEncoderDescriptor={label:"render"},this._clearDepthValue=1,this._clearReverseDepthValue=0,this._clearStencilValue=0,this._defaultSampleCount=4,this._glslang=null,this._tintWASM=null,this._glslangAndTintAreFullyLoaded=!1,this._adapterInfo={vendor:"",architecture:"",device:"",description:""},this._compiledComputeEffects={},this._counters={numEnableEffects:0,numEnableDrawWrapper:0,numBundleCreationNonCompatMode:0,numBundleReuseNonCompatMode:0},this.countersLastFrame={numEnableEffects:0,numEnableDrawWrapper:0,numBundleCreationNonCompatMode:0,numBundleReuseNonCompatMode:0},this.numMaxUncapturedErrors=20,this.scenes=[],this._virtualScenes=new Array,this._commandBuffers=[null,null],this._mainRenderPassWrapper={renderPassDescriptor:null,colorAttachmentViewDescriptor:null,depthAttachmentViewDescriptor:null,colorAttachmentGPUTextures:[],depthTextureFormat:void 0},this._rttRenderPassWrapper={renderPassDescriptor:null,colorAttachmentViewDescriptor:null,depthAttachmentViewDescriptor:null,colorAttachmentGPUTextures:[],depthTextureFormat:void 0},this._pendingDebugCommands=[],this._currentOverrideVertexBuffers=null,this._currentIndexBuffer=null,this._colorWriteLocal=!0,this._forceEnableEffect=!1,this.isNDCHalfZRange=!0,this.hasOriginBottomLeft=!1,this._workingGlslangAndTintPromise=null,this._viewportsCurrent={x:0,y:0,w:0,h:0},this._scissorsCurrent={x:0,y:0,w:0,h:0},this._scissorCached={x:0,y:0,z:0,w:0},this._stencilRefsCurrent=-1,this._blendColorsCurrent=[null,null,null,null],this._performanceMonitor=new Yl,this._name="WebGPU",this._drawCalls=new ui,t.deviceDescriptor=t.deviceDescriptor||{},t.enableGPUDebugMarkers=(s=t.enableGPUDebugMarkers)!=null?s:!1,U.Log("Babylon.js v".concat(ae.Version," - ").concat(this.description," engine")),!navigator.gpu){U.Error("WebGPU is not supported by your browser.");return}t.swapChainFormat=t.swapChainFormat||navigator.gpu.getPreferredCanvasFormat(),this._isWebGPU=!0,this._shaderPlatformName="WEBGPU",this._renderingCanvas=e,this._options=t,this._mainPassSampleCount=t.antialias?this._defaultSampleCount:1,navigator&&navigator.userAgent&&this._setupMobileChecks(),this._sharedInit(this._renderingCanvas),this._shaderProcessor=new g_,this._shaderProcessorWGSL=new U_}prepareGlslangAndTintAsync(){return this._workingGlslangAndTintPromise||(this._workingGlslangAndTintPromise=new Promise(e=>{var t,i;this._initGlslang((i=this._glslangOptions)!=null?i:(t=this._options)==null?void 0:t.glslangOptions).then(s=>{var n,r;this._glslang=s,this._tintWASM=new ei,this._tintWASM.initTwgsl((r=this._twgslOptions)!=null?r:(n=this._options)==null?void 0:n.twgslOptions).then(()=>{this._glslangAndTintAreFullyLoaded=!0,e()})})})),this._workingGlslangAndTintPromise}initAsync(e,t){return this.uniqueId=Ye._InstanceId++,this._glslangOptions=e,this._twgslOptions=t,navigator.gpu.requestAdapter(this._options).then(i=>{var s,n,r;if(i){this._adapter=i,this._adapterSupportedExtensions=[],(s=this._adapter.features)==null||s.forEach(l=>this._adapterSupportedExtensions.push(l)),this._adapterSupportedLimits=this._adapter.limits,this._adapterInfo=this._adapter.info;const o=(n=this._options.deviceDescriptor)!=null?n:{},h=(r=o==null?void 0:o.requiredFeatures)!=null?r:this._options.enableAllFeatures?this._adapterSupportedExtensions:void 0;if(h){const l=h,c=[];for(const u of l)this._adapterSupportedExtensions.indexOf(u)!==-1&&c.push(u);o.requiredFeatures=c}if(this._options.setMaximumLimits&&!o.requiredLimits){o.requiredLimits={};for(const l in this._adapterSupportedLimits)l==="minSubgroupSize"||l==="maxSubgroupSize"||(o.requiredLimits[l]=this._adapterSupportedLimits[l])}return o.label="BabylonWebGPUDevice".concat(this.uniqueId),this._adapter.requestDevice(o)}else throw"Could not retrieve a WebGPU adapter (adapter is null)."}).then(i=>{var n,r;this._device=i,this._deviceEnabledExtensions=[],(n=this._device.features)==null||n.forEach(o=>this._deviceEnabledExtensions.push(o)),this._deviceLimits=i.limits;let s=-1;this._device.addEventListener("uncapturederror",o=>{++s<this.numMaxUncapturedErrors?U.Warn("WebGPU uncaptured error (".concat(s+1,"): ").concat(o.error," - ").concat(o.error.message)):s++===this.numMaxUncapturedErrors&&U.Warn("WebGPU uncaptured error: too many warnings (".concat(this.numMaxUncapturedErrors,"), no more warnings will be reported to the console for this engine."))}),this._doNotHandleContextLost||(r=this._device.lost)==null||r.then(o=>{this._isDisposed||(this._contextWasLost=!0,U.Warn("WebGPU context lost. "+o),this.onContextLostObservable.notifyObservers(this),this._restoreEngineAfterContextLost(async()=>{var _,p,g,m;const h=this.snapshotRenderingMode,l=this.snapshotRendering,c=this.disableCacheSamplers,u=this.disableCacheRenderPipelines,f=this.disableCacheBindGroups,d=this.enableGPUTimingMeasurements;await this.initAsync((p=this._glslangOptions)!=null?p:(_=this._options)==null?void 0:_.glslangOptions,(m=this._twgslOptions)!=null?m:(g=this._options)==null?void 0:g.twgslOptions),this.snapshotRenderingMode=h,this.snapshotRendering=l,this.disableCacheSamplers=c,this.disableCacheRenderPipelines=u,this.disableCacheBindGroups=f,this.enableGPUTimingMeasurements=d,this._currentRenderPass=null}))})}).then(()=>{this._initializeLimits(),this._bufferManager=new Mr(this,this._device),this._textureHelper=new j_(this,this._device,this._bufferManager,this._deviceEnabledExtensions),this._cacheSampler=new Fs(this._device),this._cacheBindGroups=new qe(this._device,this._cacheSampler,this),this._timestampQuery=new bp(this,this._device,this._bufferManager),this._occlusionQuery=this._device.createQuerySet?new yp(this,this._device,this._bufferManager):void 0,this._bundleList=new D0(this._device),this._snapshotRendering=new Tp(this,this._snapshotRenderingMode,this._bundleList),this._ubInvertY=this._bufferManager.createBuffer(new Float32Array([-1,0]),We.Uniform|We.CopyDst,"UBInvertY"),this._ubDontInvertY=this._bufferManager.createBuffer(new Float32Array([1,0]),We.Uniform|We.CopyDst,"UBDontInvertY"),this.dbgVerboseLogsForFirstFrames&&this._count===void 0&&(this._count=0,U.Log(["%c frame #"+this._count+" - begin","background: #ffff00"])),this._uploadEncoder=this._device.createCommandEncoder(this._uploadEncoderDescriptor),this._renderEncoder=this._device.createCommandEncoder(this._renderEncoderDescriptor),this._emptyVertexBuffer=new A(this,[0],"",{stride:1,offset:0,size:1,label:"EmptyVertexBuffer"}),this._cacheRenderPipeline=new Ci(this._device,this._emptyVertexBuffer),this._depthCullingState=new up(this._cacheRenderPipeline),this._stencilStateComposer=new cp(this._cacheRenderPipeline),this._stencilStateComposer.stencilGlobal=this._stencilState,this._depthCullingState.depthTest=!0,this._depthCullingState.depthFunc=515,this._depthCullingState.depthMask=!0,this._textureHelper.setCommandEncoder(this._uploadEncoder),this._clearQuad=new vp(this._device,this,this._emptyVertexBuffer),this._defaultDrawContext=this.createDrawContext(),this._currentDrawContext=this._defaultDrawContext,this._defaultMaterialContext=this.createMaterialContext(),this._currentMaterialContext=this._defaultMaterialContext,this._initializeContextAndSwapChain(),this._initializeMainAttachments(),this.resize()}).catch(i=>{throw U.Error("A fatal error occurred during WebGPU creation/initialization."),i})}_initGlslang(e){return e=e||{},e={...Ye._GlslangDefaultOptions,...e},e.glslang?Promise.resolve(e.glslang):self.glslang?self.glslang(e.wasmPath):e.jsPath&&e.wasmPath?J.LoadBabylonScriptAsync(e.jsPath).then(()=>self.glslang(J.GetBabylonScriptURL(e.wasmPath))):Promise.reject("gslang is not available.")}_initializeLimits(){this._caps={maxTexturesImageUnits:this._deviceLimits.maxSampledTexturesPerShaderStage,maxVertexTextureImageUnits:this._deviceLimits.maxSampledTexturesPerShaderStage,maxCombinedTexturesImageUnits:this._deviceLimits.maxSampledTexturesPerShaderStage*2,maxTextureSize:this._deviceLimits.maxTextureDimension2D,maxCubemapTextureSize:this._deviceLimits.maxTextureDimension2D,maxRenderTextureSize:this._deviceLimits.maxTextureDimension2D,maxVertexAttribs:this._deviceLimits.maxVertexAttributes,maxDrawBuffers:8,maxVaryingVectors:this._deviceLimits.maxInterStageShaderVariables,maxFragmentUniformVectors:Math.floor(this._deviceLimits.maxUniformBufferBindingSize/4),maxVertexUniformVectors:Math.floor(this._deviceLimits.maxUniformBufferBindingSize/4),standardDerivatives:!0,astc:this._deviceEnabledExtensions.indexOf("texture-compression-astc")>=0?!0:void 0,s3tc:this._deviceEnabledExtensions.indexOf("texture-compression-bc")>=0?!0:void 0,pvrtc:null,etc1:null,etc2:this._deviceEnabledExtensions.indexOf("texture-compression-etc2")>=0?!0:void 0,bptc:this._deviceEnabledExtensions.indexOf("texture-compression-bc")>=0?!0:void 0,maxAnisotropy:16,uintIndices:!0,fragmentDepthSupported:!0,highPrecisionShaderSupported:!0,colorBufferFloat:!0,supportFloatTexturesResolve:!1,rg11b10ufColorRenderable:this._deviceEnabledExtensions.indexOf("rg11b10ufloat-renderable")>=0,textureFloat:!0,textureFloatLinearFiltering:this._deviceEnabledExtensions.indexOf("float32-filterable")>=0,textureFloatRender:!0,textureHalfFloat:!0,textureHalfFloatLinearFiltering:!0,textureHalfFloatRender:!0,textureLOD:!0,texelFetch:!0,drawBuffersExtension:!0,depthTextureExtension:!0,vertexArrayObject:!1,instancedArrays:!0,timerQuery:typeof BigUint64Array<"u"&&this._deviceEnabledExtensions.indexOf("timestamp-query")!==-1?!0:void 0,supportOcclusionQuery:typeof BigUint64Array<"u",canUseTimestampForTimerQuery:!0,multiview:!1,oculusMultiview:!1,parallelShaderCompile:void 0,blendMinMax:!0,maxMSAASamples:4,canUseGLInstanceID:!0,canUseGLVertexID:!0,supportComputeShaders:!0,supportSRGBBuffers:!0,supportTransformFeedbacks:!1,textureMaxLevel:!0,texture2DArrayMaxLayerCount:this._deviceLimits.maxTextureArrayLayers,disableMorphTargetTexture:!1,textureNorm16:!1},this._features={forceBitmapOverHTMLImageElement:!0,supportRenderAndCopyToLodForFloatTextures:!0,supportDepthStencilTexture:!0,supportShadowSamplers:!0,uniformBufferHardCheckMatrix:!1,allowTexturePrefiltering:!0,trackUbosInFrame:!0,checkUbosContentBeforeUpload:!0,supportCSM:!0,basisNeedsPOT:!1,support3DTextures:!0,needTypeSuffixInShaderConstants:!0,supportMSAA:!0,supportSSAO2:!0,supportIBLShadows:!0,supportExtendedTextureFormats:!0,supportSwitchCaseInShader:!0,supportSyncTextureRead:!1,needsInvertingBitmap:!1,useUBOBindingCache:!1,needShaderCodeInlining:!0,needToAlwaysBindUniformBuffers:!0,supportRenderPasses:!0,supportSpriteInstancing:!0,forceVertexBufferStrideAndOffsetMultiple4Bytes:!0,_checkNonFloatVertexBuffersDontRecreatePipelineContext:!0,_collectUbosUpdatedInFrame:!1}}_initializeContextAndSwapChain(){if(!this._renderingCanvas)throw"The rendering canvas has not been set!";this._context=this._renderingCanvas.getContext("webgpu"),this._configureContext(),this._colorFormat=this._options.swapChainFormat,this._mainRenderPassWrapper.colorAttachmentGPUTextures=[new pr(this)],this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].format=this._colorFormat,this._setColorFormat(this._mainRenderPassWrapper)}_initializeMainAttachments(){if(!this._bufferManager)return;this.flushFramebuffer(),this._mainTextureExtends={width:this.getRenderWidth(!0),height:this.getRenderHeight(!0),depthOrArrayLayers:1};const e=new Float32Array([this.getRenderHeight(!0)]);this._bufferManager.setSubData(this._ubInvertY,4,e),this._bufferManager.setSubData(this._ubDontInvertY,4,e);let t;if(this._options.antialias){const n={label:"Texture_MainColor_".concat(this._mainTextureExtends.width,"x").concat(this._mainTextureExtends.height,"_antialiasing"),size:this._mainTextureExtends,mipLevelCount:1,sampleCount:this._mainPassSampleCount,dimension:"2d",format:this._options.swapChainFormat,usage:16};this._mainTexture&&this._textureHelper.releaseTexture(this._mainTexture),this._mainTexture=this._device.createTexture(n),t=[{view:this._mainTexture.createView({label:"TextureView_MainColor_antialiasing",dimension:"2d",format:this._options.swapChainFormat,mipLevelCount:1,arrayLayerCount:1}),clearValue:new H(0,0,0,1),loadOp:"clear",storeOp:"store"}]}else t=[{view:void 0,clearValue:new H(0,0,0,1),loadOp:"clear",storeOp:"store"}];this._mainRenderPassWrapper.depthTextureFormat=this.isStencilEnable?"depth24plus-stencil8":"depth32float",this._setDepthTextureFormat(this._mainRenderPassWrapper),this._setColorFormat(this._mainRenderPassWrapper);const i={label:"Texture_MainDepthStencil_".concat(this._mainTextureExtends.width,"x").concat(this._mainTextureExtends.height),size:this._mainTextureExtends,mipLevelCount:1,sampleCount:this._mainPassSampleCount,dimension:"2d",format:this._mainRenderPassWrapper.depthTextureFormat,usage:16};this._depthTexture&&this._textureHelper.releaseTexture(this._depthTexture),this._depthTexture=this._device.createTexture(i);const s={view:this._depthTexture.createView({label:"TextureView_MainDepthStencil_".concat(this._mainTextureExtends.width,"x").concat(this._mainTextureExtends.height),dimension:"2d",format:this._depthTexture.format,mipLevelCount:1,arrayLayerCount:1}),depthClearValue:this._clearDepthValue,depthLoadOp:"clear",depthStoreOp:"store",stencilClearValue:this._clearStencilValue,stencilLoadOp:this.isStencilEnable?"clear":void 0,stencilStoreOp:this.isStencilEnable?"store":void 0};this._mainRenderPassWrapper.renderPassDescriptor={label:"MainRenderPass",colorAttachments:t,depthStencilAttachment:s}}_sharedInit(e){super._sharedInit(e),hc(this,e,this._creationOptions)}_configureContext(){this._context.configure({device:this._device,format:this._options.swapChainFormat,usage:17,alphaMode:this.premultipliedAlpha?"premultiplied":"opaque"})}resizeImageBitmap(e,t,i){return fc(this,e,t,i)}_createImageBitmapFromSource(e,t){return uc(this,e,t)}switchFullscreen(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)}enterFullscreen(e){this.isFullscreen||(this._pointerLockRequested=e,this._renderingCanvas&&dc(this._renderingCanvas))}exitFullscreen(){this.isFullscreen&&_c()}enterPointerlock(){this._renderingCanvas&&R0(this._renderingCanvas)}exitPointerlock(){pc()}_rebuildBuffers(){super._rebuildBuffers();for(const e of this._storageBuffers)e.getBuffer().engineId!==this.uniqueId&&e._rebuild()}_restoreEngineAfterContextLost(e){Ci.ResetCache(),qe.ResetCache();const t=s=>{var n;for(const r of s){for(const o of r.meshes){const h=o.subMeshes;if(h)for(const l of h)l._drawWrappers=[]}for(const o of r.materials)(n=o._materialContext)==null||n.reset()}};t(this.scenes),t(this._virtualScenes);const i=[];for(const s of this._uniformBuffers)s.name.indexOf("leftOver")<0&&i.push(s);this._uniformBuffers=i,super._restoreEngineAfterContextLost(e)}setSize(e,t,i=!1){return super.setSize(e,t,i)?(this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&U.Log(["frame #"+this._count+" - setSize -",e,t])),this._initializeMainAttachments(),this.snapshotRendering&&this.snapshotRenderingReset(),!0):!1}_getShaderProcessor(e){return e===1?this._shaderProcessorWGSL:this._shaderProcessor}_getShaderProcessingContext(e,t){return new ni(e,t)}_getCurrentRenderPass(){return this._currentRenderTarget&&!this._currentRenderPass?this._startRenderTargetRenderPass(this._currentRenderTarget,!1,null,!1,!1):this._currentRenderPass||this._startMainRenderPass(!1),this._currentRenderPass}_getCurrentRenderPassWrapper(){return this._currentRenderTarget?this._rttRenderPassWrapper:this._mainRenderPassWrapper}applyStates(){this._stencilStateComposer.apply(),this._cacheRenderPipeline.setAlphaBlendEnabled(this._alphaState.alphaBlend)}wipeCaches(e){this.preventCacheWipeBetweenFrames&&!e||(this._forceEnableEffect=!0,this._currentIndexBuffer=null,this._currentOverrideVertexBuffers=null,this._cacheRenderPipeline.setBuffers(null,null,null),e&&(this._stencilStateComposer.reset(),this._depthCullingState.reset(),this._depthCullingState.depthFunc=515,this._alphaState.reset(),this._alphaMode=1,this._alphaEquation=0,this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters,this._alphaState._blendEquationParameters),this._cacheRenderPipeline.setAlphaBlendEnabled(!1),this.setColorWrite(!0)),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null)}setColorWrite(e){this._colorWriteLocal=e,this._cacheRenderPipeline.setWriteMask(e?15:0)}getColorWrite(){return this._colorWriteLocal}_mustUpdateViewport(){const e=this._viewportCached.x,t=this._viewportCached.y,i=this._viewportCached.z,s=this._viewportCached.w,n=this._viewportsCurrent.x!==e||this._viewportsCurrent.y!==t||this._viewportsCurrent.w!==i||this._viewportsCurrent.h!==s;return n&&(this._viewportsCurrent.x=this._viewportCached.x,this._viewportsCurrent.y=this._viewportCached.y,this._viewportsCurrent.w=this._viewportCached.z,this._viewportsCurrent.h=this._viewportCached.w),n}_applyViewport(e){const t=Math.floor(this._viewportCached.x),i=Math.floor(this._viewportCached.z),s=Math.floor(this._viewportCached.w);let n=Math.floor(this._viewportCached.y);this._currentRenderTarget||(n=this.getRenderHeight(!0)-n-s),e?e.addItem(new E0(t,n,i,s)):this._getCurrentRenderPass().setViewport(t,n,i,s,0,1),this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&U.Log(["frame #"+this._count+" - viewport applied - (",this._viewportCached.x,this._viewportCached.y,this._viewportCached.z,this._viewportCached.w,") current pass is main pass="+this._currentPassIsMainPass()]))}_viewport(e,t,i,s){this._viewportCached.x=e,this._viewportCached.y=t,this._viewportCached.z=i,this._viewportCached.w=s}_mustUpdateScissor(){const e=this._scissorCached.x,t=this._scissorCached.y,i=this._scissorCached.z,s=this._scissorCached.w,n=this._scissorsCurrent.x!==e||this._scissorsCurrent.y!==t||this._scissorsCurrent.w!==i||this._scissorsCurrent.h!==s;return n&&(this._scissorsCurrent.x=this._scissorCached.x,this._scissorsCurrent.y=this._scissorCached.y,this._scissorsCurrent.w=this._scissorCached.z,this._scissorsCurrent.h=this._scissorCached.w),n}_applyScissor(e){const t=this._currentRenderTarget?this._scissorCached.y:this.getRenderHeight()-this._scissorCached.w-this._scissorCached.y;e?e.addItem(new C0(this._scissorCached.x,t,this._scissorCached.z,this._scissorCached.w)):this._getCurrentRenderPass().setScissorRect(this._scissorCached.x,t,this._scissorCached.z,this._scissorCached.w),this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&U.Log(["frame #"+this._count+" - scissor applied - (",this._scissorCached.x,this._scissorCached.y,this._scissorCached.z,this._scissorCached.w,") current pass is main pass="+this._currentPassIsMainPass()]))}_scissorIsActive(){return this._scissorCached.x!==0||this._scissorCached.y!==0||this._scissorCached.z!==0||this._scissorCached.w!==0}enableScissor(e,t,i,s){this._scissorCached.x=e,this._scissorCached.y=t,this._scissorCached.z=i,this._scissorCached.w=s}disableScissor(){this._scissorCached.x=this._scissorCached.y=this._scissorCached.z=this._scissorCached.w=0,this._scissorsCurrent.x=this._scissorsCurrent.y=this._scissorsCurrent.w=this._scissorsCurrent.h=0}_mustUpdateStencilRef(){const e=this._stencilStateComposer.funcRef!==this._stencilRefsCurrent;return e&&(this._stencilRefsCurrent=this._stencilStateComposer.funcRef),e}_applyStencilRef(e){var t,i;e?e.addItem(new Pr((t=this._stencilStateComposer.funcRef)!=null?t:0)):this._getCurrentRenderPass().setStencilReference((i=this._stencilStateComposer.funcRef)!=null?i:0)}_mustUpdateBlendColor(){const e=this._alphaState._blendConstants,t=e[0]!==this._blendColorsCurrent[0]||e[1]!==this._blendColorsCurrent[1]||e[2]!==this._blendColorsCurrent[2]||e[3]!==this._blendColorsCurrent[3];return t&&(this._blendColorsCurrent[0]=e[0],this._blendColorsCurrent[1]=e[1],this._blendColorsCurrent[2]=e[2],this._blendColorsCurrent[3]=e[3]),t}_applyBlendColor(e){e?e.addItem(new S0(this._alphaState._blendConstants.slice())):this._getCurrentRenderPass().setBlendConstant(this._alphaState._blendConstants)}_resetRenderPassStates(){this._viewportsCurrent.x=this._viewportsCurrent.y=this._viewportsCurrent.w=this._viewportsCurrent.h=0,this._scissorsCurrent.x=this._scissorsCurrent.y=this._scissorsCurrent.w=this._scissorsCurrent.h=0,this._stencilRefsCurrent=-1,this._blendColorsCurrent[0]=this._blendColorsCurrent[1]=this._blendColorsCurrent[2]=this._blendColorsCurrent[3]=null}clear(e,t,i,s=!1){e&&e.a===void 0&&(e.a=1);const n=this._scissorIsActive();this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&U.Log(["frame #"+this._count+" - clear - backBuffer=",t," depth=",i," stencil=",s," scissor is active=",n])),this._currentRenderTarget?n?(this._currentRenderPass||this._startRenderTargetRenderPass(this._currentRenderTarget,!1,t?e:null,i,s),this._applyScissor(this.compatibilityMode?null:this._bundleList),this._clearFullQuad(t?e:null,i,s)):(this._currentRenderPass&&this._endCurrentRenderPass(),this._startRenderTargetRenderPass(this._currentRenderTarget,!0,t?e:null,i,s)):((!this._currentRenderPass||!n)&&this._startMainRenderPass(!n,t?e:null,i,s),n&&(this._applyScissor(this.compatibilityMode?null:this._bundleList),this._clearFullQuad(t?e:null,i,s)))}_clearFullQuad(e,t,i){var r,o;const s=this.compatibilityMode?this._getCurrentRenderPass():null;this._clearQuad.setColorFormat(this._colorFormat),this._clearQuad.setDepthStencilFormat(this._depthTextureFormat),this._clearQuad.setMRTAttachments((r=this._cacheRenderPipeline.mrtAttachments)!=null?r:[],(o=this._cacheRenderPipeline.mrtTextureArray)!=null?o:[],this._cacheRenderPipeline.mrtTextureCount),this.compatibilityMode?s.setStencilReference(this._clearStencilValue):this._bundleList.addItem(new Pr(this._clearStencilValue));const n=this._clearQuad.clear(s,e,t,i,this.currentSampleCount);this.compatibilityMode?this._applyStencilRef(null):(this._bundleList.addBundle(n),this._applyStencilRef(this._bundleList),this._reportDrawCall())}createVertexBuffer(e,t,i){let s;return e instanceof Array?s=new Float32Array(e):e instanceof ArrayBuffer?s=new Uint8Array(e):s=e,this._bufferManager.createBuffer(s,We.Vertex|We.CopyDst,i)}createDynamicVertexBuffer(e,t){return this.createVertexBuffer(e,void 0,t)}createIndexBuffer(e,t,i){let s=!0,n;e instanceof Uint32Array||e instanceof Int32Array?n=e:e instanceof Uint16Array?(n=e,s=!1):e.length>65535?n=new Uint32Array(e):(n=new Uint16Array(e),s=!1);const r=this._bufferManager.createBuffer(n,We.Index|We.CopyDst,i);return r.is32Bits=s,r}updateDynamicIndexBuffer(e,t,i=0){const s=e;let n;e.is32Bits?n=t instanceof Uint32Array?t:new Uint32Array(t):n=t instanceof Uint16Array?t:new Uint16Array(t),this._bufferManager.setSubData(s,i,n)}updateDynamicVertexBuffer(e,t,i,s){const n=e;i===void 0&&(i=0);let r;s===void 0?(t instanceof Array?r=new Float32Array(t):t instanceof ArrayBuffer?r=new Uint8Array(t):r=t,s=r.byteLength):t instanceof Array?r=new Float32Array(t):t instanceof ArrayBuffer?r=new Uint8Array(t):r=t,this._bufferManager.setSubData(n,i,r,0,s)}_createBuffer(e,t,i){let s;e instanceof Array?s=new Float32Array(e):e instanceof ArrayBuffer?s=new Uint8Array(e):s=e;let n=0;return t&1&&(n|=We.CopySrc),t&2&&(n|=We.CopyDst),t&4&&(n|=We.Uniform),t&8&&(n|=We.Vertex),t&16&&(n|=We.Index),t&32&&(n|=We.Storage),t&64&&(n|=We.Indirect),this._bufferManager.createBuffer(s,n,i)}bindBuffersDirectly(){throw"Not implemented on WebGPU"}updateAndBindInstancesBuffer(){throw"Not implemented on WebGPU"}unbindInstanceAttributes(){}bindBuffers(e,t,i,s){this._currentIndexBuffer=t,this._currentOverrideVertexBuffers=s!=null?s:null,this._cacheRenderPipeline.setBuffers(e,t,this._currentOverrideVertexBuffers)}_releaseBuffer(e){return this._bufferManager.releaseBuffer(e)}createUniformBuffer(e,t){let i;return e instanceof Array?i=new Float32Array(e):i=e,this._bufferManager.createBuffer(i,We.Uniform|We.CopyDst,t)}createDynamicUniformBuffer(e,t){return this.createUniformBuffer(e,t)}updateUniformBuffer(e,t,i,s){i===void 0&&(i=0);const n=e;let r;s===void 0?(t instanceof Float32Array?r=t:r=new Float32Array(t),s=r.byteLength):t instanceof Float32Array?r=t:r=new Float32Array(t),this._bufferManager.setSubData(n,i,r,0,s)}bindUniformBufferBase(e,t,i){this._currentDrawContext.setBuffer(i,e)}bindUniformBlock(){}createEffect(e,t,i,s,n,r,o,h,l,c=0,u){var b,I,T;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,_=this._getGlobalDefines();let p=(b=n!=null?n:t.defines)!=null?b:"";_&&(p+="\n"+_);const g=f+"+"+d+"@"+p;if(this._compiledEffects[g]){const x=this._compiledEffects[g];return o&&x.isReady()&&o(x),x._refCount++,x}const m=new Et(e,t,i,s,this,n,r,o,h,l,g,(I=t.shaderLanguage)!=null?I:c,(T=t.extraInitializationsAsync)!=null?T:u);return this._compiledEffects[g]=m,m}_compileRawShaderToSpirV(e,t){return this._glslang.compileGLSL(e,t)}_compileShaderToSpirV(e,t,i,s){return this._compileRawShaderToSpirV(s+(i?i+"\n":"")+e,t)}_getWGSLShader(e,t,i){return i?i="//"+i.split("\n").join("\n//")+"\n":i="",i+e}_createPipelineStageDescriptor(e,t,i,s,n){return this._tintWASM&&i===0&&(e=this._tintWASM.convertSpirV2WGSL(e,s),t=this._tintWASM.convertSpirV2WGSL(t,n)),{vertexStage:{module:this._device.createShaderModule({label:"vertex",code:e}),entryPoint:"main"},fragmentStage:{module:this._device.createShaderModule({label:"fragment",code:t}),entryPoint:"main"}}}_compileRawPipelineStageDescriptor(e,t,i){const s=e.indexOf("#define DISABLE_UNIFORMITY_ANALYSIS")>=0,n=t.indexOf("#define DISABLE_UNIFORMITY_ANALYSIS")>=0,r=i===0?this._compileRawShaderToSpirV(e,"vertex"):e,o=i===0?this._compileRawShaderToSpirV(t,"fragment"):t;return this._createPipelineStageDescriptor(r,o,i,s,n)}_compilePipelineStageDescriptor(e,t,i,s){this.onBeforeShaderCompilationObservable.notifyObservers(this);const n=e.indexOf("#define DISABLE_UNIFORMITY_ANALYSIS")>=0,r=t.indexOf("#define DISABLE_UNIFORMITY_ANALYSIS")>=0,o="#version 450\n",h=s===0?this._compileShaderToSpirV(e,"vertex",i,o):this._getWGSLShader(e,"vertex",i),l=s===0?this._compileShaderToSpirV(t,"fragment",i,o):this._getWGSLShader(t,"fragment",i),c=this._createPipelineStageDescriptor(h,l,s,n,r);return this.onAfterShaderCompilationObservable.notifyObservers(this),c}createRawShaderProgram(){throw"Not available on WebGPU"}createShaderProgram(){throw"Not available on WebGPU"}inlineShaderCode(e){const t=new Hr(e);return t.debug=!1,t.processCode(),t.code}createPipelineContext(e){return new u_(e,this)}createMaterialContext(){return new zr}createDrawContext(){return new Wr(this._bufferManager)}async _preparePipelineContext(e,t,i,s,n,r,o,h,l,c,u){const f=e,d=f.shaderProcessingContext.shaderLanguage;d===0&&!this._glslangAndTintAreFullyLoaded&&await this.prepareGlslangAndTintAsync(),this.dbgShowShaderCode&&(U.Log(["defines",h]),U.Log(t),U.Log(i),U.Log("***********************************************")),f.sources={fragment:i,vertex:t,rawVertex:n,rawFragment:r},s?f.stages=this._compileRawPipelineStageDescriptor(t,i,d):f.stages=this._compilePipelineStageDescriptor(t,i,h,d),u()}getAttributes(e,t){const i=new Array(t.length),s=e;for(let n=0;n<t.length;n++){const r=t[n],o=s.shaderProcessingContext.availableAttributes[r];o!==void 0&&(i[n]=o)}return i}enableEffect(e){if(e){if(!Nl(e))this._currentEffect=e,this._currentMaterialContext=this._defaultMaterialContext,this._currentDrawContext=this._defaultDrawContext,this._counters.numEnableEffects++,this.dbgLogIfNotDrawWrapper&&U.Warn("enableEffect has been called with an Effect and not a Wrapper! effect.uniqueId=".concat(e.uniqueId,", effect.name=").concat(e.name,", effect.name.vertex=").concat(typeof e.name=="string"?"":e.name.vertex,", effect.name.fragment=").concat(typeof e.name=="string"?"":e.name.fragment),10);else if(!e.effect||e.effect===this._currentEffect&&e.materialContext===this._currentMaterialContext&&e.drawContext===this._currentDrawContext&&!this._forceEnableEffect){if(!e.effect&&this.dbgShowEmptyEnableEffectCalls)throw U.Log(["drawWrapper=",e]),"Invalid call to enableEffect: the effect property is empty!";return}else if(this._currentEffect=e.effect,this._currentMaterialContext=e.materialContext,this._currentDrawContext=e.drawContext,this._counters.numEnableDrawWrapper++,!this._currentMaterialContext)throw U.Log(["drawWrapper=",e]),"Invalid call to enableEffect: the materialContext property is empty!";this._stencilStateComposer.stencilMaterial=void 0,this._forceEnableEffect=!1,this._currentEffect.onBind&&this._currentEffect.onBind(this._currentEffect),this._currentEffect._onBindObservable&&this._currentEffect._onBindObservable.notifyObservers(this._currentEffect)}}_releaseEffect(e){this._compiledEffects[e._key]&&(delete this._compiledEffects[e._key],this._deletePipelineContext(e.getPipelineContext()))}releaseEffects(){for(const e in this._compiledEffects){const t=this._compiledEffects[e].getPipelineContext();this._deletePipelineContext(t)}this._compiledEffects={}}_deletePipelineContext(e){const t=e;t&&_0(t)}get needPOTTextures(){return!1}_createHardwareTexture(){return new pr(this)}_releaseTexture(e){const t=this._internalTexturesCache.indexOf(e);t!==-1&&this._internalTexturesCache.splice(t,1),this._textureHelper.releaseTexture(e)}_getRGBABufferInternalSizedFormat(){return 5}updateTextureComparisonFunction(e,t){e._comparisonFunction=t}_createInternalTexture(e,t,i=!0,s=0){var u,f,d;const n={};t!==void 0&&typeof t=="object"?(n.generateMipMaps=t.generateMipMaps,n.createMipMaps=t.createMipMaps,n.type=t.type===void 0?0:t.type,n.samplingMode=t.samplingMode===void 0?3:t.samplingMode,n.format=t.format===void 0?5:t.format,n.samples=(u=t.samples)!=null?u:1,n.creationFlags=(f=t.creationFlags)!=null?f:0,n.useSRGBBuffer=(d=t.useSRGBBuffer)!=null?d:!1,n.label=t.label):(n.generateMipMaps=t,n.type=0,n.samplingMode=3,n.format=5,n.samples=1,n.creationFlags=0,n.useSRGBBuffer=!1),(n.type===1&&!this._caps.textureFloatLinearFiltering||n.type===2&&!this._caps.textureHalfFloatLinearFiltering)&&(n.samplingMode=1),n.type===1&&!this._caps.textureFloat&&(n.type=0,U.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));const r=new ft(this,s),o=e.width||e,h=e.height||e,l=e.depth||0,c=e.layers||0;if(r.baseWidth=o,r.baseHeight=h,r.width=o,r.height=h,r.depth=l||c,r.isReady=!0,r.samples=n.samples,r.generateMipMaps=!!n.generateMipMaps,r.samplingMode=n.samplingMode,r.type=n.type,r.format=n.format,r.is2DArray=c>0,r.is3D=l>0,r._cachedWrapU=0,r._cachedWrapV=0,r._useSRGBBuffer=n.useSRGBBuffer,r.label=n.label,this._internalTexturesCache.push(r),!i){const _=!n.generateMipMaps&&n.createMipMaps;_&&(r.generateMipMaps=!0),this._textureHelper.createGPUTextureForInternalTexture(r,o,h,c||1,n.creationFlags),_&&(r.generateMipMaps=!1)}return r}createTexture(e,t,i,s,n=3,r=null,o=null,h=null,l=null,c=null,u=null,f,d,_,p){return this._createTextureBase(e,t,i,s,n,r,o,(g,m,b,I,T,x,y,R)=>{var C;const E=I;if(g.baseWidth=E.width,g.baseHeight=E.height,g.width=E.width,g.height=E.height,g.format=g.format!==-1?g.format:c!=null?c:5,g.type=g.type!==-1?g.type:0,g._creationFlags=_!=null?_:0,R(g.width,g.height,E,m,g,()=>{}),(C=g._hardwareTexture)!=null&&C.underlyingResource)!x&&!y&&this._generateMipmaps(g,this._uploadEncoder);else{const S=this._textureHelper.createGPUTextureForInternalTexture(g,E.width,E.height,void 0,_);Ve.IsImageBitmap(E)&&(this._textureHelper.updateTexture(E,g,E.width,E.height,g.depth,S.format,0,0,T,!1,0,0),!x&&!y&&this._generateMipmaps(g,this._uploadEncoder))}b&&b.removePendingData(g),g.isReady=!0,g.onLoadedObservable.notifyObservers(g),g.onLoadedObservable.clear()},()=>!1,h,l,c,u,f,d,p)}wrapWebGPUTexture(e){const t=new pr(this,e),i=new ft(this,0,!0);return i._hardwareTexture=t,i.isReady=!0,i}wrapWebGLTexture(){throw new Error("wrapWebGLTexture is not supported, use wrapWebGPUTexture instead.")}_getUseSRGBBuffer(e,t){return e&&this._caps.supportSRGBBuffers}_unpackFlipY(e){}updateTextureSamplingMode(e,t,i=!1){i&&(t.generateMipMaps=!0,this._generateMipmaps(t)),t.samplingMode=e}updateTextureWrappingMode(e,t,i=null,s=null){t!==null&&(e._cachedWrapU=t),i!==null&&(e._cachedWrapV=i),(e.is2DArray||e.is3D)&&s!==null&&(e._cachedWrapR=s)}updateTextureDimensions(e,t,i,s=1){if(!e._hardwareTexture||e.width===t&&e.height===i&&e.depth===s)return;const n=e._hardwareTexture.textureAdditionalUsages;e._hardwareTexture.release(),this._textureHelper.createGPUTextureForInternalTexture(e,t,i,s,n)}_setInternalTexture(e,t,i){if(i=i!=null?i:e,this._currentEffect){const n=this._currentEffect._pipelineContext.shaderProcessingContext.availableTextures[i];if(this._currentMaterialContext.setTexture(e,t),n&&n.autoBindSampler){const r=i+"Sampler";this._currentMaterialContext.setSampler(r,t)}}}createPrefilteredCubeTexture(e,t,i,s,n=null,r=null,o,h=null,l=!0){const c=u=>{if(!u){n&&n(null);return}const f=u.texture;l?u.info.sphericalPolynomial&&(f._sphericalPolynomial=u.info.sphericalPolynomial):f._sphericalPolynomial=new On,f._source=9,n&&n(f)};return this.createCubeTexture(e,t,null,!1,c,r,o,h,l,i,s)}setTexture(e,t,i,s){this._setTexture(e,i,!1,!1,s,s)}setTextureArray(e,t,i,s){for(let n=0;n<i.length;n++)this._setTexture(-1,i[n],!0,!1,s+n.toString(),s)}_setTexture(e,t,i=!1,s=!1,n="",r){if(r=r!=null?r:n,this._currentEffect){if(!t)return this._currentMaterialContext.setTexture(n,null),!1;if(t.video)t.update();else if(t.delayLoadState===4)return t.delayLoad(),!1;let o=null;if(s?o=t.depthStencilTexture:t.isReady()?o=t.getInternalTexture():t.isCube?o=this.emptyCubeTexture:t.is3D?o=this.emptyTexture3D:t.is2DArray?o=this.emptyTexture2DArray:o=this.emptyTexture,o&&!o.isMultiview){if(o.isCube&&o._cachedCoordinatesMode!==t.coordinatesMode){o._cachedCoordinatesMode=t.coordinatesMode;const h=t.coordinatesMode!==3&&t.coordinatesMode!==5?1:0;t.wrapU=h,t.wrapV=h}o._cachedWrapU=t.wrapU,o._cachedWrapV=t.wrapV,o.is3D&&(o._cachedWrapR=t.wrapR),this._setAnisotropicLevel(0,o,t.anisotropicFilteringLevel)}this._setInternalTexture(n,o,r)}else this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&U.Log(["frame #"+this._count+" - _setTexture called with a null _currentEffect! texture=",t]));return!0}_setAnisotropicLevel(e,t,i){t._cachedAnisotropicFilteringLevel!==i&&(t._cachedAnisotropicFilteringLevel=Math.min(i,this._caps.maxAnisotropy))}_bindTexture(e,t,i){e!==void 0&&this._setInternalTexture(i,t)}generateMipmaps(e){this._generateMipmaps(e)}updateTextureData(e,t,i,s,n,r,o=0,h=0,l=!1){var f;let c=e._hardwareTexture;(f=e._hardwareTexture)!=null&&f.underlyingResource||(c=this._textureHelper.createGPUTextureForInternalTexture(e));const u=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);this._textureHelper.updateTexture(u,e,n,r,e.depth,c.format,o,h,e.invertY,!1,i,s),l&&this._generateMipmaps(e)}_uploadCompressedDataToTextureDirectly(e,t,i,s,n,r=0,o=0){var c;let h=e._hardwareTexture;(c=e._hardwareTexture)!=null&&c.underlyingResource||(e.format=t,h=this._textureHelper.createGPUTextureForInternalTexture(e,i,s));const l=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);this._textureHelper.updateTexture(l,e,i,s,e.depth,h.format,r,o,!1,!1,0,0)}_uploadDataToTextureDirectly(e,t,i=0,s=0,n,r=!1){var d;const o=Math.round(Math.log(e.width)*Math.LOG2E),h=Math.round(Math.log(e.height)*Math.LOG2E),l=r?e.width:Math.pow(2,Math.max(o-s,0)),c=r?e.height:Math.pow(2,Math.max(h-s,0));let u=e._hardwareTexture;(d=e._hardwareTexture)!=null&&d.underlyingResource||(u=this._textureHelper.createGPUTextureForInternalTexture(e,l,c));const f=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);this._textureHelper.updateTexture(f,e,l,c,e.depth,u.format,i,s,e.invertY,!1,0,0)}_uploadArrayBufferViewToTexture(e,t,i=0,s=0){this._uploadDataToTextureDirectly(e,t,i,s)}_uploadImageToTexture(e,t,i=0,s=0){var l;let n=e._hardwareTexture;if((l=e._hardwareTexture)!=null&&l.underlyingResource||(n=this._textureHelper.createGPUTextureForInternalTexture(e)),t instanceof HTMLImageElement)throw"WebGPU engine: HTMLImageElement not supported in _uploadImageToTexture!";const r=t,o=Math.ceil(e.width/(1<<s)),h=Math.ceil(e.height/(1<<s));this._textureHelper.updateTexture(r,e,o,h,e.depth,n.format,i,s,e.invertY,!1,0,0)}readPixels(e,t,i,s,n=!0,r=!0){const h=this._getCurrentRenderPassWrapper().colorAttachmentGPUTextures[0];if(!h)return Promise.resolve(new Uint8Array(0));const l=h.underlyingResource,c=h.format;return l?(r&&this.flushFramebuffer(),this._textureHelper.readPixels(l,e,t,i,s,c)):Promise.resolve(new Uint8Array(0))}_measureFps(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaTime=this._performanceMonitor.instantaneousFrameTime||0}get performanceMonitor(){return this._performanceMonitor}beginFrame(){this._measureFps(),super.beginFrame()}endFrame(){if(this._endCurrentRenderPass(),this._snapshotRendering.endFrame(),this._timestampQuery.endFrame(this._renderEncoder),this._timestampIndex=0,this.flushFramebuffer(),this._textureHelper.destroyDeferredTextures(),this._bufferManager.destroyDeferredBuffers(),this._features._collectUbosUpdatedInFrame){if(this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),!this._count||this._count<this.dbgVerboseLogsNumFrames)){const e=[];for(const t in fe._UpdatedUbosInFrame)e.push(t+":"+fe._UpdatedUbosInFrame[t]);U.Log(["frame #"+this._count+" - updated ubos -",e.join(", ")])}fe._UpdatedUbosInFrame={}}this.countersLastFrame.numEnableEffects=this._counters.numEnableEffects,this.countersLastFrame.numEnableDrawWrapper=this._counters.numEnableDrawWrapper,this.countersLastFrame.numBundleCreationNonCompatMode=this._counters.numBundleCreationNonCompatMode,this.countersLastFrame.numBundleReuseNonCompatMode=this._counters.numBundleReuseNonCompatMode,this._counters.numEnableEffects=0,this._counters.numEnableDrawWrapper=0,this._counters.numBundleCreationNonCompatMode=0,this._counters.numBundleReuseNonCompatMode=0,this._cacheRenderPipeline.endFrame(),this._cacheBindGroups.endFrame(),this._pendingDebugCommands.length=0,this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),this._count<this.dbgVerboseLogsNumFrames&&U.Log(["%c frame #"+this._count+" - end","background: #ffff00"]),this._count<this.dbgVerboseLogsNumFrames&&(this._count++,this._count!==this.dbgVerboseLogsNumFrames&&U.Log(["%c frame #"+this._count+" - begin","background: #ffff00"]))),super.endFrame()}extractDriverInfo(){return""}flushFramebuffer(){this._endCurrentRenderPass(),this._commandBuffers[0]=this._uploadEncoder.finish(),this._commandBuffers[1]=this._renderEncoder.finish(),this._device.queue.submit(this._commandBuffers),this._uploadEncoder=this._device.createCommandEncoder(this._uploadEncoderDescriptor),this._renderEncoder=this._device.createCommandEncoder(this._renderEncoderDescriptor),this._timestampQuery.startFrame(this._uploadEncoder),this._textureHelper.setCommandEncoder(this._uploadEncoder),this._bundleList.reset()}_currentFrameBufferIsDefaultFrameBuffer(){return this._currentPassIsMainPass()}_startRenderTargetRenderPass(e,t,i,s,n){var I,T,x,y,R,E;this._endCurrentRenderPass();const r=e,o=r._depthStencilTexture,h=o==null?void 0:o._hardwareTexture,l=h==null?void 0:h.underlyingResource,c=h==null?void 0:h.getMSAATexture(0),u=l==null?void 0:l.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor),f=c==null?void 0:c.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor),d=h?Ve.HasStencilAspect(h.format):!1,_=[];this.useReverseDepthBuffer&&this.setDepthFunctionToGreaterOrEqual();const p=Np;i&&(p.r=i.r*255,p.g=i.g*255,p.b=i.b*255,p.a=i.a*255);const g=t&&i,m=t&&s,b=t&&n;if(r._attachments&&r.isMulti){(!this._mrtAttachments||this._mrtAttachments.length===0)&&(this._mrtAttachments=r._defaultAttachments);for(let C=0;C<this._mrtAttachments.length;++C){const S=this._mrtAttachments[C],w=r.textures[C],P=w==null?void 0:w._hardwareTexture,G=P==null?void 0:P.underlyingResource;if(P&&G){const L=r.getBaseArrayLayer(C),W=P.getMSAATexture(L),K={...this._rttRenderPassWrapper.colorAttachmentViewDescriptor,dimension:w.is3D?"3d":"2d",format:P.format,baseArrayLayer:L},ce={...this._rttRenderPassWrapper.colorAttachmentViewDescriptor,dimension:w.is3D?"3d":"2d",format:P.format,baseArrayLayer:0},$=w.type===7||w.type===5,z=G.createView(K),k=W==null?void 0:W.createView(ce);_.push({view:k||z,resolveTarget:W?z:void 0,depthSlice:w.is3D?(T=(I=r.layerIndices)==null?void 0:I[C])!=null?T:0:void 0,clearValue:S!==0&&g?$?p:i:void 0,loadOp:S!==0&&g?"clear":"load",storeOp:"store"})}}this._cacheRenderPipeline.setMRT(r.textures,this._mrtAttachments.length),this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments)}else{const C=r.texture;if(C){const S=C._hardwareTexture,w=S.underlyingResource;let P;r.is3D&&(P=this._rttRenderPassWrapper.colorAttachmentViewDescriptor.baseArrayLayer,this._rttRenderPassWrapper.colorAttachmentViewDescriptor.baseArrayLayer=0);const G=S.getMSAATexture(0),L=w.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor),W=G==null?void 0:G.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor),K=C.type===7||C.type===5;_.push({view:W||L,resolveTarget:G?L:void 0,depthSlice:P,clearValue:g?K?p:i:void 0,loadOp:g?"clear":"load",storeOp:"store"})}else _.push(null)}if((x=this._debugPushGroup)==null||x.call(this,"render target pass"+(e.label?" ("+e.label+")":""),0),this._rttRenderPassWrapper.renderPassDescriptor={label:((y=e.label)!=null?y:"RTT")+" - RenderPass",colorAttachments:_,depthStencilAttachment:o&&l?{view:f||u,depthClearValue:m?this.useReverseDepthBuffer?this._clearReverseDepthValue:this._clearDepthValue:void 0,depthLoadOp:m?"clear":"load",depthStoreOp:"store",stencilClearValue:r._depthStencilTextureWithStencil&&b?this._clearStencilValue:void 0,stencilLoadOp:d?r._depthStencilTextureWithStencil&&b?"clear":"load":void 0,stencilStoreOp:d?"store":void 0}:void 0,occlusionQuerySet:(R=this._occlusionQuery)!=null&&R.hasQueries?this._occlusionQuery.querySet:void 0},this._timestampQuery.startPass(this._rttRenderPassWrapper.renderPassDescriptor,this._timestampIndex),this._currentRenderPass=this._renderEncoder.beginRenderPass(this._rttRenderPassWrapper.renderPassDescriptor),this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),!this._count||this._count<this.dbgVerboseLogsNumFrames)){const C=r.texture;U.Log(["frame #"+this._count+" - render target begin pass - rtt name="+e.label+", internalTexture.uniqueId="+C.uniqueId+", width="+C.width+", height="+C.height+", setClearStates="+t,"renderPassDescriptor=",this._rttRenderPassWrapper.renderPassDescriptor])}(E=this._debugFlushPendingCommands)==null||E.call(this),this._resetRenderPassStates(),(!h||!Ve.HasStencilAspect(h.format))&&(this._stencilStateComposer.enabled=!1)}_startMainRenderPass(e,t,i,s){var l,c,u;this._endCurrentRenderPass(),this.useReverseDepthBuffer&&this.setDepthFunctionToGreaterOrEqual();const n=e&&t,r=e&&i,o=e&&s;this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].clearValue=n?t:void 0,this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].loadOp=n?"clear":"load",this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthClearValue=r?this.useReverseDepthBuffer?this._clearReverseDepthValue:this._clearDepthValue:void 0,this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthLoadOp=r?"clear":"load",this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilClearValue=o?this._clearStencilValue:void 0,this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilLoadOp=this.isStencilEnable?o?"clear":"load":void 0,this._mainRenderPassWrapper.renderPassDescriptor.occlusionQuerySet=(l=this._occlusionQuery)!=null&&l.hasQueries?this._occlusionQuery.querySet:void 0;const h=this._context.getCurrentTexture();this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].set(h),this._options.antialias?(wh.format=h.format,this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].resolveTarget=h.createView(wh)):(Dh.format=h.format,this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].view=h.createView(Dh)),this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&U.Log(["frame #"+this._count+" - main begin pass - texture width="+this._mainTextureExtends.width," height="+this._mainTextureExtends.height+", setClearStates="+e,"renderPassDescriptor=",this._mainRenderPassWrapper.renderPassDescriptor])),(c=this._debugPushGroup)==null||c.call(this,"main pass",0),this._timestampQuery.startPass(this._mainRenderPassWrapper.renderPassDescriptor,this._timestampIndex),this._currentRenderPass=this._renderEncoder.beginRenderPass(this._mainRenderPassWrapper.renderPassDescriptor),this._setDepthTextureFormat(this._mainRenderPassWrapper),this._setColorFormat(this._mainRenderPassWrapper),(u=this._debugFlushPendingCommands)==null||u.call(this),this._resetRenderPassStates(),this._isStencilEnable||(this._stencilStateComposer.enabled=!1)}bindFramebuffer(e,t=0,i,s,n,r=0,o=0){var c,u;const h=(c=e.texture)==null?void 0:c._hardwareTexture;this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this._endCurrentRenderPass(),this._currentRenderTarget=e;const l=this._currentRenderTarget._depthStencilTexture;this._rttRenderPassWrapper.colorAttachmentGPUTextures[0]=h,this._rttRenderPassWrapper.depthTextureFormat=l?Ve.GetWebGPUTextureFormat(-1,l.format):void 0,this._setDepthTextureFormat(this._rttRenderPassWrapper),this._setColorFormat(this._rttRenderPassWrapper),this._rttRenderPassWrapper.colorAttachmentViewDescriptor={format:this._colorFormat,dimension:e.is3D?"3d":"2d",mipLevelCount:1,baseArrayLayer:e.isCube?o*6+t:o,baseMipLevel:r,arrayLayerCount:1,aspect:"all"},this._rttRenderPassWrapper.depthAttachmentViewDescriptor={format:this._depthTextureFormat,dimension:l&&l.is3D?"3d":"2d",mipLevelCount:1,baseArrayLayer:l?l.isCube?o*6+t:o:0,baseMipLevel:0,arrayLayerCount:1,aspect:"all"},this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&U.Log(["frame #"+this._count+" - bindFramebuffer - rtt name="+e.label+", internalTexture.uniqueId="+((u=e.texture)==null?void 0:u.uniqueId)+", face="+t+", lodLevel="+r+", layer="+o,"colorAttachmentViewDescriptor=",this._rttRenderPassWrapper.colorAttachmentViewDescriptor,"depthAttachmentViewDescriptor=",this._rttRenderPassWrapper.depthAttachmentViewDescriptor])),this._cachedViewport&&!n?this.setViewport(this._cachedViewport,i,s):(i||(i=e.width,r&&(i=i/Math.pow(2,r))),s||(s=e.height,r&&(s=s/Math.pow(2,r))),this._viewport(0,0,i,s)),this.wipeCaches()}unBindFramebuffer(e,t=!1,i){var n;const s=this._currentRenderTarget;this._currentRenderTarget=null,i&&i(),this._currentRenderTarget=s,this._endCurrentRenderPass(),t||(e.isMulti?this.generateMipMapsMultiFramebuffer(e):this.generateMipMapsFramebuffer(e)),this._currentRenderTarget=null,this.dbgVerboseLogsForFirstFrames&&(this._count===void 0&&(this._count=0),(!this._count||this._count<this.dbgVerboseLogsNumFrames)&&U.Log("frame #"+this._count+" - unBindFramebuffer - rtt name="+e.label+", internalTexture.uniqueId=",(n=e.texture)==null?void 0:n.uniqueId)),this._mrtAttachments=[],this._cacheRenderPipeline.setMRT([]),this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments)}generateMipMapsFramebuffer(e){var t;!e.isMulti&&((t=e.texture)!=null&&t.generateMipMaps)&&!e.isCube&&this._generateMipmaps(e.texture)}resolveFramebuffer(e){throw new Error("resolveFramebuffer is not yet implemented in WebGPU!")}restoreDefaultFramebuffer(){this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this._currentRenderPass||this._startMainRenderPass(!1),this._cachedViewport&&this.setViewport(this._cachedViewport),this.wipeCaches()}_setColorFormat(e){var i,s;const t=(s=(i=e.colorAttachmentGPUTextures[0])==null?void 0:i.format)!=null?s:null;this._cacheRenderPipeline.setColorFormat(t),this._colorFormat!==t&&(this._colorFormat=t)}_setDepthTextureFormat(e){this._cacheRenderPipeline.setDepthStencilFormat(e.depthTextureFormat),this._depthTextureFormat!==e.depthTextureFormat&&(this._depthTextureFormat=e.depthTextureFormat)}setDitheringState(){}setRasterizerState(){}_executeWhenRenderingStateIsCompiled(e,t){t()}bindSamplers(){}_getUnpackAlignement(){return 1}_bindTextureDirectly(){return!1}setState(e,t=0,i,s=!1,n,r,o=0){var c,u;(this._depthCullingState.cull!==e||i)&&(this._depthCullingState.cull=e);const h=(u=(c=this.cullBackFaces)!=null?c:n)==null||u?1:2;(this._depthCullingState.cullFace!==h||i)&&(this._depthCullingState.cullFace=h),this.setZOffset(t),this.setZOffsetUnits(o);const l=s?this._currentRenderTarget?1:2:this._currentRenderTarget?2:1;(this._depthCullingState.frontFace!==l||i)&&(this._depthCullingState.frontFace=l),this._stencilStateComposer.stencilMaterial=r}_applyRenderPassChanges(e){const t=this._stencilStateComposer.enabled?this._mustUpdateStencilRef():!1,i=this._alphaState.alphaBlend?this._mustUpdateBlendColor():!1;this._mustUpdateViewport()&&this._applyViewport(e),this._mustUpdateScissor()&&this._applyScissor(e),t&&this._applyStencilRef(e),i&&this._applyBlendColor(e)}_draw(e,t,i,s,n){var g;const r=this._getCurrentRenderPass(),o=this._bundleList;this.applyStates();const h=this._currentEffect._pipelineContext;if(this.bindUniformBufferBase(this._currentRenderTarget?this._ubInvertY:this._ubDontInvertY,0,At.InternalsUBOName),h.uniformBuffer&&(h.uniformBuffer.update(),this.bindUniformBufferBase(h.uniformBuffer.getBuffer(),0,At.LeftOvertUBOName)),this._snapshotRendering.play){this._reportDrawCall();return}!this.compatibilityMode&&(this._currentDrawContext.isDirty(this._currentMaterialContext.updateId)||this._currentMaterialContext.isDirty||this._currentMaterialContext.forceBindGroupCreation)&&(this._currentDrawContext.fastBundle=void 0);const l=!this.compatibilityMode&&this._currentDrawContext.fastBundle;let c=r;if(l||this._snapshotRendering.record){if(this._applyRenderPassChanges(o),!this._snapshotRendering.record){this._counters.numBundleReuseNonCompatMode++,this._currentDrawContext.indirectDrawBuffer&&this._currentDrawContext.setIndirectData(s,n||1,i),o.addBundle(this._currentDrawContext.fastBundle),this._reportDrawCall();return}c=o.getBundleEncoder(this._cacheRenderPipeline.colorFormats,this._depthTextureFormat,this.currentSampleCount),o.numDrawCalls++}let u=0;if(this._currentMaterialContext.hasFloatOrDepthTextures){let m=1;for(let b=0;b<h.shaderProcessingContext.textureNames.length;++b){const I=h.shaderProcessingContext.textureNames[b],T=(g=this._currentMaterialContext.textures[I])==null?void 0:g.texture,x=T&&T.format>=13&&T.format<=18;((T==null?void 0:T.type)===1&&!this._caps.textureFloatLinearFiltering||x)&&(u|=m),m=m<<1}}this._currentMaterialContext.textureState=u;const f=this._cacheRenderPipeline.getRenderPipeline(t,this._currentEffect,this.currentSampleCount,u),d=this._cacheBindGroups.getBindGroups(h,this._currentDrawContext,this._currentMaterialContext);this._snapshotRendering.record||(this._applyRenderPassChanges(this.compatibilityMode?null:o),this.compatibilityMode||(this._counters.numBundleCreationNonCompatMode++,c=this._device.createRenderBundleEncoder({colorFormats:this._cacheRenderPipeline.colorFormats,depthStencilFormat:this._depthTextureFormat,sampleCount:Ve.GetSample(this.currentSampleCount)}))),c.setPipeline(f),this._currentIndexBuffer&&c.setIndexBuffer(this._currentIndexBuffer.underlyingResource,this._currentIndexBuffer.is32Bits?"uint32":"uint16",0);const _=this._cacheRenderPipeline.vertexBuffers;for(let m=0;m<_.length;m++){const b=_[m],I=b.effectiveBuffer;I&&c.setVertexBuffer(m,I.underlyingResource,b._validOffsetRange?0:b.byteOffset)}for(let m=0;m<d.length;m++)c.setBindGroup(m,d[m]);const p=!this.compatibilityMode&&!this._snapshotRendering.record;p&&this._currentDrawContext.indirectDrawBuffer?(this._currentDrawContext.setIndirectData(s,n||1,i),e===0?c.drawIndexedIndirect(this._currentDrawContext.indirectDrawBuffer,0):c.drawIndirect(this._currentDrawContext.indirectDrawBuffer,0)):e===0?c.drawIndexed(s,n||1,i,0,0):c.draw(s,n||1,i,0),p&&(this._currentDrawContext.fastBundle=c.finish(),o.addBundle(this._currentDrawContext.fastBundle)),this._reportDrawCall()}drawElementsType(e,t,i,s=1){this._draw(0,e,t,i,s)}drawArraysType(e,t,i,s=1){this._currentIndexBuffer=null,this._draw(1,e,t,i,s)}dispose(){var e,t;this._isDisposed=!0,this.hideLoadingUI(),this._timestampQuery.dispose(),(e=this._mainTexture)==null||e.destroy(),(t=this._depthTexture)==null||t.destroy(),this._textureHelper.destroyDeferredTextures(),this._bufferManager.destroyDeferredBuffers(),this._device.destroy(),lc(this,this._renderingCanvas),super.dispose()}getRenderWidth(e=!1){var t,i;return!e&&this._currentRenderTarget?this._currentRenderTarget.width:(i=(t=this._renderingCanvas)==null?void 0:t.width)!=null?i:0}getRenderHeight(e=!1){var t,i;return!e&&this._currentRenderTarget?this._currentRenderTarget.height:(i=(t=this._renderingCanvas)==null?void 0:t.height)!=null?i:0}getError(){return 0}createExternalTexture(e){return new Ap(e)}setExternalTexture(e,t){if(!t){this._currentMaterialContext.setTexture(e,null);return}this._setInternalTexture(e,t)}setTextureSampler(e,t){var i;(i=this._currentMaterialContext)==null||i.setSampler(e,t)}createStorageBuffer(e,t,i){return this._createBuffer(e,t|32,i)}updateStorageBuffer(e,t,i,s){const n=e;i===void 0&&(i=0);let r;s===void 0?(t instanceof Array?r=new Float32Array(t):t instanceof ArrayBuffer?r=new Uint8Array(t):r=t,s=r.byteLength):t instanceof Array?r=new Float32Array(t):t instanceof ArrayBuffer?r=new Uint8Array(t):r=t,this._bufferManager.setSubData(n,i,r,0,s)}_readFromGPUBuffer(e,t,i,s){return new Promise((n,r)=>{const o=()=>{e.mapAsync(1,0,t).then(()=>{const h=e.getMappedRange(0,t);let l=i;if(l===void 0)l=new Uint8Array(t),l.set(new Uint8Array(h));else{const c=l.constructor;l=new c(l.buffer),l.set(new c(h))}e.unmap(),this._bufferManager.releaseBuffer(e),n(l)},h=>{this.isDisposed?n(new Uint8Array):r(h)})};s?(this.flushFramebuffer(),o()):this.onEndFrameObservable.addOnce(()=>{o()})})}readFromStorageBuffer(e,t,i,s,n){i=i||e.capacity;const r=this._bufferManager.createRawBuffer(i,We.MapRead|We.CopyDst,void 0,"TempReadFromStorageBuffer");return this._renderEncoder.copyBufferToBuffer(e.underlyingResource,t!=null?t:0,r,0,i),this._readFromGPUBuffer(r,i,s,n)}readFromMultipleStorageBuffers(e,t,i,s,n){i=i||e[0].capacity;const r=this._bufferManager.createRawBuffer(i*e.length,We.MapRead|We.CopyDst,void 0,"TempReadFromMultipleStorageBuffers");for(let o=0;o<e.length;o++)this._renderEncoder.copyBufferToBuffer(e[o].underlyingResource,t!=null?t:0,r,o*i,i);return this._readFromGPUBuffer(r,i*e.length,s,n)}setStorageBuffer(e,t){var i,s;(s=this._currentDrawContext)==null||s.setBuffer(e,(i=t==null?void 0:t.getBuffer())!=null?i:null)}}Ye._GlslangDefaultOptions={jsPath:"".concat(J._DefaultCdnUrl,"/glslang/glslang.js"),wasmPath:"".concat(J._DefaultCdnUrl,"/glslang/glslang.wasm")};Ye._InstanceId=0;class Fh{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 Ec(a){a.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")}class ot{constructor(){this._dirty=!0,this._tempColor=new H(0,0,0,0),this._globalCurve=new H(0,0,0,0),this._highlightsCurve=new H(0,0,0,0),this._midtonesCurve=new H(0,0,0,0),this._shadowsCurve=new H(0,0,0,0),this._positiveCurve=new H(0,0,0,0),this._negativeCurve=new H(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",n="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(n,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))}_getColorGradingDataToRef(e,t,i,s,n){e!=null&&(e=ot._Clamp(e,0,360),t=ot._Clamp(t,-100,100),i=ot._Clamp(i,-100,100),s=ot._Clamp(s,-100,100),t=ot._ApplyColorGradingSliderNonlinear(t),t*=.5,s=ot._ApplyColorGradingSliderNonlinear(s),t<0&&(t*=-1,e=(e+180)%360),ot._FromHSBToRef(e,t,50+.25*s,n),n.scaleToRef(2,n),n.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 n=ot._Clamp(e,0,360);const r=ot._Clamp(t/100,0,1),o=ot._Clamp(i/100,0,1);if(r===0)s.r=o,s.g=o,s.b=o;else{n/=60;const h=Math.floor(n),l=n-h,c=o*(1-r),u=o*(1-r*l),f=o*(1-r*(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 Ae.Clone(()=>new ot,this)}serialize(){return Ae.Serialize(this)}static Parse(e){return Ae.Parse(()=>new ot,e,null,null)}}ot.PrepareUniforms=Ec;D([B()],ot.prototype,"_globalHue",void 0);D([B()],ot.prototype,"_globalDensity",void 0);D([B()],ot.prototype,"_globalSaturation",void 0);D([B()],ot.prototype,"_globalExposure",void 0);D([B()],ot.prototype,"_highlightsHue",void 0);D([B()],ot.prototype,"_highlightsDensity",void 0);D([B()],ot.prototype,"_highlightsSaturation",void 0);D([B()],ot.prototype,"_highlightsExposure",void 0);D([B()],ot.prototype,"_midtonesHue",void 0);D([B()],ot.prototype,"_midtonesDensity",void 0);D([B()],ot.prototype,"_midtonesSaturation",void 0);D([B()],ot.prototype,"_midtonesExposure",void 0);Ae._ColorCurvesParser=ot.Parse;function Up(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&&Ec(a),e.DITHER&&a.push("ditherIntensity")}function kp(a,e){e.COLORGRADING&&a.push("txColorTransform")}class Ne{constructor(){this.colorCurves=new ot,this._colorCurvesEnabled=!1,this._colorGradingEnabled=!1,this._colorGradingWithGreenDepth=!0,this._colorGradingBGR=!0,this._exposure=1,this._toneMappingEnabled=!1,this._toneMappingType=Ne.TONEMAPPING_STANDARD,this._contrast=1,this.vignetteStretch=0,this.vignetteCenterX=0,this.vignetteCenterY=0,this.vignetteWeight=1.5,this.vignetteColor=new H(0,0,0,0),this.vignetteCameraFov=.5,this._vignetteBlendMode=Ne.VIGNETTEMODE_MULTIPLY,this._vignetteEnabled=!1,this._ditheringEnabled=!1,this._ditheringIntensity=1/255,this._skipFinalColorClamp=!1,this._applyByPostProcess=!1,this._isEnabled=!0,this.onUpdateParameters=new Z}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===Ne._VIGNETTEMODE_MULTIPLY,e.VIGNETTEBLENDMODEOPAQUE=!e.VIGNETTEBLENDMODEMULTIPLY,!this._toneMappingEnabled)e.TONEMAPPING=0;else switch(this._toneMappingType){case Ne.TONEMAPPING_KHR_PBR_NEUTRAL:e.TONEMAPPING=3;break;case Ne.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&&ot.Bind(this.colorCurves,e),this._vignetteEnabled||this._ditheringEnabled){const i=1/e.getEngine().getRenderWidth(),s=1/e.getEngine().getRenderHeight();if(e.setFloat2("vInverseScreenSize",i,s),this._ditheringEnabled&&e.setFloat("ditherIntensity",.5*this._ditheringIntensity),this._vignetteEnabled){const n=t!=null?t:s/i;let r=Math.tan(this.vignetteCameraFov*.5),o=r*n;const h=Math.sqrt(o*r);o=Fa(o,h,this.vignetteStretch),r=Fa(r,h,this.vignetteStretch),e.setFloat4("vignetteSettings1",o,r,-o*this.vignetteCenterX,-r*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 Ae.Clone(()=>new Ne,this)}serialize(){return Ae.Serialize(this)}static Parse(e){const t=Ae.Parse(()=>new Ne,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}}Ne.TONEMAPPING_STANDARD=0;Ne.TONEMAPPING_ACES=1;Ne.TONEMAPPING_KHR_PBR_NEUTRAL=2;Ne.PrepareUniforms=Up;Ne.PrepareSamplers=kp;Ne._VIGNETTEMODE_MULTIPLY=0;Ne._VIGNETTEMODE_OPAQUE=1;D([Qd()],Ne.prototype,"colorCurves",void 0);D([B()],Ne.prototype,"_colorCurvesEnabled",void 0);D([_i("colorGradingTexture")],Ne.prototype,"_colorGradingTexture",void 0);D([B()],Ne.prototype,"_colorGradingEnabled",void 0);D([B()],Ne.prototype,"_colorGradingWithGreenDepth",void 0);D([B()],Ne.prototype,"_colorGradingBGR",void 0);D([B()],Ne.prototype,"_exposure",void 0);D([B()],Ne.prototype,"_toneMappingEnabled",void 0);D([B()],Ne.prototype,"_toneMappingType",void 0);D([B()],Ne.prototype,"_contrast",void 0);D([B()],Ne.prototype,"vignetteStretch",void 0);D([B()],Ne.prototype,"vignetteCenterX",void 0);D([B()],Ne.prototype,"vignetteCenterY",void 0);D([B()],Ne.prototype,"vignetteWeight",void 0);D([p0()],Ne.prototype,"vignetteColor",void 0);D([B()],Ne.prototype,"vignetteCameraFov",void 0);D([B()],Ne.prototype,"_vignetteBlendMode",void 0);D([B()],Ne.prototype,"_vignetteEnabled",void 0);D([B()],Ne.prototype,"_ditheringEnabled",void 0);D([B()],Ne.prototype,"_ditheringIntensity",void 0);D([B()],Ne.prototype,"_skipFinalColorClamp",void 0);D([B()],Ne.prototype,"_applyByPostProcess",void 0);D([B()],Ne.prototype,"_isEnabled",void 0);Ae._ImageProcessingConfigurationParser=Ne.Parse;vt("BABYLON.ImageProcessingConfiguration",Ne);class Ot{constructor(e,t,i,s,n,r){this.source=e,this.pointerX=t,this.pointerY=i,this.meshUnderPointer=s,this.sourceEvent=n,this.additionalData=r}static CreateNew(e,t,i){const s=e.getScene();return new Ot(e,s.pointerX,s.pointerY,s.meshUnderPointer||e,t,i)}static CreateNewFromSprite(e,t,i,s){return new Ot(e,t.pointerX,t.pointerY,t.meshUnderPointer,i,s)}static CreateNewFromScene(e,t){return new Ot(null,e.pointerX,e.pointerY,e.meshUnderPointer,t)}static CreateNewFromPrimitive(e,t,i,s){return new Ot(e,t.x,t.y,null,i,s)}}class Re{}Re.NAME_EFFECTLAYER="EffectLayer";Re.NAME_LAYER="Layer";Re.NAME_LENSFLARESYSTEM="LensFlareSystem";Re.NAME_BOUNDINGBOXRENDERER="BoundingBoxRenderer";Re.NAME_PARTICLESYSTEM="ParticleSystem";Re.NAME_GAMEPAD="Gamepad";Re.NAME_SIMPLIFICATIONQUEUE="SimplificationQueue";Re.NAME_GEOMETRYBUFFERRENDERER="GeometryBufferRenderer";Re.NAME_PREPASSRENDERER="PrePassRenderer";Re.NAME_DEPTHRENDERER="DepthRenderer";Re.NAME_DEPTHPEELINGRENDERER="DepthPeelingRenderer";Re.NAME_IBLSHADOWSRENDERER="IblShadowsRenderer";Re.NAME_POSTPROCESSRENDERPIPELINEMANAGER="PostProcessRenderPipelineManager";Re.NAME_SPRITE="Sprite";Re.NAME_SUBSURFACE="SubSurface";Re.NAME_OUTLINERENDERER="Outline";Re.NAME_PROCEDURALTEXTURE="ProceduralTexture";Re.NAME_SHADOWGENERATOR="ShadowGenerator";Re.NAME_OCTREE="Octree";Re.NAME_PHYSICSENGINE="PhysicsEngine";Re.NAME_AUDIO="Audio";Re.NAME_FLUIDRENDERER="FluidRenderer";Re.STEP_ISREADYFORMESH_EFFECTLAYER=0;Re.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER=0;Re.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER=0;Re.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER=0;Re.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER=1;Re.STEP_BEFORECAMERADRAW_PREPASS=0;Re.STEP_BEFORECAMERADRAW_EFFECTLAYER=1;Re.STEP_BEFORECAMERADRAW_LAYER=2;Re.STEP_BEFORERENDERTARGETDRAW_PREPASS=0;Re.STEP_BEFORERENDERTARGETDRAW_LAYER=1;Re.STEP_BEFORERENDERINGMESH_PREPASS=0;Re.STEP_BEFORERENDERINGMESH_OUTLINE=1;Re.STEP_AFTERRENDERINGMESH_PREPASS=0;Re.STEP_AFTERRENDERINGMESH_OUTLINE=1;Re.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW=0;Re.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER=1;Re.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE=0;Re.STEP_BEFORECLEAR_PROCEDURALTEXTURE=0;Re.STEP_BEFORECLEAR_PREPASS=1;Re.STEP_BEFORERENDERTARGETCLEAR_PREPASS=0;Re.STEP_AFTERRENDERTARGETDRAW_PREPASS=0;Re.STEP_AFTERRENDERTARGETDRAW_LAYER=1;Re.STEP_AFTERCAMERADRAW_PREPASS=0;Re.STEP_AFTERCAMERADRAW_EFFECTLAYER=1;Re.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM=2;Re.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW=3;Re.STEP_AFTERCAMERADRAW_LAYER=4;Re.STEP_AFTERCAMERADRAW_FLUIDRENDERER=5;Re.STEP_AFTERCAMERAPOSTPROCESS_LAYER=0;Re.STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER=0;Re.STEP_AFTERRENDER_AUDIO=0;Re.STEP_GATHERRENDERTARGETS_DEPTHRENDERER=0;Re.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER=1;Re.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR=2;Re.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER=3;Re.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER=0;Re.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER=1;Re.STEP_POINTERMOVE_SPRITE=0;Re.STEP_POINTERDOWN_SPRITE=0;Re.STEP_POINTERUP_SPRITE=0;class _t extends Array{constructor(e){super(...e)}static Create(){return Object.create(_t.prototype)}registerStep(e,t,i){let s=0,n=Number.MAX_VALUE;for(;s<this.length&&(n=this[s].index,!(e<n));s++);this.splice(s,0,{index:e,component:t,action:i.bind(t)})}clear(){this.length=0}}class Ce{}Ce.POINTERDOWN=1;Ce.POINTERUP=2;Ce.POINTERMOVE=4;Ce.POINTERWHEEL=8;Ce.POINTERPICK=16;Ce.POINTERTAP=32;Ce.POINTERDOUBLETAP=64;class Cc{constructor(e,t){this.type=e,this.event=t}}class Vp extends Cc{constructor(e,t,i,s){super(e,t),this.ray=null,this.originalPickingInfo=null,this.skipOnPointerObservable=!1,this.localPosition=new oe(i,s)}}class Ji extends Cc{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 li{constructor(){this.hoverCursor="",this.actions=[],this.isRecursive=!1,this.disposeWhenUnowned=!0}static get HasTriggers(){for(const e in li.Triggers)if(Object.prototype.hasOwnProperty.call(li.Triggers,e))return!0;return!1}static get HasPickTriggers(){for(const e in li.Triggers)if(Object.prototype.hasOwnProperty.call(li.Triggers,e)){const t=parseInt(e);if(t>=1&&t<=7)return!0}return!1}static HasSpecificTrigger(e){for(const t in li.Triggers)if(Object.prototype.hasOwnProperty.call(li.Triggers,t)&&parseInt(t)===e)return!0;return!1}}li.Triggers={};class Nn{}Nn.KEYDOWN=1;Nn.KEYUP=2;class Wa{constructor(e,t){this.type=e,this.event=t}}class Oh extends Wa{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}}var ge;(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"})(ge||(ge={}));var xe;(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"})(xe||(xe={}));var Bh;(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"})(Bh||(Bh={}));var Lh;(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"})(Lh||(Lh={}));var Nh;(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"})(Nh||(Nh={}));var Uh;(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"})(Uh||(Uh={}));var kh;(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"})(kh||(kh={}));var Vh;(function(a){a[a.PointerMove=0]="PointerMove",a[a.PointerDown=1]="PointerDown",a[a.PointerUp=2]="PointerUp"})(Vh||(Vh={}));class jn{}jn.DOM_DELTA_PIXEL=0;jn.DOM_DELTA_LINE=1;jn.DOM_DELTA_PAGE=2;class Ps{static CreateDeviceEvent(e,t,i,s,n,r,o){switch(e){case ge.Keyboard:return this._CreateKeyboardEvent(i,s,n,r);case ge.Mouse:if(i===xe.MouseWheelX||i===xe.MouseWheelY||i===xe.MouseWheelZ)return this._CreateWheelEvent(e,t,i,s,n,r);case ge.Touch:return this._CreatePointerEvent(e,t,i,s,n,r,o);default:throw"Unable to generate event for device ".concat(ge[e])}}static _CreatePointerEvent(e,t,i,s,n,r,o){const h=this._CreateMouseEvent(e,t,i,s,n,r);e===ge.Mouse?(h.deviceType=ge.Mouse,h.pointerId=1,h.pointerType="mouse"):(h.deviceType=ge.Touch,h.pointerId=o!=null?o:t,h.pointerType="touch");let l=0;return l+=n.pollInput(e,t,xe.LeftClick),l+=n.pollInput(e,t,xe.RightClick)*2,l+=n.pollInput(e,t,xe.MiddleClick)*4,h.buttons=l,i===xe.Move?h.type="pointermove":i>=xe.LeftClick&&i<=xe.RightClick&&(h.type=s===1?"pointerdown":"pointerup",h.button=i-2),h}static _CreateWheelEvent(e,t,i,s,n,r){const o=this._CreateMouseEvent(e,t,i,s,n,r);switch(o.pointerId=1,o.type="wheel",o.deltaMode=jn.DOM_DELTA_PIXEL,o.deltaX=0,o.deltaY=0,o.deltaZ=0,i){case xe.MouseWheelX:o.deltaX=s;break;case xe.MouseWheelY:o.deltaY=s;break;case xe.MouseWheelZ:o.deltaZ=s;break}return o}static _CreateMouseEvent(e,t,i,s,n,r){const o=this._CreateEvent(r),h=n.pollInput(e,t,xe.Horizontal),l=n.pollInput(e,t,xe.Vertical);return r?(o.movementX=0,o.movementY=0,o.offsetX=o.movementX-r.getBoundingClientRect().x,o.offsetY=o.movementY-r.getBoundingClientRect().y):(o.movementX=n.pollInput(e,t,10),o.movementY=n.pollInput(e,t,11),o.offsetX=0,o.offsetY=0),this._CheckNonCharacterKeys(o,n),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 n=this._CreateEvent(s);return this._CheckNonCharacterKeys(n,i),n.deviceType=ge.Keyboard,n.deviceSlot=0,n.inputIndex=e,n.type=t===1?"keydown":"keyup",n.key=String.fromCharCode(e),n.keyCode=e,n}static _CheckNonCharacterKeys(e,t){const i=t.isDeviceAvailable(ge.Keyboard),s=i&&t.pollInput(ge.Keyboard,0,18)===1,n=i&&t.pollInput(ge.Keyboard,0,17)===1,r=i&&(t.pollInput(ge.Keyboard,0,91)===1||t.pollInput(ge.Keyboard,0,92)===1||t.pollInput(ge.Keyboard,0,93)===1),o=i&&t.pollInput(ge.Keyboard,0,16)===1;e.altKey=s,e.ctrlKey=n,e.metaKey=r,e.shiftKey=o}static _CreateEvent(e){const t={};return t.preventDefault=()=>{},t.target=e,t}}class Gp{constructor(e,t,i){this._nativeInput=_native.DeviceInputSystem?new _native.DeviceInputSystem(e,t,(s,n,r,o)=>{const h=Ps.CreateDeviceEvent(s,n,r,o,this);i(s,n,h)}):this._createDummyNativeInput()}pollInput(e,t,i){return this._nativeInput.pollInput(e,t,i)}isDeviceAvailable(e){return e===ge.Mouse||e===ge.Touch}dispose(){this._nativeInput.dispose()}_createDummyNativeInput(){return{pollInput:()=>0,isDeviceAvailable:()=>!1,dispose:()=>{}}}}const Gh=255,zh=Object.keys(xe).length/2;class zp{constructor(e,t,i,s){this._inputs=[],this._keyboardActive=!1,this._pointerActive=!1,this._usingSafari=J.IsSafari(),this._usingMacOS=Qs()&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),this._keyboardDownEvent=n=>{},this._keyboardUpEvent=n=>{},this._keyboardBlurEvent=n=>{},this._pointerMoveEvent=n=>{},this._pointerDownEvent=n=>{},this._pointerUpEvent=n=>{},this._pointerCancelEvent=n=>{},this._pointerWheelEvent=n=>{},this._pointerBlurEvent=n=>{},this._pointerMacOSChromeOutEvent=n=>{},this._eventsAttached=!1,this._mouseId=-1,this._isUsingFirefox=Qs()&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox")!==-1,this._isUsingChromium=Qs()&&navigator.userAgent&&navigator.userAgent.indexOf("Chrome")!==-1,this._maxTouchPoints=0,this._pointerInputClearObserver=null,this._gamepadConnectedEvent=n=>{},this._gamepadDisconnectedEvent=n=>{},this._eventPrefix=J.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 ".concat(ge[e]);e>=ge.DualShock&&e<=ge.DualSense&&this._updateDevice(e,t,i);const n=s[i];if(n===void 0)throw"Unable to find input ".concat(i," for device ").concat(ge[e]," in slot ").concat(t);return i===xe.Move&&J.Warn("Unable to provide information for PointerInput.Move. Try using PointerInput.Horizontal or PointerInput.Vertical for move data."),n}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==null?void 0: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,n=t[s];if(n)for(let r=0;r<n.length;r++)n[r]=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._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(ge.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,zh);const n=this._inputs[e][t];n[0]=i,n[1]=s}_registerDevice(e,t,i){if(t===void 0)throw"Unable to register device ".concat(ge[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(ge.Keyboard,0,Gh));const t=this._inputs[ge.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(ge.Keyboard,0,i)}},this._keyboardUpEvent=e=>{this._keyboardActive||(this._keyboardActive=!0,this._registerDevice(ge.Keyboard,0,Gh));const t=this._inputs[ge.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 n=Ps.CreateDeviceEvent(ge.Keyboard,0,s,0,this,this._elementToAttachTo);t[s]=0,this._onInputChanged(ge.Keyboard,0,n)}this._metaKeys.splice(0,this._metaKeys.length)}this._onInputChanged(ge.Keyboard,0,i)}},this._keyboardBlurEvent=()=>{if(this._keyboardActive){const e=this._inputs[ge.Keyboard][0];for(let t=0;t<e.length;t++)if(e[t]!==0){e[t]=0;const i=Ps.CreateDeviceEvent(ge.Keyboard,0,t,0,this,this._elementToAttachTo);this._onInputChanged(ge.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=Qs()&&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 n=s===ge.Mouse?0:this._activeTouchIds.indexOf(i.pointerId);if(s===ge.Touch&&n===-1){const o=this._activeTouchIds.indexOf(-1);if(o>=0)n=o,this._activeTouchIds[o]=i.pointerId,this._onDeviceConnected(s,n);else{J.Warn("Max number of touches exceeded. Ignoring touches in excess of ".concat(this._maxTouchPoints));return}}this._inputs[s]||(this._inputs[s]={}),this._inputs[s][n]||this._addPointerDevice(s,n,i.clientX,i.clientY);const r=this._inputs[s][n];if(r){const o=i;o.inputIndex=xe.Move,r[xe.Horizontal]=i.clientX,r[xe.Vertical]=i.clientY,s===ge.Touch&&r[xe.LeftClick]===0&&(r[xe.LeftClick]=1),i.pointerId===void 0&&(i.pointerId=this._mouseId),this._onInputChanged(s,n,o),!this._usingSafari&&i.button!==-1&&(o.inputIndex=i.button+2,r[i.button+2]=r[i.button+2]?0:1,this._onInputChanged(s,n,o))}},this._pointerDownEvent=i=>{const s=this._getPointerType(i);let n=s===ge.Mouse?0:i.pointerId;if(s===ge.Touch){let o=this._activeTouchIds.indexOf(i.pointerId);if(o===-1&&(o=this._activeTouchIds.indexOf(-1)),o>=0)n=o,this._activeTouchIds[o]=i.pointerId;else{J.Warn("Max number of touches exceeded. Ignoring touches in excess of ".concat(this._maxTouchPoints));return}}this._inputs[s]||(this._inputs[s]={}),this._inputs[s][n]?s===ge.Touch&&this._onDeviceConnected(s,n):this._addPointerDevice(s,n,i.clientX,i.clientY);const r=this._inputs[s][n];if(r){const o=r[xe.Horizontal],h=r[xe.Vertical];if(s===ge.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{}r[xe.Horizontal]=i.clientX,r[xe.Vertical]=i.clientY,r[i.button+2]=1;const l=i;l.inputIndex=i.button+2,this._onInputChanged(s,n,l),(o!==i.clientX||h!==i.clientY)&&(l.inputIndex=xe.Move,this._onInputChanged(s,n,l))}},this._pointerUpEvent=i=>{var o,h,l,c,u;const s=this._getPointerType(i),n=s===ge.Mouse?0:this._activeTouchIds.indexOf(i.pointerId);if(s===ge.Touch){if(n===-1)return;this._activeTouchIds[n]=-1}const r=(o=this._inputs[s])==null?void 0:o[n];if(r&&r[i.button+2]!==0){const f=r[xe.Horizontal],d=r[xe.Vertical];r[xe.Horizontal]=i.clientX,r[xe.Vertical]=i.clientY,r[i.button+2]=0;const _=i;i.pointerId===void 0&&(i.pointerId=this._mouseId),(f!==i.clientX||d!==i.clientY)&&(_.inputIndex=xe.Move,this._onInputChanged(s,n,_)),_.inputIndex=i.button+2,s===ge.Mouse&&this._mouseId>=0&&((l=(h=this._elementToAttachTo).hasPointerCapture)!=null&&l.call(h,this._mouseId))?this._elementToAttachTo.releasePointerCapture(this._mouseId):i.pointerId&&((u=(c=this._elementToAttachTo).hasPointerCapture)!=null&&u.call(c,i.pointerId))&&this._elementToAttachTo.releasePointerCapture(i.pointerId),this._onInputChanged(s,n,_),s===ge.Touch&&this._onDeviceDisconnected(s,n)}},this._pointerCancelEvent=i=>{var s,n,r,o;if(i.pointerType==="mouse"){const h=this._inputs[ge.Mouse][0];this._mouseId>=0&&((n=(s=this._elementToAttachTo).hasPointerCapture)!=null&&n.call(s,this._mouseId))&&this._elementToAttachTo.releasePointerCapture(this._mouseId);for(let l=xe.LeftClick;l<=xe.BrowserForward;l++)if(h[l]===1){h[l]=0;const c=Ps.CreateDeviceEvent(ge.Mouse,0,l,0,this,this._elementToAttachTo);this._onInputChanged(ge.Mouse,0,c)}}else{const h=this._activeTouchIds.indexOf(i.pointerId);if(h===-1)return;(o=(r=this._elementToAttachTo).hasPointerCapture)!=null&&o.call(r,i.pointerId)&&this._elementToAttachTo.releasePointerCapture(i.pointerId),this._inputs[ge.Touch][h][xe.LeftClick]=0;const l=Ps.CreateDeviceEvent(ge.Touch,h,xe.LeftClick,0,this,this._elementToAttachTo,i.pointerId);this._onInputChanged(ge.Touch,h,l),this._activeTouchIds[h]=-1,this._onDeviceDisconnected(ge.Touch,h)}},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=()=>{var i,s,n,r,o;if(this.isDeviceAvailable(ge.Mouse)){const h=this._inputs[ge.Mouse][0];this._mouseId>=0&&((s=(i=this._elementToAttachTo).hasPointerCapture)!=null&&s.call(i,this._mouseId))&&this._elementToAttachTo.releasePointerCapture(this._mouseId);for(let l=xe.LeftClick;l<=xe.BrowserForward;l++)if(h[l]===1){h[l]=0;const c=Ps.CreateDeviceEvent(ge.Mouse,0,l,0,this,this._elementToAttachTo);this._onInputChanged(ge.Mouse,0,c)}}if(this.isDeviceAvailable(ge.Touch)){const h=this._inputs[ge.Touch];for(let l=0;l<this._activeTouchIds.length;l++){const c=this._activeTouchIds[l];if((r=(n=this._elementToAttachTo).hasPointerCapture)!=null&&r.call(n,c)&&this._elementToAttachTo.releasePointerCapture(c),c!==-1&&((o=h[l])==null?void 0:o[xe.LeftClick])===1){h[l][xe.LeftClick]=0;const u=Ps.CreateDeviceEvent(ge.Touch,l,xe.LeftClick,0,this,this._elementToAttachTo,c);this._onInputChanged(ge.Touch,l,u),this._activeTouchIds[l]=-1,this._onDeviceDisconnected(ge.Touch,l)}}}},this._pointerWheelEvent=i=>{const s=ge.Mouse,n=0;this._inputs[s]||(this._inputs[s]=[]),this._inputs[s][n]||(this._pointerActive=!0,this._registerDevice(s,n,zh));const r=this._inputs[s][n];if(r){r[xe.MouseWheelX]=i.deltaX||0,r[xe.MouseWheelY]=i.deltaY||i.wheelDelta||0,r[xe.MouseWheelZ]=i.deltaZ||0;const o=i;i.pointerId===void 0&&(i.pointerId=this._mouseId),r[xe.MouseWheelX]!==0&&(o.inputIndex=xe.MouseWheelX,this._onInputChanged(s,n,o)),r[xe.MouseWheelY]!==0&&(o.inputIndex=xe.MouseWheelY,this._onInputChanged(s,n,o)),r[xe.MouseWheelZ]!==0&&(o.inputIndex=xe.MouseWheelZ,this._onInputChanged(s,n,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("blur",this._pointerBlurEvent),this._elementToAttachTo.addEventListener(this._wheelEventName,this._pointerWheelEvent,e?{passive:!1}:!1),this._pointerInputClearObserver=this._engine.onEndFrameObservable.add(()=>{if(this.isDeviceAvailable(ge.Mouse)){const i=this._inputs[ge.Mouse][0];i[xe.MouseWheelX]=0,i[xe.MouseWheelY]=0,i[xe.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 n=this._inputs[e][t];i>=s.buttons.length?n[i]=s.axes[i-s.buttons.length].valueOf():n[i]=s.buttons[i].value}}_getGamepadDeviceType(e){return e.indexOf("054c")!==-1?e.indexOf("0ce6")!==-1?ge.DualSense:ge.DualShock:e.indexOf("Xbox One")!==-1||e.search("Xbox 360")!==-1||e.search("xinput")!==-1?ge.Xbox:e.indexOf("057e")!==-1?ge.Switch:ge.Generic}_getPointerType(e){let t=ge.Mouse;return(e.pointerType==="touch"||e.pointerType==="pen"||e.touches)&&(t=ge.Touch),t}}class Wh{constructor(e,t,i=0){this.deviceType=t,this.deviceSlot=i,this.onInputChangedObservable=new Z,this._deviceInputSystem=e}getInput(e){return this._deviceInputSystem.pollInput(this.deviceType,this.deviceSlot,e)}}class Wp{constructor(e){this._registeredManagers=new Array,this._refCount=0,this.registerManager=r=>{for(let o=0;o<this._devices.length;o++){const h=this._devices[o];for(const l in h){const c=+l;r._addDevice(new Wh(this._deviceInputSystem,o,c))}}this._registeredManagers.push(r)},this.unregisterManager=r=>{const o=this._registeredManagers.indexOf(r);o>-1&&this._registeredManagers.splice(o,1)};const t=Object.keys(ge).length/2;this._devices=new Array(t);const i=(r,o)=>{this._devices[r]||(this._devices[r]=new Array),this._devices[r][o]||(this._devices[r][o]=o);for(const h of this._registeredManagers){const l=new Wh(this._deviceInputSystem,r,o);h._addDevice(l)}},s=(r,o)=>{var h;(h=this._devices[r])!=null&&h[o]&&delete this._devices[r][o];for(const l of this._registeredManagers)l._removeDevice(r,o)},n=(r,o,h)=>{if(h)for(const l of this._registeredManagers)l._onInputChanged(r,o,h)};typeof _native<"u"?this._deviceInputSystem=new Gp(i,s,n):this._deviceInputSystem=new zp(e,i,s,n)}dispose(){this._deviceInputSystem.dispose()}}class Hp{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(ge).length/2;this._devices=new Array(t),this._firstDevice=new Array(t),this._engine=e,this._engine._deviceSourceManager||(this._engine._deviceSourceManager=new Wp(e)),this._engine._deviceSourceManager._refCount++,this.onDeviceConnectedObservable=new Z(i=>{for(const s of this._devices)if(s)for(const n of s)n&&this.onDeviceConnectedObservable.notifyObserver(i,n)}),this.onDeviceDisconnectedObservable=new Z,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){var s,n;const i=(s=this._devices[e])==null?void 0:s[t];this.onDeviceDisconnectedObservable.notifyObservers(i),(n=this._devices[e])!=null&&n[t]&&delete this._devices[e][t],this._updateFirstDevices(e)}_onInputChanged(e,t,i){var s,n;(n=(s=this._devices[e])==null?void 0:s[t])==null||n.onInputChangedObservable.notifyObservers(i)}_updateFirstDevices(e){switch(e){case ge.Keyboard:case ge.Mouse:this._firstDevice[e]=0;break;case ge.Touch:case ge.DualSense:case ge.DualShock:case ge.Xbox:case ge.Switch:case ge.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 O0{}O0._IsPickingAvailable=!1;class Hh{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 pt{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 oe(0,0),this._previousStartingPointerPosition=new oe(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||Ee.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 oe(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(),n=s.getInputElement();n&&(n.tabIndex=s.canvasTabIndex,i.doNotHandleCursors||(n.style.cursor=i.defaultCursor)),this._setCursorAndPointerOverMesh(e,t,i);for(const h of i._pointerMoveStage){e=e||this._pickMove(t);const l=!!(e!=null&&e.pickedMesh);e=h.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,l,n)}const r=t.inputIndex>=xe.MouseWheelX&&t.inputIndex<=xe.MouseWheelZ?Ce.POINTERWHEEL:Ce.POINTERMOVE;i.onPointerMove&&(e=e||this._pickMove(t),i.onPointerMove(t,e,r));let o;e?(o=new Ji(r,t,e),this._setRayOnPointerInfo(e,t)):(o=new Ji(r,t,null,this),this._movePointerInfo=o),i.onPointerObservable.hasObservers()&&i.onPointerObservable.notifyObservers(o,r)}_setRayOnPointerInfo(e,t){const i=this._scene;e&&O0._IsPickingAvailable&&(e.ray||(e.ray=i.createPickingRay(t.offsetX,t.offsetY,O.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,n=new Vp(i,t,this._unTranslatedPointerX,this._unTranslatedPointerY);return e&&(n.originalPickingInfo=e,n.ray=e.ray,t.pointerType==="xr-near"&&e.originMesh&&(n.nearInteractionPickingInfo=e)),s.onPrePointerObservable.notifyObservers(n,i),!!n.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 n=i.getEngine().getInputElement();if(e!=null&&e.pickedMesh){if(this.setPointerOverMesh(e.pickedMesh,t.pointerId,e,t),!i.doNotHandleCursors&&n&&this._pointerOverMesh){const r=this._pointerOverMesh._getActionManagerForTrigger();r&&r.hasPointerTriggers&&(n.style.cursor=r.hoverCursor||i.hoverCursor)}}else this.setPointerOverMesh(null,t.pointerId,e,t)}simulatePointerMove(e,t){const i=new PointerEvent("pointermove",t);i.inputIndex=xe.Move,!this._checkPrePointerObservable(e,i,Ce.POINTERMOVE)&&this._processPointerMove(e,i)}simulatePointerDown(e,t){const i=new PointerEvent("pointerdown",t);i.inputIndex=i.button+2,!this._checkPrePointerObservable(e,i,Ce.POINTERDOWN)&&this._processPointerDown(e,i)}_processPointerDown(e,t){const i=this._scene;if(e!=null&&e.pickedMesh){this._pickedDownMesh=e.pickedMesh;const r=e.pickedMesh._getActionManagerForTrigger();if(r){if(r.hasPickTriggers)switch(r.processTrigger(5,Ot.CreateNew(e.pickedMesh,t,e)),t.button){case 0:r.processTrigger(2,Ot.CreateNew(e.pickedMesh,t,e));break;case 1:r.processTrigger(4,Ot.CreateNew(e.pickedMesh,t,e));break;case 2:r.processTrigger(3,Ot.CreateNew(e.pickedMesh,t,e));break}r.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!=null&&o.pickedMesh&&r&&this._activePointerIdsCount!==0&&Date.now()-this._startingPointerTime>pt.LongPressDelay&&!this._isPointerSwiping()&&(this._startingPointerTime=0,r.processTrigger(8,Ot.CreateNew(o.pickedMesh,t)))},pt.LongPressDelay)}}else for(const r of i._pointerDownStage)e=r.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t,!1);let s;const n=Ce.POINTERDOWN;e?(i.onPointerDown&&i.onPointerDown(t,e,n),s=new Ji(n,t,e),this._setRayOnPointerInfo(e,t)):s=new Ji(n,t,null,this),i.onPointerObservable.hasObservers()&&i.onPointerObservable.notifyObservers(s,n)}_isPointerSwiping(){return this._isSwiping}simulatePointerUp(e,t,i){const s=new PointerEvent("pointerup",t);s.inputIndex=xe.Move;const n=new Hh;i?n.doubleClick=!0:n.singleClick=!0,!this._checkPrePointerObservable(e,s,Ce.POINTERUP)&&this._processPointerUp(e,s,n)}_processPointerUp(e,t,i){const s=this._scene;if(e!=null&&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 r=Ce.POINTERPICK,o=new Ji(r,t,e);this._setRayOnPointerInfo(e,t),s.onPointerObservable.notifyObservers(o,r)}const n=e.pickedMesh._getActionManagerForTrigger();if(n&&!i.ignore){n.processTrigger(7,Ot.CreateNew(e.pickedMesh,t,e)),!i.hasSwiped&&i.singleClick&&n.processTrigger(1,Ot.CreateNew(e.pickedMesh,t,e));const r=e.pickedMesh._getActionManagerForTrigger(6);i.doubleClick&&r&&r.processTrigger(6,Ot.CreateNew(e.pickedMesh,t,e))}}else if(!i.ignore)for(const n of s._pointerUpStage)e=n.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t,i.doubleClick);if(this._pickedDownMesh&&this._pickedDownMesh!==this._pickedUpMesh){const n=this._pickedDownMesh._getActionManagerForTrigger(16);n&&n.processTrigger(16,Ot.CreateNew(this._pickedDownMesh,t))}if(!i.ignore){const n=new Ji(Ce.POINTERUP,t,e);if(this._setRayOnPointerInfo(e,t),s.onPointerObservable.notifyObservers(n,Ce.POINTERUP),s.onPointerUp&&s.onPointerUp(t,e,Ce.POINTERUP),!i.hasSwiped&&!this._skipPointerTap&&!this._isMultiTouchGesture){let r=0;if(i.singleClick?r=Ce.POINTERTAP:i.doubleClick&&(r=Ce.POINTERDOUBLETAP),r){const o=new Ji(r,t,e);s.onPointerObservable.hasObservers()&&s.onPointerObservable.hasSpecificMask(r)&&s.onPointerObservable.notifyObservers(o,r)}}}}isPointerCaptured(e=0){return this._pointerCaptures[e]}attachControl(e=!0,t=!0,i=!0,s=null){const n=this._scene,r=n.getEngine();s||(s=r.getInputElement()),this._alreadyAttached&&this.detachControl(),s&&(this._alreadyAttachedTo=s),this._deviceSourceManager=new Hp(r),this._initActionManager=o=>{if(!this._meshPickProceed){const h=n.skipPointerUpPicking||n._registeredActions===0&&!this._checkForPicking()&&!n.onPointerUp?null:n.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,n.pointerUpPredicate,n.pointerUpFastCheck,n.cameraToUseForPointers,n.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>pt.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=Ce.POINTERTAP,f=new Ji(u,c,this._currentPickResult);n.onPointerObservable.hasObservers()&&n.onPointerObservable.hasSpecificMask(u)&&n.onPointerObservable.notifyObservers(f,u),this._delayedClicks[o]=null}},this._initClickEvent=(o,h,l,c)=>{var p,g;const u=new Hh;this._currentPickResult=null;let f=null,d=o.hasSpecificMask(Ce.POINTERPICK)||h.hasSpecificMask(Ce.POINTERPICK)||o.hasSpecificMask(Ce.POINTERTAP)||h.hasSpecificMask(Ce.POINTERTAP)||o.hasSpecificMask(Ce.POINTERDOUBLETAP)||h.hasSpecificMask(Ce.POINTERDOUBLETAP);!d&&li&&(f=this._initActionManager(f,u),f&&(d=f.hasPickTriggers));let _=!1;if(d){const m=l.button;if(u.hasSwiped=this._isPointerSwiping(),!u.hasSwiped){let b=!pt.ExclusiveDoubleClickMode;if(b||(b=!o.hasSpecificMask(Ce.POINTERDOUBLETAP)&&!h.hasSpecificMask(Ce.POINTERDOUBLETAP),b&&!li.HasSpecificTrigger(6)&&(f=this._initActionManager(f,u),f&&(b=!f.hasSpecificTrigger(6)))),b)(Date.now()-this._previousStartingPointerTime>pt.DoubleClickDelay||m!==this._previousButtonPressed)&&(u.singleClick=!0,c(u,this._currentPickResult),_=!0);else{const T={evt:l,clickInfo:u,timeoutId:window.setTimeout(this._delayedSimpleClick.bind(this,m,u,c),pt.DoubleClickDelay)};this._delayedClicks[m]=T}let I=o.hasSpecificMask(Ce.POINTERDOUBLETAP)||h.hasSpecificMask(Ce.POINTERDOUBLETAP);!I&&li.HasSpecificTrigger(6)&&(f=this._initActionManager(f,u),f&&(I=f.hasSpecificTrigger(6))),I&&(m===this._previousButtonPressed&&Date.now()-this._previousStartingPointerTime<pt.DoubleClickDelay&&!this._doubleClickOccured?(!u.hasSwiped&&!this._isPointerSwiping()?(this._previousStartingPointerTime=0,this._doubleClickOccured=!0,u.doubleClick=!0,u.ignore=!1,pt.ExclusiveDoubleClickMode&&this._delayedClicks[m]&&(clearTimeout((p=this._delayedClicks[m])==null?void 0:p.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,pt.ExclusiveDoubleClickMode?(this._delayedClicks[m]&&(clearTimeout((g=this._delayedClicks[m])==null?void 0:g.timeoutId),this._delayedClicks[m]=null),c(u,this._previousPickResult)):c(u,this._currentPickResult)),_=!0):(this._doubleClickOccured=!1,this._previousStartingPointerTime=this._startingPointerTime,this._previousStartingPointerPosition.x=this._startingPointerPosition.x,this._previousStartingPointerPosition.y=this._startingPointerPosition.y,this._previousButtonPressed=m))}}_||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)>pt.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>pt.DragMovementThreshold),r.isPointerLock&&r._verifyPointerLock(),this._checkPrePointerObservable(null,o,o.inputIndex>=xe.MouseWheelX&&o.inputIndex<=xe.MouseWheelZ?Ce.POINTERWHEEL:Ce.POINTERMOVE)||!n.cameraToUseForPointers&&!n.activeCamera)return;if(n.skipPointerMovePicking){this._processPointerMove(new as,o);return}n.pointerMovePredicate||(n.pointerMovePredicate=l=>l.isPickable&&l.isVisible&&l.isReady()&&l.isEnabled()&&(l.enablePointerMoveEvents||n.constantlyUpdateMeshUnderPointer||l._getActionManagerForTrigger()!==null)&&(!n.cameraToUseForPointers||(n.cameraToUseForPointers.layerMask&l.layerMask)!==0));const h=n._registeredActions>0||n.constantlyUpdateMeshUnderPointer?this._pickMove(o):null;this._processPointerMove(h,o)},this._onPointerDown=o=>{var c;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,pt.ExclusiveDoubleClickMode){for(let u=0;u<this._delayedClicks.length;u++)if(this._delayedClicks[u])if(o.button===u)clearTimeout((c=this._delayedClicks[u])==null?void 0:c.timeoutId);else{const f=this._delayedClicks[u].clickInfo;this._doubleClickOccured=!1,f.singleClick=!0,f.ignore=!1;const d=this._delayedClicks[u].evt,_=Ce.POINTERTAP,p=new Ji(_,d,this._currentPickResult);n.onPointerObservable.hasObservers()&&n.onPointerObservable.hasSpecificMask(_)&&n.onPointerObservable.notifyObservers(p,_),this._delayedClicks[u]=null}}if(this._updatePointerPosition(o),this._swipeButtonPressed===-1&&(this._swipeButtonPressed=o.button),n.preventDefaultOnPointerDown&&s&&(o.preventDefault(),s.focus()),this._startingPointerPosition.x=this._pointerX,this._startingPointerPosition.y=this._pointerY,this._startingPointerTime=Date.now(),this._checkPrePointerObservable(null,o,Ce.POINTERDOWN)||!n.cameraToUseForPointers&&!n.activeCamera)return;this._pointerCaptures[o.pointerId]=!0,n.pointerDownPredicate||(n.pointerDownPredicate=u=>u.isPickable&&u.isVisible&&u.isReady()&&u.isEnabled()&&(!n.cameraToUseForPointers||(n.cameraToUseForPointers.layerMask&u.layerMask)!==0)),this._pickedDownMesh=null;let l;n.skipPointerDownPicking||n._registeredActions===0&&!this._checkForPicking()&&!n.onPointerDown?l=new as:l=n.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,n.pointerDownPredicate,n.pointerDownFastCheck,n.cameraToUseForPointers,n.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),n.preventDefaultOnPointerUp&&s&&(o.preventDefault(),s.focus()),this._initClickEvent(n.onPrePointerObservable,n.onPointerObservable,o,(l,c)=>{if(n.onPrePointerObservable.hasObservers()&&(this._skipPointerTap=!1,!l.ignore)){if(this._checkPrePointerObservable(null,o,Ce.POINTERUP)){this._swipeButtonPressed===o.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1),o.buttons===0&&(this._pointerCaptures[o.pointerId]=!1);return}l.hasSwiped||(l.singleClick&&n.onPrePointerObservable.hasSpecificMask(Ce.POINTERTAP)&&this._checkPrePointerObservable(null,o,Ce.POINTERTAP)&&(this._skipPointerTap=!0),l.doubleClick&&n.onPrePointerObservable.hasSpecificMask(Ce.POINTERDOUBLETAP)&&this._checkPrePointerObservable(null,o,Ce.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),!(!n.cameraToUseForPointers&&!n.activeCamera)&&(n.pointerUpPredicate||(n.pointerUpPredicate=u=>u.isPickable&&u.isVisible&&u.isReady()&&u.isEnabled()&&(!n.cameraToUseForPointers||(n.cameraToUseForPointers.layerMask&u.layerMask)!==0)),!this._meshPickProceed&&(li&&li.HasTriggers||this._checkForPicking()||n.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=Nn.KEYDOWN;if(n.onPreKeyboardObservable.hasObservers()){const l=new Oh(h,o);if(n.onPreKeyboardObservable.notifyObservers(l,h),l.skipOnKeyboardObservable)return}if(n.onKeyboardObservable.hasObservers()){const l=new Wa(h,o);n.onKeyboardObservable.notifyObservers(l,h)}n.actionManager&&n.actionManager.processTrigger(14,Ot.CreateNewFromScene(n,o))},this._onKeyUp=o=>{const h=Nn.KEYUP;if(n.onPreKeyboardObservable.hasObservers()){const l=new Oh(h,o);if(n.onPreKeyboardObservable.notifyObservers(l,h),l.skipOnKeyboardObservable)return}if(n.onKeyboardObservable.hasObservers()){const l=new Wa(h,o);n.onKeyboardObservable.notifyObservers(l,h)}n.actionManager&&n.actionManager.processTrigger(15,Ot.CreateNewFromScene(n,o))},this._deviceSourceManager.onDeviceConnectedObservable.add(o=>{o.deviceType===ge.Mouse?o.onInputChangedObservable.add(h=>{this._originMouseEvent=h,h.inputIndex===xe.LeftClick||h.inputIndex===xe.MiddleClick||h.inputIndex===xe.RightClick||h.inputIndex===xe.BrowserBack||h.inputIndex===xe.BrowserForward?t&&o.getInput(h.inputIndex)===1?this._onPointerDown(h):e&&o.getInput(h.inputIndex)===0&&this._onPointerUp(h):i&&(h.inputIndex===xe.Move?this._onPointerMove(h):(h.inputIndex===xe.MouseWheelX||h.inputIndex===xe.MouseWheelY||h.inputIndex===xe.MouseWheelZ)&&this._onPointerMove(h))}):o.deviceType===ge.Touch?o.onInputChangedObservable.add(h=>{h.inputIndex===xe.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===xe.Move&&this._onPointerMove(h)}):o.deviceType===ge.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 n=this._meshUnderPointerId[t];let r;n&&(r=n._getActionManagerForTrigger(10),r&&r.processTrigger(10,Ot.CreateNew(n,s,{pointerId:t}))),e?(this._meshUnderPointerId[t]=e,this._pointerOverMesh=e,r=e._getActionManagerForTrigger(9),r&&r.processTrigger(9,Ot.CreateNew(e,s,{pointerId:t,pickResult:i}))):(delete this._meshUnderPointerId[t],this._pointerOverMesh=null)}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]}}pt.DragMovementThreshold=10;pt.LongPressDelay=500;pt.DoubleClickDelay=300;pt.ExclusiveDoubleClickMode=!1;class Sc{static get UniqueId(){const e=this._UniqueIdCounter;return this._UniqueIdCounter++,e}}Sc._UniqueIdCounter=1;class Xe{static CompareLightsPriority(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority}}Xe.FALLOFF_DEFAULT=0;Xe.FALLOFF_PHYSICAL=1;Xe.FALLOFF_GLTF=2;Xe.FALLOFF_STANDARD=3;Xe.LIGHTMAP_DEFAULT=0;Xe.LIGHTMAP_SPECULAR=1;Xe.LIGHTMAP_SHADOWSONLY=2;Xe.INTENSITYMODE_AUTOMATIC=0;Xe.INTENSITYMODE_LUMINOUSPOWER=1;Xe.INTENSITYMODE_LUMINOUSINTENSITY=2;Xe.INTENSITYMODE_ILLUMINANCE=3;Xe.INTENSITYMODE_LUMINANCE=4;Xe.LIGHTTYPEID_POINTLIGHT=0;Xe.LIGHTTYPEID_DIRECTIONALLIGHT=1;Xe.LIGHTTYPEID_SPOTLIGHT=2;Xe.LIGHTTYPEID_HEMISPHERICLIGHT=3;class Kp{constructor(){this.pointerDownFastCheck=!1,this.pointerUpFastCheck=!1,this.pointerMoveFastCheck=!1,this.skipPointerMovePicking=!1,this.skipPointerDownPicking=!1,this.skipPointerUpPicking=!1}}var Ha;(function(a){a[a.BackwardCompatible=0]="BackwardCompatible",a[a.Intermediate=1]="Intermediate",a[a.Aggressive=2]="Aggressive"})(Ha||(Ha={}));class it{static DefaultMaterialFactory(e){throw ye("StandardMaterial")}static CollisionCoordinatorFactory(){throw ye("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.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 pt.DragMovementThreshold}static set DragMovementThreshold(e){pt.DragMovementThreshold=e}static get LongPressDelay(){return pt.LongPressDelay}static set LongPressDelay(e){pt.LongPressDelay=e}static get DoubleClickDelay(){return pt.DoubleClickDelay}static set DoubleClickDelay(e){pt.DoubleClickDelay=e}static get ExclusiveDoubleClickMode(){return pt.ExclusiveDoubleClickMode}static set ExclusiveDoubleClickMode(e){pt.ExclusiveDoubleClickMode=e}bindEyePosition(e,t="vEyePosition",i=!1){const s=this._forcedViewPosition?this._forcedViewPosition:this._mirroredCameraPosition?this._mirroredCameraPosition:this.activeCamera.globalPosition,n=this.useRightHandedSystem===(this._mirroredCameraPosition!=null);return N.Vector4[0].set(s.x,s.y,s.z,n?-1:1),e&&(i?e.setFloat3(t,N.Vector4[0].x,N.Vector4[0].y,N.Vector4[0].z):e.setVector4(t,N.Vector4[0])),N.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=Ql(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 defaultMaterial(){return this._defaultMaterial||(this._defaultMaterial=it.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=it.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 pt(this),this.cameraToUseForPointers=null,this._isScene=!0,this._blockEntityCollection=!1,this.autoClear=!0,this.autoClearDepthAndStencil=!0,this._clearColor=new H(.2,.2,.3,1),this.onClearColorChangedObservable=new Z,this.ambientColor=new de(0,0,0),this.environmentIntensity=1,this._performancePriority=0,this.onScenePerformancePriorityChangedObservable=new Z,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 Z,this._onDisposeObserver=null,this.onBeforeRenderObservable=new Z,this._onBeforeRenderObserver=null,this.onAfterRenderObservable=new Z,this.onAfterRenderCameraObservable=new Z,this._onAfterRenderObserver=null,this.onBeforeAnimationsObservable=new Z,this.onAfterAnimationsObservable=new Z,this.onBeforeDrawPhaseObservable=new Z,this.onAfterDrawPhaseObservable=new Z,this.onReadyObservable=new Z,this.onBeforeCameraRenderObservable=new Z,this._onBeforeCameraRenderObserver=null,this.onAfterCameraRenderObservable=new Z,this._onAfterCameraRenderObserver=null,this.onBeforeActiveMeshesEvaluationObservable=new Z,this.onAfterActiveMeshesEvaluationObservable=new Z,this.onBeforeParticlesRenderingObservable=new Z,this.onAfterParticlesRenderingObservable=new Z,this.onDataLoadedObservable=new Z,this.onNewCameraAddedObservable=new Z,this.onCameraRemovedObservable=new Z,this.onNewLightAddedObservable=new Z,this.onLightRemovedObservable=new Z,this.onNewGeometryAddedObservable=new Z,this.onGeometryRemovedObservable=new Z,this.onNewTransformNodeAddedObservable=new Z,this.onTransformNodeRemovedObservable=new Z,this.onNewMeshAddedObservable=new Z,this.onMeshRemovedObservable=new Z,this.onNewSkeletonAddedObservable=new Z,this.onSkeletonRemovedObservable=new Z,this.onNewMaterialAddedObservable=new Z,this.onNewMultiMaterialAddedObservable=new Z,this.onMaterialRemovedObservable=new Z,this.onMultiMaterialRemovedObservable=new Z,this.onNewTextureAddedObservable=new Z,this.onTextureRemovedObservable=new Z,this.onBeforeRenderTargetsRenderObservable=new Z,this.onAfterRenderTargetsRenderObservable=new Z,this.onBeforeStepObservable=new Z,this.onAfterStepObservable=new Z,this.onActiveCameraChanged=new Z,this.onActiveCamerasChanged=new Z,this.onBeforeRenderingGroupObservable=new Z,this.onAfterRenderingGroupObservable=new Z,this.onMeshImportedObservable=new Z,this.onAnimationFileImportedObservable=new Z,this._registeredForLateAnimationBindings=new Ms(256),this._pointerPickingConfiguration=new Kp,this.onPrePointerObservable=new Z,this.onPointerObservable=new Z,this.onPreKeyboardObservable=new Z,this.onKeyboardObservable=new Z,this._useRightHandedSystem=!1,this._timeAccumulator=0,this._currentStepId=0,this._currentInternalStep=0,this._fogEnabled=!0,this._fogMode=it.FOGMODE_NONE,this.fogColor=new de(.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.physicsEnabled=!0,this.particlesEnabled=!0,this.spritesEnabled=!0,this._skeletonsEnabled=!0,this.lensFlaresEnabled=!0,this.collisionsEnabled=!0,this.gravity=new v(0,-9.807,0),this.postProcessesEnabled=!0,this.renderTargetsEnabled=!0,this.dumpNextRenderTargets=!1,this.customRenderTargets=[],this.importedMeshesFiles=[],this.probesEnabled=!0,this._meshesForIntersections=new Ms(256),this.proceduralTexturesEnabled=!0,this._totalVertices=new ui,this._activeIndices=new ui,this._activeParticles=new ui,this._activeBones=new ui,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 Ut(256),this._processedMaterials=new Ut(256),this._renderTargets=new Ms(256),this._materialsRenderTargets=new Ms(256),this._activeParticleSystems=new Ut(256),this._activeSkeletons=new Ms(32),this._softwareSkinnedMeshes=new Ms(32),this._activeAnimatables=new Array,this._transformMatrix=O.Zero(),this.requireLightSorting=!1,this._components=[],this._serializableComponents=[],this._transientComponents=[],this._beforeCameraUpdateStage=_t.Create(),this._beforeClearStage=_t.Create(),this._beforeRenderTargetClearStage=_t.Create(),this._gatherRenderTargetsStage=_t.Create(),this._gatherActiveCameraRenderTargetsStage=_t.Create(),this._isReadyForMeshStage=_t.Create(),this._beforeEvaluateActiveMeshStage=_t.Create(),this._evaluateSubMeshStage=_t.Create(),this._preActiveMeshStage=_t.Create(),this._cameraDrawRenderTargetStage=_t.Create(),this._beforeCameraDrawStage=_t.Create(),this._beforeRenderTargetDrawStage=_t.Create(),this._beforeRenderingGroupDrawStage=_t.Create(),this._beforeRenderingMeshStage=_t.Create(),this._afterRenderingMeshStage=_t.Create(),this._afterRenderingGroupDrawStage=_t.Create(),this._afterCameraDrawStage=_t.Create(),this._afterCameraPostProcessStage=_t.Create(),this._afterRenderTargetDrawStage=_t.Create(),this._afterRenderTargetPostProcessStage=_t.Create(),this._afterRenderStage=_t.Create(),this._pointerMoveStage=_t.Create(),this._pointerDownStage=_t.Create(),this._pointerUpStage=_t.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._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||Ee.LastCreatedEngine,i.virtual?e._virtualScenes.push(this):(Ee._LastCreatedScene=this,e.scenes.push(this)),this._uid=null,this._renderingManager=new Lt(this),ka&&(this.postProcessManager=new ka(this)),St()&&this.attachControl(),this._createUbo(),Ne&&(this._imageProcessingConfiguration=new Ne),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){var r,o,h;if(this._isDisposed)return!1;let t;const i=this.getEngine(),s=i.currentRenderPassId;i.currentRenderPassId=(o=(r=this.activeCamera)==null?void 0:r.renderPassId)!=null?o:s;let n=!0;for(this._pendingData.length>0&&(n=!1),(h=this.prePassRenderer)==null||h.update(),this.useOrderIndependentTransparency&&this.depthPeelingRenderer&&n&&(n=this.depthPeelingRenderer.isReady()),e&&(this._processedMaterials.reset(),this._materialsRenderTargets.reset()),t=0;t<this.meshes.length;t++){const l=this.meshes[t];if(!l.subMeshes||l.subMeshes.length===0)continue;if(!l.isReady(!0)){n=!1;continue}const c=l.hasThinInstances||l.getClassName()==="InstancedMesh"||l.getClassName()==="InstancedLinesMesh"||i.getCaps().instancedArrays&&l.instances.length>0;for(const f of this._isReadyForMeshStage)f.action(l,c)||(n=!1);if(!e)continue;const u=l.material||this.defaultMaterial;if(u)if(u._storeEffectOnSubMeshes)for(const f of l.subMeshes){const d=f.getMaterial();d&&d.hasRenderTargetTextures&&d.getRenderTargetTextures!=null&&this._processedMaterials.indexOf(d)===-1&&(this._processedMaterials.push(d),this._materialsRenderTargets.concatWithNoDuplicate(d.getRenderTargetTextures()))}else u.hasRenderTargetTextures&&u.getRenderTargetTextures!=null&&this._processedMaterials.indexOf(u)===-1&&(this._processedMaterials.push(u),this._materialsRenderTargets.concatWithNoDuplicate(u.getRenderTargetTextures()))}if(e)for(t=0;t<this._materialsRenderTargets.length;++t)this._materialsRenderTargets.data[t].isReadyForRendering()||(n=!1);for(t=0;t<this.geometries.length;t++)this.geometries[t].delayLoadState===2&&(n=!1);if(this.activeCameras&&this.activeCameras.length>0)for(const l of this.activeCameras)l.isReady(!0)||(n=!1);else this.activeCamera&&(this.activeCamera.isReady(!0)||(n=!1));for(const l of this.particleSystems)l.isReady()||(n=!1);if(this.layers)for(const l of this.layers)l.isReady()||(n=!1);return i.areAllEffectsReady()||(n=!1),i.currentRenderPassId=s,n}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=bi.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?mi.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=mi.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 fe(this._engine,void 0,!1,e!=null?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 Sc.UniqueId}addMesh(e,t=!1){this._blockEntityCollection||(this.meshes.push(e),e._resyncLightSources(),e.parent||e._addToSceneRootNodes(),J.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());J.SetImmediate(()=>{this.onNewLightAddedObservable.notifyObservers(e)})}}sortLightsByPriority(){this.requireLightSorting&&this.lights.sort(Xe.CompareLightsPriority)}addCamera(e){this._blockEntityCollection||(this.cameras.push(e),J.SetImmediate(()=>{this.onNewCameraAddedObservable.notifyObservers(e)}),e.parent||e._addToSceneRootNodes())}addSkeleton(e){this._blockEntityCollection||(this.skeletons.push(e),J.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),J.SetImmediate(()=>{this.onNewMultiMaterialAddedObservable.notifyObservers(e)}))}addMaterial(e){this._blockEntityCollection||e.getScene()===this&&e._indexInSceneMaterialArray!==-1||(e._indexInSceneMaterialArray=this.materials.length,this.materials.push(e),J.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}pushGeometry(e,t){return!t&&this._getGeometryByUniqueId(e.uniqueId)?!1:(this.addGeometry(e),J.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 n=this.getCameraById(e);if(n)return n;const r=this.getBoneById(e);return r||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 n=this.getCameraByName(e);if(n)return n;const r=this.getBoneByName(e);return r||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 n=i.getTarget(s);if(n.id===e)return n}}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 n=i.getTarget(s);if(n.name===e)return n}}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=J.RandomId()),this._uid}addExternalData(e,t){return this._externalData||(this._externalData=new Fh),this._externalData.add(e,t)}getExternalData(e){return this._externalData?this._externalData.get(e):null}getOrAddExternalDataWithFactory(e,t){return this._externalData||(this._externalData=new Fh),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 r of this._evaluateSubMeshStage)r.action(t,e);const n=e.getMaterial();n!=null&&(n.hasRenderTargetTextures&&n.getRenderTargetTextures!=null&&this._processedMaterials.indexOf(n)===-1&&(this._processedMaterials.push(n),this._materialsRenderTargets.concatWithNoDuplicate(n.getRenderTargetTextures())),this._renderingManager.dispatch(e,t,n))}}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,n=!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=n,this._skipEvaluateActiveMeshesCompletely=e,s)for(let r=0;r<this._activeMeshes.length;r++)this._activeMeshes.data[r]._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(){var i;if(this._engine.snapshotRendering&&this._engine.snapshotRenderingMode===1){this._activeMeshes.length>0&&((i=this.activeCamera)==null||i._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 s=this._activeMeshes.length;for(let n=0;n<s;n++)this._activeMeshes.data[n].computeWorldMatrix()}if(this._activeParticleSystems){const s=this._activeParticleSystems.length;for(let n=0;n<s;n++)this._activeParticleSystems.data[n].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 s of this._beforeEvaluateActiveMeshStage)s.action();const e=this.getActiveMeshCandidates(),t=e.length;for(let s=0;s<t;s++){const n=e.data[s];if(n._internalAbstractMeshDataInfo._currentLODIsUpToDate=!1,n.isBlocked||(this._totalVertices.addCount(n.getTotalVertices(),!1),!n.isReady()||!n.isEnabled()||n.scaling.hasAZeroComponent))continue;n.computeWorldMatrix(),n.actionManager&&n.actionManager.hasSpecificTriggers2(12,13)&&this._meshesForIntersections.pushNoDuplicate(n);let r=this.customLODSelector?this.customLODSelector(n,this.activeCamera):n.getLOD(this.activeCamera);if(n._internalAbstractMeshDataInfo._currentLOD=r,n._internalAbstractMeshDataInfo._currentLODIsUpToDate=!0,r!=null&&(r!==n&&r.billboardMode!==0&&r.computeWorldMatrix(),n._preActivate(),n.isVisible&&n.visibility>0&&n.layerMask&this.activeCamera.layerMask&&(this._skipFrustumClipping||n.alwaysSelectAsActiveMesh||n.isInFrustum(this._frustumPlanes)))){this._activeMeshes.push(n),this.activeCamera._activeMeshes.push(n),r!==n&&r._activate(this._renderId,!1);for(const o of this._preActiveMeshStage)o.action(n);n._activate(this._renderId,!1)&&(n.isAnInstance?n._internalAbstractMeshDataInfo._actAsRegularMesh&&(r=n):r._internalAbstractMeshDataInfo._onlyForInstances=!1,r._internalAbstractMeshDataInfo._isActive=!0,this._activeMesh(n,r)),n._postActivate()}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(let s=0;s<this.particleSystems.length;s++){const n=this.particleSystems[s];if(!n.isStarted()||!n.emitter)continue;const r=n.emitter;(!r.position||r.isEnabled())&&(this._activeParticleSystems.push(n),n.animate(),this._renderingManager.dispatchParticles(n))}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),n=s.length;i=i||n===1;for(let r=0;r<n;r++){const o=s.data[r];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){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){var r,o,h;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 l=!0;e._renderingMultiview&&e.outputRenderTarget&&(l=e.outputRenderTarget.skipInitialClear,this.autoClear&&(this._defaultFrameBufferCleared=!1,e.outputRenderTarget.skipInitialClear=!1)),this._bindFrameBuffer(this._activeCamera),e._renderingMultiview&&e.outputRenderTarget&&(e.outputRenderTarget.skipInitialClear=l)}this.updateTransformMatrix(),this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),this._evaluateActiveMeshes();for(let l=0;l<this._softwareSkinnedMeshes.length;l++){const c=this._softwareSkinnedMeshes.data[l];c.applySkeleton(c.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 l of this._gatherActiveCameraRenderTargetsStage)l.action(this._renderTargets);let n=!1;if(this.renderTargetsEnabled){if(this._intermediateRendering=!0,this._renderTargets.length>0){J.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(let l=0;l<this._renderTargets.length;l++){const c=this._renderTargets.data[l];if(c._shouldRender()){this._renderId++;const u=c.activeCamera&&c.activeCamera!==this.activeCamera;c.render(u,this.dumpNextRenderTargets),n=!0}}J.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._renderId++}for(const l of this._cameraDrawRenderTargetStage)n=l.action(this.activeCamera)||n;this._intermediateRendering=!1}this._engine.currentRenderPassId=(h=(o=(r=e.outputRenderTarget)==null?void 0:r.renderPassId)!=null?o:e.renderPassId)!=null?h:0,n&&!this.prePass&&(this._bindFrameBuffer(this._activeCamera,!1),this.updateTransformMatrix()),this.onAfterRenderTargetsRenderObservable.notifyObservers(this),this.postProcessManager&&!e._multiviewTexture&&!this.prePass&&this.postProcessManager._prepareFrame();for(const l of this._beforeCameraDrawStage)l.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 l of this._afterCameraDrawStage)l.action(this.activeCamera);if(this.postProcessManager&&!e._multiviewTexture){const l=e.outputRenderTarget?e.outputRenderTarget.renderTarget:void 0;this.postProcessManager._finalizeFrame(e.isIntermediate,l)}for(const l of this._afterCameraPostProcessStage)l.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 n=s.getTriggerParameter(),r=n.mesh?n.mesh:n,o=r.intersectsMesh(t,n.usePreciseIntersection),h=t._intersectionsInProgress.indexOf(r);o&&h===-1?s.trigger===12?(s._executeCurrent(Ot.CreateNew(t,void 0,r)),t._intersectionsInProgress.push(r)):s.trigger===13&&t._intersectionsInProgress.push(r):!o&&h>-1&&(s.trigger===13&&s._executeCurrent(Ot.CreateNew(t,void 0,r)),(!t.actionManager.hasSpecificTrigger(13,l=>{const c=l.mesh?l.mesh:l;return r===c})||s.trigger===13)&&t._intersectionsInProgress.splice(h,1))}}}}_advancePhysicsEngineStep(e){}_animate(e){}animate(){if(this._engine.isDeterministicLockStep()){let e=Math.max(it.MinDeltaTime,Math.min(this._engine.getDeltaTime(),it.MaxDeltaTime))+this._timeAccumulator;const t=this._engine.getTimeStep(),i=1e3/t/1e3;let s=0;const n=this._engine.getLockstepMaxSteps();let r=Math.floor(e/t);for(r=Math.min(r,n);e>0&&s<r;)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(it.MinDeltaTime,Math.min(this._engine.getDeltaTime(),it.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){var t;if(e!=null&&e.outputRenderTarget&&!(e!=null&&e.isRigCamera)&&(e.outputRenderTarget._cleared=!1),(t=e==null?void 0:e.rigCameras)!=null&&t.length)for(let i=0;i<e.rigCameras.length;++i){const s=e.rigCameras[i].outputRenderTarget;s&&(s._cleared=!1)}}resetDrawCache(e){if(this.meshes)for(const t of this.meshes)t.resetDrawCache(e)}_renderWithFrameGraph(e=!0,t=!1){var n;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 o=0;o<r._rigCameras.length;o++)r._rigCameras[o].update()}for(const r of this._beforeClearStage)r.action();const i=this.getActiveMeshCandidates(),s=i.length;for(let r=0;r<s;r++){const o=i.data[r];o.isBlocked||(this._totalVertices.addCount(o.getTotalVertices(),!1),!(!o.isReady()||!o.isEnabled()||o.scaling.hasAZeroComponent)&&(o.computeWorldMatrix(),o.actionManager&&o.actionManager.hasSpecificTriggers2(12,13)&&this._meshesForIntersections.pushNoDuplicate(o)))}if(this.particlesEnabled)for(let r=0;r<this.particleSystems.length;r++){const o=this.particleSystems[r];if(!o.isStarted()||!o.emitter)continue;const h=o.emitter;(!h.position||h.isEnabled())&&(this._activeParticleSystems.push(o),o.animate())}(n=this.frameGraph)==null||n.execute()}render(e=!0,t=!1){var i,s,n;if(!this.isDisposed){this.onReadyObservable.hasObservers()&&this._executeWhenReadyTimeoutId===null&&this._checkIsReady(),this._frameId++,this._defaultFrameBufferCleared=!1,this._checkCameraRenderTarget(this.activeCamera),(i=this.activeCameras)!=null&&i.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 r of this._beforeCameraUpdateStage)r.action();if(e){if(this.activeCameras&&this.activeCameras.length>0)for(let r=0;r<this.activeCameras.length;r++){const o=this.activeCameras[r];if(o.update(),o.cameraRigMode!==0)for(let h=0;h<o._rigCameras.length;h++)o._rigCameras[h].update()}else if(this.activeCamera&&(this.activeCamera.update(),this.activeCamera.cameraRigMode!==0))for(let r=0;r<this.activeCamera._rigCameras.length;r++)this.activeCamera._rigCameras[r].update()}if(this.onBeforeRenderObservable.notifyObservers(this),this.customRenderFunction)this._renderId++,this._engine.currentRenderPassId=0,this.customRenderFunction(e,t);else{const r=this.getEngine();this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);const o=(s=this.activeCameras)!=null&&s.length?this.activeCameras[0]:this.activeCamera;if(this.renderTargetsEnabled){J.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!0;for(let h=0;h<this.customRenderTargets.length;h++){const l=this.customRenderTargets[h];if(l._shouldRender()){if(this._renderId++,this.activeCamera=l.activeCamera||this.activeCamera,!this.activeCamera)throw new Error("Active camera not set");r.setViewport(this.activeCamera.viewport),this.updateTransformMatrix(),l.render(o!==this.activeCamera,this.dumpNextRenderTargets)}}J.EndPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!1,this._renderId++}this._engine.currentRenderPassId=(n=o==null?void 0:o.renderPassId)!=null?n:0,this.activeCamera=o,this._activeCamera&&this._activeCamera.cameraRigMode!==22&&!this.prePass&&this._bindFrameBuffer(this._activeCamera,!1),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(const h of this._beforeClearStage)h.action();this._clearFrameBuffer(this.activeCamera);for(const h of this._gatherRenderTargetsStage)h.action(this._renderTargets);if(this.activeCameras&&this.activeCameras.length>0)for(let h=0;h<this.activeCameras.length;h++)this._processSubCameras(this.activeCameras[h],h>0);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera,!!this.activeCamera.outputRenderTarget)}}this._checkIntersections();for(const r of this._afterRenderStage)r.action();if(this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this),this._toBeDisposed.length){for(let r=0;r<this._toBeDisposed.length;r++){const o=this._toBeDisposed[r];o&&o.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(n=>{n.onAnimationEndObservable.clear(),n.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 n of e)n.abort();this._activeRequests.length=0;try{this.onDisposeObservable.notifyObservers(this)}catch(n){U.Error("An error occurred while calling onDisposeObservable!",n)}if(this.detachControl(),this._engine.getInputElement())for(let n=0;n<this.cameras.length;n++)this.cameras[n].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,n=>n.dispose(!0)),this._disposeList(this.transformNodes,n=>n.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);s>-1&&this._engine.scenes.splice(s,1),Ee._LastCreatedScene===this&&(this._engine.scenes.length>0?Ee._LastCreatedScene=this._engine.scenes[this._engine.scenes.length-1]:Ee._LastCreatedScene=null),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._isDisposed=!0}_disposeList(e,t){const i=e.slice(0);t=t!=null?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 v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),i=new v(-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 n=s.getBoundingInfo(),r=n.boundingBox.minimumWorld,o=n.boundingBox.maximumWorld;v.CheckExtends(r,t,i),v.CheckExtends(o,t,i)}),{min:t,max:i}}createPickingRay(e,t,i,s,n=!1){throw ye("Ray")}createPickingRayToRef(e,t,i,s,n,r=!1,o=!1){throw ye("Ray")}createPickingRayInCameraSpace(e,t,i){throw ye("Ray")}createPickingRayInCameraSpaceToRef(e,t,i,s){throw ye("Ray")}pick(e,t,i,s,n,r){const o=ye("Ray",!0);return o&&U.Warn(o),new as}pickWithBoundingInfo(e,t,i,s,n){const r=ye("Ray",!0);return r&&U.Warn(r),new as}pickWithRay(e,t,i,s){throw ye("Ray")}multiPick(e,t,i,s,n){throw ye("Ray")}multiPickWithRay(e,t,i){throw ye("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 n in e){const r=e[n];ke&&ke.MatchesQuery(r,t)&&(!i||i(r))&&s.push(r)}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(63))}markAllMaterialsAsDirty(e,t){if(!this._blockMaterialDirtyMechanism)for(const i of this.materials)t&&!t(i)||i.markAsDirty(e)}_loadFile(e,t,i,s,n,r,o){const h=Ts(e,t,i,s?this.offlineProvider:void 0,n,r,o);return this._activeRequests.push(h),h.onCompleteObservable.add(l=>{this._activeRequests.splice(this._activeRequests.indexOf(l),1)}),h}_loadFileAsync(e,t,i,s,n){return new Promise((r,o)=>{this._loadFile(e,h=>{r(h)},t,i,s,(h,l)=>{o(l)},n)})}_requestFile(e,t,i,s,n,r,o){const h=x0(e,t,i,s?this.offlineProvider:void 0,n,r,o);return this._activeRequests.push(h),h.onCompleteObservable.add(l=>{this._activeRequests.splice(this._activeRequests.indexOf(l),1)}),h}_requestFileAsync(e,t,i,s,n){return new Promise((r,o)=>{this._requestFile(e,h=>{r(h)},t,i,s,h=>{o(h)},n)})}_readFile(e,t,i,s,n){const r=Ln(e,t,i,s,n);return this._activeRequests.push(r),r.onCompleteObservable.add(o=>{this._activeRequests.splice(this._activeRequests.indexOf(o),1)}),r}_readFileAsync(e,t,i){return new Promise((s,n)=>{this._readFile(e,r=>{s(r)},t,i,r=>{n(r)})})}getPerfCollector(){throw ye("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)}}it.FOGMODE_NONE=0;it.FOGMODE_EXP=1;it.FOGMODE_EXP2=2;it.FOGMODE_LINEAR=3;it.MinDeltaTime=1;it.MaxDeltaTime=1e3;vt("BABYLON.Scene",it);class ve extends bt{get position(){return this._position}set position(e){this._position=e}set upVector(e){this._upVector=e}get upVector(){return this._upVector}get screenArea(){var i,s,n,r;let e=0,t=0;if(this.mode===ve.PERSPECTIVE_CAMERA)this.fovMode===ve.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 o=this.getEngine().getRenderWidth()/2,h=this.getEngine().getRenderHeight()/2;e=((i=this.orthoRight)!=null?i:o)-((s=this.orthoLeft)!=null?s:-o),t=((n=this.orthoTop)!=null?n:h)-((r=this.orthoBottom)!=null?r:-h)}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=v.Zero(),this._upVector=v.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=ve.PERSPECTIVE_CAMERA,this.isIntermediate=!1,this.viewport=new on(0,0,1,1),this.layerMask=268435455,this.fovMode=ve.FOVMODE_VERTICAL_FIXED,this.cameraRigMode=ve.RIG_MODE_NONE,this.customRenderTargets=[],this.outputRenderTarget=null,this.onViewMatrixChangedObservable=new Z,this.onProjectionMatrixChangedObservable=new Z,this.onAfterCheckInputsObservable=new Z,this.onRestoreStateObservable=new Z,this.isRigCamera=!1,this._hasMoved=!1,this._rigCameras=new Array,this._skipRendering=!1,this._projectionMatrix=new O,this._postProcesses=new Array,this._activeMeshes=new Ut(256),this._globalPosition=v.Zero(),this._computedViewMatrix=O.Identity(),this._doNotComputeProjectionMatrix=!1,this._transformMatrix=O.Zero(),this._refreshFrustumPlanes=!0,this._absoluteRotation=re.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 ".concat(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 v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.upVector=new v(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===ve.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!==ve.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],n=s._rigPostProcess;n?(n.getEffectName()==="pass"&&(s.isIntermediate=this._postProcesses.length===0),s._postProcesses=this._postProcesses.slice(0).concat(n),n.markTextureDirty()):s._postProcesses=this._postProcesses.slice(0)}}attachPostProcess(e,t=null){return!e.isReusable()&&this._postProcesses.indexOf(e)>-1?(U.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 O.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){var n,r,o,h,l,c,u,f,d,_,p,g,m,b,I,T,x,y,R;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===ve.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 E;i.useRightHandedSystem?E=O.PerspectiveFovRHToRef:E=O.PerspectiveFovLHToRef,E(this.fov,t.getAspectRatio(this),s?this.maxZ:this.minZ,s?this.minZ:this.maxZ,this._projectionMatrix,this.fovMode===ve.FOVMODE_VERTICAL_FIXED,t.isNDCHalfZRange,this.projectionPlaneTilt,s)}else{const E=t.getRenderWidth()/2,C=t.getRenderHeight()/2;i.useRightHandedSystem?this.oblique?O.ObliqueOffCenterRHToRef((n=this.orthoLeft)!=null?n:-E,(r=this.orthoRight)!=null?r:E,(o=this.orthoBottom)!=null?o:-C,(h=this.orthoTop)!=null?h:C,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):O.OrthoOffCenterRHToRef((l=this.orthoLeft)!=null?l:-E,(c=this.orthoRight)!=null?c:E,(u=this.orthoBottom)!=null?u:-C,(f=this.orthoTop)!=null?f:C,s?this.maxZ:this.minZ,s?this.minZ:this.maxZ,this._projectionMatrix,t.isNDCHalfZRange):this.oblique?O.ObliqueOffCenterLHToRef((d=this.orthoLeft)!=null?d:-E,(_=this.orthoRight)!=null?_:E,(p=this.orthoBottom)!=null?p:-C,(g=this.orthoTop)!=null?g:C,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):O.OrthoOffCenterLHToRef((m=this.orthoLeft)!=null?m:-E,(b=this.orthoRight)!=null?b:E,(I=this.orthoBottom)!=null?I:-C,(T=this.orthoTop)!=null?T:C,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=(x=this.oblique)==null?void 0:x.angle,this._cache.obliqueLength=(y=this.oblique)==null?void 0:y.length,this._cache.obliqueOffset=(R=this.oblique)==null?void 0:R.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?v.Distance(this.position,i.target):this.position.length()))+e}_updateFrustumPlanes(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),this._frustumPlanes?mi.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=mi.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 ye("Ray")}getForwardRayToRef(e,t=100,i,s){throw ye("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!==ve.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses.length=0;else{let s=this._postProcesses.length;for(;--s>=0;){const n=this._postProcesses[s];n&&n.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=J.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==ve.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 O.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=J.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===ve.RIG_MODE_STEREOSCOPIC_ANAGLYPH&&(this._rigCameras[0].viewport=this._rigCameras[1].viewport=this.viewport)}_setupInputs(){}serialize(){const e=Ae.Serialize(this);return e.uniqueId=this.uniqueId,e.type=this.getClassName(),this.parent&&this.parent._serializeAsParent(e),this.inputs&&this.inputs.serialize(e),Ae.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.isEnabled=this.isEnabled(),e}clone(e,t=null){const i=Ae.Clone(ve.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=v.Zero();return this.getDirectionToRef(e,t),t}get absoluteRotation(){return this.getWorldMatrix().decompose(void 0,this._absoluteRotation),this._absoluteRotation}getDirectionToRef(e,t){v.TransformNormalToRef(e,this.getWorldMatrix(),t)}static GetConstructorFromName(e,t,i,s=0,n=!0){const r=bt.Construct(e,t,i,{interaxial_distance:s,isStereoscopicSideBySide:n});return r||(()=>ve._CreateDefaultParsedCamera(t,i))}computeWorldMatrix(){return this.getWorldMatrix()}static Parse(e,t){const i=e.type,s=ve.GetConstructorFromName(i,e.name,t,e.interaxial_distance,e.isStereoscopicSideBySide),n=Ae.Parse(s,e,t);if(e.parentId!==void 0&&(n._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(n._waitingParentInstanceIndex=e.parentInstanceIndex),n.inputs&&(n.inputs.parse(e),n._setupInputs()),e.upVector&&(n.upVector=v.FromArray(e.upVector)),n.setPosition&&(n.position.copyFromFloats(0,0,0),n.setPosition(v.FromArray(e.position))),e.target&&n.setTarget&&n.setTarget(v.FromArray(e.target)),e.cameraRigMode){const r=e.interaxial_distance?{interaxialDistance:e.interaxial_distance}:{};n.setCameraRigMode(e.cameraRigMode,r)}if(e.animations){for(let r=0;r<e.animations.length;r++){const o=e.animations[r],h=ys("BABYLON.Animation");h&&n.animations.push(h.Parse(o))}bt.ParseAnimationRanges(n,e,t)}return e.autoAnimate&&t.beginAnimation(n,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),e.isEnabled!==void 0&&n.setEnabled(e.isEnabled),n}_calculateHandednessMultiplier(){let e=this.getScene().useRightHandedSystem?-1:1;return this.parent&&this.parent._getWorldMatrixDeterminant()<0&&(e*=-1),e}}ve._CreateDefaultParsedCamera=(a,e)=>{throw ye("UniversalCamera")};ve.PERSPECTIVE_CAMERA=0;ve.ORTHOGRAPHIC_CAMERA=1;ve.FOVMODE_VERTICAL_FIXED=0;ve.FOVMODE_HORIZONTAL_FIXED=1;ve.RIG_MODE_NONE=0;ve.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10;ve.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11;ve.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12;ve.RIG_MODE_STEREOSCOPIC_OVERUNDER=13;ve.RIG_MODE_STEREOSCOPIC_INTERLACED=14;ve.RIG_MODE_VR=20;ve.RIG_MODE_CUSTOM=22;ve.ForceAttachControlToAlwaysPreventDefault=!1;D([yi("position")],ve.prototype,"_position",void 0);D([yi("upVector")],ve.prototype,"_upVector",void 0);D([B()],ve.prototype,"orthoLeft",null);D([B()],ve.prototype,"orthoRight",null);D([B()],ve.prototype,"orthoBottom",null);D([B()],ve.prototype,"orthoTop",null);D([B()],ve.prototype,"fov",void 0);D([B()],ve.prototype,"projectionPlaneTilt",void 0);D([B()],ve.prototype,"minZ",void 0);D([B()],ve.prototype,"maxZ",void 0);D([B()],ve.prototype,"inertia",void 0);D([B()],ve.prototype,"mode",null);D([B()],ve.prototype,"layerMask",void 0);D([B()],ve.prototype,"fovMode",void 0);D([B()],ve.prototype,"cameraRigMode",void 0);D([B()],ve.prototype,"interaxialDistance",void 0);D([B()],ve.prototype,"isStereoscopicSideBySide",void 0);class Tt{static get ForceFullSceneLoadingForIncremental(){return Tt._ForceFullSceneLoadingForIncremental}static set ForceFullSceneLoadingForIncremental(e){Tt._ForceFullSceneLoadingForIncremental=e}static get ShowLoadingScreen(){return Tt._ShowLoadingScreen}static set ShowLoadingScreen(e){Tt._ShowLoadingScreen=e}static get loggingLevel(){return Tt._LoggingLevel}static set loggingLevel(e){Tt._LoggingLevel=e}static get CleanBoneMatrixWeights(){return Tt._CleanBoneMatrixWeights}static set CleanBoneMatrixWeights(e){Tt._CleanBoneMatrixWeights=e}}Tt._ForceFullSceneLoadingForIncremental=!1;Tt._ShowLoadingScreen=!0;Tt._CleanBoneMatrixWeights=!1;Tt._LoggingLevel=0;function Xp(a,e,t,i,s,n,r,o){const h=e*A.GetTypeByteLength(t),l=r*e;if(o.length!==l)throw new Error("Output length is not valid");if(t!==A.FLOAT||s!==h){A.ForEach(a,i,s,e,t,l,n,(c,u)=>o[u]=c);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%4){U.Warn("CopyFloatData: copied misaligned data."),o.set(new Float32Array(a.buffer.slice(c,c+l*4)));return}const f=new Float32Array(a.buffer,c,l);o.set(f)}}class Nt{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 Nt(Nt.RandomId(),e.getScene());return t.applyToMesh(e),t}get meshes(){return this._meshes}constructor(e,t,i,s=!1,n=null){this.delayLoadState=0,this._totalVertices=0,this._isDisposed=!1,this._indexBufferIsUpdatable=!1,this._positionsCache=[],this._parentContainer=null,this.useBoundingInfoFromGeometry=!1,this._scene=t||Ee.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={}),n&&(this.applyToMesh(n),n.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 n=new A(this._engine,t,e,{updatable:i,postponeInternalCreation:this._meshes.length===0,stride:s,label:"Geometry_"+this.id+"_"+e});this.setVerticesBuffer(n)}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 n=this._meshes,r=n.length;if(s===A.PositionKind){this._totalVertices=t!=null?t:e._maxVerticesCount,this._updateExtend(e.getFloatData(this._totalVertices)),this._resetPointsArrayCache();const o=this._extend&&this._extend.minimum||new v(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),h=this._extend&&this._extend.maximum||new v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);for(let l=0;l<r;l++){const c=n[l];c.buildBoundingInfo(o,h),c._createGlobalSubMesh(c.isUnIndexed),c.computeWorldMatrix(!0),c.synchronizeInstances()}}this._notifyUpdate(s)}updateVerticesDataDirectly(e,t,i,s=!1){const n=this.getVertexBuffer(e);n&&(n.updateDirectly(t,i,s),this._notifyUpdate(e))}updateVerticesData(e,t,i=!1){const s=this.getVertexBuffer(e);s&&(s.update(t),e===A.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 n=s.subMeshes;for(const r of n)r.refreshBoundingInfo()}}}_bind(e,t,i,s){if(!e)return;t===void 0&&(t=this._indexBuffer);const n=this.getVertexBuffers();if(!n)return;if(t!=this._indexBuffer||!this._vertexArrayObjects&&!s){this._engine.bindBuffers(n,t,e,i);return}const r=s||this._vertexArrayObjects,o=this._engine;r[e.key]||(r[e.key]=o.recordVertexArrayObject(n,t,e,i)),o.bindVertexArrayObject(r[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&&Xp(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 n of this._meshes)n._createGlobalSubMesh(!0)}}setIndexBuffer(e,t,i){this._indices=[],this._indexBufferIsUpdatable=!1,this._indexBuffer=e,this._totalVertices=t,this._totalIndices=i,e.is32Bits||(e.is32Bits=this._totalIndices>65535);for(const s of this._meshes)s._createGlobalSubMesh(!0),s.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 n of this._meshes)n._createGlobalSubMesh(!s),n.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(A.PositionKind),!e))return;this._extend=Ic(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===A.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,n=s.length;for(let r=0;r<n;r++)this._applyToMesh(s[r]);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 n=e[s+0];e[s+0]=e[s+2],e[s+2]=n}this.setIndices(e)}const t=this.getVerticesData(A.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(A.PositionKind,t,!1)}const i=this.getVerticesData(A.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(A.NormalKind,i,!1)}}_resetPointsArrayCache(){this._positions=null}_generatePointsArray(){if(this._positions)return!0;const e=this.getVerticesData(A.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]=v.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 j;t.indices=[];const i=this.getIndices();if(i)for(let h=0;h<i.length;h++)t.indices.push(i[h]);let s=!1,n=!1,r;for(r in this._vertexBuffers){const h=this.getVerticesData(r);if(h&&(h instanceof Float32Array?t.set(new Float32Array(h),r):t.set(h.slice(0),r),!n)){const l=this.getVertexBuffer(r);l&&(s=l.isUpdatable(),n=!s)}}const o=new Nt(e,this._scene,t,s);o.delayLoadState=this.delayLoadState,o.delayLoadingFile=this.delayLoadingFile,o._delayLoadingFunction=this._delayLoadingFunction;for(r in this._delayInfo)o._delayInfo=o._delayInfo||[],o._delayInfo.push(r);return o._boundingInfo=new ri(this._extend.minimum,this._extend.maximum),o}serialize(){const e={};return e.id=this.id,e.uniqueId=this.uniqueId,e.updatable=this._updatable,ke&&ke.HasTags(this)&&(e.tags=ke.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(A.PositionKind)&&(e.positions=this._toNumberArray(this.getVerticesData(A.PositionKind)),this.isVertexBufferUpdatable(A.PositionKind)&&(e.positions._updatable=!0)),this.isVerticesDataPresent(A.NormalKind)&&(e.normals=this._toNumberArray(this.getVerticesData(A.NormalKind)),this.isVertexBufferUpdatable(A.NormalKind)&&(e.normals._updatable=!0)),this.isVerticesDataPresent(A.TangentKind)&&(e.tangents=this._toNumberArray(this.getVerticesData(A.TangentKind)),this.isVertexBufferUpdatable(A.TangentKind)&&(e.tangents._updatable=!0)),this.isVerticesDataPresent(A.UVKind)&&(e.uvs=this._toNumberArray(this.getVerticesData(A.UVKind)),this.isVertexBufferUpdatable(A.UVKind)&&(e.uvs._updatable=!0)),this.isVerticesDataPresent(A.UV2Kind)&&(e.uvs2=this._toNumberArray(this.getVerticesData(A.UV2Kind)),this.isVertexBufferUpdatable(A.UV2Kind)&&(e.uvs2._updatable=!0)),this.isVerticesDataPresent(A.UV3Kind)&&(e.uvs3=this._toNumberArray(this.getVerticesData(A.UV3Kind)),this.isVertexBufferUpdatable(A.UV3Kind)&&(e.uvs3._updatable=!0)),this.isVerticesDataPresent(A.UV4Kind)&&(e.uvs4=this._toNumberArray(this.getVerticesData(A.UV4Kind)),this.isVertexBufferUpdatable(A.UV4Kind)&&(e.uvs4._updatable=!0)),this.isVerticesDataPresent(A.UV5Kind)&&(e.uvs5=this._toNumberArray(this.getVerticesData(A.UV5Kind)),this.isVertexBufferUpdatable(A.UV5Kind)&&(e.uvs5._updatable=!0)),this.isVerticesDataPresent(A.UV6Kind)&&(e.uvs6=this._toNumberArray(this.getVerticesData(A.UV6Kind)),this.isVertexBufferUpdatable(A.UV6Kind)&&(e.uvs6._updatable=!0)),this.isVerticesDataPresent(A.ColorKind)&&(e.colors=this._toNumberArray(this.getVerticesData(A.ColorKind)),this.isVertexBufferUpdatable(A.ColorKind)&&(e.colors._updatable=!0)),this.isVerticesDataPresent(A.MatricesIndicesKind)&&(e.matricesIndices=this._toNumberArray(this.getVerticesData(A.MatricesIndicesKind)),e.matricesIndices._isExpanded=!0,this.isVertexBufferUpdatable(A.MatricesIndicesKind)&&(e.matricesIndices._updatable=!0)),this.isVerticesDataPresent(A.MatricesWeightsKind)&&(e.matricesWeights=this._toNumberArray(this.getVerticesData(A.MatricesWeightsKind)),this.isVertexBufferUpdatable(A.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 J.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,n=e.geometryId;if(s||n){const r=s?this._GetGeometryByLoadedUniqueId(s,i):i.getGeometryById(n);r&&r.applyToMesh(t)}else if(e instanceof ArrayBuffer){const r=t._binaryInfo;if(r.positionsAttrDesc&&r.positionsAttrDesc.count>0){const o=new Float32Array(e,r.positionsAttrDesc.offset,r.positionsAttrDesc.count);t.setVerticesData(A.PositionKind,o,!1)}if(r.normalsAttrDesc&&r.normalsAttrDesc.count>0){const o=new Float32Array(e,r.normalsAttrDesc.offset,r.normalsAttrDesc.count);t.setVerticesData(A.NormalKind,o,!1)}if(r.tangetsAttrDesc&&r.tangetsAttrDesc.count>0){const o=new Float32Array(e,r.tangetsAttrDesc.offset,r.tangetsAttrDesc.count);t.setVerticesData(A.TangentKind,o,!1)}if(r.uvsAttrDesc&&r.uvsAttrDesc.count>0){const o=new Float32Array(e,r.uvsAttrDesc.offset,r.uvsAttrDesc.count);t.setVerticesData(A.UVKind,o,!1)}if(r.uvs2AttrDesc&&r.uvs2AttrDesc.count>0){const o=new Float32Array(e,r.uvs2AttrDesc.offset,r.uvs2AttrDesc.count);t.setVerticesData(A.UV2Kind,o,!1)}if(r.uvs3AttrDesc&&r.uvs3AttrDesc.count>0){const o=new Float32Array(e,r.uvs3AttrDesc.offset,r.uvs3AttrDesc.count);t.setVerticesData(A.UV3Kind,o,!1)}if(r.uvs4AttrDesc&&r.uvs4AttrDesc.count>0){const o=new Float32Array(e,r.uvs4AttrDesc.offset,r.uvs4AttrDesc.count);t.setVerticesData(A.UV4Kind,o,!1)}if(r.uvs5AttrDesc&&r.uvs5AttrDesc.count>0){const o=new Float32Array(e,r.uvs5AttrDesc.offset,r.uvs5AttrDesc.count);t.setVerticesData(A.UV5Kind,o,!1)}if(r.uvs6AttrDesc&&r.uvs6AttrDesc.count>0){const o=new Float32Array(e,r.uvs6AttrDesc.offset,r.uvs6AttrDesc.count);t.setVerticesData(A.UV6Kind,o,!1)}if(r.colorsAttrDesc&&r.colorsAttrDesc.count>0){const o=new Float32Array(e,r.colorsAttrDesc.offset,r.colorsAttrDesc.count);t.setVerticesData(A.ColorKind,o,!1,r.colorsAttrDesc.stride)}if(r.matricesIndicesAttrDesc&&r.matricesIndicesAttrDesc.count>0){const o=new Int32Array(e,r.matricesIndicesAttrDesc.offset,r.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(A.MatricesIndicesKind,h,!1)}if(r.matricesIndicesExtraAttrDesc&&r.matricesIndicesExtraAttrDesc.count>0){const o=new Int32Array(e,r.matricesIndicesExtraAttrDesc.offset,r.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(A.MatricesIndicesExtraKind,h,!1)}if(r.matricesWeightsAttrDesc&&r.matricesWeightsAttrDesc.count>0){const o=new Float32Array(e,r.matricesWeightsAttrDesc.offset,r.matricesWeightsAttrDesc.count);t.setVerticesData(A.MatricesWeightsKind,o,!1)}if(r.indicesAttrDesc&&r.indicesAttrDesc.count>0){const o=new Int32Array(e,r.indicesAttrDesc.offset,r.indicesAttrDesc.count);t.setIndices(o,null)}if(r.subMeshesAttrDesc&&r.subMeshesAttrDesc.count>0){const o=new Int32Array(e,r.subMeshesAttrDesc.offset,r.subMeshesAttrDesc.count*5);t.subMeshes=[];for(let h=0;h<r.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];vi.AddToMesh(l,c,u,f,d,t)}}}else if(e.positions&&e.normals&&e.indices){if(t.setVerticesData(A.PositionKind,e.positions,e.positions._updatable),t.setVerticesData(A.NormalKind,e.normals,e.normals._updatable),e.tangents&&t.setVerticesData(A.TangentKind,e.tangents,e.tangents._updatable),e.uvs&&t.setVerticesData(A.UVKind,e.uvs,e.uvs._updatable),e.uvs2&&t.setVerticesData(A.UV2Kind,e.uvs2,e.uvs2._updatable),e.uvs3&&t.setVerticesData(A.UV3Kind,e.uvs3,e.uvs3._updatable),e.uvs4&&t.setVerticesData(A.UV4Kind,e.uvs4,e.uvs4._updatable),e.uvs5&&t.setVerticesData(A.UV5Kind,e.uvs5,e.uvs5._updatable),e.uvs6&&t.setVerticesData(A.UV6Kind,e.uvs6,e.uvs6._updatable),e.colors&&t.setVerticesData(A.ColorKind,H.CheckColors4(e.colors,e.positions.length/3),e.colors._updatable),e.matricesIndices)if(e.matricesIndices._isExpanded)delete e.matricesIndices._isExpanded,t.setVerticesData(A.MatricesIndicesKind,e.matricesIndices,e.matricesIndices._updatable);else{const r=[];for(let o=0;o<e.matricesIndices.length;o++){const h=e.matricesIndices[o];r.push(h&255),r.push((h&65280)>>8),r.push((h&16711680)>>16),r.push(h>>24&255)}t.setVerticesData(A.MatricesIndicesKind,r,e.matricesIndices._updatable)}if(e.matricesIndicesExtra)if(e.matricesIndicesExtra._isExpanded)delete e.matricesIndices._isExpanded,t.setVerticesData(A.MatricesIndicesExtraKind,e.matricesIndicesExtra,e.matricesIndicesExtra._updatable);else{const r=[];for(let o=0;o<e.matricesIndicesExtra.length;o++){const h=e.matricesIndicesExtra[o];r.push(h&255),r.push((h&65280)>>8),r.push((h&16711680)>>16),r.push(h>>24&255)}t.setVerticesData(A.MatricesIndicesExtraKind,r,e.matricesIndicesExtra._updatable)}e.matricesWeights&&(Nt._CleanMatricesWeights(e,t),t.setVerticesData(A.MatricesWeightsKind,e.matricesWeights,e.matricesWeights._updatable)),e.matricesWeightsExtra&&t.setVerticesData(A.MatricesWeightsExtraKind,e.matricesWeightsExtra,e.matricesWeights._updatable),t.setIndices(e.indices,null)}if(e.subMeshes){t.subMeshes=[];for(let r=0;r<e.subMeshes.length;r++){const o=e.subMeshes[r];vi.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(!Tt.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 n=t.getVerticesData(A.MatricesIndicesKind),r=t.getVerticesData(A.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 _=0;_<4;_++){const p=o[u+_];f+=p,p<.001&&d<0&&(d=_)}if(h)for(let _=0;_<4;_++){const p=h[u+_];f+=p,p<.001&&d<0&&(d=_+4)}if((d<0||d>l-1)&&(d=l-1),f>.001){const _=1/f;for(let p=0;p<4;p++)o[u+p]*=_;if(h)for(let p=0;p<4;p++)h[u+p]*=_}else d>=4?(h[u+d-4]=1-f,r[u+d-4]=s):(o[u+d]=1-f,n[u+d]=s)}t.setVerticesData(A.MatricesIndicesKind,n),e.matricesWeightsExtra&&t.setVerticesData(A.MatricesIndicesExtraKind,r)}static Parse(e,t,i){const s=new Nt(e.id,t,void 0,e.updatable);return s._loadedUniqueId=e.uniqueId,ke&&ke.AddTagsTo(s,e.tags),e.delayLoadingFile?(s.delayLoadState=4,s.delayLoadingFile=i+e.delayLoadingFile,s._boundingInfo=new ri(v.FromArray(e.boundingBoxMinimum),v.FromArray(e.boundingBoxMaximum)),s._delayInfo=[],e.hasUVs&&s._delayInfo.push(A.UVKind),e.hasUVs2&&s._delayInfo.push(A.UV2Kind),e.hasUVs3&&s._delayInfo.push(A.UV3Kind),e.hasUVs4&&s._delayInfo.push(A.UV4Kind),e.hasUVs5&&s._delayInfo.push(A.UV5Kind),e.hasUVs6&&s._delayInfo.push(A.UV6Kind),e.hasColors&&s._delayInfo.push(A.ColorKind),e.hasMatricesIndices&&s._delayInfo.push(A.MatricesIndicesKind),e.hasMatricesWeights&&s._delayInfo.push(A.MatricesWeightsKind),s._delayLoadingFunction=j.ImportVertexData):j.ImportVertexData(e,s),t.pushGeometry(s,!0),s}}class fs{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){Ae.Clone(()=>e,this)}serialize(){return Ae.Serialize(this)}parse(e,t,i){Ae.Parse(()=>this,e,t,i)}}D([B()],fs.prototype,"func",null);D([B()],fs.prototype,"funcRef",null);D([B()],fs.prototype,"funcMask",null);D([B()],fs.prototype,"opStencilFail",null);D([B()],fs.prototype,"opDepthFail",null);D([B()],fs.prototype,"opStencilDepthPass",null);D([B()],fs.prototype,"mask",null);D([B()],fs.prototype,"enabled",null);function Xr(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 Mc(a,e,t){var l,c,u,f,d,_;const i=!!((l=a.clipPlane)!=null?l:e.clipPlane),s=!!((c=a.clipPlane2)!=null?c:e.clipPlane2),n=!!((u=a.clipPlane3)!=null?u:e.clipPlane3),r=!!((f=a.clipPlane4)!=null?f:e.clipPlane4),o=!!((d=a.clipPlane5)!=null?d:e.clipPlane5),h=!!((_=a.clipPlane6)!=null?_:e.clipPlane6);i&&t.push("#define CLIPPLANE"),s&&t.push("#define CLIPPLANE2"),n&&t.push("#define CLIPPLANE3"),r&&t.push("#define CLIPPLANE4"),o&&t.push("#define CLIPPLANE5"),h&&t.push("#define CLIPPLANE6")}function Yp(a,e,t){var c,u,f,d,_,p;let i=!1;const s=!!((c=a.clipPlane)!=null?c:e.clipPlane),n=!!((u=a.clipPlane2)!=null?u:e.clipPlane2),r=!!((f=a.clipPlane3)!=null?f:e.clipPlane3),o=!!((d=a.clipPlane4)!=null?d:e.clipPlane4),h=!!((_=a.clipPlane5)!=null?_:e.clipPlane5),l=!!((p=a.clipPlane6)!=null?p:e.clipPlane6);return t.CLIPPLANE!==s&&(t.CLIPPLANE=s,i=!0),t.CLIPPLANE2!==n&&(t.CLIPPLANE2=n,i=!0),t.CLIPPLANE3!==r&&(t.CLIPPLANE3=r,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 Yr(a,e,t){var s,n,r,o,h,l;let i=(s=e.clipPlane)!=null?s:t.clipPlane;qs(a,"vClipPlane",i),i=(n=e.clipPlane2)!=null?n:t.clipPlane2,qs(a,"vClipPlane2",i),i=(r=e.clipPlane3)!=null?r:t.clipPlane3,qs(a,"vClipPlane3",i),i=(o=e.clipPlane4)!=null?o:t.clipPlane4,qs(a,"vClipPlane4",i),i=(h=e.clipPlane5)!=null?h:t.clipPlane5,qs(a,"vClipPlane5",i),i=(l=e.clipPlane6)!=null?l:t.clipPlane6,qs(a,"vClipPlane6",i)}function qs(a,e,t){t&&a.setFloat4(e,t.normal.x,t.normal.y,t.normal.z,t.d)}const Kh=de.Black(),Xh={NUM_MORPH_INFLUENCERS:0};function B0(a,e,t){if(!a||a.LOGARITHMICDEPTH||a.indexOf&&a.indexOf("LOGARITHMICDEPTH")>=0){const i=t.activeCamera;i.mode===1&&U.Error("Logarithmic depth is not compatible with orthographic cameras!",20),e.setFloat("logarithmicDepthConstant",2/(Math.log(i.maxZ+1)/Math.LN2))}}function L0(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(Kh,a.getEngine().useExactSrgbConversions),t.setColor3("vFogColor",Kh)):t.setColor3("vFogColor",a.fogColor))}function qp(a,e,t){Xh.NUM_MORPH_INFLUENCERS=t,Pc(a,e,Xh)}function Pc(a,e,t){const i=t.NUM_MORPH_INFLUENCERS;if(i>0&&Ee.LastCreatedEngine){const s=Ee.LastCreatedEngine.getCaps().maxVertexAttribs,n=e.morphTargetManager;if(n!=null&&n.isUsingTextureForTargets)return;const r=n&&n.supportsNormals&&t.NORMAL,o=n&&n.supportsTangents&&t.TANGENT,h=n&&n.supportsUVs&&t.UV1;for(let l=0;l<i;l++)a.push("position"+l),r&&a.push("normal"+l),o&&a.push("tangent"+l),h&&a.push("uv_"+l),a.length>s&&U.Error("Cannot add more vertex attributes for mesh "+e.name)}}function N0(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 U0(a,e){const t=a.morphTargetManager;!a||!t||e.setFloatArray("morphTargetInfluences",t.influences)}function wc(a,e){e.bindToEffect(a,"Scene")}function ms(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 vs(a,e,t){const i=a.getTextureMatrix();e.updateMatrix(t+"Matrix",i)}function Dc(a,e,t){t.BAKED_VERTEX_ANIMATION_TEXTURE&&t.INSTANCES&&a.push("bakedVertexAnimationSettingsInstanced")}function Fc(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)}}}function jp(a,e,t,i,s,n=!0){a._bindLight(e,t,i,s,n)}function $p(a,e,t,i,s=4){const n=Math.min(e.lightSources.length,s);for(let r=0;r<n;r++){const o=e.lightSources[r];jp(o,r,a,t,typeof i=="boolean"?i:i.SPECULARTERM,e.receiveShadows)}}function Zp(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 Oc(a,e){(e.INSTANCES||e.THIN_INSTANCES)&&N0(a,!!e.PREPASS_VELOCITY),e.INSTANCESCOLOR&&a.push("instanceColor")}function Qp(a,e,t=4,i=0){let s=0;for(let n=0;n<t&&a["LIGHT"+n];n++)n>0&&(s=i+n,e.addFallback(s,"LIGHT"+n)),a.SHADOWS||(a["SHADOW"+n]&&e.addFallback(i,"SHADOW"+n),a["SHADOWPCF"+n]&&e.addFallback(i,"SHADOWPCF"+n),a["SHADOWPCSS"+n]&&e.addFallback(i,"SHADOWPCSS"+n),a["SHADOWPOISSON"+n]&&e.addFallback(i,"SHADOWPOISSON"+n),a["SHADOWESM"+n]&&e.addFallback(i,"SHADOWESM"+n),a["SHADOWCLOSEESM"+n]&&e.addFallback(i,"SHADOWCLOSEESM"+n));return s++}function Jp(a,e){return e.fogEnabled&&a.applyFog&&e.fogMode!==0}function Bc(a,e,t,i,s,n,r,o=!1){r._areMiscDirty&&(r.LOGARITHMICDEPTH=t,r.POINTSIZE=i,r.FOG=s&&Jp(a,e),r.NONUNIFORMSCALING=a.nonUniformScaling,r.ALPHATEST=n,r.DECAL_AFTER_DETAIL=o)}function eg(a,e,t,i,s=4,n=!1){if(!t._areLightsDirty)return t._needNormals;let r=0;const o={needNormals:t._needNormals,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};if(a.lightsEnabled&&!n){for(const l of e.lightSources)if(tg(a,e,l,r,t,i,o),r++,r===s)break}t.SPECULARTERM=o.specularEnabled,t.SHADOWS=o.shadowEnabled;for(let l=r;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["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 tg(a,e,t,i,s,n,r){var o;switch(r.needNormals=!0,s["LIGHT"+i]===void 0&&(r.needRebuild=!0),s["LIGHT"+i]=!0,s["SPOTLIGHT"+i]=!1,s["HEMILIGHT"+i]=!1,s["POINTLIGHT"+i]=!1,s["DIRLIGHT"+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 Xe.FALLOFF_GLTF:s["LIGHT_FALLOFF_GLTF"+i]=!0;break;case Xe.FALLOFF_PHYSICAL:s["LIGHT_FALLOFF_PHYSICAL"+i]=!0;break;case Xe.FALLOFF_STANDARD:s["LIGHT_FALLOFF_STANDARD"+i]=!0;break}if(t.specular.equalsFloats(0,0,0)||(r.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 h=(o=t.getShadowGenerator(a.activeCamera))!=null?o:t.getShadowGenerator();if(h){const l=h.getShadowMap();l&&l.renderList&&l.renderList.length>0&&(r.shadowEnabled=!0,h.prepareDefines(s,i))}}t.lightmapMode!=Xe.LIGHTMAP_DEFAULT?(r.lightmapMode=!0,s["LIGHTMAPEXCLUDED"+i]=!0,s["LIGHTMAPNOSPECULAR"+i]=t.lightmapMode==Xe.LIGHTMAP_SHADOWSONLY):(s["LIGHTMAPEXCLUDED"+i]=!1,s["LIGHTMAPNOSPECULAR"+i]=!1)}function Lc(a,e,t,i,s,n=null,r=!1){let o=hg(a,i);n!==!1&&(o=Yp(t,a,i)),i.DEPTHPREPASS!==!e.getColorWrite()&&(i.DEPTHPREPASS=!i.DEPTHPREPASS,o=!0),i.INSTANCES!==s&&(i.INSTANCES=s,o=!0),i.THIN_INSTANCES!==r&&(i.THIN_INSTANCES=r,o=!0),o&&i.markAsUnprocessed()}function ig(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 sg(a,e){const t=a.morphTargetManager;t?(e.MORPHTARGETS_UV=t.supportsUVs&&e.UV1,e.MORPHTARGETS_TANGENT=t.supportsTangents&&e.TANGENT,e.MORPHTARGETS_NORMAL=t.supportsNormals&&e.NORMAL,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_TANGENT=!1,e.MORPHTARGETS_NORMAL=!1,e.MORPHTARGETS=!1,e.NUM_MORPH_INFLUENCERS=0)}function ng(a,e){const t=a.bakedVertexAnimationManager;e.BAKED_VERTEX_ANIMATION_TEXTURE=!!(t&&t.isEnabled)}function Nc(a,e,t,i,s=!1,n=!0,r=!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".concat(o===1?"":o)):!1;if(t){const o=a.useVertexColors&&a.isVerticesDataPresent("color");e.VERTEXCOLOR=o,e.VERTEXALPHA=a.hasVertexAlpha&&o&&n}return a.isVerticesDataPresent("instanceColor")&&(a.hasInstances||a.hasThinInstances)&&(e.INSTANCESCOLOR=!0),i&&ig(a,e),s&&sg(a,e),r&&ng(a,e),!0}function rg(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 ag(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 og(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 n=0;n<s.length;n++){const r=a.prePassRenderer.getIndex(s[n].type);r!==-1?(e[s[n].define]=!0,e[s[n].index]=r):e[s[n].define]=!1}}else{e.PREPASS=!1;for(let n=0;n<s.length;n++)e[s[n].define]=!1}e.PREPASS!=i&&(e.markAsUnprocessed(),e.markAsImageProcessingDirty())}function hg(a,e){let t=!1;if(a.activeCamera){const i=e.CAMERA_ORTHOGRAPHIC?1:0,s=e.CAMERA_PERSPECTIVE?1:0,n=a.activeCamera.mode===1?1:0,r=a.activeCamera.mode===0?1:0;(i^n||s^r)&&(e.CAMERA_ORTHOGRAPHIC=n===1,e.CAMERA_PERSPECTIVE=r===1,t=!0)}return t}function lg(a,e,t,i,s=null,n=!1){s&&s.push("Light"+a),!n&&(e.push("vLightData"+a,"vLightDiffuse"+a,"vLightSpecular"+a,"vLightDirection"+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)))}function cg(a,e,t,i=4){let s,n=null;if(a.uniformsNames){const r=a;s=r.uniformsNames,n=r.uniformBuffersNames,e=r.samplers,t=r.defines,i=r.maxSimultaneousLights||0}else s=a,e||(e=[]);for(let r=0;r<i&&t["LIGHT"+r];r++)lg(r,s,e,t["PROJECTEDLIGHTTEXTURE"+r],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 X{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(X.MiscDirtyFlag+X.PrePassDirtyFlag)}get alpha(){return this._alpha}set backFaceCulling(e){this._backFaceCulling!==e&&(this._backFaceCulling=e,this.markAsDirty(X.TextureDirtyFlag))}get backFaceCulling(){return this._backFaceCulling}set cullBackFaces(e){this._cullBackFaces!==e&&(this._cullBackFaces=e,this.markAsDirty(X.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 Z),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 Z),this._onUnBindObservable}get onEffectCreatedObservable(){return this._onEffectCreatedObservable||(this._onEffectCreatedObservable=new Z),this._onEffectCreatedObservable}set alphaMode(e){this._alphaMode!==e&&(this._alphaMode=e,this.markAsDirty(X.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(X.MiscDirtyFlag))}get fogEnabled(){return this._fogEnabled}get wireframe(){switch(this._fillMode){case X.WireFrameFillMode:case X.LineListDrawMode:case X.LineLoopDrawMode:case X.LineStripDrawMode:return!0}return this._scene.forceWireframe}set wireframe(e){this.fillMode=e?X.WireFrameFillMode:X.TriangleFillMode}get pointsCloud(){switch(this._fillMode){case X.PointFillMode:case X.PointListDrawMode:return!0}return this._scene.forcePointsCloud}set pointsCloud(e){this.fillMode=e?X.PointFillMode:X.TriangleFillMode}get fillMode(){return this._fillMode}set fillMode(e){this._fillMode!==e&&(this._fillMode=e,this.markAsDirty(X.MiscDirtyFlag))}get useLogarithmicDepth(){return this._useLogarithmicDepth}set useLogarithmicDepth(e){const t=this.getScene().getEngine().getCaps().fragmentDepthSupported;e&&!t&&U.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 Z,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 fs,this._useUBO=!1,this._fillMode=X.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._forceAlphaTest=!1,this._transparencyMode=null,this.name=e;const n=t||Ee.LastCreatedScene;n&&(this._scene=n,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[63]=this._markAllSubMeshesAsAllDirty.bind(this),this.id=e||J.RandomId(),this.uniqueId=this._scene.getUniqueId(),this._materialContext=this._scene.getEngine().createMaterialContext(),this._drawWrapper=new Xn(this._scene.getEngine(),!1),this._drawWrapper.materialContext=this._materialContext,this._uniformBuffer=new fe(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={}),X.OnEventObservable.notifyObservers(this,1))}_createUniformBuffer(){var t;const e=this.getScene().getEngine();(t=this._uniformBuffer)==null||t.dispose(),e.isWebGPU&&!this._forceGLSL?(this._uniformBuffer=new fe(e,void 0,void 0,this.name,!0),this._shaderLanguage=1):this._uniformBuffer=new fe(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._forceAlphaTest=e===X.MATERIAL_ALPHATESTANDBLEND,this._markAllSubMeshesAsTexturesAndMiscDirty())}get _disableAlphaBlending(){return this._transparencyMode===X.MATERIAL_OPAQUE||this._transparencyMode===X.MATERIAL_ALPHATEST}needAlphaBlending(){return this._disableAlphaBlending?!1:this.alpha<1}needAlphaBlendingForMesh(e){return e.visibility<1?!0:this._disableAlphaBlending?!1:e.hasVertexAlpha||this.needAlphaBlending()}needAlphaTesting(){return!!this._forceAlphaTest}_shouldTurnAlphaTestOn(e){return!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 n of s._drawWrappers)n&&this._materialContext===n.materialContext&&(n._wasPreviouslyReady=!1,n._wasPreviouslyUsingInstances=null,n._forceRebindOnNextCall=e)}e&&this.markAsDirty(X.AllDirtyFlag)}_preBind(e,t=null){const i=this._scene.getEngine(),n=(t==null?this.sideOrientation:t)===X.ClockWiseSideOrientation;return i.enableEffect(e||this._getDrawWrapper()),i.setState(this.backFaceCulling,this.zOffset,!1,n,this._scene._mirroredCameraPosition?!this.cullBackFaces:this.cullBackFaces,this.stencil,this.zOffsetUnits),n}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,wc(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._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),X._ParsePlugins(i,e,this._scene,t),this.pluginManager)for(const s of this.pluginManager._plugins){const n=e.pluginManager.getPlugin(s.name);n&&s.copyTo(n)}}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 n={clipPlane:!1,useInstances:!1,...i},r=this.getScene(),o=this.allowShaderHotSwapping;this.allowShaderHotSwapping=!1;const h=()=>{if(!this._scene||!this._scene.getEngine())return;const l=r.clipPlane;if(n.clipPlane&&(r.clipPlane=new Xt(0,0,0,1)),this._storeEffectOnSubMeshes){let c=!0,u=null;if(e.subMeshes){const f=new vi(0,0,0,0,0,e,void 0,!1,!1);f.materialDefines&&(f.materialDefines._renderId=-1),this.isReadyForSubMesh(e,f,n.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);n.clipPlane&&(r.clipPlane=l)};h()}forceCompilationAsync(e,t){return new Promise((i,s)=>{this.forceCompilation(e,()=>{i()},t,n=>{s(n)})})}markAsDirty(e){this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism||(X._DirtyCallbackArray.length=0,e&X.TextureDirtyFlag&&X._DirtyCallbackArray.push(X._TextureDirtyCallBack),e&X.LightDirtyFlag&&X._DirtyCallbackArray.push(X._LightsDirtyCallBack),e&X.FresnelDirtyFlag&&X._DirtyCallbackArray.push(X._FresnelDirtyCallBack),e&X.AttributesDirtyFlag&&X._DirtyCallbackArray.push(X._AttributeDirtyCallBack),e&X.MiscDirtyFlag&&X._DirtyCallbackArray.push(X._MiscDirtyCallBack),e&X.PrePassDirtyFlag&&X._DirtyCallbackArray.push(X._PrePassDirtyCallBack),X._DirtyCallbackArray.length&&this._markAllSubMeshesAsDirty(X._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){if(this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism)return;const t=this.getScene().meshes;for(const i of t)if(i.subMeshes){for(const s of i.subMeshes)if(s.getMaterial(!1)===this)for(const n of s._drawWrappers)!n||!n.defines||!n.defines.markAllAsDirty||this._materialContext===n.materialContext&&e(n.defines)}}_markScenePrePassDirty(){if(this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism)return;const e=this.getScene().enablePrePassRenderer();e&&e.markAsDirty()}_markAllSubMeshesAsAllDirty(){this._markAllSubMeshesAsDirty(X._AllDirtyCallBack)}_markAllSubMeshesAsImageProcessingDirty(){this._markAllSubMeshesAsDirty(X._ImageProcessingDirtyCallBack)}_markAllSubMeshesAsTexturesDirty(){this._markAllSubMeshesAsDirty(X._TextureDirtyCallBack)}_markAllSubMeshesAsFresnelDirty(){this._markAllSubMeshesAsDirty(X._FresnelDirtyCallBack)}_markAllSubMeshesAsFresnelAndMiscDirty(){this._markAllSubMeshesAsDirty(X._FresnelAndMiscDirtyCallBack)}_markAllSubMeshesAsLightsDirty(){this._markAllSubMeshesAsDirty(X._LightsDirtyCallBack)}_markAllSubMeshesAsAttributesDirty(){this._markAllSubMeshesAsDirty(X._AttributeDirtyCallBack)}_markAllSubMeshesAsMiscDirty(){this._markAllSubMeshesAsDirty(X._MiscDirtyCallBack)}_markAllSubMeshesAsPrePassDirty(){this._markAllSubMeshesAsDirty(X._MiscDirtyCallBack)}_markAllSubMeshesAsTexturesAndMiscDirty(){this._markAllSubMeshesAsDirty(X._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 n=this._parentContainer.materials.indexOf(this);n>-1&&this._parentContainer.materials.splice(n,1),this._parentContainer=null}if(i!==!0)if(this.meshMap)for(const n in this.meshMap){const r=this.meshMap[n];r&&(this.releaseVertexArrayObject(r,!0),r.material=null)}else{const n=s.meshes;for(const r of n)r.material===this&&!r.sourceMesh&&(this.releaseVertexArrayObject(r,!0),r.material=null)}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={})}releaseVertexArrayObject(e,t){const i=e.geometry;if(i)if(this._storeEffectOnSubMeshes){if(e.subMeshes)for(const s of e.subMeshes)i._releaseVertexArrayObject(s.effect),t&&s.effect&&s.effect.dispose()}else i._releaseVertexArrayObject(this._drawWrapper.effect)}serialize(){const e=Ae.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)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 U.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."),null;const n=J.Instantiate(e.customType).Parse(e,t,i);return n._loadedUniqueId=e.uniqueId,n}static _ParsePlugins(e,t,i,s){var n;if(e.plugins)for(const r in e.plugins){const o=e.plugins[r];let h=(n=t.pluginManager)==null?void 0:n.getPlugin(o.name);if(!h){const l=J.Instantiate("BABYLON."+r);l&&(h=new l(t))}h==null||h.parse(o,i,s)}}}X.TriangleFillMode=0;X.WireFrameFillMode=1;X.PointFillMode=2;X.PointListDrawMode=3;X.LineListDrawMode=4;X.LineLoopDrawMode=5;X.LineStripDrawMode=6;X.TriangleStripDrawMode=7;X.TriangleFanDrawMode=8;X.ClockWiseSideOrientation=0;X.CounterClockWiseSideOrientation=1;X.TextureDirtyFlag=1;X.LightDirtyFlag=2;X.FresnelDirtyFlag=4;X.AttributesDirtyFlag=8;X.MiscDirtyFlag=16;X.PrePassDirtyFlag=32;X.AllDirtyFlag=63;X.MATERIAL_OPAQUE=0;X.MATERIAL_ALPHATEST=1;X.MATERIAL_ALPHABLEND=2;X.MATERIAL_ALPHATESTANDBLEND=3;X.MATERIAL_NORMALBLENDMETHOD_WHITEOUT=0;X.MATERIAL_NORMALBLENDMETHOD_RNM=1;X.OnEventObservable=new Z;X._AllDirtyCallBack=a=>a.markAllAsDirty();X._ImageProcessingDirtyCallBack=a=>a.markAsImageProcessingDirty();X._TextureDirtyCallBack=a=>a.markAsTexturesDirty();X._FresnelDirtyCallBack=a=>a.markAsFresnelDirty();X._MiscDirtyCallBack=a=>a.markAsMiscDirty();X._PrePassDirtyCallBack=a=>a.markAsPrePassDirty();X._LightsDirtyCallBack=a=>a.markAsLightDirty();X._AttributeDirtyCallBack=a=>a.markAsAttributesDirty();X._FresnelAndMiscDirtyCallBack=a=>{X._FresnelDirtyCallBack(a),X._MiscDirtyCallBack(a)};X._TextureAndMiscDirtyCallBack=a=>{X._TextureDirtyCallBack(a),X._MiscDirtyCallBack(a)};X._DirtyCallbackArray=[];X._RunDirtyCallBacks=a=>{for(const e of X._DirtyCallbackArray)e(a)};D([B()],X.prototype,"id",void 0);D([B()],X.prototype,"uniqueId",void 0);D([B()],X.prototype,"name",void 0);D([B()],X.prototype,"metadata",void 0);D([B()],X.prototype,"checkReadyOnEveryCall",void 0);D([B()],X.prototype,"checkReadyOnlyOnce",void 0);D([B()],X.prototype,"state",void 0);D([B("alpha")],X.prototype,"_alpha",void 0);D([B("backFaceCulling")],X.prototype,"_backFaceCulling",void 0);D([B("cullBackFaces")],X.prototype,"_cullBackFaces",void 0);D([B()],X.prototype,"sideOrientation",void 0);D([B("alphaMode")],X.prototype,"_alphaMode",void 0);D([B()],X.prototype,"_needDepthPrePass",void 0);D([B()],X.prototype,"disableDepthWrite",void 0);D([B()],X.prototype,"disableColorWrite",void 0);D([B()],X.prototype,"forceDepthWrite",void 0);D([B()],X.prototype,"depthFunction",void 0);D([B()],X.prototype,"separateCullingPass",void 0);D([B("fogEnabled")],X.prototype,"_fogEnabled",void 0);D([B()],X.prototype,"pointSize",void 0);D([B()],X.prototype,"zOffset",void 0);D([B()],X.prototype,"zOffsetUnits",void 0);D([B()],X.prototype,"pointsCloud",null);D([B()],X.prototype,"fillMode",null);D([B()],X.prototype,"useLogarithmicDepth",null);D([B()],X.prototype,"transparencyMode",null);class cn extends X{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 n=t.apply(e,s);return this._markAllSubMeshesAsTexturesDirty(),n};const i=e.splice;e.splice=(s,n)=>{const r=i.apply(e,[s,n]);return this._markAllSubMeshesAsTexturesDirty(),r}}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){var t;if(super.hasTexture(e))return!0;for(let i=0;i<this.subMaterials.length;i++)if((t=this.subMaterials[i])!=null&&t.hasTexture(e))return!0;return!1}getClassName(){return"MultiMaterial"}isReadyForSubMesh(e,t,i){for(let s=0;s<this.subMaterials.length;s++){const n=this.subMaterials[s];if(n){if(n._storeEffectOnSubMeshes){if(!n.isReadyForSubMesh(e,t,i))return!1;continue}if(!n.isReady(e))return!1}}return!0}clone(e,t){const i=new cn(e,this.getScene());for(let s=0;s<this.subMaterials.length;s++){let n=null;const r=this.subMaterials[s];t&&r?n=r.clone(e+"-"+r.name):n=this.subMaterials[s],i.subMaterials.push(n)}return i}serialize(){const e={};e.name=this.name,e.id=this.id,e.uniqueId=this.uniqueId,ke&&(e.tags=ke.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 r=0;r<this.subMaterials.length;r++){const o=this.subMaterials[r];o&&o.dispose(e,t)}const n=s.multiMaterials.indexOf(this);n>=0&&s.multiMaterials.splice(n,1),super.dispose(e,t)}static ParseMultiMaterial(e,t){const i=new cn(e.name,t);return i.id=e.id,i._loadedUniqueId=e.uniqueId,ke&&ke.AddTagsTo(i,e.tags),e.materialsUniqueIds?i._waitingSubMaterialsUniqueIds=e.materialsUniqueIds:e.materials.forEach(s=>i.subMaterials.push(t.getLastMaterialById(s))),i}}vt("BABYLON.MultiMaterial",cn);class ug{constructor(e,t){this.distanceOrScreenCoverage=e,this.mesh=t}}class Uc{}class fg{constructor(){this.visibleInstances={},this.batchCache=new Yh,this.batchCacheReplacementModeInFrozenMode=new Yh,this.instancesBufferSize=32*16*4}}class Yh{constructor(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=[],this.hardwareInstancedRendering=[]}}class dg{constructor(){this.instancesCount=0,this.matrixBuffer=null,this.previousMatrixBuffer=null,this.matrixBufferSize=32*16,this.matrixData=null,this.boundingVectors=[],this.worldMatrices=null}}class _g{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}}class F extends Qe{static _GetDefaultSideOrientation(e){return e||F.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(A.PositionKind,this._internalMeshDataInfo._sourcePositions,!0),this._internalMeshDataInfo._sourceNormals&&this.setVerticesData(A.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 Z),this._internalMeshDataInfo._onBeforeRenderObservable}get onBeforeBindObservable(){return this._internalMeshDataInfo._onBeforeBindObservable||(this._internalMeshDataInfo._onBeforeBindObservable=new Z),this._internalMeshDataInfo._onBeforeBindObservable}get onAfterRenderObservable(){return this._internalMeshDataInfo._onAfterRenderObservable||(this._internalMeshDataInfo._onAfterRenderObservable=new Z),this._internalMeshDataInfo._onAfterRenderObservable}get onBetweenPassObservable(){return this._internalMeshDataInfo._onBetweenPassObservable||(this._internalMeshDataInfo._onBetweenPassObservable=new Z),this._internalMeshDataInfo._onBetweenPassObservable}get onBeforeDrawObservable(){return this._internalMeshDataInfo._onBeforeDrawObservable||(this._internalMeshDataInfo._onBeforeDrawObservable=new Z),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){const s=this.getScene();if(e._geometry&&e._geometry.applyToMesh(this),I0.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,s.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 r in n)Object.prototype.hasOwnProperty.call(n,r)&&n[r]&&this.createAnimationRange(r,n[r].from,n[r].to)}if(e.metadata&&e.metadata.clone?this.metadata=e.metadata.clone():this.metadata=e.metadata,this._internalMetadata=e._internalMetadata,ke&&ke.HasTags(e)&&ke.AddTagsTo(this,ke.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 r=0;r<n.length;r++){const o=n[r];o.clone&&o.clone(this.name+"."+o.name,this)}}if(e.morphTargetManager&&(this.morphTargetManager=e.morphTargetManager),s.getPhysicsEngine){const n=s.getPhysicsEngine();if(i&&n)if(n.getPluginVersion()===1){const r=n.getImpostorForPhysicsObject(e);r&&(this.physicsImpostor=r.clone(this))}else n.getPluginVersion()===2&&e.physicsBody&&e.physicsBody.clone(this)}for(let n=0;n<s.particleSystems.length;n++){const r=s.particleSystems[n];r.emitter===e&&r.clone(r.name,this)}this.skeleton=e.skeleton,this.refreshBoundingInfo(!0,!0),this.computeWorldMatrix(!0)}constructor(e,t=null,i=null,s=null,n,r=!0){super(e,t),this._internalMeshDataInfo=new _g,this.delayLoadState=0,this.instances=[],this._creationDataStorage=null,this._geometry=null,this._instanceDataStorage=new fg,this._thinInstanceDataStorage=new dg,this._shouldGenerateFlatShading=!1,this._originalBuilderSideOrientation=F.DEFAULTSIDE,this.ignoreCameraMaxZ=!1,t=this.getScene(),this._scene.useRightHandedSystem?this.sideOrientation=0:this.sideOrientation=1,this._onBeforeDraw=(o,h,l)=>{o&&l&&(this._uniformBuffer?this.transferToEffect(h):l.bindOnlyWorldMatrix(h))},s&&this._copySource(s,n,r),i!==null&&(this.parent=i),this._instanceDataStorage.hardwareInstancedRendering=this.getEngine().getCaps().instancedArrays,this._internalMeshDataInfo._onMeshReadyObserverAdded=o=>{o.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 Z(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 n of this.getChildTransformNodes(!0))n.getClassName()==="InstancedMesh"&&s.getClassName()==="Mesh"&&n.sourceMesh===this?n.instantiateHierarchy(s,{doNotInstantiate:t&&t.doNotInstantiate||!1,newSourcedMesh:s},i):n.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(A.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 U.Warn("You cannot use a mesh as LOD level twice"),this;const i=new ug(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,n=e.mode===ve.ORTHOGRAPHIC_CAMERA?e.minZ:s.centerWorld.subtract(e.globalPosition).length();let r=n,o=1;if(i._useLODScreenCoverage){const h=e.screenArea;let l=s.radiusWorld*e.minZ/n;l=l*l*Math.PI,r=l/h,o=-1}if(o*i._LODLevels[i._LODLevels.length-1].distanceOrScreenCoverage>o*r)return this.onLODLevelSelection&&this.onLODLevelSelection(r,this,this),this;for(let h=0;h<i._LODLevels.length;h++){const l=i._LODLevels[h];if(o*l.distanceOrScreenCoverage<o*r){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(r,this,l.mesh),l.mesh}}return this.onLODLevelSelection&&this.onLODLevelSelection(r,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){var r,o;if(!this._geometry)return null;let n=s||(o=(r=this._userInstancedBuffersStorage)==null?void 0:r.vertexBuffers[e])==null?void 0:o.getFloatData(this.instances.length+1,i||t&&this._geometry.meshes.length!==1);return n||(n=this._geometry.getVerticesData(e,t,i)),n}copyVerticesData(e,t){this._geometry&&this._geometry.copyVerticesData(e,t)}getVertexBuffer(e,t){var i,s;return this._geometry?(s=t||(i=this._userInstancedBuffersStorage)==null?void 0:i.vertexBuffers[e])!=null?s:this._geometry.getVertexBuffer(e):null}isVerticesDataPresent(e,t){var i;return this._geometry?!t&&((i=this._userInstancedBuffersStorage)==null?void 0:i.vertexBuffers[e])!==void 0||this._geometry.isVerticesDataPresent(e):this._delayInfo?this._delayInfo.indexOf(e)!==-1:!1}isVertexBufferUpdatable(e,t){var i;if(!this._geometry)return this._delayInfo?this._delayInfo.indexOf(e)!==-1:!1;if(!t){const s=(i=this._userInstancedBuffersStorage)==null?void 0:i.vertexBuffers[e];if(s)return s.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){var h,l,c,u,f,d,_;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(),n=t||i.getCaps().instancedArrays&&(this.instances.length>0||this.hasThinInstances);this.computeWorldMatrix();const r=this.material||s.defaultMaterial;if(r){if(r._storeEffectOnSubMeshes)for(const p of this.subMeshes){const g=p.getMaterial();if(g){if(g._storeEffectOnSubMeshes){if(!g.isReadyForSubMesh(this,p,n))return!1}else if(!g.isReady(this,n))return!1}}else if(!r.isReady(this,n))return!1}const o=i.currentRenderPassId;for(const p of this.lightSources){const g=p.getShadowGenerators();if(!g)continue;const m=g.values();for(let b=m.next();b.done!==!0;b=m.next()){const I=b.value;if(I&&(!((h=I.getShadowMap())!=null&&h.renderList)||(l=I.getShadowMap())!=null&&l.renderList&&((u=(c=I.getShadowMap())==null?void 0:c.renderList)==null?void 0:u.indexOf(this))!==-1)){const x=(f=I.getShadowMap().renderPassIds)!=null?f:[i.currentRenderPassId];for(let y=0;y<x.length;++y){i.currentRenderPassId=x[y];for(const R of this.subMeshes)if(!I.isReady(R,n,(_=(d=R.getMaterial())==null?void 0:d.needAlphaBlendingForMesh(this))!=null?_:!1))return i.currentRenderPassId=o,!1}i.currentRenderPassId=o}}}for(const p of this._internalMeshDataInfo._LODLevels)if(p.mesh&&!p.mesh.isReady(n))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,A.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 n=!1;if(e)n=!0;else for(const r of this.subMeshes){if(r.indexStart+r.indexCount>s){n=!0;break}if(r.verticesStart+r.verticesCount>t){n=!0;break}}if(!n)return this.subMeshes[0]}return this.releaseSubMeshes(),new vi(0,0,t,0,this.getTotalIndices(),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 n=0;n<e&&!(s>=t);n++)vi.CreateFromIndices(0,s,n===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 n=new j;n.set(t,e);const r=this.getScene();new Nt(Nt.RandomId(),r,n,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=Nt.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(A.PositionKind);if(!i)return this;if(e(i),this.updateVerticesData(A.PositionKind,i,!1,!1),t){const s=this.getIndices(),n=this.getVerticesData(A.NormalKind);if(!n)return this;j.ComputeNormals(i,s,n),this.updateVerticesData(A.NormalKind,n,!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(Nt.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this}setIndexBuffer(e,t,i){let s=this._geometry;s||(s=new Nt(Nt.RandomId(),this.getScene(),void 0,void 0,this)),s.setIndexBuffer(e,t,i)}setIndices(e,t=null,i=!1,s=!1){if(this._geometry)this._geometry.setIndices(e,t,i,s);else{const n=new j;n.indices=e;const r=this.getScene();new Nt(Nt.RandomId(),r,n,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 n=this.getScene().getEngine();let r;if(this._unIndexed)switch(this._getRenderingFillMode(i)){case X.WireFrameFillMode:r=e._getLinesIndexBuffer(this.getIndices(),n);break;default:r=null;break}else switch(this._getRenderingFillMode(i)){case X.PointFillMode:r=null;break;case X.WireFrameFillMode:r=e._getLinesIndexBuffer(this.getIndices(),n);break;default:case X.TriangleFillMode:r=this._geometry.getIndexBuffer();break}return this._bindDirect(t,r,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 n=this.getScene().getEngine();return this._unIndexed&&t!==X.WireFrameFillMode||t==X.PointFillMode?n.drawArraysType(t,e.verticesStart,e.verticesCount,this.forcedInstanceCount||i):t==X.WireFrameFillMode?n.drawElementsType(t,0,e._linesIndexCount,this.forcedInstanceCount||i):n.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(),n=s?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,r=this._instanceDataStorage.batchCache;if(r.mustReturn=!1,r.renderSelf[e]=t||!n&&this.isEnabled()&&this.isVisible,r.visibleInstances[e]=null,this._instanceDataStorage.visibleInstances&&!t){const o=this._instanceDataStorage.visibleInstances,h=i.getRenderId(),l=s?o.intermediateDefaultRenderId:o.defaultRenderId;r.visibleInstances[e]=o[h],!r.visibleInstances[e]&&l&&(r.visibleInstances[e]=o[l])}return r.hardwareInstancedRendering[e]=!t&&this._instanceDataStorage.hardwareInstancedRendering&&r.visibleInstances[e]!==null&&r.visibleInstances[e]!==void 0,this._instanceDataStorage.previousBatch=r,r}_renderWithInstances(e,t,i,s,n){var b;const r=i.visibleInstances[e._id],o=r?r.length:0,h=this._instanceDataStorage,l=h.instancesBufferSize;let c=h.instancesBuffer,u=h.instancesPreviousBuffer;const d=(o+1)*16*4;for(;h.instancesBufferSize<d;)h.instancesBufferSize*=2;(!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));let _=0,p=0;const g=i.renderSelf[e._id],m=!c||l!==h.instancesBufferSize||this._scene.needsPreviousWorldMatrices&&!h.instancesPreviousBuffer;if(!this._instanceDataStorage.manualUpdate&&(!h.isFrozen||m)){const I=this.getWorldMatrix();if(g&&(this._scene.needsPreviousWorldMatrices&&(h.masterMeshPreviousWorldMatrix?(h.masterMeshPreviousWorldMatrix.copyToArray(h.instancesPreviousData,_),h.masterMeshPreviousWorldMatrix.copyFrom(I)):(h.masterMeshPreviousWorldMatrix=I.clone(),h.masterMeshPreviousWorldMatrix.copyToArray(h.instancesPreviousData,_))),I.copyToArray(h.instancesData,_),_+=16,p++),r){if(F.INSTANCEDMESH_SORT_TRANSPARENT&&this._scene.activeCamera&&((b=e.getMaterial())!=null&&b.needAlphaBlendingForMesh(e.getRenderingMesh()))){const T=this._scene.activeCamera.globalPosition;for(let x=0;x<r.length;x++){const y=r[x];y._distanceToCamera=v.Distance(y.getBoundingInfo().boundingSphere.centerWorld,T)}r.sort((x,y)=>x._distanceToCamera>y._distanceToCamera?-1:x._distanceToCamera<y._distanceToCamera?1:0)}for(let T=0;T<r.length;T++){const x=r[T],y=x.getWorldMatrix();y.copyToArray(h.instancesData,_),this._scene.needsPreviousWorldMatrices&&(x._previousWorldMatrix?(x._previousWorldMatrix.copyToArray(h.instancesPreviousData,_),x._previousWorldMatrix.copyFrom(y)):(x._previousWorldMatrix=y.clone(),x._previousWorldMatrix.copyToArray(h.instancesPreviousData,_))),_+=16,p++}}}else p=(g?1:0)+o;return m?(c&&c.dispose(),u&&u.dispose(),c=new ln(n,h.instancesData,!0,16,!1,!0),h.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 ln(n,h.instancesPreviousData,!0,16,!1,!0),h.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(h.instancesData,0,p),this._scene.needsPreviousWorldMatrices&&(!this._instanceDataStorage.manualUpdate||this._instanceDataStorage.previousManualUpdate)&&u.updateDirectly(h.instancesPreviousData,0,p)),this._processInstancedBuffers(r,g),this.getScene()._activeIndices.addCount(e.indexCount*p,!1),n._currentDrawContext&&(n._currentDrawContext.useInstancing=!0),this._bind(e,s,t),this._draw(e,t,p),this._scene.needsPreviousWorldMatrices&&!m&&this._instanceDataStorage.manualUpdate&&(!this._instanceDataStorage.isFrozen||this._instanceDataStorage.forceMatrixUpdates)&&!this._instanceDataStorage.previousManualUpdate&&u.updateDirectly(h.instancesData,0,p),n.unbindInstanceAttributes(),this}_renderWithThinInstances(e,t,i,s){var r,o;const n=(o=(r=this._thinInstanceDataStorage)==null?void 0:r.instancesCount)!=null?o:0;this.getScene()._activeIndices.addCount(e.indexCount*n,!1),s._currentDrawContext&&(s._currentDrawContext.useInstancing=!0),this._bind(e,i,t),this._draw(e,t,n),this._scene.needsPreviousWorldMatrices&&!this._thinInstanceDataStorage.previousMatrixData&&this._thinInstanceDataStorage.matrixData&&(this._thinInstanceDataStorage.previousMatrixBuffer?this._thinInstanceDataStorage.previousMatrixBuffer.updateDirectly(this._thinInstanceDataStorage.matrixData,0,n):this._thinInstanceDataStorage.previousMatrixBuffer=this._thinInstanceCreateMatrixBuffer("previousWorld",this._thinInstanceDataStorage.matrixData,!1)),s.unbindInstanceAttributes()}_processInstancedBuffers(e,t){}_processRendering(e,t,i,s,n,r,o,h){const l=this.getScene(),c=l.getEngine();if(s=this._getRenderingFillMode(s),r&&t.getRenderingMesh().hasThinInstances)return this._renderWithThinInstances(t,s,i,c),this;if(r)this._renderWithInstances(t,s,n,i,c);else{c._currentDrawContext&&(c._currentDrawContext.useInstancing=!1);let u=0;n.renderSelf[t._id]&&(o&&o(!1,e.getWorldMatrix(),h),u++,this._draw(t,s,this._instanceDataStorage.overridenInstanceCount));const f=n.visibleInstances[t._id];if(f){const d=f.length;u+=d;for(let _=0;_<d;_++){const g=f[_].getWorldMatrix();o&&o(!0,g,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,n=!0){const r=this._scene.getEngine(),o=r.currentRenderPassId;if(e!==void 0&&(r.currentRenderPassId=e),s)(!n||n&&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];(!n||n&&l.isInFrustum(this._scene._frustumPlanes))&&this.render(l,!!t,i)}return e!==void 0&&(r.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){var R,E,C,S;const s=this.getScene();this._internalAbstractMeshDataInfo._isActiveIntermediate?this._internalAbstractMeshDataInfo._isActiveIntermediate=!1:this._internalAbstractMeshDataInfo._isActive=!1;const n=(E=(R=s.activeCameras)==null?void 0:R.length)!=null?E:0;if((n>1&&s.activeCamera===s.activeCameras[0]||n<=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,_=e.getMaterial();if(!_)return c&&(c.maxZ=l,s.updateTransformMatrix(!0)),this;if(!d.isFrozen||!this._internalMeshDataInfo._effectiveMaterial||this._internalMeshDataInfo._effectiveMaterial!==_){if(_._storeEffectOnSubMeshes){if(!_.isReadyForSubMesh(this,e,f))return c&&(c.maxZ=l,s.updateTransformMatrix(!0)),this}else if(!_.isReady(this,f))return c&&(c.maxZ=l,s.updateTransformMatrix(!0)),this;this._internalMeshDataInfo._effectiveMaterial=_}else if(_._storeEffectOnSubMeshes&&!((C=e._drawWrapper)!=null&&C._wasPreviouslyReady)||!_._storeEffectOnSubMeshes&&!_._getDrawWrapper()._wasPreviouslyReady)return c&&(c.maxZ=l,s.updateTransformMatrix(!0)),this;t&&h.setAlphaMode(this._internalMeshDataInfo._effectiveMaterial.alphaMode);let p;this._internalMeshDataInfo._effectiveMaterial._storeEffectOnSubMeshes?p=e._drawWrapper:p=this._internalMeshDataInfo._effectiveMaterial._getDrawWrapper();const g=(S=p==null?void 0:p.effect)!=null?S:null;for(const w of s._beforeRenderingMeshStage)w.action(this,e,o,g);if(!p||!g)return c&&(c.maxZ=l,s.updateTransformMatrix(!0)),this;const m=i||this;let b;if(!d.isFrozen&&(this._internalMeshDataInfo._effectiveMaterial.backFaceCulling||this._internalMeshDataInfo._effectiveMaterial.sideOrientation!==null||this._internalMeshDataInfo._effectiveMaterial.twoSidedLighting)){const w=m._getWorldMatrixDeterminant();b=this._internalMeshDataInfo._effectiveMaterial._getEffectiveOrientation(this),w<0&&(b=b===X.ClockWiseSideOrientation?X.CounterClockWiseSideOrientation:X.ClockWiseSideOrientation),d.sideOrientation=b}else b=d.sideOrientation;const I=this._internalMeshDataInfo._effectiveMaterial._preBind(p,b);this._internalMeshDataInfo._effectiveMaterial.forceDepthWrite&&h.setDepthWrite(!0);const T=this._internalMeshDataInfo._effectiveMaterial,x=T.fillMode;this._internalMeshDataInfo._onBeforeBindObservable&&this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this),f||this._bind(e,g,x,!1);const y=m.getWorldMatrix();T._storeEffectOnSubMeshes?T.bindForSubMesh(y,this,e):T.bind(y,this),!T.backFaceCulling&&T.separateCullingPass&&(h.setState(!0,T.zOffset,!1,!I,T.cullBackFaces,T.stencil,T.zOffsetUnits),this._processRendering(this,e,g,x,o,f,this._onBeforeDraw,this._internalMeshDataInfo._effectiveMaterial),h.setState(!0,T.zOffset,!1,I,T.cullBackFaces,T.stencil,T.zOffsetUnits),this._internalMeshDataInfo._onBetweenPassObservable&&this._internalMeshDataInfo._onBetweenPassObservable.notifyObservers(e)),this._processRendering(this,e,g,x,o,f,this._onBeforeDraw,this._internalMeshDataInfo._effectiveMaterial),this._internalMeshDataInfo._effectiveMaterial.unbind();for(const w of s._afterRenderingMeshStage)w.action(this,e,o,g);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(A.MatricesWeightsKind)&&(this.isVerticesDataPresent(A.MatricesWeightsExtraKind)?this._normalizeSkinWeightsAndExtra():this._normalizeSkinFourWeights())}_normalizeSkinFourWeights(){const e=this.getVerticesData(A.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 n=1/s;e[i]*=n,e[i+1]*=n,e[i+2]*=n,e[i+3]*=n}}this.setVerticesData(A.MatricesWeightsKind,e)}_normalizeSkinWeightsAndExtra(){const e=this.getVerticesData(A.MatricesWeightsExtraKind),t=this.getVerticesData(A.MatricesWeightsKind),i=t.length;for(let s=0;s<i;s+=4){let n=t[s]+t[s+1]+t[s+2]+t[s+3];if(n+=e[s]+e[s+1]+e[s+2]+e[s+3],n===0)t[s]=1;else{const r=1/n;t[s]*=r,t[s+1]*=r,t[s+2]*=r,t[s+3]*=r,e[s]*=r,e[s+1]*=r,e[s+2]*=r,e[s+3]*=r}}this.setVerticesData(A.MatricesWeightsKind,t),this.setVerticesData(A.MatricesWeightsKind,e)}validateSkinning(){const e=this.getVerticesData(A.MatricesWeightsExtraKind),t=this.getVerticesData(A.MatricesWeightsKind);if(t===null||this.skeleton==null)return{skinned:!1,valid:!0,report:"not skinned"};const i=t.length;let s=0,n=0,r=0,o=0;const h=e===null?4:8,l=[];for(let g=0;g<=h;g++)l[g]=0;const c=.001;for(let g=0;g<i;g+=4){let m=t[g],b=m,I=b===0?0:1;for(let T=1;T<h;T++){const x=T<4?t[g+T]:e[g+T-4];x>m&&s++,x!==0&&I++,b+=x,m=x}if(l[I]++,I>r&&(r=I),b===0)n++;else{const T=1/b;let x=0;for(let y=0;y<h;y++)y<4?x+=Math.abs(t[g+y]-t[g+y]*T):x+=Math.abs(e[g+y-4]-e[g+y-4]*T);x>c&&o++}}const u=this.skeleton.bones.length,f=this.getVerticesData(A.MatricesIndicesKind),d=this.getVerticesData(A.MatricesIndicesExtraKind);let _=0;for(let g=0;g<i;g+=4)for(let m=0;m<h;m++){const b=m<4?f[g+m]:d[g+m-4];(b>=u||b<0)&&_++}const p="Number of Weights = "+i/4+"\nMaximum influences = "+r+"\nMissing Weights = "+n+"\nNot Sorted = "+s+"\nNot Normalized = "+o+"\nWeightCounts = ["+l+"]\nNumber of bones = "+u+"\nBad Bone Indices = "+_;return{skinned:!0,valid:n===0&&o===0&&_===0,report:p}}_checkDelayState(){const e=this.getScene();return this._geometry?this._geometry.load(e):this.delayLoadState===4&&(this.delayLoadState=2,this._queueLoad(e)),this}_queueLoad(e){e.addPendingData(this);const t=this.delayLoadingFile.indexOf(".babylonbinarymeshdata")!==-1;return J.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(A.PositionKind))return this;const t=this.subMeshes.splice(0);this._resetPointsArrayCache();let i=this.getVerticesData(A.PositionKind);const s=v.Zero();let n;for(n=0;n<i.length;n+=3)v.TransformCoordinatesFromFloatsToRef(i[n],i[n+1],i[n+2],e,s).toArray(i,n);if(this.setVerticesData(A.PositionKind,i,this.getVertexBuffer(A.PositionKind).isUpdatable()),this.isVerticesDataPresent(A.NormalKind)){for(i=this.getVerticesData(A.NormalKind),n=0;n<i.length;n+=3)v.TransformNormalFromFloatsToRef(i[n],i[n+1],i[n+2],e,s).normalize().toArray(i,n);this.setVerticesData(A.NormalKind,i,this.getVertexBuffer(A.NormalKind).isUpdatable())}if(this.isVerticesDataPresent(A.TangentKind)){for(i=this.getVerticesData(A.TangentKind),n=0;n<i.length;n+=4)v.TransformNormalFromFloatsToRef(i[n],i[n+1],i[n+2],e,s).normalize().toArray(i,n);this.setVerticesData(A.TangentKind,i,this.getVertexBuffer(A.TangentKind).isUpdatable())}return e.determinant()<0&&this.flipFaces(),this.releaseSubMeshes(),this.subMeshes=t,this}bakeCurrentTransformIntoVertices(e=!0){return 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){return new F(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 n=i.meshMap[s];n&&(n._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 n of s){const r=n;r._internalMeshDataInfo&&r._internalMeshDataInfo._source&&r._internalMeshDataInfo._source===this&&(r._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,n,r,o=!1,h){const l=this.getScene(),c=u=>{const f=u.width,d=u.height,p=this.getEngine().createCanvas(f,d).getContext("2d");p.drawImage(u,0,0);const g=p.getImageData(0,0,f,d).data;this.applyDisplacementMapFromBuffer(g,f,d,t,i,n,r,o),s&&s(this)};return J.LoadImage(e,c,h||(()=>{}),l.offlineProvider),this}applyDisplacementMapFromBuffer(e,t,i,s,n,r,o,h=!1){if(!this.isVerticesDataPresent(A.PositionKind)||!this.isVerticesDataPresent(A.NormalKind)||!this.isVerticesDataPresent(A.UVKind))return U.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),this;const l=this.getVerticesData(A.PositionKind,!0,!0),c=this.getVerticesData(A.NormalKind),u=this.getVerticesData(A.UVKind);let f=v.Zero();const d=v.Zero(),_=oe.Zero();r=r||oe.Zero(),o=o||new oe(1,1);for(let p=0;p<l.length;p+=3){v.FromArrayToRef(l,p,f),v.FromArrayToRef(c,p,d),oe.FromArrayToRef(u,p/3*2,_);const g=Math.abs(_.x*o.x+r.x%1)*(t-1)%t|0,m=Math.abs(_.y*o.y+r.y%1)*(i-1)%i|0,b=(g+m*t)*4,I=e[b]/255,T=e[b+1]/255,x=e[b+2]/255,y=I*.3+T*.59+x*.11;d.normalize(),d.scaleInPlace(s+(n-s)*y),f=f.add(d),f.toArray(l,p)}return j.ComputeNormals(l,this.getIndices(),c),h?(this.setVerticesData(A.PositionKind,l),this.setVerticesData(A.NormalKind,c),this.setVerticesData(A.UVKind,u)):(this.updateVerticesData(A.PositionKind,l),this.updateVerticesData(A.NormalKind,c)),this}_getFlattenedNormals(e,t){const i=new Float32Array(e.length*3);let s=0;const n=this.sideOrientation===(this._scene.useRightHandedSystem?1:0);for(let r=0;r<e.length;r+=3){const o=v.FromArray(t,e[r]*3),h=v.FromArray(t,e[r+1]*3),l=v.FromArray(t,e[r+2]*3),c=o.subtract(h),u=l.subtract(h),f=v.Normalize(v.Cross(c,u));n&&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=>{var l;return!((l=this.getVertexBuffer(h))!=null&&l.getIsInstanced())}),i=this.getIndices(),s={},n=(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},r=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===A.NormalKind){const u=this._getFlattenedNormals(i,s[A.PositionKind]);this.setVerticesData(A.NormalKind,u,l.isUpdatable(),c)}else this.setVerticesData(h,n(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(n(c,3));const u=l.getNormals();u&&l.setNormals(e?this._getFlattenedNormals(i,c):n(u,3));const f=l.getTangents();f&&l.setTangents(n(f,3));const d=l.getUVs();d&&l.setUVs(n(d,2))}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();vi.AddToMesh(h.materialIndex,h.indexStart,h.indexCount,h.indexStart,h.indexCount,this).setBoundingInfo(l)}return this.setBoundingInfo(r),this.synchronizeInstances(),this}convertToFlatShadedMesh(){return this._convertToUnIndexedMesh(!0)}convertToUnIndexedMesh(){return this._convertToUnIndexedMesh()}flipFaces(e=!1){const t=j.ExtractFromMesh(this);let i;if(e&&this.isVerticesDataPresent(A.NormalKind)&&t.normals){for(i=0;i<t.normals.length;i++)t.normals[i]*=-1;this.setVerticesData(A.NormalKind,t.normals,this.isVertexBufferUpdatable(A.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(A.PositionKind),!0)}return this}increaseVertices(e=1){const t=j.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,n=t.uvs&&!Array.isArray(t.uvs)&&Array.from?Array.from(t.uvs):t.uvs,r=t.normals&&!Array.isArray(t.normals)&&Array.from?Array.from(t.normals):t.normals;if(!i||!s)U.Warn("Couldn't increase number of vertices : VertexData must contain at least indices and positions");else{t.indices=i,t.positions=s,n&&(t.uvs=n),r&&(t.normals=r);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 v(0,0,0),f=new v(0,0,0),d=new oe(0,0),_=new Array,p=new Array,g=new Array;let m,b=s.length,I;n&&(I=n.length);let T;r&&(T=r.length);for(let x=0;x<i.length;x+=3){p[0]=i[x],p[1]=i[x+1],p[2]=i[x+2];for(let y=0;y<3;y++)if(l=p[y],c=p[(y+1)%3],g[l]===void 0&&g[c]===void 0?(g[l]=new Array,g[c]=new Array):(g[l]===void 0&&(g[l]=new Array),g[c]===void 0&&(g[c]=new Array)),g[l][c]===void 0&&g[c][l]===void 0){g[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,r&&(f.x=(r[3*c]-r[3*l])/o,f.y=(r[3*c+1]-r[3*l+1])/o,f.z=(r[3*c+2]-r[3*l+2])/o),n&&(d.x=(n[2*c]-n[2*l])/o,d.y=(n[2*c+1]-n[2*l+1])/o),g[l][c].push(l);for(let R=1;R<o;R++)g[l][c].push(s.length/3),s[b++]=s[3*l]+R*u.x,s[b++]=s[3*l+1]+R*u.y,s[b++]=s[3*l+2]+R*u.z,r&&(r[T++]=r[3*l]+R*f.x,r[T++]=r[3*l+1]+R*f.y,r[T++]=r[3*l+2]+R*f.z),n&&(n[I++]=n[2*l]+R*d.x,n[I++]=n[2*l+1]+R*d.y);g[l][c].push(c),g[c][l]=new Array,m=g[l][c].length;for(let R=0;R<m;R++)g[c][l][R]=g[l][c][m-1-R]}h[0][0]=i[x],h[1][0]=g[i[x]][i[x+1]][1],h[1][1]=g[i[x]][i[x+2]][1];for(let y=2;y<o;y++){h[y][0]=g[i[x]][i[x+1]][y],h[y][y]=g[i[x]][i[x+2]][y],u.x=(s[3*h[y][y]]-s[3*h[y][0]])/y,u.y=(s[3*h[y][y]+1]-s[3*h[y][0]+1])/y,u.z=(s[3*h[y][y]+2]-s[3*h[y][0]+2])/y,r&&(f.x=(r[3*h[y][y]]-r[3*h[y][0]])/y,f.y=(r[3*h[y][y]+1]-r[3*h[y][0]+1])/y,f.z=(r[3*h[y][y]+2]-r[3*h[y][0]+2])/y),n&&(d.x=(n[2*h[y][y]]-n[2*h[y][0]])/y,d.y=(n[2*h[y][y]+1]-n[2*h[y][0]+1])/y);for(let R=1;R<y;R++)h[y][R]=s.length/3,s[b++]=s[3*h[y][0]]+R*u.x,s[b++]=s[3*h[y][0]+1]+R*u.y,s[b++]=s[3*h[y][0]+2]+R*u.z,r&&(r[T++]=r[3*h[y][0]]+R*f.x,r[T++]=r[3*h[y][0]+1]+R*f.y,r[T++]=r[3*h[y][0]+2]+R*f.z),n&&(n[I++]=n[2*h[y][0]]+R*d.x,n[I++]=n[2*h[y][0]+1]+R*d.y)}h[o]=g[i[x+1]][i[x+2]],_.push(h[0][0],h[1][0],h[1][1]);for(let y=1;y<o;y++){let R;for(R=0;R<y;R++)_.push(h[y][R],h[y+1][R],h[y+1][R+1]),_.push(h[y][R],h[y+1][R+1],h[y][R+1]);_.push(h[y][R],h[y+1][R],h[y+1][R+1])}}t.indices=_,t.applyToMesh(this,this.isVertexBufferUpdatable(A.PositionKind))}}forceSharedVertices(){const e=j.ExtractFromMesh(this),t=e.uvs,i=e.indices,s=e.positions,n=e.colors,r=e.matricesIndices,o=e.matricesWeights,h=e.matricesIndicesExtra,l=e.matricesWeightsExtra;if(i===void 0||s===void 0||i===null||s===null)U.Warn("VertexData contains empty entries");else{const c=new Array,u=new Array,f=new Array,d=new Array,_=new Array,p=new Array,g=new Array,m=new Array;let b=new Array,I=0;const T={};let x,y;for(let E=0;E<i.length;E+=3){y=[i[E],i[E+1],i[E+2]],b=[];for(let C=0;C<3;C++){b[C]="";for(let S=0;S<3;S++)Math.abs(s[3*y[C]+S])<1e-8&&(s[3*y[C]+S]=0),b[C]+=s[3*y[C]+S]+"|"}if(!(b[0]==b[1]||b[0]==b[2]||b[1]==b[2]))for(let C=0;C<3;C++){if(x=T[b[C]],x===void 0){T[b[C]]=I,x=I++;for(let S=0;S<3;S++)c.push(s[3*y[C]+S]);if(n!=null)for(let S=0;S<4;S++)d.push(n[4*y[C]+S]);if(t!=null)for(let S=0;S<2;S++)f.push(t[2*y[C]+S]);if(r!=null)for(let S=0;S<4;S++)_.push(r[4*y[C]+S]);if(o!=null)for(let S=0;S<4;S++)p.push(o[4*y[C]+S]);if(h!=null)for(let S=0;S<4;S++)g.push(h[4*y[C]+S]);if(l!=null)for(let S=0;S<4;S++)m.push(l[4*y[C]+S])}u.push(x)}}const R=new Array;j.ComputeNormals(c,u,R),e.positions=c,e.indices=u,e.normals=R,t!=null&&(e.uvs=f),n!=null&&(e.colors=d),r!=null&&(e.matricesIndices=_),o!=null&&(e.matricesWeights=p),h!=null&&(e.matricesIndicesExtra=g),o!=null&&(e.matricesWeightsExtra=m),e.applyToMesh(this,this.isVertexBufferUpdatable(A.PositionKind))}}static _instancedMeshFactory(e,t){throw ye("InstancedMesh")}static _PhysicsImpostorParser(e,t,i){throw ye("PhysicsImpostor")}createInstance(e){const t=F._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(A.PositionKind);if(!i||!t)return this;const s=[];for(let r=0;r<i.length;r=r+3)s.push(v.FromArray(i,r));const n=[];return Sr.SyncAsyncForLoop(s.length,40,r=>{const o=s.length-1-r,h=s[o];for(let l=0;l<o;++l){const c=s[l];if(h.equals(c)){n[o]=l;break}}},()=>{for(let o=0;o<t.length;++o)t[o]=n[t[o]]||t[o];const r=this.subMeshes.slice(0);this.setIndices(t),this.subMeshes=r,e&&e(this)}),this}serialize(e={}){e.name=this.name,e.id=this.id,e.uniqueId=this.uniqueId,e.type=this.getClassName(),ke&&ke.HasTags(this)&&(e.tags=ke.GetTags(this)),e.position=this.position.asArray(),this.rotationQuaternion?e.rotationQuaternion=this.rotationQuaternion.asArray():this.rotation&&(e.rotation=this.rotation.asArray()),e.scaling=this.scaling.asArray(),this._postMultiplyPivotMatrix?e.pivotMatrix=this.getPivotMatrix().asArray():e.localMatrix=this.getPivotMatrix().asArray(),e.isEnabled=this.isEnabled(!1),e.isVisible=this.isVisible,e.infiniteDistance=this.infiniteDistance,e.pickable=this.isPickable,e.receiveShadows=this.receiveShadows,e.billboardMode=this.billboardMode,e.visibility=this.visibility,e.alwaysSelectAsActiveMesh=this.alwaysSelectAsActiveMesh,e.checkCollisions=this.checkCollisions,e.ellipsoid=this.ellipsoid.asArray(),e.ellipsoidOffset=this.ellipsoidOffset.asArray(),e.doNotSyncBoundingInfo=this.doNotSyncBoundingInfo,e.isBlocker=this.isBlocker,e.sideOrientation=this.sideOrientation,this.parent&&this.parent._serializeAsParent(e),e.isUnIndexed=this.isUnIndexed;const t=this._geometry;if(t&&this.subMeshes){e.geometryUniqueId=t.uniqueId,e.geometryId=t.id,e.subMeshes=[];for(let i=0;i<this.subMeshes.length;i++){const s=this.subMeshes[i];e.subMeshes.push({materialIndex:s.materialIndex,verticesStart:s.verticesStart,verticesCount:s.verticesCount,indexStart:s.indexStart,indexCount:s.indexCount})}}if(this.material?this.material.doNotSerialize||(e.materialUniqueId=this.material.uniqueId,e.materialId=this.material.id):(this.material=null,e.materialUniqueId=this._scene.defaultMaterial.uniqueId,e.materialId=this._scene.defaultMaterial.id),this.morphTargetManager&&(e.morphTargetManagerId=this.morphTargetManager.uniqueId),this.skeleton&&(e.skeletonId=this.skeleton.id,e.numBoneInfluencers=this.numBoneInfluencers),this.getScene()._getComponent(Re.NAME_PHYSICSENGINE)){const i=this.getPhysicsImpostor();i&&(e.physicsMass=i.getParam("mass"),e.physicsFriction=i.getParam("friction"),e.physicsRestitution=i.getParam("mass"),e.physicsImpostor=i.type)}this.metadata&&(e.metadata=this.metadata),e.instances=[];for(let i=0;i<this.instances.length;i++){const s=this.instances[i];if(s.doNotSerialize)continue;const n={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(n),s.rotationQuaternion?n.rotationQuaternion=s.rotationQuaternion.asArray():s.rotation&&(n.rotation=s.rotation.asArray()),this.getScene()._getComponent(Re.NAME_PHYSICSENGINE)){const r=s.getPhysicsImpostor();r&&(n.physicsMass=r.getParam("mass"),n.physicsFriction=r.getParam("friction"),n.physicsRestitution=r.getParam("mass"),n.physicsImpostor=r.type)}s.metadata&&(n.metadata=s.metadata),s.actionManager&&(n.actions=s.actionManager.serialize(s.name)),e.instances.push(n),Ae.AppendSerializedAnimations(s,n),n.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 Ae.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()){U.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){U.Error("Invalid morph target. Target must have positions.");return}this.geometry.setVerticesData(A.PositionKind+t,s,!1,3);const n=i.getNormals();n&&this.geometry.setVerticesData(A.NormalKind+t,n,!1,3);const r=i.getTangents();r&&this.geometry.setVerticesData(A.TangentKind+t,r,!1,3);const o=i.getUVs();o&&this.geometry.setVerticesData(A.UVKind+"_"+t,o,!1,2)}}else{let t=0;for(;this.geometry.isVerticesDataPresent(A.PositionKind+t);)this.geometry.removeVerticesData(A.PositionKind+t),this.geometry.isVerticesDataPresent(A.NormalKind+t)&&this.geometry.removeVerticesData(A.NormalKind+t),this.geometry.isVerticesDataPresent(A.TangentKind+t)&&this.geometry.removeVerticesData(A.TangentKind+t),this.geometry.isVerticesDataPresent(A.UVKind+t)&&this.geometry.removeVerticesData(A.UVKind+"_"+t),t++}}static Parse(e,t,i){let s;if(e.type&&e.type==="LinesMesh"?s=F._LinesMeshParser(e,t):e.type&&e.type==="GroundMesh"?s=F._GroundMeshParser(e,t):e.type&&e.type==="GoldbergMesh"?s=F._GoldbergMeshParser(e,t):e.type&&e.type==="GreasedLineMesh"?s=F._GreasedLineMeshParser(e,t):e.type&&e.type==="TrailMesh"?s=F._TrailMeshParser(e,t):s=new F(e.name,t),s.id=e.id,s._waitingParsedUniqueId=e.uniqueId,ke&&ke.AddTagsTo(s,e.tags),s.position=v.FromArray(e.position),e.metadata!==void 0&&(s.metadata=e.metadata),e.rotationQuaternion?s.rotationQuaternion=re.FromArray(e.rotationQuaternion):e.rotation&&(s.rotation=v.FromArray(e.rotation)),s.scaling=v.FromArray(e.scaling),e.localMatrix?s.setPreTransformMatrix(O.FromArray(e.localMatrix)):e.pivotMatrix&&s.setPivotMatrix(O.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=v.FromArray(e.ellipsoid)),e.ellipsoidOffset&&(s.ellipsoidOffset=v.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=de.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(v.FromArray(e.boundingBoxMinimum),v.FromArray(e.boundingBoxMaximum)),e._binaryInfo&&(s._binaryInfo=e._binaryInfo),s._delayInfo=[],e.hasUVs&&s._delayInfo.push(A.UVKind),e.hasUVs2&&s._delayInfo.push(A.UV2Kind),e.hasUVs3&&s._delayInfo.push(A.UV3Kind),e.hasUVs4&&s._delayInfo.push(A.UV4Kind),e.hasUVs5&&s._delayInfo.push(A.UV5Kind),e.hasUVs6&&s._delayInfo.push(A.UV6Kind),e.hasColors&&s._delayInfo.push(A.ColorKind),e.hasMatricesIndices&&s._delayInfo.push(A.MatricesIndicesKind),e.hasMatricesWeights&&s._delayInfo.push(A.MatricesWeightsKind),s._delayLoadingFunction=Nt._ImportGeometry,Tt.ForceFullSceneLoadingForIncremental&&s._checkDelayState()):Nt._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 n=0;n<e.animations.length;n++){const r=e.animations[n],o=ys("BABYLON.Animation");o&&s.animations.push(o.Parse(r))}bt.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=F._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 n=0;n<e.instances.length;n++){const r=e.instances[n],o=s.createInstance(r.name);if(r.id&&(o.id=r.id),ke&&(r.tags?ke.AddTagsTo(o,r.tags):ke.AddTagsTo(o,e.tags)),o.position=v.FromArray(r.position),r.metadata!==void 0&&(o.metadata=r.metadata),r.parentId!==void 0&&(o._waitingParentId=r.parentId),r.parentInstanceIndex!==void 0&&(o._waitingParentInstanceIndex=r.parentInstanceIndex),r.isEnabled!==void 0&&r.isEnabled!==null&&o.setEnabled(r.isEnabled),r.isVisible!==void 0&&r.isVisible!==null&&(o.isVisible=r.isVisible),r.isPickable!==void 0&&r.isPickable!==null&&(o.isPickable=r.isPickable),r.rotationQuaternion?o.rotationQuaternion=re.FromArray(r.rotationQuaternion):r.rotation&&(o.rotation=v.FromArray(r.rotation)),o.scaling=v.FromArray(r.scaling),r.checkCollisions!=null&&r.checkCollisions!=null&&(o.checkCollisions=r.checkCollisions),r.pickable!=null&&r.pickable!=null&&(o.isPickable=r.pickable),r.showBoundingBox!=null&&r.showBoundingBox!=null&&(o.showBoundingBox=r.showBoundingBox),r.showSubMeshesBoundingBox!=null&&r.showSubMeshesBoundingBox!=null&&(o.showSubMeshesBoundingBox=r.showSubMeshesBoundingBox),r.alphaIndex!=null&&r.showSubMeshesBoundingBox!=null&&(o.alphaIndex=r.alphaIndex),r.physicsImpostor&&(o.physicsImpostor=F._PhysicsImpostorParser(t,o,r)),r.actions!==void 0&&(o._waitingData.actions=r.actions),r.animations){for(let h=0;h<r.animations.length;h++){const l=r.animations[h],c=ys("BABYLON.Animation");c&&o.animations.push(c.Parse(l))}bt.ParseAnimationRanges(o,r,t),r.autoAnimate&&t.beginAnimation(o,r.autoAnimateFrom,r.autoAnimateTo,r.autoAnimateLoop,r.autoAnimateSpeed||1)}}if(e.thinInstances){const n=e.thinInstances;if(s.thinInstanceEnablePicking=!!n.enablePicking,n.matrixData?(s.thinInstanceSetBuffer("matrix",new Float32Array(n.matrixData),16,!1),s._thinInstanceDataStorage.matrixBufferSize=n.matrixBufferSize,s._thinInstanceDataStorage.instancesCount=n.instancesCount):s._thinInstanceDataStorage.matrixBufferSize=n.matrixBufferSize,e.thinInstances.userThinInstance){const r=e.thinInstances.userThinInstance;for(const o in r.data)s.thinInstanceSetBuffer(o,new Float32Array(r.data[o]),r.strides[o],!1),s._userThinInstanceBuffersStorage.sizes[o]=r.sizes[o]}}return s}setPositionsForCPUSkinning(){const e=this._internalMeshDataInfo;if(!e._sourcePositions){const t=this.getVerticesData(A.PositionKind);if(!t)return e._sourcePositions;e._sourcePositions=new Float32Array(t),this.isVertexBufferUpdatable(A.PositionKind)||this.setVerticesData(A.PositionKind,t,!0)}return e._sourcePositions}setNormalsForCPUSkinning(){const e=this._internalMeshDataInfo;if(!e._sourceNormals){const t=this.getVerticesData(A.NormalKind);if(!t)return e._sourceNormals;e._sourceNormals=new Float32Array(t),this.isVertexBufferUpdatable(A.NormalKind)||this.setVerticesData(A.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(A.PositionKind))return this;if(!this.isVerticesDataPresent(A.MatricesIndicesKind))return this;if(!this.isVerticesDataPresent(A.MatricesWeightsKind))return this;const t=this.isVerticesDataPresent(A.NormalKind),i=this._internalMeshDataInfo;if(!i._sourcePositions){const m=this.subMeshes.slice();this.setPositionsForCPUSkinning(),this.subMeshes=m}t&&!i._sourceNormals&&this.setNormalsForCPUSkinning();let s=this.getVerticesData(A.PositionKind);if(!s)return this;s instanceof Float32Array||(s=new Float32Array(s));let n=this.getVerticesData(A.NormalKind);if(t){if(!n)return this;n instanceof Float32Array||(n=new Float32Array(n))}const r=this.getVerticesData(A.MatricesIndicesKind),o=this.getVerticesData(A.MatricesWeightsKind);if(!o||!r)return this;const h=this.numBoneInfluencers>4,l=h?this.getVerticesData(A.MatricesIndicesExtraKind):null,c=h?this.getVerticesData(A.MatricesWeightsExtraKind):null,u=e.getTransformMatrices(this),f=v.Zero(),d=new O,_=new O;let p=0,g;for(let m=0;m<s.length;m+=3,p+=4){let b;for(g=0;g<4;g++)b=o[p+g],b>0&&(O.FromFloat32ArrayToRefScaled(u,Math.floor(r[p+g]*16),b,_),d.addToSelf(_));if(h)for(g=0;g<4;g++)b=c[p+g],b>0&&(O.FromFloat32ArrayToRefScaled(u,Math.floor(l[p+g]*16),b,_),d.addToSelf(_));v.TransformCoordinatesFromFloatsToRef(i._sourcePositions[m],i._sourcePositions[m+1],i._sourcePositions[m+2],d,f),f.toArray(s,m),t&&(v.TransformNormalFromFloatsToRef(i._sourceNormals[m],i._sourceNormals[m+1],i._sourceNormals[m+2],d,f),f.toArray(n,m)),d.reset()}return this.updateVerticesData(A.PositionKind,s),t&&this.updateVerticesData(A.NormalKind,n),this}static MinMax(e){let t=null,i=null;return e.forEach(function(s){const r=s.getBoundingInfo().boundingBox;!t||!i?(t=r.minimumWorld,i=r.maximumWorld):(t.minimizeInPlace(r.minimumWorld),i.maximizeInPlace(r.maximumWorld))}),!t||!i?{min:v.Zero(),max:v.Zero()}:{min:t,max:i}}static Center(e){const t=e instanceof Array?F.MinMax(e):e;return v.Center(t.min,t.max)}static MergeMeshes(e,t=!0,i,s,n,r){return F0(F._MergeMeshesCoroutine(e,t,i,s,n,r,!1))}static MergeMeshesAsync(e,t=!0,i,s,n,r){return Ep(F._MergeMeshesCoroutine(e,t,i,s,n,r,!0),Ip())}static*_MergeMeshesCoroutine(e,t=!0,i,s,n,r,o){if(e=e.filter(Boolean),e.length===0)return null;let h;if(!i){let R=0;for(h=0;h<e.length;h++)if(R+=e[h].getTotalVertices(),R>=65536)return U.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}r&&(n=!1);const l=new Array,c=new Array,u=new Array,f=e[0].sideOrientation;for(h=0;h<e.length;h++){const R=e[h];if(R.isAnInstance)return U.Warn("Cannot merge instance meshes."),null;if(f!==R.sideOrientation)return U.Warn("Cannot merge meshes with different sideOrientation values."),null;if(n&&u.push(R.getTotalIndices()),r)if(R.material){const E=R.material;if(E instanceof cn){for(let C=0;C<E.subMaterials.length;C++)l.indexOf(E.subMaterials[C])<0&&l.push(E.subMaterials[C]);for(let C=0;C<R.subMeshes.length;C++)c.push(l.indexOf(E.subMaterials[R.subMeshes[C].materialIndex])),u.push(R.subMeshes[C].indexCount)}else{l.indexOf(E)<0&&l.push(E);for(let C=0;C<R.subMeshes.length;C++)c.push(l.indexOf(E)),u.push(R.subMeshes[C].indexCount)}}else for(let E=0;E<R.subMeshes.length;E++)c.push(0),u.push(R.subMeshes[E].indexCount)}const d=e[0],_=R=>{const E=R.computeWorldMatrix(!0);return{vertexData:j.ExtractFromMesh(R,!1,!1),transform:E}},{vertexData:p,transform:g}=_(d);o&&(yield);const m=new Array(e.length-1);for(let R=1;R<e.length;R++)m[R-1]=_(e[R]),o&&(yield);const b=p._mergeCoroutine(g,m,i,o,!t);let I=b.next();for(;!I.done;)o&&(yield),I=b.next();const T=I.value;s||(s=new F(d.name+"_merged",d.getScene()));const x=T._applyToCoroutine(s,void 0,o);let y=x.next();for(;!y.done;)o&&(yield),y=x.next();if(s.checkCollisions=d.checkCollisions,s.sideOrientation=d.sideOrientation,t)for(h=0;h<e.length;h++)e[h].dispose();if(n||r){s.releaseSubMeshes(),h=0;let R=0;for(;h<u.length;)vi.CreateFromIndices(0,R,u[h],s,void 0,!1),R+=u[h],h++;for(const E of s.subMeshes)E.refreshBoundingInfo();s.computeWorldMatrix(!0)}if(r){const R=new cn(d.name+"_merged",d.getScene());R.subMaterials=l;for(let E=0;E<s.subMeshes.length;E++)s.subMeshes[E].materialIndex=c[E];s.material=R}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===X.CounterClockWiseSideOrientation}_getRenderingFillMode(e){var i;const t=this.getScene();return t.forcePointsCloud?X.PointFillMode:t.forceWireframe?X.WireFrameFillMode:(i=this.overrideRenderingFillMode)!=null?i:e}setMaterialByID(e){return this.setMaterialById(e)}static CreateRibbon(e,t,i,s,n,r,o,h,l){throw new Error("Import MeshBuilder to populate this function")}static CreateDisc(e,t,i,s,n,r){throw new Error("Import MeshBuilder to populate this function")}static CreateBox(e,t,i,s,n){throw new Error("Import MeshBuilder to populate this function")}static CreateSphere(e,t,i,s,n,r){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,n,r,o,h,l){throw new Error("Import MeshBuilder to populate this function")}static CreateTorus(e,t,i,s,n,r,o){throw new Error("Import MeshBuilder to populate this function")}static CreateTorusKnot(e,t,i,s,n,r,o,h,l,c){throw new Error("Import MeshBuilder to populate this function")}static CreateLines(e,t,i,s,n){throw new Error("Import MeshBuilder to populate this function")}static CreateDashedLines(e,t,i,s,n,r,o,h){throw new Error("Import MeshBuilder to populate this function")}static CreatePolygon(e,t,i,s,n,r,o){throw new Error("Import MeshBuilder to populate this function")}static ExtrudePolygon(e,t,i,s,n,r,o,h){throw new Error("Import MeshBuilder to populate this function")}static ExtrudeShape(e,t,i,s,n,r,o,h,l,c){throw new Error("Import MeshBuilder to populate this function")}static ExtrudeShapeCustom(e,t,i,s,n,r,o,h,l,c,u,f){throw new Error("Import MeshBuilder to populate this function")}static CreateLathe(e,t,i,s,n,r,o){throw new Error("Import MeshBuilder to populate this function")}static CreatePlane(e,t,i,s,n){throw new Error("Import MeshBuilder to populate this function")}static CreateGround(e,t,i,s,n,r){throw new Error("Import MeshBuilder to populate this function")}static CreateTiledGround(e,t,i,s,n,r,o,h,l){throw new Error("Import MeshBuilder to populate this function")}static CreateGroundFromHeightMap(e,t,i,s,n,r,o,h,l,c,u){throw new Error("Import MeshBuilder to populate this function")}static CreateTube(e,t,i,s,n,r,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,n,r){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")}}F.FRONTSIDE=j.FRONTSIDE;F.BACKSIDE=j.BACKSIDE;F.DOUBLESIDE=j.DOUBLESIDE;F.DEFAULTSIDE=j.DEFAULTSIDE;F.NO_CAP=0;F.CAP_START=1;F.CAP_END=2;F.CAP_ALL=3;F.NO_FLIP=0;F.FLIP_TILE=1;F.ROTATE_TILE=2;F.FLIP_ROW=3;F.ROTATE_ROW=4;F.FLIP_N_ROTATE_TILE=5;F.FLIP_N_ROTATE_ROW=6;F.CENTER=0;F.LEFT=1;F.RIGHT=2;F.TOP=3;F.BOTTOM=4;F.INSTANCEDMESH_SORT_TRANSPARENT=!1;F._GroundMeshParser=(a,e)=>{throw ye("GroundMesh")};F._GoldbergMeshParser=(a,e)=>{throw ye("GoldbergMesh")};F._LinesMeshParser=(a,e)=>{throw ye("LinesMesh")};F._GreasedLineMeshParser=(a,e)=>{throw ye("GreasedLineMesh")};F._GreasedLineRibbonMeshParser=(a,e)=>{throw ye("GreasedLineRibbonMesh")};F._TrailMeshParser=(a,e)=>{throw ye("TrailMesh")};vt("BABYLON.Mesh",F);class pg{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===Ce.POINTERDOWN){this._isPointerDown=!0;return}i.type===Ce.POINTERUP&&(this._isPointerDown=!1)}),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add(()=>{if(this._reachTargetAlpha())return;const i=bi.Now;let s=0;this._lastFrameTime!=null&&(s=i-this._lastFrameTime),this._lastFrameTime=i,this._applyUserInteraction();const n=i-this._lastInteractionTime-this._idleRotationWaitTime,r=Math.max(Math.min(n/this._idleRotationSpinupTime,1),0);this._cameraRotationSpeed=this._idleRotationSpeed*r,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!=null?e:bi.Now}_reachTargetAlpha(){return this._attachedCamera&&this.targetAlpha?Math.abs(this._attachedCamera.alpha-this.targetAlpha)<Le:!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=bi.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}}class wi{constructor(){this._easingMode=wi.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 wi.EASINGMODE_EASEIN:return this.easeInCore(e);case wi.EASINGMODE_EASEOUT:return 1-this.easeInCore(1-e)}return e>=.5?(1-this.easeInCore((1-e)*2))*.5+.5:this.easeInCore(e*2)*.5}}wi.EASINGMODE_EASEIN=0;wi.EASINGMODE_EASEOUT=1;wi.EASINGMODE_EASEINOUT=2;class gg extends wi{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 mg extends wi{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 qr{constructor(e,t,i){this.name=e,this.from=t,this.to=i}clone(){return new qr(this.name,this.from,this.to)}}const vg=Object.freeze(new re(0,0,0,0)),bg=Object.freeze(v.Zero()),xg=Object.freeze(oe.Zero()),yg=Object.freeze(hi.Zero()),Tg=Object.freeze(de.Black()),Ag=Object.freeze(new H(0,0,0,0)),Ii={key:0,repeatCount:0,loopMode:2};class te{static _PrepareAnimation(e,t,i,s,n,r,o,h){let l;if(!isNaN(parseFloat(n))&&isFinite(n)?l=te.ANIMATIONTYPE_FLOAT:n instanceof re?l=te.ANIMATIONTYPE_QUATERNION:n instanceof v?l=te.ANIMATIONTYPE_VECTOR3:n instanceof oe?l=te.ANIMATIONTYPE_VECTOR2:n instanceof de?l=te.ANIMATIONTYPE_COLOR3:n instanceof H?l=te.ANIMATIONTYPE_COLOR4:n instanceof hi&&(l=te.ANIMATIONTYPE_SIZE),l==null)return null;const c=new te(e,t,i,l,o),u=[{frame:0,value:n},{frame:s,value:r}];return c.setKeys(u),h!==void 0&&c.setEasingFunction(h),c}static CreateAnimation(e,t,i,s){const n=new te(e+"Animation",e,i,t,te.ANIMATIONLOOPMODE_CONSTANT);return n.setEasingFunction(s),n}static CreateAndStartAnimation(e,t,i,s,n,r,o,h,l,c,u){const f=te._PrepareAnimation(e,i,s,n,r,o,h,l);return!f||(t.getScene&&(u=t.getScene()),!u)?null:u.beginDirectAnimation(t,[f],0,n,f.loopMode===1,1,c)}static CreateAndStartHierarchyAnimation(e,t,i,s,n,r,o,h,l,c,u){const f=te._PrepareAnimation(e,s,n,r,o,h,l,c);return f?t.getScene().beginDirectHierarchyAnimation(t,i,[f],0,r,f.loopMode===1,1,u):null}static CreateMergeAndStartAnimation(e,t,i,s,n,r,o,h,l,c){const u=te._PrepareAnimation(e,i,s,n,r,o,h,l);return u?(t.animations.push(u),t.getScene().beginAnimation(t,0,n,u.loopMode===1,1,c)):null}static MakeAnimationAdditive(e,t,i,s=!1,n){var b,I;let r;typeof t=="object"?r=t:r={referenceFrame:t!=null?t:0,range:i,cloneOriginalAnimation:s,clonedAnimationName:n};let o=e;if(r.cloneOriginalAnimation&&(o=e.clone(),o.name=r.clonedAnimationName||o.name),!o._keys.length)return o;const h=r.referenceFrame&&r.referenceFrame>=0?r.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:N.Vector3[0],referenceQuaternion:N.Quaternion[0],referenceScaling:N.Vector3[1],keyPosition:N.Vector3[2],keyQuaternion:N.Quaternion[1],keyScaling:N.Vector3[3]};let _=c.frame,p=f.frame;if(r.range){const T=o.getRange(r.range);T&&(_=T.from,p=T.to)}else _=(b=r.fromFrame)!=null?b:_,p=(I=r.toFrame)!=null?I:p;if(_!==c.frame&&(l=o.createKeyForFrame(_)),p!==f.frame&&(u=o.createKeyForFrame(p)),o._keys.length===1){const T=o._getKeyValue(o._keys[0]);d.referenceValue=T.clone?T.clone():T}else if(h<=c.frame){const T=o._getKeyValue(c.value);d.referenceValue=T.clone?T.clone():T}else if(h>=f.frame){const T=o._getKeyValue(f.value);d.referenceValue=T.clone?T.clone():T}else{Ii.key=0;const T=o._interpolate(h,Ii);d.referenceValue=T.clone?T.clone():T}o.dataType===te.ANIMATIONTYPE_QUATERNION?d.referenceValue.normalize().conjugateInPlace():o.dataType===te.ANIMATIONTYPE_MATRIX&&(d.referenceValue.decompose(d.referenceScaling,d.referenceQuaternion,d.referencePosition),d.referenceQuaternion.normalize().conjugateInPlace());let g=Number.MAX_VALUE;const m=r.clipKeys?[]:null;for(let T=l;T<=u;T++){let x=o._keys[T];if((m||r.cloneOriginalAnimation)&&(x={frame:x.frame,value:x.value.clone?x.value.clone():x.value,inTangent:x.inTangent,outTangent:x.outTangent,interpolation:x.interpolation,lockedTangent:x.lockedTangent},m&&(g===Number.MAX_VALUE&&(g=x.frame),x.frame-=g,m.push(x))),!(T&&o.dataType!==te.ANIMATIONTYPE_FLOAT&&x.value===c.value))switch(o.dataType){case te.ANIMATIONTYPE_MATRIX:x.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),O.ComposeToRef(d.keyScaling,d.keyQuaternion,d.keyPosition,x.value);break;case te.ANIMATIONTYPE_QUATERNION:d.referenceValue.multiplyToRef(x.value,x.value);break;case te.ANIMATIONTYPE_VECTOR2:case te.ANIMATIONTYPE_VECTOR3:case te.ANIMATIONTYPE_COLOR3:case te.ANIMATIONTYPE_COLOR4:x.value.subtractToRef(d.referenceValue,x.value);break;case te.ANIMATIONTYPE_SIZE:x.value.width-=d.referenceValue.width,x.value.height-=d.referenceValue.height;break;default:x.value-=d.referenceValue}}return m&&o.setKeys(m,!0),o}static TransitionTo(e,t,i,s,n,r,o,h=null){if(o<=0)return i[e]=t,h&&h(),null;const l=n*(o/1e3);r.setKeys([{frame:0,value:i[e].clone?i[e].clone():i[e]},{frame:l,value:t}]),i.animations||(i.animations=[]),i.animations.push(r);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,n,r){this.name=e,this.targetProperty=t,this.framePerSecond=i,this.dataType=s,this.loopMode=n,this.enableBlending=r,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=n===void 0?te.ANIMATIONLOOPMODE_CYCLE:n,this.uniqueId=te._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 qr(e,t,i))}deleteRange(e,t=!0){const i=this._ranges[e];if(i){if(t){const s=i.from,n=i.to;for(let r=this._keys.length-1;r>=0;r--)this._keys[r].frame>=s&&this._keys[r].frame<=n&&this._keys.splice(r,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 Rr(e,t,i)}floatInterpolateFunctionWithTangents(e,t,i,s,n){return Xd(e,t,i,s,n)}quaternionInterpolateFunction(e,t,i){return re.Slerp(e,t,i)}quaternionInterpolateFunctionWithTangents(e,t,i,s,n){return re.Hermite(e,t,i,s,n).normalize()}vector3InterpolateFunction(e,t,i){return v.Lerp(e,t,i)}vector3InterpolateFunctionWithTangents(e,t,i,s,n){return v.Hermite(e,t,i,s,n)}vector2InterpolateFunction(e,t,i){return oe.Lerp(e,t,i)}vector2InterpolateFunctionWithTangents(e,t,i,s,n){return oe.Hermite(e,t,i,s,n)}sizeInterpolateFunction(e,t,i){return hi.Lerp(e,t,i)}color3InterpolateFunction(e,t,i){return de.Lerp(e,t,i)}color3InterpolateFunctionWithTangents(e,t,i,s,n){return de.Hermite(e,t,i,s,n)}color4InterpolateFunction(e,t,i){return H.Lerp(e,t,i)}color4InterpolateFunctionWithTangents(e,t,i,s,n){return H.Hermite(e,t,i,s,n)}_getKeyValue(e){return typeof e=="function"?e():e}evaluate(e){return Ii.key=0,this._interpolate(e,Ii)}_interpolate(e,t,i=!1){var p;if(t.loopMode===te.ANIMATIONLOOPMODE_CONSTANT&&t.repeatCount>0)return t.highLimitValue.clone?t.highLimitValue.clone():t.highLimitValue;const s=this._keys,n=s.length;let r=t.key;for(;r>=0&&e<s[r].frame;)--r;for(;r+1<=n-1&&e>=s[r+1].frame;)++r;if(t.key=r,r<0)return i?void 0:this._getKeyValue(s[0].value);if(r+1>n-1)return i?void 0:this._getKeyValue(s[n-1].value);const o=s[r],h=s[r+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 _=o.easingFunction||this.getEasingFunction();switch(_!==null&&(d=_.ease(d)),this.dataType){case te.ANIMATIONTYPE_FLOAT:{const g=u?this.floatInterpolateFunctionWithTangents(l,o.outTangent*f,c,h.inTangent*f,d):this.floatInterpolateFunction(l,c,d);switch(t.loopMode){case te.ANIMATIONLOOPMODE_CYCLE:case te.ANIMATIONLOOPMODE_CONSTANT:case te.ANIMATIONLOOPMODE_YOYO:return g;case te.ANIMATIONLOOPMODE_RELATIVE:case te.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return((p=t.offsetValue)!=null?p:0)*t.repeatCount+g}break}case te.ANIMATIONTYPE_QUATERNION:{const g=u?this.quaternionInterpolateFunctionWithTangents(l,o.outTangent.scale(f),c,h.inTangent.scale(f),d):this.quaternionInterpolateFunction(l,c,d);switch(t.loopMode){case te.ANIMATIONLOOPMODE_CYCLE:case te.ANIMATIONLOOPMODE_CONSTANT:case te.ANIMATIONLOOPMODE_YOYO:return g;case te.ANIMATIONLOOPMODE_RELATIVE:case te.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return g.addInPlace((t.offsetValue||vg).scale(t.repeatCount))}return g}case te.ANIMATIONTYPE_VECTOR3:{const g=u?this.vector3InterpolateFunctionWithTangents(l,o.outTangent.scale(f),c,h.inTangent.scale(f),d):this.vector3InterpolateFunction(l,c,d);switch(t.loopMode){case te.ANIMATIONLOOPMODE_CYCLE:case te.ANIMATIONLOOPMODE_CONSTANT:case te.ANIMATIONLOOPMODE_YOYO:return g;case te.ANIMATIONLOOPMODE_RELATIVE:case te.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return g.add((t.offsetValue||bg).scale(t.repeatCount))}break}case te.ANIMATIONTYPE_VECTOR2:{const g=u?this.vector2InterpolateFunctionWithTangents(l,o.outTangent.scale(f),c,h.inTangent.scale(f),d):this.vector2InterpolateFunction(l,c,d);switch(t.loopMode){case te.ANIMATIONLOOPMODE_CYCLE:case te.ANIMATIONLOOPMODE_CONSTANT:case te.ANIMATIONLOOPMODE_YOYO:return g;case te.ANIMATIONLOOPMODE_RELATIVE:case te.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return g.add((t.offsetValue||xg).scale(t.repeatCount))}break}case te.ANIMATIONTYPE_SIZE:{switch(t.loopMode){case te.ANIMATIONLOOPMODE_CYCLE:case te.ANIMATIONLOOPMODE_CONSTANT:case te.ANIMATIONLOOPMODE_YOYO:return this.sizeInterpolateFunction(l,c,d);case te.ANIMATIONLOOPMODE_RELATIVE:case te.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return this.sizeInterpolateFunction(l,c,d).add((t.offsetValue||yg).scale(t.repeatCount))}break}case te.ANIMATIONTYPE_COLOR3:{const g=u?this.color3InterpolateFunctionWithTangents(l,o.outTangent.scale(f),c,h.inTangent.scale(f),d):this.color3InterpolateFunction(l,c,d);switch(t.loopMode){case te.ANIMATIONLOOPMODE_CYCLE:case te.ANIMATIONLOOPMODE_CONSTANT:case te.ANIMATIONLOOPMODE_YOYO:return g;case te.ANIMATIONLOOPMODE_RELATIVE:case te.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return g.add((t.offsetValue||Tg).scale(t.repeatCount))}break}case te.ANIMATIONTYPE_COLOR4:{const g=u?this.color4InterpolateFunctionWithTangents(l,o.outTangent.scale(f),c,h.inTangent.scale(f),d):this.color4InterpolateFunction(l,c,d);switch(t.loopMode){case te.ANIMATIONLOOPMODE_CYCLE:case te.ANIMATIONLOOPMODE_CONSTANT:case te.ANIMATIONLOOPMODE_YOYO:return g;case te.ANIMATIONLOOPMODE_RELATIVE:case te.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return g.add((t.offsetValue||Ag).scale(t.repeatCount))}break}case te.ANIMATIONTYPE_MATRIX:{switch(t.loopMode){case te.ANIMATIONLOOPMODE_CYCLE:case te.ANIMATIONLOOPMODE_CONSTANT:case te.ANIMATIONLOOPMODE_YOYO:return te.AllowMatricesInterpolation?this.matrixInterpolateFunction(l,c,d,t.workValue):l;case te.ANIMATIONLOOPMODE_RELATIVE:case te.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return l}break}}return 0}matrixInterpolateFunction(e,t,i,s){return te.AllowMatrixDecomposeForInterpolation?s?(O.DecomposeLerpToRef(e,t,i,s),s):O.DecomposeLerp(e,t,i):s?(O.LerpToRef(e,t,i,s),s):O.Lerp(e,t,i)}clone(){const e=new te(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){Ii.key=0;const t=this._interpolate(e,Ii,!0);if(!t)return this._keys[Ii.key].frame===e?Ii.key:Ii.key+1;const i={frame:e,value:t.clone?t.clone():t};return this._keys.splice(Ii.key+1,0,i),Ii.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 n=i[s],r={};switch(r.frame=n.frame,t){case te.ANIMATIONTYPE_FLOAT:r.values=[n.value],n.inTangent!==void 0&&r.values.push(n.inTangent),n.outTangent!==void 0&&(n.inTangent===void 0&&r.values.push(void 0),r.values.push(n.outTangent)),n.interpolation!==void 0&&(n.inTangent===void 0&&r.values.push(void 0),n.outTangent===void 0&&r.values.push(void 0),r.values.push(n.interpolation));break;case te.ANIMATIONTYPE_QUATERNION:case te.ANIMATIONTYPE_MATRIX:case te.ANIMATIONTYPE_VECTOR3:case te.ANIMATIONTYPE_COLOR3:case te.ANIMATIONTYPE_COLOR4:r.values=n.value.asArray(),n.inTangent!=null&&r.values.push(n.inTangent.asArray()),n.outTangent!=null&&(n.inTangent===void 0&&r.values.push(void 0),r.values.push(n.outTangent.asArray())),n.interpolation!==void 0&&(n.inTangent===void 0&&r.values.push(void 0),n.outTangent===void 0&&r.values.push(void 0),r.values.push(n.interpolation));break}e.keys.push(r)}e.ranges=[];for(const s in this._ranges){const n=this._ranges[s];if(!n)continue;const r={};r.name=s,r.from=n.from,r.to=n.to,e.ranges.push(r)}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 te(e.name,e.property,e.framePerSecond,e.dataType,e.loopBehavior),i=e.dataType,s=[];let n,r;for(e.enableBlending&&(t.enableBlending=e.enableBlending),e.blendingSpeed&&(t.blendingSpeed=e.blendingSpeed),r=0;r<e.keys.length;r++){const o=e.keys[r];let h,l,c;switch(i){case te.ANIMATIONTYPE_FLOAT:n=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 te.ANIMATIONTYPE_QUATERNION:if(n=re.FromArray(o.values),o.values.length>=8){const f=re.FromArray(o.values.slice(4,8));f.equals(re.Zero())||(h=f)}if(o.values.length>=12){const f=re.FromArray(o.values.slice(8,12));f.equals(re.Zero())||(l=f)}o.values.length>=13&&(c=o.values[12]);break;case te.ANIMATIONTYPE_MATRIX:n=O.FromArray(o.values),o.values.length>=17&&(c=o.values[16]);break;case te.ANIMATIONTYPE_COLOR3:n=de.FromArray(o.values),o.values[3]&&(h=de.FromArray(o.values[3])),o.values[4]&&(l=de.FromArray(o.values[4])),o.values[5]&&(c=o.values[5]);break;case te.ANIMATIONTYPE_COLOR4:n=H.FromArray(o.values),o.values[4]&&(h=H.FromArray(o.values[4])),o.values[5]&&(l=H.FromArray(o.values[5])),o.values[6]&&(c=H.FromArray(o.values[6]));break;case te.ANIMATIONTYPE_VECTOR3:default:n=v.FromArray(o.values),o.values[3]&&(h=v.FromArray(o.values[3])),o.values[4]&&(l=v.FromArray(o.values[4])),o.values[5]&&(c=o.values[5]);break}const u={};u.frame=o.frame,u.value=n,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(r=0;r<e.ranges.length;r++)n=e.ranges[r],t.createRange(n.name,n.from,n.to);return t}static AppendSerializedAnimations(e,t){Ae.AppendSerializedAnimations(e,t)}static ParseFromFileAsync(e,t){return new Promise((i,s)=>{const n=new Ft;n.addEventListener("readystatechange",()=>{if(n.readyState==4)if(n.status==200){let r=JSON.parse(n.responseText);if(r.animations&&(r=r.animations),r.length){const o=[];for(const h of r)o.push(this.Parse(h));i(o)}else{const o=this.Parse(r);e&&(o.name=e),i(o)}}else s("Unable to load the animation")}),n.open("GET",t),n.send()})}static ParseFromSnippetAsync(e){return new Promise((t,i)=>{const s=new Ft;s.addEventListener("readystatechange",()=>{if(s.readyState==4)if(s.status==200){const n=JSON.parse(JSON.parse(s.responseText).jsonPayload);if(n.animations){const r=JSON.parse(n.animations),o=[];for(const h of r.animations){const l=this.Parse(h);l.snippetId=e,o.push(l)}t(o)}else{const r=JSON.parse(n.animation),o=this.Parse(r);o.snippetId=e,t(o)}}else i("Unable to load the snippet "+e)}),s.open("GET",this.SnippetUrl+"/"+e.replace(/#/g,"/")),s.send()})}}te._UniqueIdGenerator=0;te.AllowMatricesInterpolation=!1;te.AllowMatrixDecomposeForInterpolation=!0;te.SnippetUrl="https://snippet.babylonjs.com";te.ANIMATIONTYPE_FLOAT=0;te.ANIMATIONTYPE_VECTOR3=1;te.ANIMATIONTYPE_QUATERNION=2;te.ANIMATIONTYPE_MATRIX=3;te.ANIMATIONTYPE_COLOR3=4;te.ANIMATIONTYPE_COLOR4=7;te.ANIMATIONTYPE_VECTOR2=5;te.ANIMATIONTYPE_SIZE=6;te.ANIMATIONLOOPMODE_RELATIVE=0;te.ANIMATIONLOOPMODE_CYCLE=1;te.ANIMATIONLOOPMODE_CONSTANT=2;te.ANIMATIONLOOPMODE_YOYO=4;te.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT=5;te.CreateFromSnippetAsync=te.ParseFromSnippetAsync;vt("BABYLON.Animation",te);bt._AnimationRangeFactory=(a,e,t)=>new qr(a,e,t);class Ns{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||(Ns.EasingFunction.setEasingMode(Ns.EasingMode),this._radiusBounceTransition=te.CreateAnimation("radius",te.ANIMATIONTYPE_FLOAT,60,Ns.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;const t=te.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()}}Ns.EasingFunction=new gg(.3);Ns.EasingMode=wi.EASINGMODE_EASEOUT;class jt{constructor(){this.onTargetFramingAnimationEndObservable=new Z,this._mode=jt.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();jt.EasingFunction.setEasingMode(jt.EasingMode),this._onPrePointerObservableObserver=t.onPrePointerObservable.add(i=>{if(i.type===Ce.POINTERDOWN){this._isPointerDown=!0;return}i.type===Ce.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 v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),n=new v(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(let r=0;r<e.length;r++){const o=e[r].getHierarchyBoundingVectors(!0);v.CheckExtends(o.min,s,n),v.CheckExtends(o.max,s,n)}this.zoomOnBoundingInfo(s,n,t,i)}zoomOnBoundingInfo(e,t,i=!1,s=null){let n;if(!this._attachedCamera)return!1;const r=e.y,o=t.y,h=r+(o-r)*this._positionScale,l=t.subtract(e).scale(.5);if(i)n=new v(0,h,0);else{const f=e.add(l);n=new v(f.x,h,f.z)}this._vectorTransition||(this._vectorTransition=te.CreateAnimation("target",te.ANIMATIONTYPE_VECTOR3,60,jt.EasingFunction)),this._betaIsAnimating=!0;let c=te.TransitionTo("target",n,this._attachedCamera,this._attachedCamera.getScene(),60,this._vectorTransition,this._framingTime);c&&this._animatables.push(c);let u=0;if(this._mode===jt.FitFrustumSidesMode){const f=this._calculateLowerRadiusFromModelBoundingSphere(e,t);this.autoCorrectCameraLimitsAndSensibility&&(this._attachedCamera.lowerRadiusLimit=l.length()+this._attachedCamera.minZ),u=f}else this._mode===jt.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=te.CreateAnimation("radius",te.ANIMATIONTYPE_FLOAT,60,jt.EasingFunction)),c=te.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===jt.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=bi.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=te.CreateAnimation("beta",te.ANIMATIONTYPE_FLOAT,60,jt.EasingFunction));const s=te.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=bi.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}}jt.EasingFunction=new mg;jt.EasingMode=wi.EASINGMODE_EASEINOUT;jt.IgnoreBoundsSizeMode=0;jt.FitFrustumSidesMode=1;bt.AddNodeConstructor("TargetCamera",(a,e)=>()=>new wt(a,v.Zero(),e));class wt extends ve{constructor(e,t,i,s=!0){super(e,t,i,s),this._tmpUpVector=v.Zero(),this._tmpTargetVector=v.Zero(),this.cameraDirection=new v(0,0,0),this.cameraRotation=new oe(0,0),this.ignoreParentScaling=!1,this.updateUpVectorFromRotation=!1,this._tmpQuaternion=new re,this.rotation=new v(0,0,0),this.speed=2,this.noRotationConstraint=!1,this.invertRotation=!1,this.inverseRotationSpeed=.2,this.lockedTarget=null,this._currentTarget=v.Zero(),this._initialFocalDistance=1,this._viewMatrix=O.Zero(),this._camMatrix=O.Zero(),this._cameraTransformMatrix=O.Zero(),this._cameraRotationMatrix=O.Zero(),this._referencePoint=new v(0,0,1),this._transformedReferencePoint=v.Zero(),this._deferredPositionUpdate=new v,this._deferredRotationQuaternionUpdate=new re,this._deferredRotationUpdate=new v,this._deferredUpdated=!1,this._deferOnly=!1,this._defaultUp=v.Up(),this._cachedRotationZ=0,this._cachedQuaternionRotationZ=0}getFrontPosition(e){this.getWorldMatrix();const t=this.getTarget().subtract(this.position);return t.normalize(),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 v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new re(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+=Le),this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),O.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&&re.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(N.Matrix[0]),v.TransformNormalToRef(this.cameraDirection,N.Matrix[0],N.Vector3[0]),this._deferredPositionUpdate.addInPlace(N.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()&&(re.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*Le&&(this.cameraDirection.x=0),Math.abs(this.cameraDirection.y)<this.speed*Le&&(this.cameraDirection.y=0),Math.abs(this.cameraDirection.z)<this.speed*Le&&(this.cameraDirection.z=0),this.cameraDirection.scaleInPlace(this.inertia)),i&&(Math.abs(this.cameraRotation.x)<this.speed*Le&&(this.cameraRotation.x=0),Math.abs(this.cameraRotation.y)<this.speed*Le&&(this.cameraRotation.y=0),this.cameraRotation.scaleInPlace(this.inertia)),super._checkInputs()}_updateCameraRotationMatrix(){this.rotationQuaternion?this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix):O.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix)}_rotateUpVectorWithCameraRotationMatrix(){return v.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),v.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget),this.updateUpVectorFromRotation&&(this.rotationQuaternion?Gt.Y.rotateByQuaternionToRef(this.rotationQuaternion,this.upVector):(re.FromEulerVectorToRef(this.rotation,this._tmpQuaternion),Gt.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();v.TransformCoordinatesToRef(e,s,this._globalPosition),v.TransformCoordinatesToRef(t,s,this._tmpTargetVector),v.TransformNormalToRef(i,s,this._tmpUpVector),this._markSyncedWithParent()}else this._globalPosition.copyFrom(e),this._tmpTargetVector.copyFrom(t),this._tmpUpVector.copyFrom(i);this.getScene().useRightHandedSystem?O.LookAtRHToRef(this._globalPosition,this._tmpTargetVector,this._tmpUpVector,this._viewMatrix):O.LookAtLHToRef(this._globalPosition,this._tmpTargetVector,this._tmpUpVector,this._viewMatrix);return}if(this.getScene().useRightHandedSystem?O.LookAtRHToRef(e,t,i,this._viewMatrix):O.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!==ve.RIG_MODE_NONE){const i=new wt(e,this.position.clone(),this.getScene());return i.isRigCamera=!0,i.rigParent=this,this.cameraRigMode===ve.RIG_MODE_VR&&(this.rotationQuaternion||(this.rotationQuaternion=new re),i._cameraRigParams={},i.rotationQuaternion=new re),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 ve.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case ve.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case ve.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case ve.RIG_MODE_STEREOSCOPIC_OVERUNDER:case ve.RIG_MODE_STEREOSCOPIC_INTERLACED:{const i=this.cameraRigMode===ve.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?1:-1,s=this.cameraRigMode===ve.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?-1:1;this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*i,e),this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*s,t);break}case ve.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,wt._TargetFocalPoint),wt._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);const s=wt._TargetFocalPoint.addInPlace(this.position);O.TranslationToRef(-s.x,-s.y,-s.z,wt._TargetTransformMatrix),wt._TargetTransformMatrix.multiplyToRef(O.RotationAxis(t.upVector,e),wt._RigCamTransformMatrix),O.TranslationToRef(s.x,s.y,s.z,wt._TargetTransformMatrix),wt._RigCamTransformMatrix.multiplyToRef(wt._TargetTransformMatrix,wt._RigCamTransformMatrix),v.TransformCoordinatesToRef(this.position,wt._RigCamTransformMatrix,t.position),t.setTarget(s)}getClassName(){return"TargetCamera"}}wt._RigCamTransformMatrix=new O;wt._TargetTransformMatrix=new O;wt._TargetFocalPoint=new v;D([yi()],wt.prototype,"rotation",void 0);D([B()],wt.prototype,"speed",void 0);D([ic("lockedTargetId")],wt.prototype,"lockedTarget",void 0);var Un={};class Rg{constructor(e){this.attachedToElement=!1,this.attached={},this.camera=e,this.checkInputs=()=>{}}add(e){const t=e.getSimpleName();if(this.attached[t]){U.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=ve.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],n=Ae.Serialize(s);t[s.getClassName()]=n}e.inputsmgr=t}parse(e){const t=e.inputsmgr;if(t){this.clear();for(const i in t){const s=Un[i];if(s){const n=t[i],r=Ae.Parse(()=>new s,n,null);this.add(r)}}}else for(const i in this.attached){const s=Un[this.attached[i].getClassName()];if(s){const n=Ae.Parse(()=>new s,e,null);this.remove(this.attached[i]),this.add(n)}}}}class kc{constructor(){this._currentActiveButton=-1,this.buttons=[0,1,2]}attachControl(e){e=J.BackCompatCameraNoPreventDefault(arguments);const t=this.camera.getEngine(),i=t.getInputElement();let s=0,n=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=>{var u,f;const h=o.event,l=h.pointerType==="touch";if(o.type!==Ce.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 d=h.movementX,_=h.movementY;this.onTouch(null,d,_),this._pointA=null,this._pointB=null}else{if(o.type!==Ce.POINTERDOWN&&o.type!==Ce.POINTERDOUBLETAP&&l&&((u=this._pointA)==null?void 0:u.pointerId)!==h.pointerId&&((f=this._pointB)==null?void 0:f.pointerId)!==h.pointerId)return;if(o.type===Ce.POINTERDOWN&&(this._currentActiveButton===-1||l)){try{c==null||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._currentActiveButton===-1&&!l&&(this._currentActiveButton=h.button),this.onButtonDown(h),e||(h.preventDefault(),i&&i.focus())}else if(o.type===Ce.POINTERDOUBLETAP)this.onDoubleTap(h.pointerType);else if(o.type===Ce.POINTERUP&&(this._currentActiveButton===h.button||l)){try{c==null||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||n)&&(this.onMultiTouch(this._pointA,this._pointB,s,0,n,null),s=0,n=null),this._currentActiveButton=-1,this.onButtonUp(h),e||h.preventDefault()}else if(o.type===Ce.POINTERMOVE){if(e||h.preventDefault(),this._pointA&&this._pointB===null){const d=h.clientX-this._pointA.x,_=h.clientY-this._pointA.y;this._pointA.x=h.clientX,this._pointA.y=h.clientY,this.onTouch(this._pointA,d,_)}else if(this._pointA&&this._pointB){const d=this._pointA.pointerId===h.pointerId?this._pointA:this._pointB;d.x=h.clientX,d.y=h.clientY;const _=this._pointA.x-this._pointB.x,p=this._pointA.y-this._pointB.y,g=_*_+p*p,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,n,m),n=m,s=g}}}},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,Ce.POINTERDOWN|Ce.POINTERUP|Ce.POINTERMOVE|Ce.POINTERDOUBLETAP),this._onLostFocus=()=>{this._pointA=this._pointB=null,s=0,n=null,this.onLostFocus()},this._contextMenuBind=o=>this.onContextMenu(o),i&&i.addEventListener("contextmenu",this._contextMenuBind,!1);const r=this.camera.getScene().getEngine().getHostWindow();r&&J.RegisterTopRootEvents(r,[{name:"blur",handler:this._onLostFocus}])}detachControl(){if(this._onLostFocus){const e=this.camera.getScene().getEngine().getHostWindow();e&&J.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._currentActiveButton=-1}getClassName(){return"BaseCameraPointersInput"}getSimpleName(){return"pointers"}onDoubleTap(e){}onTouch(e,t,i){}onMultiTouch(e,t,i,s,n,r){}onContextMenu(e){e.preventDefault()}onButtonDown(e){}onButtonUp(e){}onLostFocus(){}}D([B()],kc.prototype,"buttons",void 0);class Qt extends kc{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||Qt.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,n,r){i===0&&n===null||s===0&&r===null||(this.multiTouchPanAndZoom?(this._computePinchZoom(i,s),this._computeMultiTouchPanning(n,r)):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(n,r)):this.multiTouchPanning?this._computeMultiTouchPanning(n,r):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}}Qt.MinimumRadiusForPinch=.001;D([B()],Qt.prototype,"buttons",void 0);D([B()],Qt.prototype,"angularSensibilityX",void 0);D([B()],Qt.prototype,"angularSensibilityY",void 0);D([B()],Qt.prototype,"pinchPrecision",void 0);D([B()],Qt.prototype,"pinchDeltaPercentage",void 0);D([B()],Qt.prototype,"useNaturalPinchZoom",void 0);D([B()],Qt.prototype,"pinchZoom",void 0);D([B()],Qt.prototype,"panningSensibility",void 0);D([B()],Qt.prototype,"multiTouchPanning",void 0);D([B()],Qt.prototype,"multiTouchPanAndZoom",void 0);Un.ArcRotateCameraPointersInput=Qt;class Fi{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=J.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===Nn.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"}}D([B()],Fi.prototype,"keysUp",void 0);D([B()],Fi.prototype,"keysDown",void 0);D([B()],Fi.prototype,"keysLeft",void 0);D([B()],Fi.prototype,"keysRight",void 0);D([B()],Fi.prototype,"keysReset",void 0);D([B()],Fi.prototype,"panningSensibility",void 0);D([B()],Fi.prototype,"zoomingSensibility",void 0);D([B()],Fi.prototype,"useAltToZoom",void 0);D([B()],Fi.prototype,"angularSpeed",void 0);Un.ArcRotateCameraKeyboardMoveInput=Fi;const Ig=40;class $n{constructor(){this.wheelPrecision=3,this.zoomToMouseLocation=!1,this.wheelDeltaPercentage=0,this.customComputeDeltaFromMouseWheel=null,this._viewOffset=new v(0,0,0),this._globalOffset=new v(0,0,0),this._inertialPanning=v.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=J.BackCompatCameraNoPreventDefault(arguments),this._wheel=t=>{if(t.type!==Ce.POINTERWHEEL)return;const i=t.event;let s=0;const n=i.deltaMode===jn.DOM_DELTA_LINE?Ig:1,r=-(i.deltaY*n);if(this.customComputeDeltaFromMouseWheel)s=this.customComputeDeltaFromMouseWheel(r,this,i);else if(this.wheelDeltaPercentage){if(s=this._computeDeltaFromMouseWheelLegacyEvent(r,this.camera.radius),s>0){let o=this.camera.radius,h=this.camera.inertialRadiusOffset+s;for(let l=0;l<20&&Math.abs(h)>.001;l++)o-=h,h*=this.camera.inertia;o=ht(o,0,Number.MAX_VALUE),s=this._computeDeltaFromMouseWheelLegacyEvent(r,o)}}else s=r/(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,Ce.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=Xt.FromPositionAndNormal(e.target,t)}_getPosition(){var n;const e=this.camera,t=e.getScene(),i=t.createPickingRay(t.pointerX,t.pointerY,O.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=v.TransformNormal(this._viewOffset,e._cameraTransformMatrix),i.origin.addInPlace(this._globalOffset));let s=0;return this._hitPlane&&(s=(n=i.intersectsPlane(this._hitPlane))!=null?n:0),i.origin.addInPlace(i.direction.scaleInPlace(s))}_zoomToMouse(e){var h,l;const t=this.camera,i=1-t.inertia;if(t.lowerRadiusLimit){const c=(h=t.lowerRadiusLimit)!=null?h:0;t.radius-(t.inertialRadiusOffset+e)/i<c&&(e=(t.radius-c)*i-t.inertialRadiusOffset)}if(t.upperRadiusLimit){const c=(l=t.upperRadiusLimit)!=null?l:0;t.radius-(t.inertialRadiusOffset+e)/i>c&&(e=(t.radius-c)*i-t.inertialRadiusOffset)}const n=e/i/t.radius,r=this._getPosition(),o=N.Vector3[6];r.subtractToRef(t.target,o),o.scaleInPlace(n),o.scaleInPlace(i),this._inertialPanning.addInPlace(o),t.inertialRadiusOffset+=e}_zeroIfClose(e){Math.abs(e.x)<Le&&(e.x=0),Math.abs(e.y)<Le&&(e.y=0),Math.abs(e.z)<Le&&(e.z=0)}}D([B()],$n.prototype,"wheelPrecision",void 0);D([B()],$n.prototype,"zoomToMouseLocation",void 0);D([B()],$n.prototype,"wheelDeltaPercentage",void 0);Un.ArcRotateCameraMouseWheelInput=$n;class Eg extends Rg{constructor(e){super(e)}addMouseWheel(){return this.add(new $n),this}addPointers(){return this.add(new Qt),this}addKeyboard(){return this.add(new Fi),this}}bt.AddNodeConstructor("ArcRotateCamera",(a,e)=>()=>new tt(a,0,0,1,v.Zero(),e));class tt extends wt{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 O,this._upToYMatrix=new O,this._upVector=v.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()}get upVector(){return this._upVector}setMatUp(){O.RotationAlignToRef(v.UpReadOnly,this._upVector,this._yToUpMatrix),O.RotationAlignToRef(this._upVector,v.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 bouncingBehavior(){return this._bouncingBehavior}get useBouncingBehavior(){return this._bouncingBehavior!=null}set useBouncingBehavior(e){e!==this.useBouncingBehavior&&(e?(this._bouncingBehavior=new Ns,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 jt,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 pg,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))}constructor(e,t,i,s,n,r,o=!0){super(e,v.Zero(),r,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.inertialPanningX=0,this.inertialPanningY=0,this.pinchToPanMaxDistance=20,this.panningDistanceLimit=null,this.panningOriginTarget=v.Zero(),this.panningInertia=.9,this.zoomOnFactor=1,this.targetScreenOffset=oe.Zero(),this.allowUpsideDown=!0,this.useInputToRestoreState=!0,this.restoreStateInterpolationFactor=0,this._viewMatrix=new O,this.panningAxis=new v(1,1,0),this._transformedDirection=new v,this.mapPanning=!1,this._progressiveRestore=!1,this.onMeshTargetChangedObservable=new Z,this.checkCollisions=!1,this.collisionRadius=new v(.5,.5,.5),this._previousPosition=v.Zero(),this._collisionVelocity=v.Zero(),this._newPosition=v.Zero(),this._computationVector=v.Zero(),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 _=Math.sin(this.beta);_===0&&(_=1e-4);const p=this._getTargetPosition();this._computationVector.copyFromFloats(this.radius*u*_,this.radius*d,this.radius*f*_),p.addToRef(this._computationVector,this._newPosition),this._position.copyFrom(this._newPosition);let g=this.upVector;this.allowUpsideDown&&this.beta<0&&(g=g.clone(),g=g.negate()),this._computeViewMatrix(this._position,p,g),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y),this._collisionTriggered=!1},this._target=v.Zero(),n&&this.setTarget(n),this.alpha=t,this.beta=i,this.radius=s,this.getViewMatrix(),this.inputs=new Eg(this),this.inputs.addKeyboard().addMouseWheel().addPointers()}_initCache(){super._initCache(),this._cache._target=new v(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=oe.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._goalAlpha=this.alpha,this._storedBeta=this._goalBeta=this.beta,this._storedRadius=this._goalRadius=this.radius,this._storedTarget=this._goalTarget=this._getTargetPosition().clone(),this._storedTargetScreenOffset=this._goalTargetScreenOffset=this.targetScreenOffset.clone(),super.storeState()}_restoreStateValues(){return this.hasStateStored()&&this.restoreStateInterpolationFactor>Le&&this.restoreStateInterpolationFactor<1?(this.interpolateTo(this._storedAlpha,this._storedBeta,this._storedRadius,this._storedTarget,this._storedTargetScreenOffset),!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}interpolateTo(e=this.alpha,t=this.beta,i=this.radius,s=this.target,n=this.targetScreenOffset){var r,o,h,l,c,u;this._progressiveRestore=!0,this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,e=ht(e,(r=this.lowerAlphaLimit)!=null?r:-1/0,(o=this.upperAlphaLimit)!=null?o:1/0),t=ht(t,(h=this.lowerBetaLimit)!=null?h:-1/0,(l=this.upperBetaLimit)!=null?l:1/0),i=ht(i,(c=this.lowerRadiusLimit)!=null?c:-1/0,(u=this.upperRadiusLimit)!=null?u:1/0),this._goalAlpha=e,this._goalBeta=t,this._goalRadius=i,this._goalTarget=s,this._goalTargetScreenOffset=n}_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 n=arguments;t=J.BackCompatCameraNoPreventDefault(n),this._useCtrlForPanning=i,this._panningMouseButton=s,typeof n[0]=="boolean"&&(n.length>1&&(this._useCtrlForPanning=n[1]),n.length>2&&(this._panningMouseButton=n[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){if(this.inputs.checkInputs(),this._progressiveRestore){const e=this._scene.getEngine().getDeltaTime()/1e3,t=1-Math.pow(2,-e/this.restoreStateInterpolationFactor);this.setTarget(v.Lerp(this.getTarget(),this._goalTarget,t)),re.RotationAlphaBetaGammaToRef(this._goalAlpha,this._goalBeta,0,N.Quaternion[0]),re.RotationAlphaBetaGammaToRef(this.alpha,this.beta,0,N.Quaternion[1]),re.SlerpToRef(N.Quaternion[1],N.Quaternion[0],t,N.Quaternion[2]),N.Quaternion[2].normalize(),N.Quaternion[2].toAlphaBetaGammaToRef(N.Vector3[0]),this.alpha=N.Vector3[0].x,this.beta=N.Vector3[0].y,this.radius+=(this._goalRadius-this.radius)*t,oe.LerpToRef(this.targetScreenOffset,this._goalTargetScreenOffset,t,this.targetScreenOffset),(v.DistanceSquared(this.getTarget(),this._goalTarget)<Le&&N.Quaternion[2].equalsWithEpsilon(N.Quaternion[0])&&Math.pow(this._goalRadius-this.radius,2)<Le&&oe.Distance(this.targetScreenOffset,this._goalTargetScreenOffset)<Le||this.inertialAlphaOffset!==0||this.inertialBetaOffset!==0||this.inertialRadiusOffset!==0||this.inertialPanningX!==0||this.inertialPanningY!==0)&&(this._progressiveRestore=!1)}if(this.inertialAlphaOffset!==0||this.inertialBetaOffset!==0||this.inertialRadiusOffset!==0){const e=this.invertRotation?-1:1,t=this._calculateHandednessMultiplier();let i=this.inertialAlphaOffset*t;this.beta<0&&(i*=-1),this.alpha+=i*e,this.beta+=this.inertialBetaOffset*e,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)<Le&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<Le&&(this.inertialBetaOffset=0),Math.abs(this.inertialRadiusOffset)<this.speed*Le&&(this.inertialRadiusOffset=0)}if(this.inertialPanningX!==0||this.inertialPanningY!==0){const e=new v(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY);if(this._viewMatrix.invertToRef(this._cameraTransformMatrix),e.multiplyInPlace(this.panningAxis),v.TransformNormalToRef(e,this._cameraTransformMatrix,this._transformedDirection),this.mapPanning){const t=this.upVector,i=v.CrossToRef(this._transformedDirection,t,this._transformedDirection);v.CrossToRef(t,i,this._transformedDirection)}else this.panningAxis.y||(this._transformedDirection.y=0);if(!this._targetHost)if(this.panningDistanceLimit)this._transformedDirection.addInPlace(this._target),v.DistanceSquared(this._transformedDirection,this.panningOriginTarget)<=this.panningDistanceLimit*this.panningDistanceLimit&&this._target.copyFrom(this._transformedDirection);else{if(this.parent){const t=N.Matrix[0];this.parent.getWorldMatrix().getRotationMatrixToRef(t),t.transposeToRef(t),v.TransformCoordinatesToRef(this._transformedDirection,t,this._transformedDirection)}this._target.addInPlace(this._transformedDirection)}this.inertialPanningX*=this.panningInertia,this.inertialPanningY*=this.panningInertia,Math.abs(this.inertialPanningX)<this.speed*Le&&(this.inertialPanningX=0),Math.abs(this.inertialPanningY)<this.speed*Le&&(this.inertialPanningY=0)}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)}rebuildAnglesAndRadius(){this._position.subtractToRef(this._getTargetPosition(),this._computationVector),(this._upVector.x!==0||this._upVector.y!==1||this._upVector.z!==0)&&v.TransformCoordinatesToRef(this._computationVector,this._upToYMatrix,this._computationVector),this.radius=this._computationVector.length(),this.radius===0&&(this.radius=1e-4);const e=this.alpha;this._computationVector.x===0&&this._computationVector.z===0?this.alpha=Math.PI/2:this.alpha=Math.acos(this._computationVector.x/Math.sqrt(Math.pow(this._computationVector.x,2)+Math.pow(this._computationVector.z,2))),this._computationVector.z<0&&(this.alpha=2*Math.PI-this.alpha);const t=Math.round((e-this.alpha)/(2*Math.PI));this.alpha+=t*2*Math.PI,this.beta=Math.acos(this._computationVector.y/this.radius),this._checkLimits()}setPosition(e){this._position.equals(e)||(this._position.copyFrom(e),this.rebuildAnglesAndRadius())}setTarget(e,t=!1,i=!1,s=!1){var n;if(s=(n=this.overrideCloneAlphaBetaRadius)!=null?n: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,o=this._getTargetPosition();if(o&&!i&&o.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 n=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)&&v.TransformCoordinatesToRef(this._computationVector,this._yToUpMatrix,this._computationVector),n.addToRef(this._computationVector,this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions){const r=this.getScene().collisionCoordinator;this._collider||(this._collider=r.createCollider()),this._collider._radius=this.collisionRadius,this._newPosition.subtractToRef(this._position,this._collisionVelocity),this._collisionTriggered=!0,r.getNewPosition(this._position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}else{this._position.copyFrom(this._newPosition);let r=this.upVector;this.allowUpsideDown&&s<0&&(r=r.negate()),this._computeViewMatrix(this._position,n,r),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y)}return this._currentTarget=n,this._viewMatrix}zoomOn(e,t=!1){e=e||this.getScene().meshes;const i=F.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 n=e||this.getScene().meshes;i=F.MinMax(n),s=v.Distance(i.min,i.max)}else{const n=e;i=n,s=n.distance}this._target=F.Center(i),t||(this.maxZ=s*2)}createRigCamera(e,t){let i=0;switch(this.cameraRigMode){case ve.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case ve.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case ve.RIG_MODE_STEREOSCOPIC_OVERUNDER:case ve.RIG_MODE_STEREOSCOPIC_INTERLACED:case ve.RIG_MODE_VR:i=this._cameraRigParams.stereoHalfAngle*(t===0?1:-1);break;case ve.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:i=this._cameraRigParams.stereoHalfAngle*(t===0?-1:1);break}const s=new tt(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 ve.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case ve.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case ve.RIG_MODE_STEREOSCOPIC_OVERUNDER:case ve.RIG_MODE_STEREOSCOPIC_INTERLACED:case ve.RIG_MODE_VR:e.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,t.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case ve.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=v.Distance(e,t),r=this.getScene().getEngine().getAspectRatio(this),o=Math.tan(this.fov/2),h=o*r,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"}}D([B()],tt.prototype,"alpha",void 0);D([B()],tt.prototype,"beta",void 0);D([B()],tt.prototype,"radius",void 0);D([B()],tt.prototype,"overrideCloneAlphaBetaRadius",void 0);D([yi("target")],tt.prototype,"_target",void 0);D([ic("targetHost")],tt.prototype,"_targetHost",void 0);D([B()],tt.prototype,"inertialAlphaOffset",void 0);D([B()],tt.prototype,"inertialBetaOffset",void 0);D([B()],tt.prototype,"inertialRadiusOffset",void 0);D([B()],tt.prototype,"lowerAlphaLimit",void 0);D([B()],tt.prototype,"upperAlphaLimit",void 0);D([B()],tt.prototype,"lowerBetaLimit",void 0);D([B()],tt.prototype,"upperBetaLimit",void 0);D([B()],tt.prototype,"lowerRadiusLimit",void 0);D([B()],tt.prototype,"upperRadiusLimit",void 0);D([B()],tt.prototype,"inertialPanningX",void 0);D([B()],tt.prototype,"inertialPanningY",void 0);D([B()],tt.prototype,"pinchToPanMaxDistance",void 0);D([B()],tt.prototype,"panningDistanceLimit",void 0);D([yi()],tt.prototype,"panningOriginTarget",void 0);D([B()],tt.prototype,"panningInertia",void 0);D([B()],tt.prototype,"zoomToMouseLocation",null);D([B()],tt.prototype,"zoomOnFactor",void 0);D([tc()],tt.prototype,"targetScreenOffset",void 0);D([B()],tt.prototype,"allowUpsideDown",void 0);D([B()],tt.prototype,"useInputToRestoreState",void 0);D([B()],tt.prototype,"restoreStateInterpolationFactor",void 0);vt("BABYLON.ArcRotateCamera",tt);class Fe extends bt{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 de(1,1,1),this.specular=new de(1,1,1),this.falloffType=Fe.FALLOFF_DEFAULT,this.intensity=1,this._range=Number.MAX_VALUE,this._inverseSquaredRange=0,this._photometricScale=1,this._intensityMode=Fe.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 fe(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,n=!0){var h;const r=e.toString();let o=!1;if(this._uniformBuffer.bindToEffect(i,"Light"+r),this._renderId!==t.getRenderId()||this._lastUseSpecular!==s||!this._uniformBuffer.useUbo){this._renderId=t.getRenderId(),this._lastUseSpecular=s;const l=this.getScaledIntensity();this.transferToEffect(i,r),this.diffuse.scaleToRef(l,Js.Color3[0]),this._uniformBuffer.updateColor4("vLightDiffuse",Js.Color3[0],this.range,r),s&&(this.specular.scaleToRef(l,Js.Color3[1]),this._uniformBuffer.updateColor4("vLightSpecular",Js.Color3[1],this.radius,r)),o=!0}if(this.transferTexturesToEffect(i,r),t.shadowsEnabled&&this.shadowEnabled&&n){const l=(h=this.getShadowGenerator(t.activeCamera))!=null?h:this.getShadowGenerator();l&&(l.bindShadowLight(r,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){var t;return this._shadowGenerators===null?null:(t=this._shadowGenerators.get(e))!=null?t:null}getShadowGenerators(){return this._shadowGenerators}getAbsolutePosition(){return v.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=Fe.GetConstructorFromName(this.getTypeID(),e,this.getScene());if(!i)return null;const s=Ae.Clone(i,this);return e&&(s.name=e),t&&(s.parent=t),s.setEnabled(this.isEnabled()),this.onClonedObservable.notifyObservers(s),s}serialize(){const e=Ae.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)})),Ae.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.isEnabled=this.isEnabled(),e}static GetConstructorFromName(e,t,i){const s=bt.Construct("Light_Type_"+e,t,i);return s||null}static Parse(e,t){const i=Fe.GetConstructorFromName(e.type,e.name,t);if(!i)return null;const s=Ae.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 n=0;n<e.animations.length;n++){const r=e.animations[n],o=ys("BABYLON.Animation");o&&s.animations.push(o.Parse(r))}bt.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 n=t.apply(e,s);for(const r of s)r._resyncLightSource(this);return n};const i=e.splice;e.splice=(s,n)=>{const r=i.apply(e,[s,n]);for(const o of r)o._resyncLightSource(this);return r};for(const s of e)s._resyncLightSource(this)}_hookArrayForIncludedOnly(e){const t=e.push;e.push=(...s)=>{const n=t.apply(e,s);return this._resyncMeshes(),n};const i=e.splice;e.splice=(s,n)=>{const r=i.apply(e,[s,n]);return this._resyncMeshes(),r},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===Fe.INTENSITYMODE_AUTOMATIC&&(t===Fe.LIGHTTYPEID_DIRECTIONALLIGHT?i=Fe.INTENSITYMODE_ILLUMINANCE:i=Fe.INTENSITYMODE_LUMINOUSINTENSITY),t){case Fe.LIGHTTYPEID_POINTLIGHT:case Fe.LIGHTTYPEID_SPOTLIGHT:switch(i){case Fe.INTENSITYMODE_LUMINOUSPOWER:e=1/(4*Math.PI);break;case Fe.INTENSITYMODE_LUMINOUSINTENSITY:e=1;break;case Fe.INTENSITYMODE_LUMINANCE:e=this.radius*this.radius;break}break;case Fe.LIGHTTYPEID_DIRECTIONALLIGHT:switch(i){case Fe.INTENSITYMODE_ILLUMINANCE:e=1;break;case Fe.INTENSITYMODE_LUMINANCE:{let s=this.radius;s=Math.max(s,.001),e=2*Math.PI*(1-Math.cos(s));break}}break;case Fe.LIGHTTYPEID_HEMISPHERICLIGHT:e=1;break}return e}_reorderLightsInScene(){const e=this.getScene();this._renderPriority!=0&&(e.requireLightSorting=!0),this.getScene().sortLightsByPriority()}}Fe.FALLOFF_DEFAULT=Xe.FALLOFF_DEFAULT;Fe.FALLOFF_PHYSICAL=Xe.FALLOFF_PHYSICAL;Fe.FALLOFF_GLTF=Xe.FALLOFF_GLTF;Fe.FALLOFF_STANDARD=Xe.FALLOFF_STANDARD;Fe.LIGHTMAP_DEFAULT=Xe.LIGHTMAP_DEFAULT;Fe.LIGHTMAP_SPECULAR=Xe.LIGHTMAP_SPECULAR;Fe.LIGHTMAP_SHADOWSONLY=Xe.LIGHTMAP_SHADOWSONLY;Fe.INTENSITYMODE_AUTOMATIC=Xe.INTENSITYMODE_AUTOMATIC;Fe.INTENSITYMODE_LUMINOUSPOWER=Xe.INTENSITYMODE_LUMINOUSPOWER;Fe.INTENSITYMODE_LUMINOUSINTENSITY=Xe.INTENSITYMODE_LUMINOUSINTENSITY;Fe.INTENSITYMODE_ILLUMINANCE=Xe.INTENSITYMODE_ILLUMINANCE;Fe.INTENSITYMODE_LUMINANCE=Xe.INTENSITYMODE_LUMINANCE;Fe.LIGHTTYPEID_POINTLIGHT=Xe.LIGHTTYPEID_POINTLIGHT;Fe.LIGHTTYPEID_DIRECTIONALLIGHT=Xe.LIGHTTYPEID_DIRECTIONALLIGHT;Fe.LIGHTTYPEID_SPOTLIGHT=Xe.LIGHTTYPEID_SPOTLIGHT;Fe.LIGHTTYPEID_HEMISPHERICLIGHT=Xe.LIGHTTYPEID_HEMISPHERICLIGHT;D([ls()],Fe.prototype,"diffuse",void 0);D([ls()],Fe.prototype,"specular",void 0);D([B()],Fe.prototype,"falloffType",void 0);D([B()],Fe.prototype,"intensity",void 0);D([B()],Fe.prototype,"range",null);D([B()],Fe.prototype,"intensityMode",null);D([B()],Fe.prototype,"radius",null);D([B()],Fe.prototype,"_renderPriority",void 0);D([je("_reorderLightsInScene")],Fe.prototype,"renderPriority",void 0);D([B("shadowEnabled")],Fe.prototype,"_shadowEnabled",void 0);D([B("excludeWithLayerMask")],Fe.prototype,"_excludeWithLayerMask",void 0);D([B("includeOnlyWithLayerMask")],Fe.prototype,"_includeOnlyWithLayerMask",void 0);D([B("lightmapMode")],Fe.prototype,"_lightmapMode",void 0);class Zn extends Fe{constructor(){super(...arguments),this._needProjectionMatrixCompute=!0,this._viewMatrix=O.Identity(),this._projectionMatrix=O.Identity()}_setPosition(e){this._position=e}get position(){return this._position}set position(e){this._setPosition(e)}_setDirection(e){this._direction=e}get direction(){return this._direction}set direction(e){this._setDirection(e)}get shadowMinZ(){return this._shadowMinZ}set shadowMinZ(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()}get shadowMaxZ(){return this._shadowMaxZ}set shadowMaxZ(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()}computeTransformedInformation(){return this.parent&&this.parent.getWorldMatrix?(this.transformedPosition||(this.transformedPosition=v.Zero()),v.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=v.Zero()),v.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this.transformedDirection)),!0):!1}getDepthScale(){return 50}getShadowDirection(e){return this.transformedDirection?this.transformedDirection:this.direction}getAbsolutePosition(){return this.transformedPosition?this.transformedPosition:this.position}setDirectionToTarget(e){return this.direction=v.Normalize(e.subtract(this.position)),this.direction}getRotation(){this.direction.normalize();const e=v.Cross(this.direction,Gt.Y),t=v.Cross(e,this.direction);return v.RotationFromAxis(e,t,this.direction)}needCube(){return!1}needProjectionMatrixCompute(){return this._needProjectionMatrixCompute}forceProjectionMatrixCompute(){this._needProjectionMatrixCompute=!0}_initCache(){super._initCache(),this._cache.position=v.Zero()}_isSynchronized(){return!!this._cache.position.equals(this.position)}computeWorldMatrix(e){return!e&&this.isSynchronized()?(this._currentRenderId=this.getScene().getRenderId(),this._worldMatrix):(this._updateCache(),this._cache.position.copyFrom(this.position),this._worldMatrix||(this._worldMatrix=O.Identity()),O.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this.parent&&this.parent.getWorldMatrix&&(this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix),this._markSyncedWithParent()),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix)}getDepthMinZ(e){return this.shadowMinZ!==void 0?this.shadowMinZ:e.minZ}getDepthMaxZ(e){return this.shadowMaxZ!==void 0?this.shadowMaxZ:e.maxZ}setShadowProjectionMatrix(e,t,i){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,i,e):this._setDefaultShadowProjectionMatrix(e,t,i),this}_syncParentEnabledState(){super._syncParentEnabledState(),(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition=null,this.transformedDirection=null)}getViewMatrix(e){const t=N.Vector3[0];let i=this.position;this.computeTransformedInformation()&&(i=this.transformedPosition),v.NormalizeToRef(this.getShadowDirection(e),t),Math.abs(v.Dot(t,v.Up()))===1&&(t.z=1e-13);const s=N.Vector3[1];return i.addToRef(t,s),O.LookAtLHToRef(i,s,v.Up(),this._viewMatrix),this._viewMatrix}getProjectionMatrix(e,t){return this.setShadowProjectionMatrix(this._projectionMatrix,e!=null?e:this._viewMatrix,t!=null?t:[]),this._projectionMatrix}}D([yi()],Zn.prototype,"position",null);D([yi()],Zn.prototype,"direction",null);D([B()],Zn.prototype,"shadowMinZ",null);D([B()],Zn.prototype,"shadowMaxZ",null);bt.AddNodeConstructor("Light_Type_0",(a,e)=>()=>new jr(a,v.Zero(),e));class jr extends Zn{get shadowAngle(){return this._shadowAngle}set shadowAngle(e){this._shadowAngle=e,this.forceProjectionMatrixCompute()}get direction(){return this._direction}set direction(e){const t=this.needCube();if(this._direction=e,this.needCube()!==t&&this._shadowGenerators){const i=this._shadowGenerators.values();for(let s=i.next();s.done!==!0;s=i.next())s.value.recreateShadowMap()}}constructor(e,t,i){super(e,i),this._shadowAngle=Math.PI/2,this.position=t}getClassName(){return"PointLight"}getTypeID(){return Fe.LIGHTTYPEID_POINTLIGHT}needCube(){return!this.direction}getShadowDirection(e){if(this.direction)return super.getShadowDirection(e);switch(e){case 0:return new v(1,0,0);case 1:return new v(-1,0,0);case 2:return new v(0,-1,0);case 3:return new v(0,1,0);case 4:return new v(0,0,1);case 5:return new v(0,0,-1)}return v.Zero()}_setDefaultShadowProjectionMatrix(e,t,i){const s=this.getScene().activeCamera;if(!s)return;const n=this.shadowMinZ!==void 0?this.shadowMinZ:s.minZ,r=this.shadowMaxZ!==void 0?this.shadowMaxZ:s.maxZ,o=this.getScene().getEngine().useReverseDepthBuffer;O.PerspectiveFovLHToRef(this.shadowAngle,1,o?r:n,o?n:r,e,!0,this._scene.getEngine().isNDCHalfZRange,void 0,o)}_buildUniformLayout(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("vLightFalloff",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()}transferToEffect(e,t){return this.computeTransformedInformation()?this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,0,t):this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,0,t),this._uniformBuffer.updateFloat4("vLightFalloff",this.range,this._inverseSquaredRange,0,0,t),this}transferToNodeMaterialEffect(e,t){return this.computeTransformedInformation()?e.setFloat3(t,this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z):e.setFloat3(t,this.position.x,this.position.y,this.position.z),this}prepareLightSpecificDefines(e,t){e["POINTLIGHT"+t]=!0}}D([B()],jr.prototype,"shadowAngle",null);vt("BABYLON.PointLight",jr);class qh{constructor(){this.previousWorldMatrices={},this.previousBones={}}static AddUniforms(e){e.push("previousWorld","previousViewProjection","mPreviousBones")}static AddSamplers(e){}bindForSubMesh(e,t,i,s,n){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 r=t.getEngine();this.currentViewProjection.updateFlag!==t.getTransformMatrix().updateFlag?(this._lastUpdateFrameId=r.frameId,this.previousViewProjection.copyFrom(this.currentViewProjection),this.currentViewProjection.copyFrom(t.getTransformMatrix())):this._lastUpdateFrameId!==r.frameId&&(this._lastUpdateFrameId=r.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 k0{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=!1,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){var s,n,r,o,h;const t=(r=(n=(s=this._externalProperties)==null?void 0:s[e])==null?void 0:n.type)!=null?r:typeof this[e],i=(h=(o=this._externalProperties)==null?void 0:o[e])==null?void 0:h.default;switch(t){case"number":this[e]=i!=null?i:0;break;case"string":this[e]=i!=null?i:"";break;default:this[e]=i!=null?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+"\n";break;default:s&&(e+="#define "+i+"\n");break}}return e}}class V0 extends X{constructor(e,t,i=!0,s=!1){super(e,t,void 0,s),this._normalMatrix=new O,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 De{static get DiffuseTextureEnabled(){return this._DiffuseTextureEnabled}static set DiffuseTextureEnabled(e){this._DiffuseTextureEnabled!==e&&(this._DiffuseTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get DetailTextureEnabled(){return this._DetailTextureEnabled}static set DetailTextureEnabled(e){this._DetailTextureEnabled!==e&&(this._DetailTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get DecalMapEnabled(){return this._DecalMapEnabled}static set DecalMapEnabled(e){this._DecalMapEnabled!==e&&(this._DecalMapEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get AmbientTextureEnabled(){return this._AmbientTextureEnabled}static set AmbientTextureEnabled(e){this._AmbientTextureEnabled!==e&&(this._AmbientTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get OpacityTextureEnabled(){return this._OpacityTextureEnabled}static set OpacityTextureEnabled(e){this._OpacityTextureEnabled!==e&&(this._OpacityTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get ReflectionTextureEnabled(){return this._ReflectionTextureEnabled}static set ReflectionTextureEnabled(e){this._ReflectionTextureEnabled!==e&&(this._ReflectionTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get EmissiveTextureEnabled(){return this._EmissiveTextureEnabled}static set EmissiveTextureEnabled(e){this._EmissiveTextureEnabled!==e&&(this._EmissiveTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get SpecularTextureEnabled(){return this._SpecularTextureEnabled}static set SpecularTextureEnabled(e){this._SpecularTextureEnabled!==e&&(this._SpecularTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get BumpTextureEnabled(){return this._BumpTextureEnabled}static set BumpTextureEnabled(e){this._BumpTextureEnabled!==e&&(this._BumpTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get LightmapTextureEnabled(){return this._LightmapTextureEnabled}static set LightmapTextureEnabled(e){this._LightmapTextureEnabled!==e&&(this._LightmapTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get RefractionTextureEnabled(){return this._RefractionTextureEnabled}static set RefractionTextureEnabled(e){this._RefractionTextureEnabled!==e&&(this._RefractionTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get ColorGradingTextureEnabled(){return this._ColorGradingTextureEnabled}static set ColorGradingTextureEnabled(e){this._ColorGradingTextureEnabled!==e&&(this._ColorGradingTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get FresnelEnabled(){return this._FresnelEnabled}static set FresnelEnabled(e){this._FresnelEnabled!==e&&(this._FresnelEnabled=e,ae.MarkAllMaterialsAsDirty(4))}static get ClearCoatTextureEnabled(){return this._ClearCoatTextureEnabled}static set ClearCoatTextureEnabled(e){this._ClearCoatTextureEnabled!==e&&(this._ClearCoatTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get ClearCoatBumpTextureEnabled(){return this._ClearCoatBumpTextureEnabled}static set ClearCoatBumpTextureEnabled(e){this._ClearCoatBumpTextureEnabled!==e&&(this._ClearCoatBumpTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get ClearCoatTintTextureEnabled(){return this._ClearCoatTintTextureEnabled}static set ClearCoatTintTextureEnabled(e){this._ClearCoatTintTextureEnabled!==e&&(this._ClearCoatTintTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get SheenTextureEnabled(){return this._SheenTextureEnabled}static set SheenTextureEnabled(e){this._SheenTextureEnabled!==e&&(this._SheenTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get AnisotropicTextureEnabled(){return this._AnisotropicTextureEnabled}static set AnisotropicTextureEnabled(e){this._AnisotropicTextureEnabled!==e&&(this._AnisotropicTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get ThicknessTextureEnabled(){return this._ThicknessTextureEnabled}static set ThicknessTextureEnabled(e){this._ThicknessTextureEnabled!==e&&(this._ThicknessTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get RefractionIntensityTextureEnabled(){return this._ThicknessTextureEnabled}static set RefractionIntensityTextureEnabled(e){this._RefractionIntensityTextureEnabled!==e&&(this._RefractionIntensityTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get TranslucencyIntensityTextureEnabled(){return this._TranslucencyIntensityTextureEnabled}static set TranslucencyIntensityTextureEnabled(e){this._TranslucencyIntensityTextureEnabled!==e&&(this._TranslucencyIntensityTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get TranslucencyColorTextureEnabled(){return this._TranslucencyColorTextureEnabled}static set TranslucencyColorTextureEnabled(e){this._TranslucencyColorTextureEnabled!==e&&(this._TranslucencyColorTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}static get IridescenceTextureEnabled(){return this._IridescenceTextureEnabled}static set IridescenceTextureEnabled(e){this._IridescenceTextureEnabled!==e&&(this._IridescenceTextureEnabled=e,ae.MarkAllMaterialsAsDirty(1))}}De._DiffuseTextureEnabled=!0;De._DetailTextureEnabled=!0;De._DecalMapEnabled=!0;De._AmbientTextureEnabled=!0;De._OpacityTextureEnabled=!0;De._ReflectionTextureEnabled=!0;De._EmissiveTextureEnabled=!0;De._SpecularTextureEnabled=!0;De._BumpTextureEnabled=!0;De._LightmapTextureEnabled=!0;De._RefractionTextureEnabled=!0;De._ColorGradingTextureEnabled=!0;De._FresnelEnabled=!0;De._ClearCoatTextureEnabled=!0;De._ClearCoatBumpTextureEnabled=!0;De._ClearCoatTintTextureEnabled=!0;De._SheenTextureEnabled=!0;De._AnisotropicTextureEnabled=!0;De._ThicknessTextureEnabled=!0;De._RefractionIntensityTextureEnabled=!0;De._TranslucencyIntensityTextureEnabled=!0;De._TranslucencyColorTextureEnabled=!0;De._IridescenceTextureEnabled=!0;class G0{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 n=i.meshes[s];if(!n.material){!this._mesh.material&&n.computeBonesUsingShaders&&n.numBoneInfluencers>0&&(n.computeBonesUsingShaders=!1);continue}if(!(!n.computeBonesUsingShaders||n.numBoneInfluencers===0)){if(n.material.getEffect()===t)n.computeBonesUsingShaders=!1;else if(n.subMeshes){for(const r of n.subMeshes)if(r.effect===t){n.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}}const Cg=new RegExp("^([gimus]+)!");class xs{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 "'.concat(e.name,'" can\'t be added to the material "').concat(this._material.name,'" because the plugin is not compatible with the shader language of the material.');const t=e.getClassName();xs._MaterialPluginClassToMainDefine[t]||(xs._MaterialPluginClassToMainDefine[t]="MATERIALPLUGIN_"+ ++xs._MaterialPluginCounter),this._material._callbackPluginEventGeneric=(s,n)=>this._handlePluginEvent(s,n),this._plugins.push(e),this._plugins.sort((s,n)=>s.priority-n.priority),this._codeInjectionPoints={};const i={};i[xs._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){var i;switch(e){case 512:{const s=t;for(const n of this._activePlugins)n.getActiveTextures(s.activeTextures);break}case 256:{const s=t;for(const n of this._activePlugins)n.getAnimatables(s.animatables);break}case 1024:{const s=t;let n=!1;for(const r of this._activePlugins)if(n=r.hasTexture(s.texture),n)break;s.hasTexture=n;break}case 2:{const s=t;for(const n of this._plugins)n.dispose(s.forceDisposeTextures);break}case 4:{const s=t;s.defineNames=this._defineNamesFromPlugins;break}case 128:{const s=t;for(const n of this._activePlugins)s.fallbackRank=n.addFallbacks(s.defines,s.fallbacks,s.fallbackRank),n.getAttributes(s.attributes,this._scene,s.mesh);this._uniformList.length>0&&s.uniforms.push(...this._uniformList),this._samplerList.length>0&&s.samplers.push(...this._samplerList),this._uboList.length>0&&s.uniformBuffersNames.push(...this._uboList),s.customCode=this._injectCustomCode(s,s.customCode);break}case 8:{const s=t;this._uboDeclaration="",this._vertexDeclaration="",this._fragmentDeclaration="",this._uniformList=[],this._samplerList=[],this._uboList=[];const n=this._material.shaderLanguage===1;for(const r of this._plugins){const o=r.getUniforms(this._material.shaderLanguage);if(o){if(o.ubo)for(const h of o.ubo){if(h.size&&h.type){const l=(i=h.arraySize)!=null?i:0;if(s.ubo.addUniform(h.name,h.size,l),n){let c;switch(h.type){case"mat4":c="mat4x4f";break;case"float":c="f32";break;default:c="".concat(h.type,"f");break}this._uboDeclaration+="uniform ".concat(h.name,": ").concat(c).concat(l>0?"[".concat(l,"]"):"",";\n")}else this._uboDeclaration+="".concat(h.type," ").concat(h.name).concat(l>0?"[".concat(l,"]"):"",";\n")}this._uniformList.push(h.name)}o.vertex&&(this._vertexDeclaration+=o.vertex+"\n"),o.fragment&&(this._fragmentDeclaration+=o.fragment+"\n")}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)=>{var o,h;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 n=(o=this._codeInjectionPoints)==null?void 0:o[i];if(!n)return s;let r=null;for(let l in n){let c="";for(const u of this._activePlugins){let f=(h=u.getCustomCode(i,this._material.shaderLanguage))==null?void 0:h[l];f&&(u.resolveIncludes&&(r===null&&(r={defines:[],indexParameters:e.indexParameters,isFragment:!1,shouldUseHighPrecisionShader:this._engine._shouldUseHighPrecisionShader,processor:void 0,supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:Me.GetShadersRepository(0),includesShadersStore:Me.GetIncludesShadersStore(0),version:void 0,platformName:this._engine.shaderPlatformName,processingContext:void 0,isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer,processCodeAfterIncludes:void 0}),r.isFragment=i==="fragment",Dn(f,r,d=>f=d)),c+=f+"\n")}if(c.length>0)if(l.charAt(0)==="!"){l=l.substring(1);let u="g";if(l.charAt(0)==="!")u="",l=l.substring(1);else{const p=Cg.exec(l);p&&p.length>=2&&(u=p[1],l=l.substring(u.length+1))}u.indexOf("g")<0&&(u+="g");const f=s,d=new RegExp(l,u);let _=d.exec(f);for(;_!==null;){let p=c;for(let g=0;g<_.length;++g)p=p.replace("$"+g,_[g]);s=s.replace(_[0],p),_=d.exec(f)}}else{const u="#define "+l;s=s.replace(u,"\n"+c+"\n"+u)}}return s}}}xs._MaterialPluginClassToMainDefine={};xs._MaterialPluginCounter=0;Ee.OnEnginesDisposedObservable.add(()=>{Mg()});const Sg=[];let jh=null;function Mg(){Sg.length=0,X.OnEventObservable.remove(jh),jh=null}class gn{isCompatible(e){switch(e){case 0:return!0;default:return!1}}_enable(e){e&&this._pluginManager._activatePlugin(this)}constructor(e,t,i,s,n=!0,r=!1,o=!1){this.priority=500,this.resolveIncludes=!1,this.registerForExtraEvents=!1,this._material=e,this.name=t,this.priority=i,this.resolveIncludes=o,e.pluginManager||(e.pluginManager=new xs(e),e.onDisposeObservable.add(()=>{e.pluginManager=void 0})),this._pluginDefineNames=s,this._pluginManager=e.pluginManager,n&&this._pluginManager._addPlugin(this),r&&this._enable(!0),this.markAllDefinesAsDirty=e._dirtyCallbacks[63]}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){Ae.Clone(()=>e,this)}serialize(){return Ae.Serialize(this)}parse(e,t,i){Ae.Parse(()=>this,e,t,i)}}D([B()],gn.prototype,"name",void 0);D([B()],gn.prototype,"priority",void 0);D([B()],gn.prototype,"resolveIncludes",void 0);D([B()],gn.prototype,"registerForExtraEvents",void 0);vt("BABYLON.MaterialPluginBase",gn);class Pg extends k0{constructor(){super(...arguments),this.DETAIL=!1,this.DETAILDIRECTUV=0,this.DETAIL_NORMALBLENDMETHOD=0}}class Ks extends gn{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"DetailMap",140,new Pg,t),this._texture=null,this.diffuseBlendLevel=1,this.roughnessBlendLevel=1,this.bumpLevel=1,this._normalBlendMethod=X.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&&De.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&&De.DetailTextureEnabled&&this._isEnabled?(ms(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&&De.DetailTextureEnabled&&(e.updateFloat4("vDetailInfos",this._texture.coordinatesIndex,this.diffuseBlendLevel,this.bumpLevel,this.roughnessBlendLevel),vs(this._texture,e,"detail")),t.texturesEnabled&&this._texture&&De.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){var t;e&&((t=this._texture)==null||t.dispose())}getClassName(){return"DetailMapConfiguration"}getSamplers(e){e.push("detailSampler")}getUniforms(){return{ubo:[{name:"vDetailInfos",size:4,type:"vec4"},{name:"detailMatrix",size:16,type:"mat4"}]}}}D([_i("detailTexture"),je("_markAllSubMeshesAsTexturesDirty")],Ks.prototype,"texture",void 0);D([B()],Ks.prototype,"diffuseBlendLevel",void 0);D([B()],Ks.prototype,"roughnessBlendLevel",void 0);D([B()],Ks.prototype,"bumpLevel",void 0);D([B(),je("_markAllSubMeshesAsTexturesDirty")],Ks.prototype,"normalBlendMethod",void 0);D([B(),je("_markAllSubMeshesAsTexturesDirty")],Ks.prototype,"isEnabled",void 0);var $h;(function(a){a[a.Zero=0]="Zero",a[a.One=1]="One",a[a.MaxViewZ=2]="MaxViewZ"})($h||($h={}));class ti{static CreateConfiguration(e){return ti._Configurations[e]={defines:{},previousWorldMatrices:{},previousViewProjection:O.Zero(),currentViewProjection:O.Zero(),previousBones:{},lastUpdateFrameId:-1,excludedSkinnedMesh:[]},ti._Configurations[e]}static DeleteConfiguration(e){delete ti._Configurations[e]}static GetConfiguration(e){return ti._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=ti._Configurations[e];if(!s)return;i.PREPASS=!0,i.PREPASS_COLOR=!1,i.PREPASS_COLOR_INDEX=-1;let n=0;for(let r=0;r<ti.GeometryTextureDescriptions.length;r++){const o=ti.GeometryTextureDescriptions[r],h=o.define,l=o.defineIndex,c=s.defines[l];c!==void 0?(i[h]=!0,i[l]=c,n++):(i[h]=!1,delete i[l])}i.SCENE_MRT_COUNT=n,i.BONES_VELOCITY_ENABLED=t.useBones&&t.computeBonesUsingShaders&&t.skeleton&&!t.skeleton.isUsingTextureForMatrices&&s.excludedSkinnedMesh.indexOf(t)===-1}static Bind(e,t,i,s){const n=ti._Configurations[e];if(n&&(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());const r=i.getScene();n.previousViewProjection||(n.previousViewProjection=r.getTransformMatrix().clone(),n.currentViewProjection=r.getTransformMatrix().clone());const o=r.getEngine();if(n.currentViewProjection.updateFlag!==r.getTransformMatrix().updateFlag?(n.lastUpdateFrameId=o.frameId,n.previousViewProjection.copyFrom(n.currentViewProjection),n.currentViewProjection.copyFrom(r.getTransformMatrix())):n.lastUpdateFrameId!==o.frameId&&(n.lastUpdateFrameId=o.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 h=i.skeleton;if(!h.isUsingTextureForMatrices||t.getUniformIndex("boneTextureWidth")===-1){const l=h.getTransformMatrices(i);l&&(n.previousBones[i.uniqueId]||(n.previousBones[i.uniqueId]=l.slice()),t.setMatrices("mPreviousBones",n.previousBones[i.uniqueId]),n.previousBones[i.uniqueId].set(l))}}}}}ti.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"}];ti._Configurations={};const Aa={effect:null,subMesh:null};class wg extends k0{constructor(e){super(e),this.MAINUV1=!1,this.MAINUV2=!1,this.MAINUV3=!1,this.MAINUV4=!1,this.MAINUV5=!1,this.MAINUV6=!1,this.DIFFUSE=!1,this.DIFFUSEDIRECTUV=0,this.BAKED_VERTEX_ANIMATION_TEXTURE=!1,this.AMBIENT=!1,this.AMBIENTDIRECTUV=0,this.OPACITY=!1,this.OPACITYDIRECTUV=0,this.OPACITYRGB=!1,this.REFLECTION=!1,this.EMISSIVE=!1,this.EMISSIVEDIRECTUV=0,this.SPECULAR=!1,this.SPECULARDIRECTUV=0,this.BUMP=!1,this.BUMPDIRECTUV=0,this.PARALLAX=!1,this.PARALLAX_RHS=!1,this.PARALLAXOCCLUSION=!1,this.SPECULAROVERALPHA=!1,this.CLIPPLANE=!1,this.CLIPPLANE2=!1,this.CLIPPLANE3=!1,this.CLIPPLANE4=!1,this.CLIPPLANE5=!1,this.CLIPPLANE6=!1,this.ALPHATEST=!1,this.DEPTHPREPASS=!1,this.ALPHAFROMDIFFUSE=!1,this.POINTSIZE=!1,this.FOG=!1,this.SPECULARTERM=!1,this.DIFFUSEFRESNEL=!1,this.OPACITYFRESNEL=!1,this.REFLECTIONFRESNEL=!1,this.REFRACTIONFRESNEL=!1,this.EMISSIVEFRESNEL=!1,this.FRESNEL=!1,this.NORMAL=!1,this.TANGENT=!1,this.UV1=!1,this.UV2=!1,this.UV3=!1,this.UV4=!1,this.UV5=!1,this.UV6=!1,this.VERTEXCOLOR=!1,this.VERTEXALPHA=!1,this.NUM_BONE_INFLUENCERS=0,this.BonesPerMesh=0,this.BONETEXTURE=!1,this.BONES_VELOCITY_ENABLED=!1,this.INSTANCES=!1,this.THIN_INSTANCES=!1,this.INSTANCESCOLOR=!1,this.GLOSSINESS=!1,this.ROUGHNESS=!1,this.EMISSIVEASILLUMINATION=!1,this.LINKEMISSIVEWITHDIFFUSE=!1,this.REFLECTIONFRESNELFROMSPECULAR=!1,this.LIGHTMAP=!1,this.LIGHTMAPDIRECTUV=0,this.OBJECTSPACE_NORMALMAP=!1,this.USELIGHTMAPASSHADOWMAP=!1,this.REFLECTIONMAP_3D=!1,this.REFLECTIONMAP_SPHERICAL=!1,this.REFLECTIONMAP_PLANAR=!1,this.REFLECTIONMAP_CUBIC=!1,this.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,this.USE_LOCAL_REFRACTIONMAP_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.REFLECTIONMAP_OPPOSITEZ=!1,this.INVERTCUBICMAP=!1,this.LOGARITHMICDEPTH=!1,this.REFRACTION=!1,this.REFRACTIONMAP_3D=!1,this.REFLECTIONOVERALPHA=!1,this.TWOSIDEDLIGHTING=!1,this.SHADOWFLOAT=!1,this.MORPHTARGETS=!1,this.MORPHTARGETS_NORMAL=!1,this.MORPHTARGETS_TANGENT=!1,this.MORPHTARGETS_UV=!1,this.NUM_MORPH_INFLUENCERS=0,this.MORPHTARGETS_TEXTURE=!1,this.NONUNIFORMSCALING=!1,this.PREMULTIPLYALPHA=!1,this.ALPHATEST_AFTERALLALPHACOMPUTATIONS=!1,this.ALPHABLEND=!0,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.RGBDLIGHTMAP=!1,this.RGBDREFLECTION=!1,this.RGBDREFRACTION=!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.MULTIVIEW=!1,this.ORDER_INDEPENDENT_TRANSPARENCY=!1,this.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!1,this.CAMERA_ORTHOGRAPHIC=!1,this.CAMERA_PERSPECTIVE=!1,this.IS_REFLECTION_LINEAR=!1,this.IS_REFRACTION_LINEAR=!1,this.EXPOSURE=!1,this.DECAL_AFTER_DETAIL=!1,this.rebuild()}setReflectionMode(e){const t=["REFLECTIONMAP_CUBIC","REFLECTIONMAP_EXPLICIT","REFLECTIONMAP_PLANAR","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_SKYBOX","REFLECTIONMAP_SPHERICAL","REFLECTIONMAP_EQUIRECTANGULAR","REFLECTIONMAP_EQUIRECTANGULAR_FIXED","REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"];for(const i of t)this[i]=i===e}}class ee extends V0{get imageProcessingConfiguration(){return this._imageProcessingConfiguration}set imageProcessingConfiguration(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()}_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()})))}get isPrePassCapable(){return!this.disableDepthWrite}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}get canRenderToMRT(){return!0}constructor(e,t,i=!1){super(e,t,void 0,i||ee.ForceGLSL),this._diffuseTexture=null,this._ambientTexture=null,this._opacityTexture=null,this._reflectionTexture=null,this._emissiveTexture=null,this._specularTexture=null,this._bumpTexture=null,this._lightmapTexture=null,this._refractionTexture=null,this.ambientColor=new de(0,0,0),this.diffuseColor=new de(1,1,1),this.specularColor=new de(1,1,1),this.emissiveColor=new de(0,0,0),this.specularPower=64,this._useAlphaFromDiffuseTexture=!1,this._useEmissiveAsIllumination=!1,this._linkEmissiveWithDiffuse=!1,this._useSpecularOverAlpha=!1,this._useReflectionOverAlpha=!1,this._disableLighting=!1,this._useObjectSpaceNormalMap=!1,this._useParallax=!1,this._useParallaxOcclusion=!1,this.parallaxScaleBias=.05,this._roughness=0,this.indexOfRefraction=.98,this.invertRefractionY=!0,this.alphaCutOff=.4,this._useLightmapAsShadowmap=!1,this._useReflectionFresnelFromSpecular=!1,this._useGlossinessFromSpecularMapAlpha=!1,this._maxSimultaneousLights=4,this._invertNormalMapX=!1,this._invertNormalMapY=!1,this._twoSidedLighting=!1,this._applyDecalMapAfterDetailMap=!1,this._shadersLoaded=!1,this._renderTargets=new Ut(16),this._worldViewProjectionMatrix=O.Zero(),this._globalAmbientColor=new de(0,0,0),this._cacheHasRenderTargetTextures=!1,this.detailMap=new Ks(this),this._attachImageProcessingConfiguration(null),this.prePassConfiguration=new qh,this.getRenderTargetTextures=()=>(this._renderTargets.reset(),ee.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._renderTargets.push(this._reflectionTexture),ee.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._renderTargets.push(this._refractionTexture),this._eventInfo.renderTargets=this._renderTargets,this._callbackPluginEventFillRenderTargetTextures(this._eventInfo),this._renderTargets)}get hasRenderTargetTextures(){return ee.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget||ee.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget?!0:this._cacheHasRenderTargetTextures}getClassName(){return"StandardMaterial"}needAlphaBlending(){return this._disableAlphaBlending?!1:this.alpha<1||this._opacityTexture!=null||this._shouldUseAlphaFromDiffuseTexture()||this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled}needAlphaTesting(){return this._forceAlphaTest?!0:this._hasAlphaChannel()&&(this._transparencyMode==null||this._transparencyMode===X.MATERIAL_ALPHATEST)}_shouldUseAlphaFromDiffuseTexture(){return this._diffuseTexture!=null&&this._diffuseTexture.hasAlpha&&this._useAlphaFromDiffuseTexture&&this._transparencyMode!==X.MATERIAL_OPAQUE}_hasAlphaChannel(){return this._diffuseTexture!=null&&this._diffuseTexture.hasAlpha||this._opacityTexture!=null}getAlphaTestTexture(){return this._diffuseTexture}isReadyForSubMesh(e,t,i=!1){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 wg(this._eventInfo.defineNames));const n=this.getScene(),r=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;const o=n.getEngine();r._needNormals=eg(n,e,r,!0,this._maxSimultaneousLights,this._disableLighting),rg(n,r);const h=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if(og(n,r,this.canRenderToMRT&&!h),ag(n,r,h),ti.PrepareDefines(o.currentRenderPassId,e,r),r._areTexturesDirty){this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._cacheHasRenderTargetTextures=this._eventInfo.hasRenderTargetTextures,r._needUVs=!1;for(let c=1;c<=6;++c)r["MAINUV"+c]=!1;if(n.texturesEnabled){if(r.DIFFUSEDIRECTUV=0,r.BUMPDIRECTUV=0,r.AMBIENTDIRECTUV=0,r.OPACITYDIRECTUV=0,r.EMISSIVEDIRECTUV=0,r.SPECULARDIRECTUV=0,r.LIGHTMAPDIRECTUV=0,this._diffuseTexture&&ee.DiffuseTextureEnabled)if(this._diffuseTexture.isReadyOrNotBlocking())ms(this._diffuseTexture,r,"DIFFUSE");else return!1;else r.DIFFUSE=!1;if(this._ambientTexture&&ee.AmbientTextureEnabled)if(this._ambientTexture.isReadyOrNotBlocking())ms(this._ambientTexture,r,"AMBIENT");else return!1;else r.AMBIENT=!1;if(this._opacityTexture&&ee.OpacityTextureEnabled)if(this._opacityTexture.isReadyOrNotBlocking())ms(this._opacityTexture,r,"OPACITY"),r.OPACITYRGB=this._opacityTexture.getAlphaFromRGB;else return!1;else r.OPACITY=!1;if(this._reflectionTexture&&ee.ReflectionTextureEnabled)if(this._reflectionTexture.isReadyOrNotBlocking()){switch(r._needNormals=!0,r.REFLECTION=!0,r.ROUGHNESS=this._roughness>0,r.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,r.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===ie.INVCUBIC_MODE,r.REFLECTIONMAP_3D=this._reflectionTexture.isCube,r.REFLECTIONMAP_OPPOSITEZ=r.REFLECTIONMAP_3D&&this.getScene().useRightHandedSystem?!this._reflectionTexture.invertZ:this._reflectionTexture.invertZ,r.RGBDREFLECTION=this._reflectionTexture.isRGBD,this._reflectionTexture.coordinatesMode){case ie.EXPLICIT_MODE:r.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case ie.PLANAR_MODE:r.setReflectionMode("REFLECTIONMAP_PLANAR");break;case ie.PROJECTION_MODE:r.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case ie.SKYBOX_MODE:r.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case ie.SPHERICAL_MODE:r.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case ie.EQUIRECTANGULAR_MODE:r.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case ie.FIXED_EQUIRECTANGULAR_MODE:r.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case ie.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:r.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");break;case ie.CUBIC_MODE:case ie.INVCUBIC_MODE:default:r.setReflectionMode("REFLECTIONMAP_CUBIC");break}r.USE_LOCAL_REFLECTIONMAP_CUBIC=!!this._reflectionTexture.boundingBoxSize}else return!1;else r.REFLECTION=!1,r.REFLECTIONMAP_OPPOSITEZ=!1;if(this._emissiveTexture&&ee.EmissiveTextureEnabled)if(this._emissiveTexture.isReadyOrNotBlocking())ms(this._emissiveTexture,r,"EMISSIVE");else return!1;else r.EMISSIVE=!1;if(this._lightmapTexture&&ee.LightmapTextureEnabled)if(this._lightmapTexture.isReadyOrNotBlocking())ms(this._lightmapTexture,r,"LIGHTMAP"),r.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,r.RGBDLIGHTMAP=this._lightmapTexture.isRGBD;else return!1;else r.LIGHTMAP=!1;if(this._specularTexture&&ee.SpecularTextureEnabled)if(this._specularTexture.isReadyOrNotBlocking())ms(this._specularTexture,r,"SPECULAR"),r.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha;else return!1;else r.SPECULAR=!1;if(n.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&ee.BumpTextureEnabled){if(this._bumpTexture.isReady())ms(this._bumpTexture,r,"BUMP"),r.PARALLAX=this._useParallax,r.PARALLAX_RHS=n.useRightHandedSystem,r.PARALLAXOCCLUSION=this._useParallaxOcclusion;else return!1;r.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap}else r.BUMP=!1,r.PARALLAX=!1,r.PARALLAX_RHS=!1,r.PARALLAXOCCLUSION=!1;if(this._refractionTexture&&ee.RefractionTextureEnabled)if(this._refractionTexture.isReadyOrNotBlocking())r._needUVs=!0,r.REFRACTION=!0,r.REFRACTIONMAP_3D=this._refractionTexture.isCube,r.RGBDREFRACTION=this._refractionTexture.isRGBD,r.USE_LOCAL_REFRACTIONMAP_CUBIC=!!this._refractionTexture.boundingBoxSize;else return!1;else r.REFRACTION=!1;r.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else r.DIFFUSE=!1,r.AMBIENT=!1,r.OPACITY=!1,r.REFLECTION=!1,r.EMISSIVE=!1,r.LIGHTMAP=!1,r.BUMP=!1,r.REFRACTION=!1;r.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),r.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,r.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,r.SPECULAROVERALPHA=this._useSpecularOverAlpha,r.PREMULTIPLYALPHA=this.alphaMode===7||this.alphaMode===8,r.ALPHATEST_AFTERALLALPHACOMPUTATIONS=this.transparencyMode!==null,r.ALPHABLEND=this.transparencyMode===null||this.needAlphaBlendingForMesh(e)}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=r,this._eventInfo.subMesh=t,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh)return!1;if(r._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(r),r.IS_REFLECTION_LINEAR=this.reflectionTexture!=null&&!this.reflectionTexture.gammaSpace,r.IS_REFRACTION_LINEAR=this.refractionTexture!=null&&!this.refractionTexture.gammaSpace}r._areFresnelDirty&&(ee.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(r.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,r.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,r.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,r.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,r.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,r.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,r._needNormals=!0,r.FRESNEL=!0):r.FRESNEL=!1),Bc(e,n,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,r,this._applyDecalMapAfterDetailMap),Lc(n,o,this,r,i,null,t.getRenderingMesh().hasThinInstances),this._eventInfo.defines=r,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo),Nc(e,r,!0,!0,!0),this._callbackPluginEventPrepareDefines(this._eventInfo);let l=!1;if(r.isDirty){const c=r._areLightsDisposed;r.markAsProcessed();const u=new G0;r.REFLECTION&&u.addFallback(0,"REFLECTION"),r.SPECULAR&&u.addFallback(0,"SPECULAR"),r.BUMP&&u.addFallback(0,"BUMP"),r.PARALLAX&&u.addFallback(1,"PARALLAX"),r.PARALLAX_RHS&&u.addFallback(1,"PARALLAX_RHS"),r.PARALLAXOCCLUSION&&u.addFallback(0,"PARALLAXOCCLUSION"),r.SPECULAROVERALPHA&&u.addFallback(0,"SPECULAROVERALPHA"),r.FOG&&u.addFallback(1,"FOG"),r.POINTSIZE&&u.addFallback(0,"POINTSIZE"),r.LOGARITHMICDEPTH&&u.addFallback(0,"LOGARITHMICDEPTH"),Qp(r,u,this._maxSimultaneousLights),r.SPECULARTERM&&u.addFallback(0,"SPECULARTERM"),r.DIFFUSEFRESNEL&&u.addFallback(1,"DIFFUSEFRESNEL"),r.OPACITYFRESNEL&&u.addFallback(2,"OPACITYFRESNEL"),r.REFLECTIONFRESNEL&&u.addFallback(3,"REFLECTIONFRESNEL"),r.EMISSIVEFRESNEL&&u.addFallback(4,"EMISSIVEFRESNEL"),r.FRESNEL&&u.addFallback(4,"FRESNEL"),r.MULTIVIEW&&u.addFallback(0,"MULTIVIEW");const f=[A.PositionKind];r.NORMAL&&f.push(A.NormalKind),r.TANGENT&&f.push(A.TangentKind);for(let y=1;y<=6;++y)r["UV"+y]&&f.push("uv".concat(y===1?"":y));r.VERTEXCOLOR&&f.push(A.ColorKind),Zp(f,e,r,u),Oc(f,r),Pc(f,e,r),Dc(f,e,r);let d="default";const _=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","visibility","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","normalMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","vReflectionPosition","vReflectionSize","vRefractionPosition","vRefractionSize","logarithmicDepthConstant","vTangentSpaceParams","alphaCutOff","boneTextureWidth","morphTargetTextureInfo","morphTargetTextureIndices"],p=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler","boneSampler","morphTargets","oitDepthSampler","oitFrontColorSampler"],g=["Material","Scene","Mesh"],m={maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:r.NUM_MORPH_INFLUENCERS};this._eventInfo.fallbacks=u,this._eventInfo.fallbackRank=0,this._eventInfo.defines=r,this._eventInfo.uniforms=_,this._eventInfo.attributes=f,this._eventInfo.samplers=p,this._eventInfo.uniformBuffersNames=g,this._eventInfo.customCode=void 0,this._eventInfo.mesh=e,this._eventInfo.indexParameters=m,this._callbackPluginEventGeneric(128,this._eventInfo),ti.AddUniformsAndSamplers(_,p),qh.AddUniforms(_),Ne&&(Ne.PrepareUniforms(_,r),Ne.PrepareSamplers(p,r)),cg({uniformsNames:_,uniformBuffersNames:g,samplers:p,defines:r,maxSimultaneousLights:this._maxSimultaneousLights}),Xr(_);const b={};this.customShaderNameResolve&&(d=this.customShaderNameResolve(d,_,g,p,r,f,b));const I=r.toString(),T=t.effect;let x=n.getEngine().createEffect(d,{attributes:f,uniformsNames:_,uniformBuffersNames:g,samplers:p,defines:I,fallbacks:u,onCompiled:this.onCompiled,onError:this.onError,indexParameters:m,processFinalCode:b.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:r.PREPASS,shaderLanguage:this._shaderLanguage,extraInitializationsAsync:this._shadersLoaded?void 0:async()=>{this._shaderLanguage===1?await Promise.all([Oe(()=>import("./default.vertex-Caa9iT2n.js"),__vite__mapDeps([20,21,22,23,24,25,26,27,3,4,5,6,7,8,9,10])),Oe(()=>import("./default.fragment-DzWBfowK.js"),__vite__mapDeps([28,21,29,26,30,31,3,4,5,6,7,8,9,10]))]):await Promise.all([Oe(()=>import("./default.vertex-B3P8Ow0L.js"),__vite__mapDeps([32,33,34,35,36,37,38,3,4,5,6,7,8,9,10])),Oe(()=>import("./default.fragment-BQ0cgw4g.js"),__vite__mapDeps([39,33,34,35,3,4,5,6,7,8,9,10]))]),this._shadersLoaded=!0}},o);if(this._eventInfo.customCode=void 0,x)if(this._onEffectCreatedObservable&&(Aa.effect=x,Aa.subMesh=t,this._onEffectCreatedObservable.notifyObservers(Aa)),this.allowShaderHotSwapping&&T&&!x.isReady()){if(x=T,r.markAsUnprocessed(),l=this.isFrozen,c)return r._areLightsDisposed=!0,!1}else n.resetCachedMaterial(),t.setEffect(x,r,this._materialContext)}return!t.effect||!t.effect.isReady()?!1:(r._renderId=n.getRenderId(),s._wasPreviouslyReady=!l,s._wasPreviouslyUsingInstances=i,this._checkScenePerformancePriority(),!0)}buildUniformLayout(){const e=this._uniformBuffer;e.addUniform("diffuseLeftColor",4),e.addUniform("diffuseRightColor",4),e.addUniform("opacityParts",4),e.addUniform("reflectionLeftColor",4),e.addUniform("reflectionRightColor",4),e.addUniform("refractionLeftColor",4),e.addUniform("refractionRightColor",4),e.addUniform("emissiveLeftColor",4),e.addUniform("emissiveRightColor",4),e.addUniform("vDiffuseInfos",2),e.addUniform("vAmbientInfos",2),e.addUniform("vOpacityInfos",2),e.addUniform("vReflectionInfos",2),e.addUniform("vReflectionPosition",3),e.addUniform("vReflectionSize",3),e.addUniform("vEmissiveInfos",2),e.addUniform("vLightmapInfos",2),e.addUniform("vSpecularInfos",2),e.addUniform("vBumpInfos",3),e.addUniform("diffuseMatrix",16),e.addUniform("ambientMatrix",16),e.addUniform("opacityMatrix",16),e.addUniform("reflectionMatrix",16),e.addUniform("emissiveMatrix",16),e.addUniform("lightmapMatrix",16),e.addUniform("specularMatrix",16),e.addUniform("bumpMatrix",16),e.addUniform("vTangentSpaceParams",2),e.addUniform("pointSize",1),e.addUniform("alphaCutOff",1),e.addUniform("refractionMatrix",16),e.addUniform("vRefractionInfos",4),e.addUniform("vRefractionPosition",3),e.addUniform("vRefractionSize",3),e.addUniform("vSpecularColor",4),e.addUniform("vEmissiveColor",3),e.addUniform("vDiffuseColor",4),e.addUniform("vAmbientColor",3),super.buildUniformLayout()}bindForSubMesh(e,t,i){var l;const s=this.getScene(),n=i.materialDefines;if(!n)return;const r=i.effect;if(!r)return;this._activeEffect=r,t.getMeshUniformBuffer().bindToEffect(r,"Mesh"),t.transferToEffect(e),this._uniformBuffer.bindToEffect(r,"Material"),this.prePassConfiguration.bindForSubMesh(this._activeEffect,s,t,e,this.isFrozen),ti.Bind(s.getEngine().currentRenderPassId,this._activeEffect,t,e),this._eventInfo.subMesh=i,this._callbackPluginEventHardBindForSubMesh(this._eventInfo),n.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));const o=this._mustRebind(s,r,i,t.visibility);Fc(t,r);const h=this._uniformBuffer;if(o){if(this.bindViewProjection(r),!h.useUbo||!this.isFrozen||!h.isSync||i._drawWrapper._forceRebindOnNextCall){if(ee.FresnelEnabled&&n.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(h.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),h.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&h.updateColor4("opacityParts",new de(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(h.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),h.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(h.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),h.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(h.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),h.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),s.texturesEnabled){if(this._diffuseTexture&&ee.DiffuseTextureEnabled&&(h.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),vs(this._diffuseTexture,h,"diffuse")),this._ambientTexture&&ee.AmbientTextureEnabled&&(h.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),vs(this._ambientTexture,h,"ambient")),this._opacityTexture&&ee.OpacityTextureEnabled&&(h.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),vs(this._opacityTexture,h,"opacity")),this._hasAlphaChannel()&&h.updateFloat("alphaCutOff",this.alphaCutOff),this._reflectionTexture&&ee.ReflectionTextureEnabled&&(h.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),h.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix()),this._reflectionTexture.boundingBoxSize)){const c=this._reflectionTexture;h.updateVector3("vReflectionPosition",c.boundingBoxPosition),h.updateVector3("vReflectionSize",c.boundingBoxSize)}if(this._emissiveTexture&&ee.EmissiveTextureEnabled&&(h.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),vs(this._emissiveTexture,h,"emissive")),this._lightmapTexture&&ee.LightmapTextureEnabled&&(h.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),vs(this._lightmapTexture,h,"lightmap")),this._specularTexture&&ee.SpecularTextureEnabled&&(h.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),vs(this._specularTexture,h,"specular")),this._bumpTexture&&s.getEngine().getCaps().standardDerivatives&&ee.BumpTextureEnabled&&(h.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),vs(this._bumpTexture,h,"bump"),s._mirroredCameraPosition?h.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):h.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&ee.RefractionTextureEnabled){let c=1;if(this._refractionTexture.isCube||(h.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(c=this._refractionTexture.depth)),h.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,c,this.invertRefractionY?-1:1),this._refractionTexture.boundingBoxSize){const u=this._refractionTexture;h.updateVector3("vRefractionPosition",u.boundingBoxPosition),h.updateVector3("vRefractionSize",u.boundingBoxSize)}}}this.pointsCloud&&h.updateFloat("pointSize",this.pointSize),h.updateColor4("vSpecularColor",this.specularColor,this.specularPower),h.updateColor3("vEmissiveColor",ee.EmissiveTextureEnabled?this.emissiveColor:de.BlackReadOnly),h.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha),s.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),h.updateColor3("vAmbientColor",this._globalAmbientColor)}s.texturesEnabled&&(this._diffuseTexture&&ee.DiffuseTextureEnabled&&r.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&ee.AmbientTextureEnabled&&r.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&ee.OpacityTextureEnabled&&r.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&ee.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?r.setTexture("reflectionCubeSampler",this._reflectionTexture):r.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&ee.EmissiveTextureEnabled&&r.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&ee.LightmapTextureEnabled&&r.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&ee.SpecularTextureEnabled&&r.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&s.getEngine().getCaps().standardDerivatives&&ee.BumpTextureEnabled&&r.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&ee.RefractionTextureEnabled&&(this._refractionTexture.isCube?r.setTexture("refractionCubeSampler",this._refractionTexture):r.setTexture("refraction2DSampler",this._refractionTexture))),this.getScene().useOrderIndependentTransparency&&this.needAlphaBlendingForMesh(t)&&this.getScene().depthPeelingRenderer.bind(r),this._eventInfo.subMesh=i,this._callbackPluginEventBindForSubMesh(this._eventInfo),Yr(r,this,s),this.bindEyePosition(r)}else s.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);(o||!this.isFrozen)&&(s.lightsEnabled&&!this._disableLighting&&$p(s,t,r,n,this._maxSimultaneousLights),(s.fogEnabled&&t.applyFog&&s.fogMode!==it.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture||t.receiveShadows||n.PREPASS)&&this.bindView(r),L0(s,t,r),n.NUM_MORPH_INFLUENCERS&&U0(t,r),n.BAKED_VERTEX_ANIMATION_TEXTURE&&((l=t.bakedVertexAnimationManager)==null||l.bind(r,n.INSTANCES)),this.useLogarithmicDepth&&B0(n,r,s),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._afterBind(t,this._activeEffect,i),h.update()}getAnimatables(){const e=super.getAnimatables();return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),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._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),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._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e}getActiveTextures(){const e=super.getActiveTextures();return this._diffuseTexture&&e.push(this._diffuseTexture),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._specularTexture&&e.push(this._specularTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e}hasTexture(e){return!!(super.hasTexture(e)||this._diffuseTexture===e||this._ambientTexture===e||this._opacityTexture===e||this._reflectionTexture===e||this._emissiveTexture===e||this._specularTexture===e||this._bumpTexture===e||this._lightmapTexture===e||this._refractionTexture===e)}dispose(e,t){var i,s,n,r,o,h,l,c,u;t&&((i=this._diffuseTexture)==null||i.dispose(),(s=this._ambientTexture)==null||s.dispose(),(n=this._opacityTexture)==null||n.dispose(),(r=this._reflectionTexture)==null||r.dispose(),(o=this._emissiveTexture)==null||o.dispose(),(h=this._specularTexture)==null||h.dispose(),(l=this._bumpTexture)==null||l.dispose(),(c=this._lightmapTexture)==null||c.dispose(),(u=this._refractionTexture)==null||u.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),super.dispose(e,t)}clone(e,t=!0,i=""){const s=Ae.Clone(()=>new ee(e,this.getScene()),this,{cloneTexturesOnlyOnce:t});return s.name=e,s.id=e,this.stencil.copyTo(s.stencil),this._clonePlugins(s,i),s}static Parse(e,t,i){const s=Ae.Parse(()=>new ee(e.name,t),e,t,i);return e.stencil&&s.stencil.parse(e.stencil,t,i),X._ParsePlugins(e,s,t,i),s}static get DiffuseTextureEnabled(){return De.DiffuseTextureEnabled}static set DiffuseTextureEnabled(e){De.DiffuseTextureEnabled=e}static get DetailTextureEnabled(){return De.DetailTextureEnabled}static set DetailTextureEnabled(e){De.DetailTextureEnabled=e}static get AmbientTextureEnabled(){return De.AmbientTextureEnabled}static set AmbientTextureEnabled(e){De.AmbientTextureEnabled=e}static get OpacityTextureEnabled(){return De.OpacityTextureEnabled}static set OpacityTextureEnabled(e){De.OpacityTextureEnabled=e}static get ReflectionTextureEnabled(){return De.ReflectionTextureEnabled}static set ReflectionTextureEnabled(e){De.ReflectionTextureEnabled=e}static get EmissiveTextureEnabled(){return De.EmissiveTextureEnabled}static set EmissiveTextureEnabled(e){De.EmissiveTextureEnabled=e}static get SpecularTextureEnabled(){return De.SpecularTextureEnabled}static set SpecularTextureEnabled(e){De.SpecularTextureEnabled=e}static get BumpTextureEnabled(){return De.BumpTextureEnabled}static set BumpTextureEnabled(e){De.BumpTextureEnabled=e}static get LightmapTextureEnabled(){return De.LightmapTextureEnabled}static set LightmapTextureEnabled(e){De.LightmapTextureEnabled=e}static get RefractionTextureEnabled(){return De.RefractionTextureEnabled}static set RefractionTextureEnabled(e){De.RefractionTextureEnabled=e}static get ColorGradingTextureEnabled(){return De.ColorGradingTextureEnabled}static set ColorGradingTextureEnabled(e){De.ColorGradingTextureEnabled=e}static get FresnelEnabled(){return De.FresnelEnabled}static set FresnelEnabled(e){De.FresnelEnabled=e}}ee.ForceGLSL=!1;D([_i("diffuseTexture")],ee.prototype,"_diffuseTexture",void 0);D([je("_markAllSubMeshesAsTexturesAndMiscDirty")],ee.prototype,"diffuseTexture",void 0);D([_i("ambientTexture")],ee.prototype,"_ambientTexture",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"ambientTexture",void 0);D([_i("opacityTexture")],ee.prototype,"_opacityTexture",void 0);D([je("_markAllSubMeshesAsTexturesAndMiscDirty")],ee.prototype,"opacityTexture",void 0);D([_i("reflectionTexture")],ee.prototype,"_reflectionTexture",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"reflectionTexture",void 0);D([_i("emissiveTexture")],ee.prototype,"_emissiveTexture",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"emissiveTexture",void 0);D([_i("specularTexture")],ee.prototype,"_specularTexture",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"specularTexture",void 0);D([_i("bumpTexture")],ee.prototype,"_bumpTexture",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"bumpTexture",void 0);D([_i("lightmapTexture")],ee.prototype,"_lightmapTexture",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"lightmapTexture",void 0);D([_i("refractionTexture")],ee.prototype,"_refractionTexture",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"refractionTexture",void 0);D([ls("ambient")],ee.prototype,"ambientColor",void 0);D([ls("diffuse")],ee.prototype,"diffuseColor",void 0);D([ls("specular")],ee.prototype,"specularColor",void 0);D([ls("emissive")],ee.prototype,"emissiveColor",void 0);D([B()],ee.prototype,"specularPower",void 0);D([B("useAlphaFromDiffuseTexture")],ee.prototype,"_useAlphaFromDiffuseTexture",void 0);D([je("_markAllSubMeshesAsTexturesAndMiscDirty")],ee.prototype,"useAlphaFromDiffuseTexture",void 0);D([B("useEmissiveAsIllumination")],ee.prototype,"_useEmissiveAsIllumination",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useEmissiveAsIllumination",void 0);D([B("linkEmissiveWithDiffuse")],ee.prototype,"_linkEmissiveWithDiffuse",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"linkEmissiveWithDiffuse",void 0);D([B("useSpecularOverAlpha")],ee.prototype,"_useSpecularOverAlpha",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useSpecularOverAlpha",void 0);D([B("useReflectionOverAlpha")],ee.prototype,"_useReflectionOverAlpha",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useReflectionOverAlpha",void 0);D([B("disableLighting")],ee.prototype,"_disableLighting",void 0);D([je("_markAllSubMeshesAsLightsDirty")],ee.prototype,"disableLighting",void 0);D([B("useObjectSpaceNormalMap")],ee.prototype,"_useObjectSpaceNormalMap",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useObjectSpaceNormalMap",void 0);D([B("useParallax")],ee.prototype,"_useParallax",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useParallax",void 0);D([B("useParallaxOcclusion")],ee.prototype,"_useParallaxOcclusion",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useParallaxOcclusion",void 0);D([B()],ee.prototype,"parallaxScaleBias",void 0);D([B("roughness")],ee.prototype,"_roughness",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"roughness",void 0);D([B()],ee.prototype,"indexOfRefraction",void 0);D([B()],ee.prototype,"invertRefractionY",void 0);D([B()],ee.prototype,"alphaCutOff",void 0);D([B("useLightmapAsShadowmap")],ee.prototype,"_useLightmapAsShadowmap",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useLightmapAsShadowmap",void 0);D([Kn("diffuseFresnelParameters")],ee.prototype,"_diffuseFresnelParameters",void 0);D([je("_markAllSubMeshesAsFresnelDirty")],ee.prototype,"diffuseFresnelParameters",void 0);D([Kn("opacityFresnelParameters")],ee.prototype,"_opacityFresnelParameters",void 0);D([je("_markAllSubMeshesAsFresnelAndMiscDirty")],ee.prototype,"opacityFresnelParameters",void 0);D([Kn("reflectionFresnelParameters")],ee.prototype,"_reflectionFresnelParameters",void 0);D([je("_markAllSubMeshesAsFresnelDirty")],ee.prototype,"reflectionFresnelParameters",void 0);D([Kn("refractionFresnelParameters")],ee.prototype,"_refractionFresnelParameters",void 0);D([je("_markAllSubMeshesAsFresnelDirty")],ee.prototype,"refractionFresnelParameters",void 0);D([Kn("emissiveFresnelParameters")],ee.prototype,"_emissiveFresnelParameters",void 0);D([je("_markAllSubMeshesAsFresnelDirty")],ee.prototype,"emissiveFresnelParameters",void 0);D([B("useReflectionFresnelFromSpecular")],ee.prototype,"_useReflectionFresnelFromSpecular",void 0);D([je("_markAllSubMeshesAsFresnelDirty")],ee.prototype,"useReflectionFresnelFromSpecular",void 0);D([B("useGlossinessFromSpecularMapAlpha")],ee.prototype,"_useGlossinessFromSpecularMapAlpha",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"useGlossinessFromSpecularMapAlpha",void 0);D([B("maxSimultaneousLights")],ee.prototype,"_maxSimultaneousLights",void 0);D([je("_markAllSubMeshesAsLightsDirty")],ee.prototype,"maxSimultaneousLights",void 0);D([B("invertNormalMapX")],ee.prototype,"_invertNormalMapX",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"invertNormalMapX",void 0);D([B("invertNormalMapY")],ee.prototype,"_invertNormalMapY",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"invertNormalMapY",void 0);D([B("twoSidedLighting")],ee.prototype,"_twoSidedLighting",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],ee.prototype,"twoSidedLighting",void 0);D([B("applyDecalMapAfterDetailMap")],ee.prototype,"_applyDecalMapAfterDetailMap",void 0);D([je("_markAllSubMeshesAsMiscDirty")],ee.prototype,"applyDecalMapAfterDetailMap",void 0);vt("BABYLON.StandardMaterial",ee);it.DefaultMaterialFactory=a=>new ee("default material",a);function Dg(a,e){const t=e.method||"GET";return new Promise((i,s)=>{const n=new Ft;n.addEventListener("readystatechange",()=>{if(n.readyState==4)if(n.status==200){const r={};if(e.responseHeaders)for(const o of e.responseHeaders)r[o]=n.getResponseHeader(o)||"";i({response:n.response,headerValues:r})}else s("Unable to fetch data from ".concat(a,". Error code: ").concat(n.status))}),n.open(t,a),n.send()})}var Zh;(function(a){a[a.Clean=0]="Clean",a[a.Stop=1]="Stop",a[a.Sync=2]="Sync",a[a.NoSync=3]="NoSync"})(Zh||(Zh={}));function Fg(a){return!!a.createPlugin}function Og(a){return!!a.name}const Vc=new Z,Wi={};let Ra=!1;function $r(){return Wi[".babylon"]}function Bg(a){for(const e in Wi){const t=Wi[e];if(t.mimeType===a)return t}}function Ka(a,e){const t=Wi[a];return t||(U.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?$r():void 0)}function Lg(a){return!!Wi[a]}function Ng(a){for(const e in Wi){const t=Wi[e].plugin;if(t.canDirectLoad&&t.canDirectLoad(a))return Wi[e]}return $r()}function Ug(a){const e=a.indexOf("?");e!==-1&&(a=a.substring(0,e));const t=a.lastIndexOf(".");return a.substring(t,a.length).toLowerCase()}function kg(a){return a.substring(0,5)==="data:"?a.substring(5):null}function z0(a,e,t){let s="Unable to load from "+(a.rawData?"binary data":a.url);return e?s+=": ".concat(e):t&&(s+=": ".concat(t)),s}async function W0(a,e,t,i,s,n,r,o,h){var d;const l=kg(a.url);if(a.rawData&&!r)throw"When using ArrayBufferView to load data the file extension must be provided.";const c=!l&&!r?Ug(a.url):"";let u=r?Ka(r,!0):l?Ng(a.url):Ka(c,!1);if(!u&&c){if(a.url&&!a.url.startsWith("blob:")){const _=await Dg(a.url,{method:"HEAD",responseHeaders:["Content-Type"]}),p=_.headerValues?_.headerValues["Content-Type"]:"";p&&(u=Bg(p))}u||(u=$r())}if(!u)throw new Error("No plugin or fallback for ".concat(r!=null?r:a.url));if(((d=h==null?void 0:h[u.plugin.name])==null?void 0:d.enabled)===!1)throw new Error("The '".concat(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(_=>{if(Fg(u.plugin)){const g=u.plugin.createPlugin(h!=null?h:{});return g instanceof Promise?(g.then(_).catch(m=>{s("Error instantiating plugin.",m)}),null):(_(g),g)}else return _(u.plugin),u.plugin})(_=>{var y;if(!_)throw"The loader plugin corresponding to the '".concat(r,"' file type has not been found. If using es6, please import the plugin you wish to use before.");if(Vc.notifyObservers(_),l&&(_.canDirectLoad&&_.canDirectLoad(a.url)||!y0(a.url))){if(_.directLoad){const R=_.directLoad(e,l);R instanceof Promise?R.then(E=>{t(_,E)}).catch(E=>{s("Error in directLoad of _loadData: "+E,E)}):t(_,R)}else t(_,l);return}const p=u.isBinary,g=(R,E)=>{if(e.isDisposed){s("Scene has been disposed");return}t(_,R,E)};let m=null,b=!1;(y=_.onDisposeObservable)==null||y.add(()=>{b=!0,m&&(m.abort(),m=null),n()});const I=()=>{if(b)return;const R=(E,C)=>{s(E==null?void 0:E.statusText,C)};if(!_.loadFile&&a.rawData)throw"Plugin does not support loading ArrayBufferView.";m=_.loadFile?_.loadFile(e,a.rawData||a.file||a.url,a.rootUrl,g,i,p,R,o):e._loadFile(a.file||a.url,g,i,!0,p,R)},T=e.getEngine();let x=T.enableOfflineSupport;if(x){let R=!1;for(const E of e.disableOfflineSupportExceptionRules)if(E.test(a.url)){R=!0;break}x=!R}x&&ae.OfflineProviderFactory?e.offlineProvider=ae.OfflineProviderFactory(a.url,I,T.disableManifestCheck):I()})}function H0(a,e){let t,i,s=null,n=null;if(!e)t=a,i=J.GetFilename(a),a=J.GetFolderPath(a);else if(Og(e))t="file:".concat(e.name),i=e.name,s=e;else if(ArrayBuffer.isView(e))t="",i=g0(),n=e;else if(e.startsWith("data:"))t=e,i="";else if(a){const r=e;if(r.substring(0,1)==="/")return J.Error("Wrong sceneFilename parameter"),null;t=a+r,i=r}else t=e,i=J.GetFilename(e),a=J.GetFolderPath(e);return{url:t,rootUrl:a,name:i,file:s,rawData:n}}function Gc(a){if(typeof a.extensions=="string"){const e=a.extensions;Wi[e.toLowerCase()]={plugin:a,isBinary:!1}}else{const e=a.extensions;Object.keys(e).forEach(t=>{Wi[t.toLowerCase()]={plugin:a,isBinary:e[t].isBinary,mimeType:e[t].mimeType}})}}async function zc(a,e,t="",i=Ee.LastCreatedScene,s=null,n=null,r=null,o=null,h="",l={}){if(!i)return U.Error("No scene available to import mesh to"),null;const c=H0(e,t);if(!c)return null;const u={};i.addPendingData(u);const f=()=>{i.removePendingData(u)},d=(g,m)=>{const b=z0(c,g,m);r?r(i,b,new cs(b,Hs.SceneLoaderError,m)):U.Error(b),f()},_=n?g=>{try{n(g)}catch(m){d("Error in onProgress callback: "+m,m)}}:void 0,p=(g,m,b,I,T,x,y,R)=>{if(i.importedMeshesFiles.push(c.url),s)try{s(g,m,b,I,T,x,y,R)}catch(E){d("Error in onSuccess callback: "+E,E)}i.removePendingData(u)};return await W0(c,i,(g,m,b)=>{if(g.rewriteRootURL&&(c.rootUrl=g.rewriteRootURL(c.rootUrl,b)),g.importMesh){const I=g,T=[],x=[],y=[];if(!I.importMesh(a,i,m,c.rootUrl,T,x,y,d))return;i.loadingPluginName=g.name,p(T,x,y,[],[],[],[],[])}else g.importMeshAsync(a,i,m,c.rootUrl,_,c.name).then(T=>{i.loadingPluginName=g.name,p(T.meshes,T.particleSystems,T.skeletons,T.animationGroups,T.transformNodes,T.geometries,T.lights,T.spriteManagers)}).catch(T=>{d(T.message,T)})},_,d,f,o,h,l)}function Vg(a,e,t,i,s,n,r,o){return new Promise((h,l)=>{zc(a,e,t,i,(c,u,f,d,_,p,g,m)=>{h({meshes:c,particleSystems:u,skeletons:f,animationGroups:d,transformNodes:_,geometries:p,lights:g,spriteManagers:m})},s,(c,u,f)=>{l(f||new Error(u))},n,r,o)})}function Wc(a,e="",t=Ee.LastCreatedEngine,i=null,s=null,n=null,r=null,o="",h={}){if(!t){J.Error("No engine available");return}K0(a,e,new it(t),i,s,n,r,o,h)}function Gg(a,e,t,i,s,n,r){return new Promise((o,h)=>{Wc(a,e,t,l=>{o(l)},i,(l,c,u)=>{h(u||new Error(c))},s,n,r)})}async function K0(a,e="",t=Ee.LastCreatedScene,i=null,s=null,n=null,r=null,o="",h={}){if(!t)return U.Error("No scene available to append to"),null;const l=H0(a,e);if(!l)return null;const c={};t.addPendingData(c);const u=()=>{t.removePendingData(c)};Tt.ShowLoadingScreen&&!Ra&&(Ra=!0,t.getEngine().displayLoadingUI(),t.executeWhenReady(()=>{t.getEngine().hideLoadingUI(),Ra=!1}));const f=(p,g)=>{const m=z0(l,p,g);n?n(t,m,new cs(m,Hs.SceneLoaderError,g)):U.Error(m),u()},d=s?p=>{try{s(p)}catch(g){f("Error in onProgress callback",g)}}:void 0,_=()=>{if(i)try{i(t)}catch(p){f("Error in onSuccess callback",p)}t.removePendingData(c)};return await W0(l,t,(p,g)=>{if(p.load){if(!p.load(t,g,l.rootUrl,f))return;t.loadingPluginName=p.name,_()}else p.loadAsync(t,g,l.rootUrl,d,l.name).then(()=>{t.loadingPluginName=p.name,_()}).catch(b=>{f(b.message,b)})},d,f,u,r,o,h)}function zg(a,e,t,i,s,n,r){return new Promise((o,h)=>{K0(a,e,t,l=>{o(l)},i,(l,c,u)=>{h(u||new Error(c))},s,n,r)})}async function X0(a,e="",t=Ee.LastCreatedScene,i=null,s=null,n=null,r=null,o="",h={}){if(!t)return U.Error("No scene available to load asset container to"),null;const l=H0(a,e);if(!l)return null;const c={};t.addPendingData(c);const u=()=>{t.removePendingData(c)},f=(p,g)=>{const m=z0(l,p,g);n?n(t,m,new cs(m,Hs.SceneLoaderError,g)):U.Error(m),u()},d=s?p=>{try{s(p)}catch(g){f("Error in onProgress callback",g)}}:void 0,_=p=>{if(i)try{i(p)}catch(g){f("Error in onSuccess callback",g)}t.removePendingData(c)};return await W0(l,t,(p,g)=>{if(p.loadAssetContainer){const b=p.loadAssetContainer(t,g,l.rootUrl,f);if(!b)return;b.populateRootNodes(),t.loadingPluginName=p.name,_(b)}else p.loadAssetContainerAsync?p.loadAssetContainerAsync(t,g,l.rootUrl,d,l.name).then(b=>{b.populateRootNodes(),t.loadingPluginName=p.name,_(b)}).catch(b=>{f(b.message,b)}):f("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.")},d,f,u,r,o,h)}function Wg(a,e,t,i,s,n,r){return new Promise((o,h)=>{X0(a,e,t,l=>{o(l)},i,(l,c,u)=>{h(u||new Error(c))},s,n,r)})}function Hc(a,e="",t=Ee.LastCreatedScene,i=!0,s=0,n=null,r=null,o=null,h=null,l=null,c="",u={}){if(!t){U.Error("No scene available to load animations to");return}if(i){for(const p of t.animatables)p.reset();t.stopAllAnimations(),t.animationGroups.slice().forEach(p=>{p.dispose()}),t.getNodes().forEach(p=>{p.animations&&(p.animations=[])})}else switch(s){case 0:t.animationGroups.slice().forEach(_=>{_.dispose()});break;case 1:t.animationGroups.forEach(_=>{_.stop()});break;case 2:t.animationGroups.forEach(_=>{_.reset(),_.restart()});break;case 3:break;default:U.Error("Unknown animation group loading mode value '"+s+"'");return}const f=t.animatables.length;X0(a,e,t,_=>{_.mergeAnimationsTo(t,t.animatables.slice(f),n),_.dispose(),t.onAnimationFileImportedObservable.notifyObservers(t),r&&r(t)},o,h,l,c,u)}function Hg(a,e,t,i,s,n,r,o,h,l){return new Promise((c,u)=>{Hc(a,e,t,i,s,n,f=>{c(f)},r,(f,d,_)=>{u(_||new Error(d))},o,h,l)})}class ks{static get ForceFullSceneLoadingForIncremental(){return Tt.ForceFullSceneLoadingForIncremental}static set ForceFullSceneLoadingForIncremental(e){Tt.ForceFullSceneLoadingForIncremental=e}static get ShowLoadingScreen(){return Tt.ShowLoadingScreen}static set ShowLoadingScreen(e){Tt.ShowLoadingScreen=e}static get loggingLevel(){return Tt.loggingLevel}static set loggingLevel(e){Tt.loggingLevel=e}static get CleanBoneMatrixWeights(){return Tt.CleanBoneMatrixWeights}static set CleanBoneMatrixWeights(e){Tt.CleanBoneMatrixWeights=e}static GetDefaultPlugin(){return $r()}static GetPluginForExtension(e){var t;return(t=Ka(e,!0))==null?void 0:t.plugin}static IsPluginForExtensionAvailable(e){return Lg(e)}static RegisterPlugin(e){Gc(e)}static ImportMesh(e,t,i,s,n,r,o,h,l){zc(e,t,i,s,n,r,o,h,l)}static ImportMeshAsync(e,t,i,s,n,r,o){return Vg(e,t,i,s,n,r,o)}static Load(e,t,i,s,n,r,o,h){Wc(e,t,i,s,n,r,o,h)}static LoadAsync(e,t,i,s,n,r){return Gg(e,t,i,s,n,r)}static Append(e,t,i,s,n,r,o,h){K0(e,t,i,s,n,r,o,h)}static AppendAsync(e,t,i,s,n,r){return zg(e,t,i,s,n,r)}static LoadAssetContainer(e,t,i,s,n,r,o,h){X0(e,t,i,s,n,r,o,h)}static LoadAssetContainerAsync(e,t,i,s,n,r){return Wg(e,t,i,s,n,r)}static ImportAnimations(e,t,i,s,n,r,o,h,l,c,u){Hc(e,t,i,s,n,r,o,h,l,c,u)}static ImportAnimationsAsync(e,t,i,s,n,r,o,h,l,c,u){return Hg(e,t,i,s,n,r,h,c,u)}}ks.NO_LOGGING=0;ks.MINIMAL_LOGGING=1;ks.SUMMARY_LOGGING=2;ks.DETAILED_LOGGING=3;ks.OnPluginActivatedObservable=Vc;class Zr extends mt{getClassName(){return"FxaaPostProcess"}constructor(e,t,i=null,s,n,r,o=0){super(e,"fxaa",["texelSize"],null,t,i,s||ie.BILINEAR_SAMPLINGMODE,n,r,null,o,"fxaa",void 0,!0);const h=this._getDefines();this.updateEffect(h),this.onApplyObservable.add(l=>{const c=this.texelSize;l.setFloat2("texelSize",c.x,c.y)})}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([Oe(()=>import("./fxaa.fragment-CKBSH8ak.js"),__vite__mapDeps([40,3,4,5,6,7,8,9,10])),Oe(()=>import("./fxaa.vertex-pl3gzfER.js"),__vite__mapDeps([41,3,4,5,6,7,8,9,10]))]))):t.push(Promise.all([Oe(()=>import("./fxaa.fragment-CQ-OctB5.js"),__vite__mapDeps([42,3,4,5,6,7,8,9,10])),Oe(()=>import("./fxaa.vertex-D11BDiUg.js"),__vite__mapDeps([43,3,4,5,6,7,8,9,10]))])),super._gatherImports(e,t)}_getDefines(){const e=this.getEngine();return e&&e.extractDriverInfo().toLowerCase().indexOf("mali")>-1?"#define MALI 1\n":null}static _Parse(e,t,i,s){return Ae.Parse(()=>new Zr(e.name,e.options,t,e.renderTargetSamplingMode,i.getEngine(),e.reusable),e,i,s)}}vt("BABYLON.FxaaPostProcess",Zr);let Ds,Os=null;async function Kg(){return Os||(Os=new Promise((a,e)=>{let t,i=null;const s={preserveDrawingBuffer:!0,depth:!1,stencil:!1,alpha:!0,premultipliedAlpha:!1,antialias:!1,failIfMajorPerformanceCaveat:!1};Oe(async()=>{const{ThinEngine:n}=await Promise.resolve().then(()=>kd);return{ThinEngine:n}},void 0).then(({ThinEngine:n})=>{try{t=new OffscreenCanvas(100,100),i=new n(t,!1,s)}catch{t=document.createElement("canvas"),i=new n(t,!1,s)}Ee.Instances.pop(),Ee.OnEnginesDisposedObservable.add(o=>{i&&o!==i&&!i.isDisposed&&Ee.Instances.length===0&&j0()}),i.getCaps().parallelShaderCompile=void 0;const r=new tp(i);Oe(async()=>{const{passPixelShader:o}=await import("./pass.fragment-BkcfUm5b.js");return{passPixelShader:o}},__vite__mapDeps([19,3,4,5,6,7,8,9,10])).then(({passPixelShader:o})=>{if(!i){e("Engine is not defined");return}const h=new Kt({engine:i,name:o.name,fragmentShader:o.shader,samplerNames:["textureSampler"]});Ds={canvas:t,engine:i,renderer:r,wrapper:h},a(Ds)})}).catch(e)})),await Os}async function Y0(a,e,t,i,s="image/png",n,r){const o=await t.readPixels(0,0,a,e),h=new Uint8Array(o.buffer);Vs(a,e,h,i,s,n,!0,void 0,r)}function q0(a,e,t,i="image/png",s,n=!1,r=!1,o){return new Promise(h=>{Vs(a,e,t,l=>h(l),i,s,n,r,o)})}function Vs(a,e,t,i,s="image/png",n,r=!1,o=!1,h){Kg().then(l=>{if(l.engine.setSize(a,e,!0),t instanceof Float32Array){const u=new Uint8Array(t.length);let f=t.length;for(;f--;){const d=t[f];u[f]=Math.round(ht(d)*255)}t=u}const c=l.engine.createRawTexture(t,a,e,5,!1,!r,1);l.renderer.setViewport(),l.renderer.applyEffectWrapper(l.wrapper),l.wrapper.effect._bindTexture("textureSampler",c),l.renderer.draw(),o?J.ToBlob(l.canvas,u=>{const f=new FileReader;f.onload=d=>{const _=d.target.result;i&&i(_)},f.readAsArrayBuffer(u)},s,h):J.EncodeScreenshotCanvasData(l.canvas,i,s,n,h),c.dispose()})}function j0(){Ds?(Ds.wrapper.dispose(),Ds.renderer.dispose(),Ds.engine.dispose()):Os==null||Os.then(a=>{a.wrapper.dispose(),a.renderer.dispose(),a.engine.dispose()}),Os=null,Ds=null}const Xg={DumpData:Vs,DumpDataAsync:q0,DumpFramebuffer:Y0,Dispose:j0},Yg=()=>{J.DumpData=Vs,J.DumpDataAsync=q0,J.DumpFramebuffer=Y0};Yg();const qg=Object.freeze(Object.defineProperty({__proto__:null,Dispose:j0,DumpData:Vs,DumpDataAsync:q0,DumpFramebuffer:Y0,DumpTools:Xg},Symbol.toStringTag,{value:"Module"}));let ps=null;function Qr(a,e,t,i,s="image/png",n=!1,r){const{height:o,width:h}=Yc(a,e,t);if(!(o&&h)){U.Error("Invalid 'size' parameter !");return}ps||(ps=document.createElement("canvas")),ps.width=h,ps.height=o;const l=ps.getContext("2d"),c=a.getRenderWidth()/a.getRenderHeight();let u=h,f=u/c;f>o&&(f=o,u=f*c);const d=Math.max(0,h-u)/2,_=Math.max(0,o-f)/2;e.getScene().activeCamera!==e?Jr(a,e,t,g=>{if(n){const m=new Blob([g]);J.DownloadBlob(m),i&&i("")}else i&&i(g)},s,1,a.getCreationOptions().antialias,void 0,void 0,void 0,void 0,r):a.onEndFrameObservable.addOnce(()=>{const g=a.getRenderingCanvas();l&&g&&l.drawImage(g,d,_,u,f),ps&&(n?(J.EncodeScreenshotCanvasData(ps,void 0,s,void 0,r),i&&i("")):J.EncodeScreenshotCanvasData(ps,i,s,void 0,r))})}function Kc(a,e,t,i="image/png",s){return new Promise((n,r)=>{Qr(a,e,t,o=>{typeof o<"u"?n(o):r(new Error("Data is undefined"))},i,void 0,s)})}function jg(a,e,t,i,s="image/png",n){return new Promise(r=>{Qr(a,e,{width:t,height:i},()=>{r()},s,!0,n)})}function Jr(a,e,t,i,s="image/png",n=1,r=!1,o,h=!1,l=!1,c=!0,u,f){const{height:d,width:_,finalWidth:p,finalHeight:g}=Yc(a,e,t),m={width:_,height:d};if(!(d&&_)){U.Error("Invalid 'size' parameter !");return}const b={width:a.getRenderWidth(),height:a.getRenderHeight()};a.setSize(_,d);const I=e.getScene(),T=new us("screenShot",m,I,!1,!1,0,!1,ie.BILINEAR_SAMPLINGMODE,void 0,l,void 0,void 0,void 0,n);T.renderList=I.meshes.slice(),T.samples=n,T.renderSprites=h,T.activeCamera=e,T.forceLayerMaskCheck=c,f==null||f(T);const x=()=>{T.isReadyForRendering()&&e.isReady(!0)?(a.onEndFrameObservable.addOnce(()=>{p===_&&g===d?T.readPixels(void 0,void 0,void 0,!1).then(R=>{Vs(_,d,R,i,s,o,!0,void 0,u),T.dispose()}):(a.isWebGPU?Oe(()=>import("./pass.fragment-CM2j9WLA.js"),__vite__mapDeps([18,3,4,5,6,7,8,9,10])):Oe(()=>import("./pass.fragment-BkcfUm5b.js"),__vite__mapDeps([19,3,4,5,6,7,8,9,10]))).then(()=>ip("pass",T.getInternalTexture(),I,void 0,void 0,void 0,p,g).then(E=>{a._readTexturePixels(E,p,g,-1,0,null,!0,!1,0,0).then(C=>{Vs(p,g,C,i,s,o,!0,void 0,u),E.dispose()})}))}),I.incrementRenderId(),I.resetCachedMaterial(),T.render(!0),a.setSize(b.width,b.height),e.getProjectionMatrix(!0)):setTimeout(x,16)},y=()=>{I.incrementRenderId(),I.resetCachedMaterial(),x()};if(r){const R=new Zr("antialiasing",1,I.activeCamera);T.addPostProcess(R),R.onEffectCreatedObservable.addOnce(E=>{E.isReady()?y():E.onCompiled=()=>{y()}})}else y()}function Xc(a,e,t,i="image/png",s=1,n=!1,r,o=!1,h=!1,l=!0,c,u){return new Promise((f,d)=>{Jr(a,e,t,_=>{typeof _<"u"?f(_):d(new Error("Data is undefined"))},i,s,n,r,o,h,l,c,u)})}function Yc(a,e,t){let i=0,s=0,n=0,r=0;if(typeof t=="object"){const o=t.precision?Math.abs(t.precision):1;t.width&&t.height?(i=t.height*o,s=t.width*o):t.width&&!t.height?(s=t.width*o,i=Math.round(s/a.getAspectRatio(e))):t.height&&!t.width?(i=t.height*o,s=Math.round(i*a.getAspectRatio(e))):(s=Math.round(a.getRenderWidth()*o),i=Math.round(s/a.getAspectRatio(e))),t.finalWidth&&t.finalHeight?(r=t.finalHeight,n=t.finalWidth):t.finalWidth&&!t.finalHeight?(n=t.finalWidth,r=Math.round(n/a.getAspectRatio(e))):t.finalHeight&&!t.finalWidth?(r=t.finalHeight,n=Math.round(r*a.getAspectRatio(e))):(n=s,r=i)}else isNaN(t)||(i=t,s=t,n=t,r=t);return s&&(s=Math.floor(s)),i&&(i=Math.floor(i)),n&&(n=Math.floor(n)),r&&(r=Math.floor(r)),{height:i|0,width:s|0,finalWidth:n|0,finalHeight:r|0}}const $g={CreateScreenshot:Qr,CreateScreenshotAsync:Kc,CreateScreenshotWithResizeAsync:jg,CreateScreenshotUsingRenderTarget:Jr,CreateScreenshotUsingRenderTargetAsync:Xc},Zg=()=>{J.CreateScreenshot=Qr,J.CreateScreenshotAsync=Kc,J.CreateScreenshotUsingRenderTarget=Jr,J.CreateScreenshotUsingRenderTargetAsync=Xc};Zg();F._instancedMeshFactory=(a,e)=>{const t=new ea(a,e);if(e.instancedBuffers){t.instancedBuffers={};for(const i in e.instancedBuffers)t.instancedBuffers[i]=e.instancedBuffers[i]}return t};class ea extends Qe{constructor(e,t){super(e,t.getScene()),this._indexInSourceMeshInstanceArray=-1,this._distanceToCamera=0,t.addInstance(this),this._sourceMesh=t,this._unIndexed=t._unIndexed,this.position.copyFrom(t.position),this.rotation.copyFrom(t.rotation),this.scaling.copyFrom(t.scaling),t.rotationQuaternion&&(this.rotationQuaternion=t.rotationQuaternion.clone()),this.animations=t.animations.slice();for(const i of t.getAnimationRanges())i!=null&&this.createAnimationRange(i.name,i.from,i.to);this.infiniteDistance=t.infiniteDistance,this.setPivotMatrix(t.getPivotMatrix()),this.refreshBoundingInfo(!0,!0),this._syncSubMeshes()}getClassName(){return"InstancedMesh"}get lightSources(){return this._sourceMesh._lightSources}_resyncLightSources(){}_resyncLightSource(){}_removeLightSource(){}get receiveShadows(){return this._sourceMesh.receiveShadows}set receiveShadows(e){var t;((t=this._sourceMesh)==null?void 0:t.receiveShadows)!==e&&J.Warn("Setting receiveShadows on an instanced mesh has no effect")}get material(){return this._sourceMesh.material}set material(e){var t;((t=this._sourceMesh)==null?void 0:t.material)!==e&&J.Warn("Setting material on an instanced mesh has no effect")}get visibility(){return this._sourceMesh.visibility}set visibility(e){var t;((t=this._sourceMesh)==null?void 0:t.visibility)!==e&&J.Warn("Setting visibility on an instanced mesh has no effect")}get skeleton(){return this._sourceMesh.skeleton}set skeleton(e){var t;((t=this._sourceMesh)==null?void 0:t.skeleton)!==e&&J.Warn("Setting skeleton on an instanced mesh has no effect")}get renderingGroupId(){return this._sourceMesh.renderingGroupId}set renderingGroupId(e){!this._sourceMesh||e===this._sourceMesh.renderingGroupId||U.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene")}getTotalVertices(){return this._sourceMesh?this._sourceMesh.getTotalVertices():0}getTotalIndices(){return this._sourceMesh.getTotalIndices()}get sourceMesh(){return this._sourceMesh}createInstance(e){return this._sourceMesh.createInstance(e)}isReady(e=!1){return this._sourceMesh.isReady(e,!0)}getVerticesData(e,t,i){return this._sourceMesh.getVerticesData(e,t,i)}copyVerticesData(e,t){this._sourceMesh.copyVerticesData(e,t)}setVerticesData(e,t,i,s){return this.sourceMesh&&this.sourceMesh.setVerticesData(e,t,i,s),this.sourceMesh}updateVerticesData(e,t,i,s){return this.sourceMesh&&this.sourceMesh.updateVerticesData(e,t,i,s),this.sourceMesh}setIndices(e,t=null){return this.sourceMesh&&this.sourceMesh.setIndices(e,t),this.sourceMesh}isVerticesDataPresent(e){return this._sourceMesh.isVerticesDataPresent(e)}getIndices(){return this._sourceMesh.getIndices()}get _positions(){return this._sourceMesh._positions}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._sourceMesh.geometry?this._sourceMesh.geometry.boundingBias:null;return this._refreshBoundingInfo(this._sourceMesh._getData(i,null,A.PositionKind),s),this}_preActivate(){return this._currentLOD&&this._currentLOD._preActivate(),this}_activate(e,t){if(super._activate(e,t),this._sourceMesh.subMeshes||U.Warn("Instances should only be created for meshes with geometry."),this._currentLOD){if(this._currentLOD._getWorldMatrixDeterminant()>=0!=this._getWorldMatrixDeterminant()>=0)return this._internalAbstractMeshDataInfo._actAsRegularMesh=!0,!0;if(this._internalAbstractMeshDataInfo._actAsRegularMesh=!1,this._currentLOD._registerInstanceForRenderId(this,e),t){if(!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate=!0,!0}else if(!this._currentLOD._internalAbstractMeshDataInfo._isActive)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances=!0,!0}return!1}_postActivate(){this._sourceMesh.edgesShareWithInstances&&this._sourceMesh._edgesRenderer&&this._sourceMesh._edgesRenderer.isEnabled&&this._sourceMesh._renderingGroup?(this._sourceMesh._renderingGroup._edgesRenderers.pushNoDuplicate(this._sourceMesh._edgesRenderer),this._sourceMesh._edgesRenderer.customInstances.push(this.getWorldMatrix())):this._edgesRenderer&&this._edgesRenderer.isEnabled&&this._sourceMesh._renderingGroup&&this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer)}getWorldMatrix(){if(this._currentLOD&&this._currentLOD.billboardMode!==Te.BILLBOARDMODE_NONE&&this._currentLOD._masterMesh!==this){this._billboardWorldMatrix||(this._billboardWorldMatrix=new O);const e=this._currentLOD._masterMesh;return this._currentLOD._masterMesh=this,N.Vector3[7].copyFrom(this._currentLOD.position),this._currentLOD.position.set(0,0,0),this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(!0)),this._currentLOD.position.copyFrom(N.Vector3[7]),this._currentLOD._masterMesh=e,this._billboardWorldMatrix}return super.getWorldMatrix()}get isAnInstance(){return!0}getLOD(e){if(!e)return this;const t=this.sourceMesh.getLODLevels();if(!t||t.length===0)this._currentLOD=this.sourceMesh;else{const i=this.getBoundingInfo();this._currentLOD=this.sourceMesh.getLOD(e,i.boundingSphere)}return this._currentLOD}_preActivateForIntermediateRendering(e){return this.sourceMesh._preActivateForIntermediateRendering(e)}_syncSubMeshes(){if(this.releaseSubMeshes(),this._sourceMesh.subMeshes)for(let e=0;e<this._sourceMesh.subMeshes.length;e++)this._sourceMesh.subMeshes[e].clone(this,this._sourceMesh);return this}_generatePointsArray(){return this._sourceMesh._generatePointsArray()}_updateBoundingInfo(){return this.hasBoundingInfo?this.getBoundingInfo().update(this.worldMatrixFromCache):this.buildBoundingInfo(this.absolutePosition,this.absolutePosition,this.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache),this}clone(e,t=null,i,s){const n=(s||this._sourceMesh).createInstance(e);if(I0.DeepCopy(this,n,["name","subMeshes","uniqueId","parent","lightSources","receiveShadows","material","visibility","skeleton","sourceMesh","isAnInstance","facetNb","isFacetDataEnabled","isBlocked","useBones","hasInstances","collider","edgesRenderer","forward","up","right","absolutePosition","absoluteScaling","absoluteRotationQuaternion","isWorldMatrixFrozen","nonUniformScaling","behaviors","worldMatrixFromCache","hasThinInstances","hasBoundingInfo"],[]),this.refreshBoundingInfo(),t&&(n.parent=t),!i)for(let r=0;r<this.getScene().meshes.length;r++){const o=this.getScene().meshes[r];o.parent===this&&o.clone(o.name,n)}return n.computeWorldMatrix(!0),this.onClonedObservable.notifyObservers(n),n}dispose(e,t=!1){this._sourceMesh.removeInstance(this),super.dispose(e,t)}_serializeAsParent(e){super._serializeAsParent(e),e.parentId=this._sourceMesh.uniqueId,e.parentInstanceIndex=this._indexInSourceMeshInstanceArray}instantiateHierarchy(e=null,t,i){const s=this.clone("Clone of "+(this.name||this.id),e||this.parent,!0,t&&t.newSourcedMesh);s&&i&&i(this,s);for(const n of this.getChildTransformNodes(!0))n.instantiateHierarchy(s,t,i);return s}}F.prototype.registerInstancedBuffer=function(a,e){var t,i;if((i=(t=this._userInstancedBuffersStorage)==null?void 0:t.vertexBuffers[a])==null||i.dispose(),!this.instancedBuffers){this.instancedBuffers={};for(const s of this.instances)s.instancedBuffers={}}this._userInstancedBuffersStorage||(this._userInstancedBuffersStorage={data:{},vertexBuffers:{},strides:{},sizes:{},vertexArrayObjects:this.getEngine().getCaps().vertexArrayObject?{}:void 0}),this.instancedBuffers[a]=null,this._userInstancedBuffersStorage.strides[a]=e,this._userInstancedBuffersStorage.sizes[a]=e*32,this._userInstancedBuffersStorage.data[a]=new Float32Array(this._userInstancedBuffersStorage.sizes[a]),this._userInstancedBuffersStorage.vertexBuffers[a]=new A(this.getEngine(),this._userInstancedBuffersStorage.data[a],a,!0,!1,e,!0);for(const s of this.instances)s.instancedBuffers[a]=null;this._invalidateInstanceVertexArrayObject(),this._markSubMeshesAsAttributesDirty()};F.prototype._processInstancedBuffers=function(a,e){const t=a?a.length:0;for(const i in this.instancedBuffers){let s=this._userInstancedBuffersStorage.sizes[i];const n=this._userInstancedBuffersStorage.strides[i],r=(t+1)*n;for(;s<r;)s*=2;this._userInstancedBuffersStorage.data[i].length!=s&&(this._userInstancedBuffersStorage.data[i]=new Float32Array(s),this._userInstancedBuffersStorage.sizes[i]=s,this._userInstancedBuffersStorage.vertexBuffers[i]&&(this._userInstancedBuffersStorage.vertexBuffers[i].dispose(),this._userInstancedBuffersStorage.vertexBuffers[i]=null));const o=this._userInstancedBuffersStorage.data[i];let h=0;if(e){const l=this.instancedBuffers[i];l.toArray?l.toArray(o,h):l.copyToArray?l.copyToArray(o,h):o[h]=l,h+=n}for(let l=0;l<t;l++){const u=a[l].instancedBuffers[i];u.toArray?u.toArray(o,h):u.copyToArray?u.copyToArray(o,h):o[h]=u,h+=n}this._userInstancedBuffersStorage.vertexBuffers[i]?this._userInstancedBuffersStorage.vertexBuffers[i].updateDirectly(o,0):(this._userInstancedBuffersStorage.vertexBuffers[i]=new A(this.getEngine(),this._userInstancedBuffersStorage.data[i],i,!0,!1,n,!0),this._invalidateInstanceVertexArrayObject())}};F.prototype._invalidateInstanceVertexArrayObject=function(){if(!(!this._userInstancedBuffersStorage||this._userInstancedBuffersStorage.vertexArrayObjects===void 0)){for(const a in this._userInstancedBuffersStorage.vertexArrayObjects)this.getEngine().releaseVertexArrayObject(this._userInstancedBuffersStorage.vertexArrayObjects[a]);this._userInstancedBuffersStorage.vertexArrayObjects={}}};F.prototype._disposeInstanceSpecificData=function(){for(this._instanceDataStorage.instancesBuffer&&(this._instanceDataStorage.instancesBuffer.dispose(),this._instanceDataStorage.instancesBuffer=null);this.instances.length;)this.instances[0].dispose();for(const a in this.instancedBuffers)this._userInstancedBuffersStorage.vertexBuffers[a]&&this._userInstancedBuffersStorage.vertexBuffers[a].dispose();this._invalidateInstanceVertexArrayObject(),this.instancedBuffers={}};vt("BABYLON.InstancedMesh",ea);const Ia={effect:null,subMesh:null};class os extends V0{constructor(e,t,i,s={},n=!0){super(e,t,n),this._textures={},this._textureArrays={},this._externalTextures={},this._floats={},this._ints={},this._uints={},this._floatsArrays={},this._colors3={},this._colors3Arrays={},this._colors4={},this._colors4Arrays={},this._vectors2={},this._vectors3={},this._vectors4={},this._quaternions={},this._quaternionsArrays={},this._matrices={},this._matrixArrays={},this._matrices3x3={},this._matrices2x2={},this._vectors2Arrays={},this._vectors3Arrays={},this._vectors4Arrays={},this._uniformBuffers={},this._textureSamplers={},this._storageBuffers={},this._cachedWorldViewMatrix=new O,this._cachedWorldViewProjectionMatrix=new O,this._multiview=!1,this._materialHelperNeedsPreviousMatrices=!1,this._shaderPath=i,this._options={needAlphaBlending:!1,needAlphaTesting:!1,attributes:["position","normal","uv"],uniforms:["worldViewProjection"],uniformBuffers:[],samplers:[],externalTextures:[],samplerObjects:[],storageBuffers:[],defines:[],useClipPlane:!1,...s}}get shaderPath(){return this._shaderPath}set shaderPath(e){this._shaderPath=e}get options(){return this._options}get isMultiview(){return this._multiview}getClassName(){return"ShaderMaterial"}needAlphaBlending(){return this.alpha<1||this._options.needAlphaBlending}needAlphaTesting(){return this._options.needAlphaTesting}_checkUniform(e){this._options.uniforms.indexOf(e)===-1&&this._options.uniforms.push(e)}setTexture(e,t){return this._options.samplers.indexOf(e)===-1&&this._options.samplers.push(e),this._textures[e]=t,this}removeTexture(e){delete this._textures[e]}setTextureArray(e,t){return this._options.samplers.indexOf(e)===-1&&this._options.samplers.push(e),this._checkUniform(e),this._textureArrays[e]=t,this}setExternalTexture(e,t){return this._options.externalTextures.indexOf(e)===-1&&this._options.externalTextures.push(e),this._externalTextures[e]=t,this}setFloat(e,t){return this._checkUniform(e),this._floats[e]=t,this}setInt(e,t){return this._checkUniform(e),this._ints[e]=t,this}setUInt(e,t){return this._checkUniform(e),this._uints[e]=t,this}setFloats(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this}setColor3(e,t){return this._checkUniform(e),this._colors3[e]=t,this}setColor3Array(e,t){return this._checkUniform(e),this._colors3Arrays[e]=t.reduce((i,s)=>(s.toArray(i,i.length),i),[]),this}setColor4(e,t){return this._checkUniform(e),this._colors4[e]=t,this}setColor4Array(e,t){return this._checkUniform(e),this._colors4Arrays[e]=t.reduce((i,s)=>(s.toArray(i,i.length),i),[]),this}setVector2(e,t){return this._checkUniform(e),this._vectors2[e]=t,this}setVector3(e,t){return this._checkUniform(e),this._vectors3[e]=t,this}setVector4(e,t){return this._checkUniform(e),this._vectors4[e]=t,this}setQuaternion(e,t){return this._checkUniform(e),this._quaternions[e]=t,this}setQuaternionArray(e,t){return this._checkUniform(e),this._quaternionsArrays[e]=t.reduce((i,s)=>(s.toArray(i,i.length),i),[]),this}setMatrix(e,t){return this._checkUniform(e),this._matrices[e]=t,this}setMatrices(e,t){this._checkUniform(e);const i=new Float32Array(t.length*16);for(let s=0;s<t.length;s++)t[s].copyToArray(i,s*16);return this._matrixArrays[e]=i,this}setMatrix3x3(e,t){return this._checkUniform(e),this._matrices3x3[e]=t,this}setMatrix2x2(e,t){return this._checkUniform(e),this._matrices2x2[e]=t,this}setArray2(e,t){return this._checkUniform(e),this._vectors2Arrays[e]=t,this}setArray3(e,t){return this._checkUniform(e),this._vectors3Arrays[e]=t,this}setArray4(e,t){return this._checkUniform(e),this._vectors4Arrays[e]=t,this}setUniformBuffer(e,t){return this._options.uniformBuffers.indexOf(e)===-1&&this._options.uniformBuffers.push(e),this._uniformBuffers[e]=t,this}setTextureSampler(e,t){return this._options.samplerObjects.indexOf(e)===-1&&this._options.samplerObjects.push(e),this._textureSamplers[e]=t,this}setStorageBuffer(e,t){return this._options.storageBuffers.indexOf(e)===-1&&this._options.storageBuffers.push(e),this._storageBuffers[e]=t,this}setDefine(e,t){const i=e.trimEnd()+" ",s=this.options.defines.findIndex(n=>n===e||n.startsWith(i));return s>=0&&this.options.defines.splice(s,1),(typeof t!="boolean"||t)&&this.options.defines.push(i+t),this}isReadyForSubMesh(e,t,i){return this.isReady(e,i,t)}isReady(e,t,i){var x,y,R;const s=i&&this._storeEffectOnSubMeshes;if(this.isFrozen){const E=s?i._drawWrapper:this._drawWrapper;if(E.effect&&E._wasPreviouslyReady&&E._wasPreviouslyUsingInstances===t)return!0}const n=this.getScene(),r=n.getEngine(),o=[],h=[],l=new G0;let c=this._shaderPath,u=this._options.uniforms,f=this._options.uniformBuffers,d=this._options.samplers;r.getCaps().multiview&&n.activeCamera&&n.activeCamera.outputRenderTarget&&n.activeCamera.outputRenderTarget.getViewCount()>1&&(this._multiview=!0,o.push("#define MULTIVIEW"),u.indexOf("viewProjection")!==-1&&u.indexOf("viewProjectionR")===-1&&u.push("viewProjectionR"));for(let E=0;E<this._options.defines.length;E++){const C=this._options.defines[E].indexOf("#define")===0?this._options.defines[E]:"#define ".concat(this._options.defines[E]);o.push(C)}for(let E=0;E<this._options.attributes.length;E++)h.push(this._options.attributes[E]);if(e&&e.isVerticesDataPresent(A.ColorKind)&&(h.indexOf(A.ColorKind)===-1&&h.push(A.ColorKind),o.push("#define VERTEXCOLOR")),t&&(o.push("#define INSTANCES"),N0(h,this._materialHelperNeedsPreviousMatrices),e!=null&&e.hasThinInstances&&(o.push("#define THIN_INSTANCES"),e&&e.isVerticesDataPresent(A.ColorInstanceKind)&&(h.push(A.ColorInstanceKind),o.push("#define INSTANCESCOLOR")))),e&&e.useBones&&e.computeBonesUsingShaders&&e.skeleton){h.push(A.MatricesIndicesKind),h.push(A.MatricesWeightsKind),e.numBoneInfluencers>4&&(h.push(A.MatricesIndicesExtraKind),h.push(A.MatricesWeightsExtraKind));const E=e.skeleton;o.push("#define NUM_BONE_INFLUENCERS "+e.numBoneInfluencers),l.addCPUSkinningFallback(0,e),E.isUsingTextureForMatrices?(o.push("#define BONETEXTURE"),u.indexOf("boneTextureWidth")===-1&&u.push("boneTextureWidth"),this._options.samplers.indexOf("boneSampler")===-1&&this._options.samplers.push("boneSampler")):(o.push("#define BonesPerMesh "+(E.bones.length+1)),u.indexOf("mBones")===-1&&u.push("mBones"))}else o.push("#define NUM_BONE_INFLUENCERS 0");let _=0;const p=e?e.morphTargetManager:null;if(p){const E=p.supportsUVs&&o.indexOf("#define UV1")!==-1,C=p.supportsTangents&&o.indexOf("#define TANGENT")!==-1,S=p.supportsNormals&&o.indexOf("#define NORMAL")!==-1;_=p.numMaxInfluencers||p.numInfluencers,E&&o.push("#define MORPHTARGETS_UV"),C&&o.push("#define MORPHTARGETS_TANGENT"),S&&o.push("#define MORPHTARGETS_NORMAL"),_>0&&o.push("#define MORPHTARGETS"),p.isUsingTextureForTargets&&(o.push("#define MORPHTARGETS_TEXTURE"),u.indexOf("morphTargetTextureIndices")===-1&&u.push("morphTargetTextureIndices"),this._options.samplers.indexOf("morphTargets")===-1&&this._options.samplers.push("morphTargets")),o.push("#define NUM_MORPH_INFLUENCERS "+_);for(let w=0;w<_;w++)h.push(A.PositionKind+w),S&&h.push(A.NormalKind+w),C&&h.push(A.TangentKind+w),E&&h.push(A.UVKind+"_"+w);_>0&&(u=u.slice(),u.push("morphTargetInfluences"),u.push("morphTargetCount"),u.push("morphTargetTextureInfo"),u.push("morphTargetTextureIndices"))}else o.push("#define NUM_MORPH_INFLUENCERS 0");if(e){const E=e.bakedVertexAnimationManager;E&&E.isEnabled&&(o.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),u.indexOf("bakedVertexAnimationSettings")===-1&&u.push("bakedVertexAnimationSettings"),u.indexOf("bakedVertexAnimationTextureSizeInverted")===-1&&u.push("bakedVertexAnimationTextureSizeInverted"),u.indexOf("bakedVertexAnimationTime")===-1&&u.push("bakedVertexAnimationTime"),this._options.samplers.indexOf("bakedVertexAnimationTexture")===-1&&this._options.samplers.push("bakedVertexAnimationTexture")),Dc(h,e,o)}for(const E in this._textures)if(!this._textures[E].isReady())return!1;e&&this._shouldTurnAlphaTestOn(e)&&o.push("#define ALPHATEST"),this._options.useClipPlane!==!1&&(Xr(u),Mc(this,n,o)),n.fogEnabled&&(e!=null&&e.applyFog)&&n.fogMode!==it.FOGMODE_NONE&&(o.push("#define FOG"),u.indexOf("view")===-1&&u.push("view"),u.indexOf("vFogInfos")===-1&&u.push("vFogInfos"),u.indexOf("vFogColor")===-1&&u.push("vFogColor")),this._useLogarithmicDepth&&(o.push("#define LOGARITHMICDEPTH"),u.indexOf("logarithmicDepthConstant")===-1&&u.push("logarithmicDepthConstant")),this.customShaderNameResolve&&(u=u.slice(),f=f.slice(),d=d.slice(),c=this.customShaderNameResolve(this.name,u,f,d,o,h));const g=s?i._getDrawWrapper(void 0,!0):this._drawWrapper,m=(x=g==null?void 0:g.effect)!=null?x:null,b=(y=g==null?void 0:g.defines)!=null?y:null,I=o.join("\n");let T=m;return b!==I&&(T=r.createEffect(c,{attributes:h,uniformsNames:u,uniformBuffersNames:f,samplers:d,defines:I,fallbacks:l,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousMorphTargets:_},shaderLanguage:this._options.shaderLanguage,extraInitializationsAsync:this._options.extraInitializationsAsync},r),s?i.setEffect(T,I,this._materialContext):g&&g.setEffect(T,I),this._onEffectCreatedObservable&&(Ia.effect=T,Ia.subMesh=(R=i!=null?i:e==null?void 0:e.subMeshes[0])!=null?R:null,this._onEffectCreatedObservable.notifyObservers(Ia))),g._wasPreviouslyUsingInstances=!!t,T!=null&&T.isReady()?(m!==T&&n.resetCachedMaterial(),g._wasPreviouslyReady=!0,!0):!1}bindOnlyWorldMatrix(e,t){const i=this.getScene(),s=t!=null?t:this.getEffect();s&&(this._options.uniforms.indexOf("world")!==-1&&s.setMatrix("world",e),this._options.uniforms.indexOf("worldView")!==-1&&(e.multiplyToRef(i.getViewMatrix(),this._cachedWorldViewMatrix),s.setMatrix("worldView",this._cachedWorldViewMatrix)),this._options.uniforms.indexOf("worldViewProjection")!==-1&&(e.multiplyToRef(i.getTransformMatrix(),this._cachedWorldViewProjectionMatrix),s.setMatrix("worldViewProjection",this._cachedWorldViewProjectionMatrix)),this._options.uniforms.indexOf("view")!==-1&&s.setMatrix("view",i.getViewMatrix()))}bindForSubMesh(e,t,i){var s;this.bind(e,t,(s=i._drawWrapperOverride)==null?void 0:s.effect,i)}bind(e,t,i,s){var u;const n=s&&this._storeEffectOnSubMeshes,r=i!=null?i:n?s.effect:this.getEffect();if(!r)return;const o=this.getScene();this._activeEffect=r,this.bindOnlyWorldMatrix(e,i);const h=this._options.uniformBuffers;let l=!1;if(r&&h&&h.length>0&&o.getEngine().supportsUniformBuffers)for(let f=0;f<h.length;++f)switch(h[f]){case"Mesh":t&&(t.getMeshUniformBuffer().bindToEffect(r,"Mesh"),t.transferToEffect(e));break;case"Scene":wc(r,o.getSceneUniformBuffer()),o.finalizeSceneUbo(),l=!0;break}const c=t&&n?this._mustRebind(o,r,s,t.visibility):o.getCachedMaterial()!==this;if(r&&c){!l&&this._options.uniforms.indexOf("view")!==-1&&r.setMatrix("view",o.getViewMatrix()),!l&&this._options.uniforms.indexOf("projection")!==-1&&r.setMatrix("projection",o.getProjectionMatrix()),!l&&this._options.uniforms.indexOf("viewProjection")!==-1&&(r.setMatrix("viewProjection",o.getTransformMatrix()),this._multiview&&r.setMatrix("viewProjectionR",o._transformMatrixR)),o.activeCamera&&this._options.uniforms.indexOf("cameraPosition")!==-1&&r.setVector3("cameraPosition",o.activeCamera.globalPosition),Fc(t,r),Yr(r,this,o),this._useLogarithmicDepth&&B0(n?s.materialDefines:r.defines,r,o),t&&L0(o,t,r);let f;for(f in this._textures)r.setTexture(f,this._textures[f]);for(f in this._textureArrays)r.setTextureArray(f,this._textureArrays[f]);for(f in this._ints)r.setInt(f,this._ints[f]);for(f in this._uints)r.setUInt(f,this._uints[f]);for(f in this._floats)r.setFloat(f,this._floats[f]);for(f in this._floatsArrays)r.setArray(f,this._floatsArrays[f]);for(f in this._colors3)r.setColor3(f,this._colors3[f]);for(f in this._colors3Arrays)r.setArray3(f,this._colors3Arrays[f]);for(f in this._colors4){const m=this._colors4[f];r.setFloat4(f,m.r,m.g,m.b,m.a)}for(f in this._colors4Arrays)r.setArray4(f,this._colors4Arrays[f]);for(f in this._vectors2)r.setVector2(f,this._vectors2[f]);for(f in this._vectors3)r.setVector3(f,this._vectors3[f]);for(f in this._vectors4)r.setVector4(f,this._vectors4[f]);for(f in this._quaternions)r.setQuaternion(f,this._quaternions[f]);for(f in this._matrices)r.setMatrix(f,this._matrices[f]);for(f in this._matrixArrays)r.setMatrices(f,this._matrixArrays[f]);for(f in this._matrices3x3)r.setMatrix3x3(f,this._matrices3x3[f]);for(f in this._matrices2x2)r.setMatrix2x2(f,this._matrices2x2[f]);for(f in this._vectors2Arrays)r.setArray2(f,this._vectors2Arrays[f]);for(f in this._vectors3Arrays)r.setArray3(f,this._vectors3Arrays[f]);for(f in this._vectors4Arrays)r.setArray4(f,this._vectors4Arrays[f]);for(f in this._quaternionsArrays)r.setArray4(f,this._quaternionsArrays[f]);for(f in this._uniformBuffers){const m=this._uniformBuffers[f].getBuffer();m&&r.bindUniformBuffer(m,f)}const d=o.getEngine(),_=d.setExternalTexture;if(_)for(f in this._externalTextures)_.call(d,f,this._externalTextures[f]);const p=d.setTextureSampler;if(p)for(f in this._textureSamplers)p.call(d,f,this._textureSamplers[f]);const g=d.setStorageBuffer;if(g)for(f in this._storageBuffers)g.call(d,f,this._storageBuffers[f])}if(r&&t&&(c||!this.isFrozen)){const f=t.morphTargetManager;f&&f.numInfluencers>0&&U0(t,r);const d=t.bakedVertexAnimationManager;if(d&&d.isEnabled){const _=n?s._drawWrapper:this._drawWrapper;(u=t.bakedVertexAnimationManager)==null||u.bind(r,!!_._wasPreviouslyUsingInstances)}}this._afterBind(t,r,s)}getActiveTextures(){const e=super.getActiveTextures();for(const t in this._textures)e.push(this._textures[t]);for(const t in this._textureArrays){const i=this._textureArrays[t];for(let s=0;s<i.length;s++)e.push(i[s])}return e}hasTexture(e){if(super.hasTexture(e))return!0;for(const t in this._textures)if(this._textures[t]===e)return!0;for(const t in this._textureArrays){const i=this._textureArrays[t];for(let s=0;s<i.length;s++)if(i[s]===e)return!0}return!1}clone(e){const t=Ae.Clone(()=>new os(e,this.getScene(),this._shaderPath,this._options,this._storeEffectOnSubMeshes),this);t.name=e,t.id=e,typeof t._shaderPath=="object"&&(t._shaderPath={...t._shaderPath}),this._options={...this._options},Object.keys(this._options).forEach(i=>{const s=this._options[i];Array.isArray(s)&&(this._options[i]=s.slice(0))}),this.stencil.copyTo(t.stencil);for(const i in this._textures)t.setTexture(i,this._textures[i]);for(const i in this._textureArrays)t.setTextureArray(i,this._textureArrays[i]);for(const i in this._externalTextures)t.setExternalTexture(i,this._externalTextures[i]);for(const i in this._ints)t.setInt(i,this._ints[i]);for(const i in this._uints)t.setUInt(i,this._uints[i]);for(const i in this._floats)t.setFloat(i,this._floats[i]);for(const i in this._floatsArrays)t.setFloats(i,this._floatsArrays[i]);for(const i in this._colors3)t.setColor3(i,this._colors3[i]);for(const i in this._colors3Arrays)t._colors3Arrays[i]=this._colors3Arrays[i];for(const i in this._colors4)t.setColor4(i,this._colors4[i]);for(const i in this._colors4Arrays)t._colors4Arrays[i]=this._colors4Arrays[i];for(const i in this._vectors2)t.setVector2(i,this._vectors2[i]);for(const i in this._vectors3)t.setVector3(i,this._vectors3[i]);for(const i in this._vectors4)t.setVector4(i,this._vectors4[i]);for(const i in this._quaternions)t.setQuaternion(i,this._quaternions[i]);for(const i in this._quaternionsArrays)t._quaternionsArrays[i]=this._quaternionsArrays[i];for(const i in this._matrices)t.setMatrix(i,this._matrices[i]);for(const i in this._matrixArrays)t._matrixArrays[i]=this._matrixArrays[i].slice();for(const i in this._matrices3x3)t.setMatrix3x3(i,this._matrices3x3[i]);for(const i in this._matrices2x2)t.setMatrix2x2(i,this._matrices2x2[i]);for(const i in this._vectors2Arrays)t.setArray2(i,this._vectors2Arrays[i]);for(const i in this._vectors3Arrays)t.setArray3(i,this._vectors3Arrays[i]);for(const i in this._vectors4Arrays)t.setArray4(i,this._vectors4Arrays[i]);for(const i in this._uniformBuffers)t.setUniformBuffer(i,this._uniformBuffers[i]);for(const i in this._textureSamplers)t.setTextureSampler(i,this._textureSamplers[i]);for(const i in this._storageBuffers)t.setStorageBuffer(i,this._storageBuffers[i]);return t}dispose(e,t,i){if(t){let s;for(s in this._textures)this._textures[s].dispose();for(s in this._textureArrays){const n=this._textureArrays[s];for(let r=0;r<n.length;r++)n[r].dispose()}}this._textures={},super.dispose(e,t,i)}serialize(){const e=Ae.Serialize(this);e.customType="BABYLON.ShaderMaterial",e.uniqueId=this.uniqueId,e.options=this._options,e.shaderPath=this._shaderPath,e.storeEffectOnSubMeshes=this._storeEffectOnSubMeshes;let t;e.stencil=this.stencil.serialize(),e.textures={};for(t in this._textures)e.textures[t]=this._textures[t].serialize();e.textureArrays={};for(t in this._textureArrays){e.textureArrays[t]=[];const i=this._textureArrays[t];for(let s=0;s<i.length;s++)e.textureArrays[t].push(i[s].serialize())}e.ints={};for(t in this._ints)e.ints[t]=this._ints[t];e.uints={};for(t in this._uints)e.uints[t]=this._uints[t];e.floats={};for(t in this._floats)e.floats[t]=this._floats[t];e.floatsArrays={};for(t in this._floatsArrays)e.floatsArrays[t]=this._floatsArrays[t];e.colors3={};for(t in this._colors3)e.colors3[t]=this._colors3[t].asArray();e.colors3Arrays={};for(t in this._colors3Arrays)e.colors3Arrays[t]=this._colors3Arrays[t];e.colors4={};for(t in this._colors4)e.colors4[t]=this._colors4[t].asArray();e.colors4Arrays={};for(t in this._colors4Arrays)e.colors4Arrays[t]=this._colors4Arrays[t];e.vectors2={};for(t in this._vectors2)e.vectors2[t]=this._vectors2[t].asArray();e.vectors3={};for(t in this._vectors3)e.vectors3[t]=this._vectors3[t].asArray();e.vectors4={};for(t in this._vectors4)e.vectors4[t]=this._vectors4[t].asArray();e.quaternions={};for(t in this._quaternions)e.quaternions[t]=this._quaternions[t].asArray();e.matrices={};for(t in this._matrices)e.matrices[t]=this._matrices[t].asArray();e.matrixArray={};for(t in this._matrixArrays)e.matrixArray[t]=this._matrixArrays[t];e.matrices3x3={};for(t in this._matrices3x3)e.matrices3x3[t]=this._matrices3x3[t];e.matrices2x2={};for(t in this._matrices2x2)e.matrices2x2[t]=this._matrices2x2[t];e.vectors2Arrays={};for(t in this._vectors2Arrays)e.vectors2Arrays[t]=this._vectors2Arrays[t];e.vectors3Arrays={};for(t in this._vectors3Arrays)e.vectors3Arrays[t]=this._vectors3Arrays[t];e.vectors4Arrays={};for(t in this._vectors4Arrays)e.vectors4Arrays[t]=this._vectors4Arrays[t];e.quaternionsArrays={};for(t in this._quaternionsArrays)e.quaternionsArrays[t]=this._quaternionsArrays[t];return e}static Parse(e,t,i){const s=Ae.Parse(()=>new os(e.name,t,e.shaderPath,e.options,e.storeEffectOnSubMeshes),e,t,i);let n;e.stencil&&s.stencil.parse(e.stencil,t,i);for(n in e.textures)s.setTexture(n,ie.Parse(e.textures[n],t,i));for(n in e.textureArrays){const r=e.textureArrays[n],o=[];for(let h=0;h<r.length;h++)o.push(ie.Parse(r[h],t,i));s.setTextureArray(n,o)}for(n in e.ints)s.setInt(n,e.ints[n]);for(n in e.uints)s.setUInt(n,e.uints[n]);for(n in e.floats)s.setFloat(n,e.floats[n]);for(n in e.floatsArrays)s.setFloats(n,e.floatsArrays[n]);for(n in e.colors3)s.setColor3(n,de.FromArray(e.colors3[n]));for(n in e.colors3Arrays){const r=e.colors3Arrays[n].reduce((o,h,l)=>(l%3===0?o.push([h]):o[o.length-1].push(h),o),[]).map(o=>de.FromArray(o));s.setColor3Array(n,r)}for(n in e.colors4)s.setColor4(n,H.FromArray(e.colors4[n]));for(n in e.colors4Arrays){const r=e.colors4Arrays[n].reduce((o,h,l)=>(l%4===0?o.push([h]):o[o.length-1].push(h),o),[]).map(o=>H.FromArray(o));s.setColor4Array(n,r)}for(n in e.vectors2)s.setVector2(n,oe.FromArray(e.vectors2[n]));for(n in e.vectors3)s.setVector3(n,v.FromArray(e.vectors3[n]));for(n in e.vectors4)s.setVector4(n,Pe.FromArray(e.vectors4[n]));for(n in e.quaternions)s.setQuaternion(n,re.FromArray(e.quaternions[n]));for(n in e.matrices)s.setMatrix(n,O.FromArray(e.matrices[n]));for(n in e.matrixArray)s._matrixArrays[n]=new Float32Array(e.matrixArray[n]);for(n in e.matrices3x3)s.setMatrix3x3(n,e.matrices3x3[n]);for(n in e.matrices2x2)s.setMatrix2x2(n,e.matrices2x2[n]);for(n in e.vectors2Arrays)s.setArray2(n,e.vectors2Arrays[n]);for(n in e.vectors3Arrays)s.setArray3(n,e.vectors3Arrays[n]);for(n in e.vectors4Arrays)s.setArray4(n,e.vectors4Arrays[n]);for(n in e.quaternionsArrays)s.setArray4(n,e.quaternionsArrays[n]);return s}static ParseFromFileAsync(e,t,i,s=""){return new Promise((n,r)=>{const o=new Ft;o.addEventListener("readystatechange",()=>{if(o.readyState==4)if(o.status==200){const h=JSON.parse(o.responseText),l=this.Parse(h,i||Ee.LastCreatedScene,s);e&&(l.name=e),n(l)}else r("Unable to load the ShaderMaterial")}),o.open("GET",t),o.send()})}static ParseFromSnippetAsync(e,t,i=""){return new Promise((s,n)=>{const r=new Ft;r.addEventListener("readystatechange",()=>{if(r.readyState==4)if(r.status==200){const o=JSON.parse(JSON.parse(r.responseText).jsonPayload),h=JSON.parse(o.shaderMaterial),l=this.Parse(h,t||Ee.LastCreatedScene,i);l.snippetId=e,s(l)}else n("Unable to load the snippet "+e)}),r.open("GET",this.SnippetUrl+"/"+e.replace(/#/g,"/")),r.send()})}}os.SnippetUrl="https://snippet.babylonjs.com";os.CreateFromSnippetAsync=os.ParseFromSnippetAsync;vt("BABYLON.ShaderMaterial",os);F._LinesMeshParser=(a,e)=>Hi.Parse(a,e);class Hi extends F{_isShaderMaterial(e){return e.getClassName()==="ShaderMaterial"}constructor(e,t=null,i=null,s=null,n,r,o,h){super(e,t,i,s,n),this.useVertexColor=r,this.useVertexAlpha=o,this.color=new de(1,1,1),this.alpha=1,this._shaderLanguage=0,s&&(this.color=s.color.clone(),this.alpha=s.alpha,this.useVertexColor=s.useVertexColor,this.useVertexAlpha=s.useVertexAlpha),this.intersectionThreshold=.1;const l=[],c={attributes:[A.PositionKind],uniforms:["world","viewProjection"],needAlphaBlending:!0,defines:l,useClipPlane:null,shaderLanguage:0};o===!1?c.needAlphaBlending=!1:c.defines.push("#define VERTEXALPHA"),r?(c.defines.push("#define VERTEXCOLOR"),c.attributes.push(A.ColorKind)):(c.uniforms.push("color"),this._color4=new H),h?this.material=h:(this.getScene().getEngine().isWebGPU&&!Hi.ForceGLSL&&(this._shaderLanguage=1),c.shaderLanguage=this._shaderLanguage,c.extraInitializationsAsync=async()=>{this._shaderLanguage===1?await Promise.all([Oe(()=>import("./color.vertex-Ccg8Ge1R.js"),__vite__mapDeps([44,22,23,24,3,4,5,6,7,8,9,10])),Oe(()=>import("./color.fragment-DNkpzaOC.js"),__vite__mapDeps([45,29,30,3,4,5,6,7,8,9,10]))]):await Promise.all([Oe(()=>import("./color.vertex-BL9BK6Le.js"),__vite__mapDeps([46,36,38,3,4,5,6,7,8,9,10])),Oe(()=>import("./color.fragment-BjUREcw_.js"),__vite__mapDeps([47,3,4,5,6,7,8,9,10]))])},this.material=new os("colorShader",this.getScene(),"color",c,!1),this.material.doNotSerialize=!0)}isReady(){return this._lineMaterial.isReady(this,!!this._userInstancedBuffersStorage||this.hasThinInstances)?super.isReady():!1}getClassName(){return"LinesMesh"}get material(){return this._lineMaterial}set material(e){this._lineMaterial=e,this._lineMaterial.fillMode=X.LineListDrawMode}get checkCollisions(){return!1}set checkCollisions(e){}_bind(e,t){if(!this._geometry)return this;const i=this.isUnIndexed?null:this._geometry.getIndexBuffer();if(!this._userInstancedBuffersStorage||this.hasThinInstances?this._geometry._bind(t,i):this._geometry._bind(t,i,this._userInstancedBuffersStorage.vertexBuffers,this._userInstancedBuffersStorage.vertexArrayObjects),!this.useVertexColor&&this._isShaderMaterial(this._lineMaterial)){const{r:s,g:n,b:r}=this.color;this._color4.set(s,n,r,this.alpha),this._lineMaterial.setColor4("color",this._color4)}return this}_draw(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;const s=this.getScene().getEngine();return this._unIndexed?s.drawArraysType(X.LineListDrawMode,e.verticesStart,e.verticesCount,i):s.drawElementsType(X.LineListDrawMode,e.indexStart,e.indexCount,i),this}dispose(e,t=!1,i){i||this._lineMaterial.dispose(!1,!1,!0),super.dispose(e)}clone(e,t=null,i){return new Hi(e,this.getScene(),t,this,i)}createInstance(e){const t=new qc(e,this);if(this.instancedBuffers){t.instancedBuffers={};for(const i in this.instancedBuffers)t.instancedBuffers[i]=this.instancedBuffers[i]}return t}serialize(e){super.serialize(e),e.color=this.color.asArray(),e.alpha=this.alpha}static Parse(e,t){const i=new Hi(e.name,t);return i.color=de.FromArray(e.color),i.alpha=e.alpha,i}}Hi.ForceGLSL=!1;class qc extends ea{constructor(e,t){super(e,t),this.intersectionThreshold=t.intersectionThreshold}getClassName(){return"InstancedLinesMesh"}}Qe.prototype.disableEdgesRendering=function(){return this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=null),this};Qe.prototype.enableEdgesRendering=function(a=.95,e=!1,t){return this.disableEdgesRendering(),this._edgesRenderer=new ta(this,a,e,!0,t),this};Object.defineProperty(Qe.prototype,"edgesRenderer",{get:function(){return this._edgesRenderer},enumerable:!0,configurable:!0});Hi.prototype.enableEdgesRendering=function(a=.95,e=!1){return this.disableEdgesRendering(),this._edgesRenderer=new Jg(this,a,e),this};qc.prototype.enableEdgesRendering=function(a=.95,e=!1){return Hi.prototype.enableEdgesRendering.apply(this,arguments),this};class Qg{constructor(){this.edges=[],this.edgesConnectedCount=0}}class ta{get linesPositions(){return this._linesPositions}get linesNormals(){return this._linesNormals}get linesIndices(){return this._linesIndices}get lineShader(){return this._lineShader}set lineShader(e){this._lineShader=e}static _GetShader(e,t){if(!e._edgeRenderLineShader){const i=new os("lineShader",e,"line",{attributes:["position","normal"],uniforms:["world","viewProjection","color","width","aspectRatio"],uniformBuffers:["Scene","Mesh"],shaderLanguage:t,extraInitializationsAsync:async()=>{t===1?await Promise.all([Oe(()=>import("./line.vertex-ChOZncX4.js"),__vite__mapDeps([48,23,26,27,3,4,5,6,7,8,9,10])),Oe(()=>import("./line.fragment-azBhzxfj.js"),__vite__mapDeps([49,29,26,31,3,4,5,6,7,8,9,10]))]):await Promise.all([Oe(()=>import("./line.vertex-DNyxgHBi.js"),__vite__mapDeps([50,34,3,4,5,6,7,8,9,10])),Oe(()=>import("./line.fragment-thDij4Gq.js"),__vite__mapDeps([51,3,4,5,6,7,8,9,10]))])}},!1);i.disableDepthWrite=!0,i.backFaceCulling=!1,i.checkReadyOnEveryCall=e.getEngine().isWebGPU,e._edgeRenderLineShader=i}return e._edgeRenderLineShader}get shaderLanguage(){return this._shaderLanguage}constructor(e,t=.95,i=!1,s=!0,n){var o;this.edgesWidthScalerForOrthographic=1e3,this.edgesWidthScalerForPerspective=50,this._linesPositions=new Array,this._linesNormals=new Array,this._linesIndices=new Array,this._buffers={},this._buffersForInstances={},this._checkVerticesInsteadOfIndices=!1,this.isEnabled=!0,this.customInstances=new Ut(32),this._shaderLanguage=0,this._source=e,this._checkVerticesInsteadOfIndices=i,this._options=n!=null?n:null,this._epsilon=t;const r=this._source.getScene().getEngine();r.isWebGPU&&(this._drawWrapper=new Xn(r),this._shaderLanguage=1),this._prepareRessources(),s&&((o=n==null?void 0:n.useAlternateEdgeFinder)==null||o?this._generateEdgesLinesAlternate():this._generateEdgesLines()),this._meshRebuildObserver=this._source.onRebuildObservable.add(()=>{this._rebuild()}),this._meshDisposeObserver=this._source.onDisposeObservable.add(()=>{this.dispose()})}_prepareRessources(){this._lineShader||(this._lineShader=ta._GetShader(this._source.getScene(),this._shaderLanguage))}_rebuild(){let e=this._buffers[A.PositionKind];e&&e._rebuild(),e=this._buffers[A.NormalKind],e&&e._rebuild();const i=this._source.getScene().getEngine();this._ib=i.createIndexBuffer(this._linesIndices)}dispose(){var t;this._source.onRebuildObservable.remove(this._meshRebuildObserver),this._source.onDisposeObservable.remove(this._meshDisposeObserver);let e=this._buffers[A.PositionKind];e&&(e.dispose(),this._buffers[A.PositionKind]=null),e=this._buffers[A.NormalKind],e&&(e.dispose(),this._buffers[A.NormalKind]=null),this._ib&&this._source.getScene().getEngine()._releaseBuffer(this._ib),this._lineShader.dispose(),(t=this._drawWrapper)==null||t.dispose()}_processEdgeForAdjacencies(e,t,i,s,n){return e===i&&t===s||e===s&&t===i?0:e===s&&t===n||e===n&&t===s?1:e===n&&t===i||e===i&&t===n?2:-1}_processEdgeForAdjacenciesWithVertices(e,t,i,s,n){return e.equalsWithEpsilon(i,1e-10)&&t.equalsWithEpsilon(s,1e-10)||e.equalsWithEpsilon(s,1e-10)&&t.equalsWithEpsilon(i,1e-10)?0:e.equalsWithEpsilon(s,1e-10)&&t.equalsWithEpsilon(n,1e-10)||e.equalsWithEpsilon(n,1e-10)&&t.equalsWithEpsilon(s,1e-10)?1:e.equalsWithEpsilon(n,1e-10)&&t.equalsWithEpsilon(i,1e-10)||e.equalsWithEpsilon(i,1e-10)&&t.equalsWithEpsilon(n,1e-10)?2:-1}_checkEdge(e,t,i,s,n){let r;t===void 0?r=!0:r=v.Dot(i[e],i[t])<this._epsilon,r&&this.createLine(s,n,this._linesPositions.length/3)}createLine(e,t,i){this._linesPositions.push(e.x,e.y,e.z,e.x,e.y,e.z,t.x,t.y,t.z,t.x,t.y,t.z),this._linesNormals.push(t.x,t.y,t.z,-1,t.x,t.y,t.z,1,e.x,e.y,e.z,-1,e.x,e.y,e.z,1),this._linesIndices.push(i,i+1,i+2,i,i+2,i+3)}_tessellateTriangle(e,t,i,s){const n=(E,C,S)=>{S>=0&&C.push(S);for(let w=0;w<E.length;++w)C.push(E[w][0])};let r=0;e[1].length>=e[0].length&&e[1].length>=e[2].length?r=1:e[2].length>=e[0].length&&e[2].length>=e[1].length&&(r=2);for(let E=0;E<3;++E)E===r?e[E].sort((C,S)=>C[1]<S[1]?-1:C[1]>S[1]?1:0):e[E].sort((C,S)=>C[1]>S[1]?-1:C[1]<S[1]?1:0);const o=[],h=[];n(e[r],o,-1);const l=o.length;for(let E=r+2;E>=r+1;--E)n(e[E%3],h,E!==r+2?s[i[t+(E+1)%3]]:-1);const c=h.length,u=0,f=0;i.push(s[i[t+r]],o[0],h[0]),i.push(s[i[t+(r+1)%3]],h[c-1],o[l-1]);const d=l<=c,_=d?l:c,p=d?c:l,g=d?l-1:c-1,m=d?0:1;let b=l+c-2,I=d?u:f,T=d?f:u;const x=d?o:h,y=d?h:o;let R=0;for(;b-- >0;){m?i.push(x[I],y[T]):i.push(y[T],x[I]),R+=_;let E;R>=p&&I<g?(E=x[++I],R-=p):E=y[++T],i.push(E)}i[t+0]=i[i.length-3],i[t+1]=i[i.length-2],i[t+2]=i[i.length-1],i.length=i.length-3}_generateEdgesLinesAlternate(){var l,c,u,f,d,_,p,g,m,b;const e=this._source.getVerticesData(A.PositionKind);let t=this._source.getIndices();if(!t||!e)return;Array.isArray(t)||(t=Array.from(t));const i=(c=(l=this._options)==null?void 0:l.useFastVertexMerger)!=null?c:!0,s=i?Math.round(-Math.log((f=(u=this._options)==null?void 0:u.epsilonVertexMerge)!=null?f:1e-6)/Math.log(10)):(_=(d=this._options)==null?void 0:d.epsilonVertexMerge)!=null?_:1e-6,n=[],r=[];if(i){const I={};for(let T=0;T<e.length;T+=3){const x=e[T+0],y=e[T+1],R=e[T+2],E=x.toFixed(s)+"|"+y.toFixed(s)+"|"+R.toFixed(s);if(I[E]!==void 0)n.push(I[E]);else{const C=T/3;I[E]=C,n.push(C),r.push(C)}}}else for(let I=0;I<e.length;I+=3){const T=e[I+0],x=e[I+1],y=e[I+2];let R=!1;for(let E=0;E<I&&!R;E+=3){const C=e[E+0],S=e[E+1],w=e[E+2];if(Math.abs(T-C)<s&&Math.abs(x-S)<s&&Math.abs(y-w)<s){n.push(E/3),R=!0;break}}R||(n.push(I/3),r.push(I/3))}if((p=this._options)!=null&&p.applyTessellation){const I=(m=(g=this._options)==null?void 0:g.epsilonVertexAligned)!=null?m:1e-6,T=[];for(let x=0;x<t.length;x+=3){let y;for(let R=0;R<3;++R){const E=n[t[x+R]],C=n[t[x+(R+1)%3]],S=n[t[x+(R+2)%3]];if(E===C)continue;const w=e[E*3+0],P=e[E*3+1],G=e[E*3+2],L=e[C*3+0],W=e[C*3+1],K=e[C*3+2],ce=Math.sqrt((L-w)*(L-w)+(W-P)*(W-P)+(K-G)*(K-G));for(let $=0;$<r.length-1;$++){const z=r[$];if(z===E||z===C||z===S)continue;const k=e[z*3+0],M=e[z*3+1],V=e[z*3+2],q=Math.sqrt((k-w)*(k-w)+(M-P)*(M-P)+(V-G)*(V-G)),he=Math.sqrt((k-L)*(k-L)+(M-W)*(M-W)+(V-K)*(V-K));Math.abs(q+he-ce)<I&&(y||(y={index:x,edgesPoints:[[],[],[]]},T.push(y)),y.edgesPoints[R].push([z,q]))}}}for(let x=0;x<T.length;++x){const y=T[x];this._tessellateTriangle(y.edgesPoints,y.index,t,n)}T.length=0}const o={};for(let I=0;I<t.length;I+=3){let T;for(let x=0;x<3;++x){let y=n[t[I+x]],R=n[t[I+(x+1)%3]];const E=n[t[I+(x+2)%3]];if(y===R||(y===E||R===E)&&((b=this._options)!=null&&b.removeDegeneratedTriangles))continue;if(N.Vector3[0].copyFromFloats(e[y*3+0],e[y*3+1],e[y*3+2]),N.Vector3[1].copyFromFloats(e[R*3+0],e[R*3+1],e[R*3+2]),N.Vector3[2].copyFromFloats(e[E*3+0],e[E*3+1],e[E*3+2]),T||(N.Vector3[1].subtractToRef(N.Vector3[0],N.Vector3[3]),N.Vector3[2].subtractToRef(N.Vector3[1],N.Vector3[4]),T=v.Cross(N.Vector3[3],N.Vector3[4]),T.normalize()),y>R){const w=y;y=R,R=w}const C=y+"_"+R,S=o[C];S?S.done||(v.Dot(T,S.normal)<this._epsilon&&this.createLine(N.Vector3[0],N.Vector3[1],this._linesPositions.length/3),S.done=!0):o[C]={normal:T,done:!1,index:I,i:x}}}for(const I in o){const T=o[I];if(!T.done){const x=n[t[T.index+T.i]],y=n[t[T.index+(T.i+1)%3]];N.Vector3[0].copyFromFloats(e[x*3+0],e[x*3+1],e[x*3+2]),N.Vector3[1].copyFromFloats(e[y*3+0],e[y*3+1],e[y*3+2]),this.createLine(N.Vector3[0],N.Vector3[1],this._linesPositions.length/3)}}const h=this._source.getScene().getEngine();this._buffers[A.PositionKind]=new A(h,this._linesPositions,A.PositionKind,!1),this._buffers[A.NormalKind]=new A(h,this._linesNormals,A.NormalKind,!1,!1,4),this._buffersForInstances[A.PositionKind]=this._buffers[A.PositionKind],this._buffersForInstances[A.NormalKind]=this._buffers[A.NormalKind],this._ib=h.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length}_generateEdgesLines(){const e=this._source.getVerticesData(A.PositionKind),t=this._source.getIndices();if(!t||!e)return;const i=[],s=[];let n,r;for(n=0;n<t.length;n+=3){r=new Qg;const h=t[n],l=t[n+1],c=t[n+2];r.p0=new v(e[h*3],e[h*3+1],e[h*3+2]),r.p1=new v(e[l*3],e[l*3+1],e[l*3+2]),r.p2=new v(e[c*3],e[c*3+1],e[c*3+2]);const u=v.Cross(r.p1.subtract(r.p0),r.p2.subtract(r.p1));u.normalize(),s.push(u),i.push(r)}for(n=0;n<i.length;n++){r=i[n];for(let h=n+1;h<i.length;h++){const l=i[h];if(r.edgesConnectedCount===3)break;if(l.edgesConnectedCount===3)continue;const c=t[h*3],u=t[h*3+1],f=t[h*3+2];for(let d=0;d<3;d++){let _=0;if(r.edges[d]===void 0){switch(d){case 0:this._checkVerticesInsteadOfIndices?_=this._processEdgeForAdjacenciesWithVertices(r.p0,r.p1,l.p0,l.p1,l.p2):_=this._processEdgeForAdjacencies(t[n*3],t[n*3+1],c,u,f);break;case 1:this._checkVerticesInsteadOfIndices?_=this._processEdgeForAdjacenciesWithVertices(r.p1,r.p2,l.p0,l.p1,l.p2):_=this._processEdgeForAdjacencies(t[n*3+1],t[n*3+2],c,u,f);break;case 2:this._checkVerticesInsteadOfIndices?_=this._processEdgeForAdjacenciesWithVertices(r.p2,r.p0,l.p0,l.p1,l.p2):_=this._processEdgeForAdjacencies(t[n*3+2],t[n*3],c,u,f);break}if(_!==-1&&(r.edges[d]=h,l.edges[_]=n,r.edgesConnectedCount++,l.edgesConnectedCount++,r.edgesConnectedCount===3))break}}}}for(n=0;n<i.length;n++){const h=i[n];this._checkEdge(n,h.edges[0],s,h.p0,h.p1),this._checkEdge(n,h.edges[1],s,h.p1,h.p2),this._checkEdge(n,h.edges[2],s,h.p2,h.p0)}const o=this._source.getScene().getEngine();this._buffers[A.PositionKind]=new A(o,this._linesPositions,A.PositionKind,!1),this._buffers[A.NormalKind]=new A(o,this._linesNormals,A.NormalKind,!1,!1,4),this._buffersForInstances[A.PositionKind]=this._buffers[A.PositionKind],this._buffersForInstances[A.NormalKind]=this._buffers[A.NormalKind],this._ib=o.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length}isReady(){return this._lineShader.isReady(this._source,this._source.hasInstances&&this.customInstances.length>0||this._source.hasThinInstances)}render(){const e=this._source.getScene(),t=this._lineShader._getDrawWrapper();if(this._drawWrapper&&this._lineShader._setDrawWrapper(this._drawWrapper),!this.isReady()||!e.activeCamera){this._lineShader._setDrawWrapper(t);return}const i=this._source.hasInstances&&this.customInstances.length>0,s=i||this._source.hasThinInstances;let n=0;if(s)if(this._buffersForInstances.world0=this._source.getVertexBuffer("world0"),this._buffersForInstances.world1=this._source.getVertexBuffer("world1"),this._buffersForInstances.world2=this._source.getVertexBuffer("world2"),this._buffersForInstances.world3=this._source.getVertexBuffer("world3"),i){const o=this._source._instanceDataStorage;if(n=this.customInstances.length,!o.instancesData){this._source.getScene()._activeMeshesFrozen||this.customInstances.reset();return}if(!o.isFrozen){let h=0;for(let l=0;l<n;++l)this.customInstances.data[l].copyToArray(o.instancesData,h),h+=16;o.instancesBuffer.updateDirectly(o.instancesData,0,n)}}else n=this._source.thinInstanceCount;const r=e.getEngine();this._lineShader._preBind(),this._source.edgesColor.a!==1?r.setAlphaMode(2):r.setAlphaMode(0),r.bindBuffers(s?this._buffersForInstances:this._buffers,this._ib,this._lineShader.getEffect()),e.resetCachedMaterial(),this._lineShader.setColor4("color",this._source.edgesColor),e.activeCamera.mode===ve.ORTHOGRAPHIC_CAMERA?this._lineShader.setFloat("width",this._source.edgesWidth/this.edgesWidthScalerForOrthographic):this._lineShader.setFloat("width",this._source.edgesWidth/this.edgesWidthScalerForPerspective),this._lineShader.setFloat("aspectRatio",r.getAspectRatio(e.activeCamera)),this._lineShader.bind(this._source.getWorldMatrix(),this._source),r.drawElementsType(X.TriangleFillMode,0,this._indicesCount,n),this._lineShader.unbind(),s&&r.unbindInstanceAttributes(),this._source.getScene()._activeMeshesFrozen||this.customInstances.reset(),this._lineShader._setDrawWrapper(t)}}class Jg extends ta{constructor(e,t=.95,i=!1){super(e,t,i,!1),this._generateEdgesLines()}_generateEdgesLines(){const e=this._source.getVerticesData(A.PositionKind),t=this._source.getIndices();if(!t||!e)return;const i=N.Vector3[0],s=N.Vector3[1],n=t.length-1;for(let o=0,h=0;o<n;o+=2,h+=4)v.FromArrayToRef(e,3*t[o],i),v.FromArrayToRef(e,3*t[o+1],s),this.createLine(i,s,h);const r=this._source.getScene().getEngine();this._buffers[A.PositionKind]=new A(r,this._linesPositions,A.PositionKind,!1),this._buffers[A.NormalKind]=new A(r,this._linesNormals,A.NormalKind,!1,!1,4),this._ib=r.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length}}class Si{constructor(){this.materials=[]}parseMTL(e,t,i,s){if(t instanceof ArrayBuffer)return;const n=t.split("\n"),r=/\s+/;let o,h=null;for(let l=0;l<n.length;l++){const c=n[l].trim();if(c.length===0||c.charAt(0)==="#")continue;const u=c.indexOf(" ");let f=u>=0?c.substring(0,u):c;f=f.toLowerCase();const d=u>=0?c.substring(u+1).trim():"";if(f==="newmtl")h&&this.materials.push(h),e._blockEntityCollection=!!s,h=new ee(d,e),h._parentContainer=s,e._blockEntityCollection=!1;else if(f==="kd"&&h)o=d.split(r,3).map(parseFloat),h.diffuseColor=de.FromArray(o);else if(f==="ka"&&h)o=d.split(r,3).map(parseFloat),h.ambientColor=de.FromArray(o);else if(f==="ks"&&h)o=d.split(r,3).map(parseFloat),h.specularColor=de.FromArray(o);else if(f==="ke"&&h)o=d.split(r,3).map(parseFloat),h.emissiveColor=de.FromArray(o);else if(f==="ns"&&h)h.specularPower=parseFloat(d);else if(f==="d"&&h)h.alpha=parseFloat(d);else if(f==="map_ka"&&h)h.ambientTexture=Si._GetTexture(i,d,e);else if(f==="map_kd"&&h)h.diffuseTexture=Si._GetTexture(i,d,e);else if(f==="map_ks"&&h)h.specularTexture=Si._GetTexture(i,d,e);else if(f!=="map_ns")if(f==="map_bump"&&h){const _=d.split(r),p=_.indexOf("-bm");let g=null;p>=0&&(g=_[p+1],_.splice(p,2)),h.bumpTexture=Si._GetTexture(i,_.join(" "),e),h.bumpTexture&&g!==null&&(h.bumpTexture.level=parseFloat(g))}else f==="map_d"&&h&&(h.opacityTexture=Si._GetTexture(i,d,e))}h&&this.materials.push(h)}static _GetTexture(e,t,i){if(!t)return null;let s=e;if(e==="file:"){let n=t.lastIndexOf("\\");n===-1&&(n=t.lastIndexOf("/")),n>-1?s+=t.substring(n+1):s+=t}else s+=t;return new ie(s,i,!1,Si.INVERT_TEXTURE_Y)}}Si.INVERT_TEXTURE_Y=!0;class He{constructor(e,t,i){this._positions=[],this._normals=[],this._uvs=[],this._colors=[],this._extColors=[],this._meshesFromObj=[],this._indicesForBabylon=[],this._wrappedPositionForBabylon=[],this._wrappedUvsForBabylon=[],this._wrappedColorsForBabylon=[],this._wrappedNormalsForBabylon=[],this._tuplePosNorm=[],this._curPositionInIndices=0,this._hasMeshes=!1,this._unwrappedPositionsForBabylon=[],this._unwrappedColorsForBabylon=[],this._unwrappedNormalsForBabylon=[],this._unwrappedUVForBabylon=[],this._triangles=[],this._materialNameFromObj="",this._objMeshName="",this._increment=1,this._isFirstMaterial=!0,this._grayColor=new H(.5,.5,.5,1),this._hasLineData=!1,this._materialToUse=e,this._babylonMeshesArray=t,this._loadingOptions=i}_isInArray(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[]});const i=e[t[0]].normals.indexOf(t[1]);return i===-1?-1:e[t[0]].idx[i]}_isInArrayUV(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[],uv:[]});const i=e[t[0]].normals.indexOf(t[1]);return i!=1&&t[2]===e[t[0]].uv[i]?e[t[0]].idx[i]:-1}_setData(e,t,i,s,n,r,o){let h;this._loadingOptions.optimizeWithUV?h=this._isInArrayUV(this._tuplePosNorm,[e,i,t]):h=this._isInArray(this._tuplePosNorm,[e,i]),h===-1?(this._indicesForBabylon.push(this._wrappedPositionForBabylon.length),this._wrappedPositionForBabylon.push(s),n=n!=null?n:new oe(0,0),this._wrappedUvsForBabylon.push(n),this._wrappedNormalsForBabylon.push(r),o!==void 0&&this._wrappedColorsForBabylon.push(o),this._tuplePosNorm[e].normals.push(i),this._tuplePosNorm[e].idx.push(this._curPositionInIndices++),this._loadingOptions.optimizeWithUV&&this._tuplePosNorm[e].uv.push(t)):this._indicesForBabylon.push(h)}_unwrapData(){try{for(let e=0;e<this._wrappedPositionForBabylon.length;e++)this._unwrappedPositionsForBabylon.push(this._wrappedPositionForBabylon[e].x*this._handednessSign,this._wrappedPositionForBabylon[e].y,this._wrappedPositionForBabylon[e].z),this._unwrappedNormalsForBabylon.push(this._wrappedNormalsForBabylon[e].x*this._handednessSign,this._wrappedNormalsForBabylon[e].y,this._wrappedNormalsForBabylon[e].z),this._unwrappedUVForBabylon.push(this._wrappedUvsForBabylon[e].x,this._wrappedUvsForBabylon[e].y),this._loadingOptions.importVertexColors&&this._unwrappedColorsForBabylon.push(this._wrappedColorsForBabylon[e].r,this._wrappedColorsForBabylon[e].g,this._wrappedColorsForBabylon[e].b,this._wrappedColorsForBabylon[e].a);this._wrappedPositionForBabylon.length=0,this._wrappedNormalsForBabylon.length=0,this._wrappedUvsForBabylon.length=0,this._wrappedColorsForBabylon.length=0,this._tuplePosNorm.length=0,this._curPositionInIndices=0}catch{throw new Error("Unable to unwrap data while parsing OBJ data.")}}_getTriangles(e,t){for(let i=t;i<e.length-1;i++)this._pushTriangle(e,i)}_getColor(e){var t;if(this._loadingOptions.importVertexColors)return(t=this._extColors[e])!=null?t:this._colors[e]}_setDataForCurrentFaceWithPattern1(e,t){this._getTriangles(e,t);for(let i=0;i<this._triangles.length;i++){const s=parseInt(this._triangles[i])-1;this._setData(s,0,0,this._positions[s],oe.Zero(),v.Up(),this._getColor(s))}this._triangles.length=0}_setDataForCurrentFaceWithPattern2(e,t){var i;this._getTriangles(e,t);for(let s=0;s<this._triangles.length;s++){const n=this._triangles[s].split("/"),r=parseInt(n[0])-1,o=parseInt(n[1])-1;this._setData(r,o,0,this._positions[r],(i=this._uvs[o])!=null?i:oe.Zero(),v.Up(),this._getColor(r))}this._triangles.length=0}_setDataForCurrentFaceWithPattern3(e,t){var i,s;this._getTriangles(e,t);for(let n=0;n<this._triangles.length;n++){const r=this._triangles[n].split("/"),o=parseInt(r[0])-1,h=parseInt(r[1])-1,l=parseInt(r[2])-1;this._setData(o,h,l,this._positions[o],(i=this._uvs[h])!=null?i:oe.Zero(),(s=this._normals[l])!=null?s:v.Up())}this._triangles.length=0}_setDataForCurrentFaceWithPattern4(e,t){this._getTriangles(e,t);for(let i=0;i<this._triangles.length;i++){const s=this._triangles[i].split("//"),n=parseInt(s[0])-1,r=parseInt(s[1])-1;this._setData(n,1,r,this._positions[n],oe.Zero(),this._normals[r],this._getColor(n))}this._triangles.length=0}_setDataForCurrentFaceWithPattern5(e,t){this._getTriangles(e,t);for(let i=0;i<this._triangles.length;i++){const s=this._triangles[i].split("/"),n=this._positions.length+parseInt(s[0]),r=this._uvs.length+parseInt(s[1]),o=this._normals.length+parseInt(s[2]);this._setData(n,r,o,this._positions[n],this._uvs[r],this._normals[o],this._getColor(n))}this._triangles.length=0}_addPreviousObjMesh(){this._meshesFromObj.length>0&&(this._handledMesh=this._meshesFromObj[this._meshesFromObj.length-1],this._unwrapData(),this._loadingOptions.useLegacyBehavior&&this._indicesForBabylon.reverse(),this._handledMesh.indices=this._indicesForBabylon.slice(),this._handledMesh.positions=this._unwrappedPositionsForBabylon.slice(),this._handledMesh.normals=this._unwrappedNormalsForBabylon.slice(),this._handledMesh.uvs=this._unwrappedUVForBabylon.slice(),this._handledMesh.hasLines=this._hasLineData,this._loadingOptions.importVertexColors&&(this._handledMesh.colors=this._unwrappedColorsForBabylon.slice()),this._indicesForBabylon.length=0,this._unwrappedPositionsForBabylon.length=0,this._unwrappedColorsForBabylon.length=0,this._unwrappedNormalsForBabylon.length=0,this._unwrappedUVForBabylon.length=0,this._hasLineData=!1)}_optimizeNormals(e){const t=e.getVerticesData(A.PositionKind),i=e.getVerticesData(A.NormalKind),s={};if(!t||!i)return;for(let r=0;r<t.length/3;r++){const o=t[r*3+0],h=t[r*3+1],l=t[r*3+2],c=o+"_"+h+"_"+l;let u=s[c];u||(u=[],s[c]=u),u.push(r)}const n=new v;for(const r in s){const o=s[r];if(o.length<2)continue;const h=o[0];for(let l=1;l<o.length;++l){const c=o[l];i[h*3+0]+=i[c*3+0],i[h*3+1]+=i[c*3+1],i[h*3+2]+=i[c*3+2]}n.copyFromFloats(i[h*3+0],i[h*3+1],i[h*3+2]),n.normalize();for(let l=0;l<o.length;++l){const c=o[l];i[c*3+0]=n.x,i[c*3+1]=n.y,i[c*3+2]=n.z}}e.setVerticesData(A.NormalKind,i)}static _IsLineElement(e){return e.startsWith("l")}static _IsObjectElement(e){return e.startsWith("o")}static _IsGroupElement(e){return e.startsWith("g")}static _GetZbrushMRGB(e,t){if(!e.startsWith("mrgb"))return null;if(e=e.replace("mrgb","").trim(),t)return[];const i=/[a-z0-9]/g,s=e.match(i);if(!s||s.length%8!==0)return[];const n=[];for(let r=0;r<s.length/8;r++){const o=s[r*8+2]+s[r*8+3],h=s[r*8+4]+s[r*8+5],l=s[r*8+6]+s[r*8+7];n.push(new H(parseInt(o,16)/255,parseInt(h,16)/255,parseInt(l,16)/255,1))}return n}parse(e,t,i,s,n){var c,u;t=t.replace(/#MRGB/g,"mrgb"),t=t.replace(/#.*$/gm,"").trim(),this._loadingOptions.useLegacyBehavior?(this._pushTriangle=(f,d)=>this._triangles.push(f[0],f[d],f[d+1]),this._handednessSign=1):i.useRightHandedSystem?(this._pushTriangle=(f,d)=>this._triangles.push(f[0],f[d+1],f[d]),this._handednessSign=1):(this._pushTriangle=(f,d)=>this._triangles.push(f[0],f[d],f[d+1]),this._handednessSign=-1);const r=t.split("\n"),o=[];let h=[];o.push(h);for(let f=0;f<r.length;f++){const d=r[f].trim().replace(/\s\s/g," ");if(!(d.length===0||d.charAt(0)==="#"))if((He._IsGroupElement(d)||He._IsObjectElement(d))&&(h=[],o.push(h)),He._IsLineElement(d)){const _=d.split(" ");for(let p=1;p<_.length-1;p++)h.push("l ".concat(_[p]," ").concat(_[p+1]))}else h.push(d)}const l=o.flat();for(let f=0;f<l.length;f++){const d=l[f].trim().replace(/\s\s/g," ");let _;if(!(d.length===0||d.charAt(0)==="#"))if(He.VertexPattern.test(d)){if(_=d.match(/[^ ]+/g),this._positions.push(new v(parseFloat(_[1]),parseFloat(_[2]),parseFloat(_[3]))),this._loadingOptions.importVertexColors)if(_.length>=7){const p=parseFloat(_[4]),g=parseFloat(_[5]),m=parseFloat(_[6]);this._colors.push(new H(p>1?p/255:p,g>1?g/255:g,m>1?m/255:m,_.length===7||_[7]===void 0?1:parseFloat(_[7])))}else this._colors.push(this._grayColor)}else if((_=He.NormalPattern.exec(d))!==null)this._normals.push(new v(parseFloat(_[1]),parseFloat(_[2]),parseFloat(_[3])));else if((_=He.UVPattern.exec(d))!==null)this._uvs.push(new oe(parseFloat(_[1])*this._loadingOptions.UVScaling.x,parseFloat(_[2])*this._loadingOptions.UVScaling.y));else if((_=He.FacePattern3.exec(d))!==null)this._setDataForCurrentFaceWithPattern3(_[1].trim().split(" "),1);else if((_=He.FacePattern4.exec(d))!==null)this._setDataForCurrentFaceWithPattern4(_[1].trim().split(" "),1);else if((_=He.FacePattern5.exec(d))!==null)this._setDataForCurrentFaceWithPattern5(_[1].trim().split(" "),1);else if((_=He.FacePattern2.exec(d))!==null)this._setDataForCurrentFaceWithPattern2(_[1].trim().split(" "),1);else if((_=He.FacePattern1.exec(d))!==null)this._setDataForCurrentFaceWithPattern1(_[1].trim().split(" "),1);else if((_=He.LinePattern1.exec(d))!==null)this._setDataForCurrentFaceWithPattern1(_[1].trim().split(" "),0),this._hasLineData=!0;else if((_=He.LinePattern2.exec(d))!==null)this._setDataForCurrentFaceWithPattern2(_[1].trim().split(" "),0),this._hasLineData=!0;else if(_=He._GetZbrushMRGB(d,!this._loadingOptions.importVertexColors))_.forEach(p=>{this._extColors.push(p)});else if((_=He.LinePattern3.exec(d))!==null)this._setDataForCurrentFaceWithPattern3(_[1].trim().split(" "),0),this._hasLineData=!0;else if(He.GroupDescriptor.test(d)||He.ObjectDescriptor.test(d)){const p={name:d.substring(2).trim(),indices:null,positions:null,normals:null,uvs:null,colors:null,materialName:this._materialNameFromObj,isObject:He.ObjectDescriptor.test(d)};this._addPreviousObjMesh(),this._meshesFromObj.push(p),this._hasMeshes=!0,this._isFirstMaterial=!0,this._increment=1}else if(He.UseMtlDescriptor.test(d)){if(this._materialNameFromObj=d.substring(7).trim(),!this._isFirstMaterial||!this._hasMeshes){this._addPreviousObjMesh();const p={name:(this._objMeshName||"mesh")+"_mm"+this._increment.toString(),indices:null,positions:null,normals:null,uvs:null,colors:null,materialName:this._materialNameFromObj,isObject:!1};this._increment++,this._meshesFromObj.push(p),this._hasMeshes=!0}this._hasMeshes&&this._isFirstMaterial&&(this._meshesFromObj[this._meshesFromObj.length-1].materialName=this._materialNameFromObj,this._isFirstMaterial=!1)}else He.MtlLibGroupDescriptor.test(d)?n(d.substring(7).trim()):He.SmoothDescriptor.test(d)||U.Log("Unhandled expression at line : "+d)}if(this._hasMeshes&&(this._handledMesh=this._meshesFromObj[this._meshesFromObj.length-1],this._loadingOptions.useLegacyBehavior&&this._indicesForBabylon.reverse(),this._unwrapData(),this._handledMesh.indices=this._indicesForBabylon,this._handledMesh.positions=this._unwrappedPositionsForBabylon,this._handledMesh.normals=this._unwrappedNormalsForBabylon,this._handledMesh.uvs=this._unwrappedUVForBabylon,this._handledMesh.hasLines=this._hasLineData,this._loadingOptions.importVertexColors&&(this._handledMesh.colors=this._unwrappedColorsForBabylon)),!this._hasMeshes){let f=null;if(this._indicesForBabylon.length)this._loadingOptions.useLegacyBehavior&&this._indicesForBabylon.reverse(),this._unwrapData();else{for(const d of this._positions)this._unwrappedPositionsForBabylon.push(d.x,d.y,d.z);if(this._normals.length)for(const d of this._normals)this._unwrappedNormalsForBabylon.push(d.x,d.y,d.z);if(this._uvs.length)for(const d of this._uvs)this._unwrappedUVForBabylon.push(d.x,d.y);if(this._extColors.length)for(const d of this._extColors)this._unwrappedColorsForBabylon.push(d.r,d.g,d.b,d.a);else if(this._colors.length)for(const d of this._colors)this._unwrappedColorsForBabylon.push(d.r,d.g,d.b,d.a);this._materialNameFromObj||(f=new ee(Nt.RandomId(),i),f.pointsCloud=!0,this._materialNameFromObj=f.name,this._normals.length||(f.disableLighting=!0,f.emissiveColor=de.White()))}this._meshesFromObj.push({name:Nt.RandomId(),indices:this._indicesForBabylon,positions:this._unwrappedPositionsForBabylon,colors:this._unwrappedColorsForBabylon,normals:this._unwrappedNormalsForBabylon,uvs:this._unwrappedUVForBabylon,materialName:this._materialNameFromObj,directMaterial:f,isObject:!0,hasLines:this._hasLineData})}for(let f=0;f<this._meshesFromObj.length;f++){if(e&&this._meshesFromObj[f].name){if(e instanceof Array){if(e.indexOf(this._meshesFromObj[f].name)===-1)continue}else if(this._meshesFromObj[f].name!==e)continue}this._handledMesh=this._meshesFromObj[f],i._blockEntityCollection=!!s;const d=new F(this._meshesFromObj[f].name,i);if(d._parentContainer=s,i._blockEntityCollection=!1,this._handledMesh._babylonMesh=d,!this._handledMesh.isObject){for(let p=f-1;p>=0;--p)if(this._meshesFromObj[p].isObject&&this._meshesFromObj[p]._babylonMesh){d.parent=this._meshesFromObj[p]._babylonMesh;break}}if(this._materialToUse.push(this._meshesFromObj[f].materialName),this._handledMesh.hasLines&&((c=d._internalMetadata)!=null||(d._internalMetadata={}),d._internalMetadata._isLine=!0),((u=this._handledMesh.positions)==null?void 0:u.length)===0){this._babylonMeshesArray.push(d);continue}const _=new j;if(_.uvs=this._handledMesh.uvs,_.indices=this._handledMesh.indices,_.positions=this._handledMesh.positions,this._loadingOptions.computeNormals){const p=new Array;j.ComputeNormals(this._handledMesh.positions,this._handledMesh.indices,p),_.normals=p}else _.normals=this._handledMesh.normals;this._loadingOptions.importVertexColors&&(_.colors=this._handledMesh.colors),_.applyToMesh(d),this._loadingOptions.invertY&&(d.scaling.y*=-1),this._loadingOptions.optimizeNormals&&this._optimizeNormals(d),this._babylonMeshesArray.push(d),this._handledMesh.directMaterial&&(d.material=this._handledMesh.directMaterial)}}}He.ObjectDescriptor=/^o/;He.GroupDescriptor=/^g/;He.MtlLibGroupDescriptor=/^mtllib /;He.UseMtlDescriptor=/^usemtl /;He.SmoothDescriptor=/^s /;He.VertexPattern=/^v(\s+[\d|.|+|\-|e|E]+){3,7}/;He.NormalPattern=/^vn(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/;He.UVPattern=/^vt(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/;He.FacePattern1=/^f\s+(([\d]{1,}[\s]?){3,})+/;He.FacePattern2=/^f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/;He.FacePattern3=/^f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/;He.FacePattern4=/^f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/;He.FacePattern5=/^f\s+(((-[\d]{1,}\/-[\d]{1,}\/-[\d]{1,}[\s]?){3,})+)/;He.LinePattern1=/^l\s+(([\d]{1,}[\s]?){2,})+/;He.LinePattern2=/^l\s+((([\d]{1,}\/[\d]{1,}[\s]?){2,})+)/;He.LinePattern3=/^l\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){2,})+)/;class jc{constructor(){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.sounds=null,this.effectLayers=[],this.layers=[],this.reflectionProbes=[]}get environmentTexture(){return this._environmentTexture}set environmentTexture(e){this._environmentTexture=e}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}}class e1 extends jc{}class t1{constructor(){this.rootNodes=[],this.skeletons=[],this.animationGroups=[]}dispose(){this.rootNodes.slice(0).forEach(e=>{e.dispose()}),this.rootNodes.length=0,this.skeletons.slice(0).forEach(e=>{e.dispose()}),this.skeletons.length=0,this.animationGroups.slice(0).forEach(e=>{e.dispose()}),this.animationGroups.length=0}}class i1 extends jc{constructor(e){super(),this._wasAddedToScene=!1,e=e||Ee.LastCreatedScene,e&&(this.scene=e,this.proceduralTextures=[],e.onDisposeObservable.add(()=>{this._wasAddedToScene||this.dispose()}),this._onContextRestoredObserver=e.getEngine().onContextRestoredObservable.add(()=>{for(const t of this.geometries)t._rebuild();for(const t of this.meshes)t._rebuild();for(const t of this.particleSystems)t.rebuild();for(const t of this.textures)t._rebuild()}))}_topologicalSort(e){const t=new Map;for(const o of e)t.set(o.uniqueId,o);const i={dependsOn:new Map,dependedBy:new Map};for(const o of e){const h=o.uniqueId;i.dependsOn.set(h,new Set),i.dependedBy.set(h,new Set)}for(const o of e){const h=o.uniqueId,l=i.dependsOn.get(h);if(o instanceof ea){const u=o.sourceMesh;t.has(u.uniqueId)&&(l.add(u.uniqueId),i.dependedBy.get(u.uniqueId).add(h))}const c=i.dependedBy.get(h);for(const u of o.getDescendants()){const f=u.uniqueId;t.has(f)&&(c.add(f),i.dependsOn.get(f).add(h))}}const s=[],n=[];for(const o of e){const h=o.uniqueId;i.dependsOn.get(h).size===0&&(n.push(o),t.delete(h))}const r=n;for(;r.length>0;){const o=r.shift();s.push(o);const h=i.dependedBy.get(o.uniqueId);for(const l of Array.from(h.values())){const c=i.dependsOn.get(l);c.delete(o.uniqueId),c.size===0&&t.get(l)&&(r.push(t.get(l)),t.delete(l))}}return t.size>0&&(U.Error("SceneSerializer._topologicalSort: There were unvisited nodes:"),t.forEach(o=>U.Error(o.name))),s}_addNodeAndDescendantsToList(e,t,i,s){if(!(!i||s&&!s(i)||t.has(i.uniqueId))){e.push(i),t.add(i.uniqueId);for(const n of i.getDescendants(!0))this._addNodeAndDescendantsToList(e,t,n,s)}}_isNodeInContainer(e){return e instanceof Qe&&this.meshes.indexOf(e)!==-1||e instanceof Te&&this.transformNodes.indexOf(e)!==-1||e instanceof Fe&&this.lights.indexOf(e)!==-1||e instanceof ve&&this.cameras.indexOf(e)!==-1}_isValidHierarchy(){for(const e of this.meshes)if(e.parent&&!this._isNodeInContainer(e.parent))return U.Warn("Node ".concat(e.name," has a parent that is not in the container.")),!1;for(const e of this.transformNodes)if(e.parent&&!this._isNodeInContainer(e.parent))return U.Warn("Node ".concat(e.name," has a parent that is not in the container.")),!1;for(const e of this.lights)if(e.parent&&!this._isNodeInContainer(e.parent))return U.Warn("Node ".concat(e.name," has a parent that is not in the container.")),!1;for(const e of this.cameras)if(e.parent&&!this._isNodeInContainer(e.parent))return U.Warn("Node ".concat(e.name," has a parent that is not in the container.")),!1;return!0}instantiateModelsToScene(e,t=!1,i){this._isValidHierarchy()||J.Warn("SceneSerializer.InstantiateModelsToScene: The Asset Container hierarchy is not valid.");const s={},n={},r=new t1,o=[],h=[],l={doNotInstantiate:!0,...i},c=(p,g)=>{if(s[p.uniqueId]=g.uniqueId,n[g.uniqueId]=g,e&&(g.name=e(p.name)),g instanceof F){const m=g;if(m.morphTargetManager){const b=p.morphTargetManager;m.morphTargetManager=b.clone();for(let I=0;I<b.numTargets;I++){const T=b.getTarget(I),x=m.morphTargetManager.getTarget(I);s[T.uniqueId]=x.uniqueId,n[x.uniqueId]=x}}}},u=[],f=new Set;for(const p of this.transformNodes)p.parent===null&&this._addNodeAndDescendantsToList(u,f,p,l.predicate);for(const p of this.meshes)p.parent===null&&this._addNodeAndDescendantsToList(u,f,p,l.predicate);const d=this._topologicalSort(u),_=(p,g)=>{if(c(p,g),p.parent){const m=s[p.parent.uniqueId],b=n[m];b?g.parent=b:g.parent=p.parent}if(g.position&&p.position&&g.position.copyFrom(p.position),g.rotationQuaternion&&p.rotationQuaternion&&g.rotationQuaternion.copyFrom(p.rotationQuaternion),g.rotation&&p.rotation&&g.rotation.copyFrom(p.rotation),g.scaling&&p.scaling&&g.scaling.copyFrom(p.scaling),g.material){const m=g;if(m.material)if(t){const b=p.material;if(h.indexOf(b)===-1){let I=b.clone(e?e(b.name):"Clone of "+b.name);if(h.push(b),s[b.uniqueId]=I.uniqueId,n[I.uniqueId]=I,b.getClassName()==="MultiMaterial"){const T=b;for(const x of T.subMaterials)x&&(I=x.clone(e?e(x.name):"Clone of "+x.name),h.push(x),s[x.uniqueId]=I.uniqueId,n[I.uniqueId]=I);T.subMaterials=T.subMaterials.map(x=>x&&n[s[x.uniqueId]])}}m.getClassName()!=="InstancedMesh"&&(m.material=n[s[b.uniqueId]])}else m.material.getClassName()==="MultiMaterial"?this.scene.multiMaterials.indexOf(m.material)===-1&&this.scene.addMultiMaterial(m.material):this.scene.materials.indexOf(m.material)===-1&&this.scene.addMaterial(m.material)}g.parent===null&&r.rootNodes.push(g)};return d.forEach(p=>{if(p.getClassName()==="InstancedMesh"){const g=p,m=g.sourceMesh,b=s[m.uniqueId],T=(typeof b=="number"?n[b]:m).createInstance(g.name);_(g,T)}else{let g=!0;p.getClassName()==="TransformNode"||p.getClassName()==="Node"||p.skeleton||!p.getTotalVertices||p.getTotalVertices()===0?g=!1:l.doNotInstantiate&&(typeof l.doNotInstantiate=="function"?g=!l.doNotInstantiate(p):g=!l.doNotInstantiate);const m=g?p.createInstance("instance of ".concat(p.name)):p.clone("Clone of ".concat(p.name),null,!0);if(!m)throw new Error("Could not clone or instantiate node on Asset Container ".concat(p.name));_(p,m)}}),this.skeletons.forEach(p=>{if(l.predicate&&!l.predicate(p))return;const g=p.clone(e?e(p.name):"Clone of "+p.name);for(const m of this.meshes)if(m.skeleton===p&&!m.isAnInstance){const b=n[s[m.uniqueId]];if(!b||b.isAnInstance||(b.skeleton=g,o.indexOf(g)!==-1))continue;o.push(g);for(const I of g.bones)I._linkedTransformNode&&(I._linkedTransformNode=n[s[I._linkedTransformNode.uniqueId]])}r.skeletons.push(g)}),this.animationGroups.forEach(p=>{if(l.predicate&&!l.predicate(p))return;const g=p.clone(e?e(p.name):"Clone of "+p.name,m=>n[s[m.uniqueId]]||m);r.animationGroups.push(g)}),r}addAllToScene(){if(!this._wasAddedToScene){this._isValidHierarchy()||J.Warn("SceneSerializer.addAllToScene: The Asset Container hierarchy is not valid."),this._wasAddedToScene=!0,this.addToScene(null),this.environmentTexture&&(this.scene.environmentTexture=this.environmentTexture);for(const e of this.scene._serializableComponents)e.addFromContainer(this);this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null}}addToScene(e=null){const t=[];this.cameras.forEach(i=>{e&&!e(i)||(this.scene.addCamera(i),t.push(i))}),this.lights.forEach(i=>{e&&!e(i)||(this.scene.addLight(i),t.push(i))}),this.meshes.forEach(i=>{e&&!e(i)||(this.scene.addMesh(i),t.push(i))}),this.skeletons.forEach(i=>{e&&!e(i)||this.scene.addSkeleton(i)}),this.animations.forEach(i=>{e&&!e(i)||this.scene.addAnimation(i)}),this.animationGroups.forEach(i=>{e&&!e(i)||this.scene.addAnimationGroup(i)}),this.multiMaterials.forEach(i=>{e&&!e(i)||this.scene.addMultiMaterial(i)}),this.materials.forEach(i=>{e&&!e(i)||this.scene.addMaterial(i)}),this.morphTargetManagers.forEach(i=>{e&&!e(i)||this.scene.addMorphTargetManager(i)}),this.geometries.forEach(i=>{e&&!e(i)||this.scene.addGeometry(i)}),this.transformNodes.forEach(i=>{e&&!e(i)||(this.scene.addTransformNode(i),t.push(i))}),this.actionManagers.forEach(i=>{e&&!e(i)||this.scene.addActionManager(i)}),this.textures.forEach(i=>{e&&!e(i)||this.scene.addTexture(i)}),this.reflectionProbes.forEach(i=>{e&&!e(i)||this.scene.addReflectionProbe(i)});for(const i of t)i.parent&&this.scene.getNodes().indexOf(i.parent)===-1&&(i.setParent?i.setParent(null):i.parent=null)}removeAllFromScene(){this._isValidHierarchy()||J.Warn("SceneSerializer.removeAllFromScene: The Asset Container hierarchy is not valid."),this._wasAddedToScene=!1,this.removeFromScene(null),this.environmentTexture===this.scene.environmentTexture&&(this.scene.environmentTexture=null);for(const e of this.scene._serializableComponents)e.removeFromContainer(this)}removeFromScene(e=null){this.cameras.forEach(t=>{e&&!e(t)||this.scene.removeCamera(t)}),this.lights.forEach(t=>{e&&!e(t)||this.scene.removeLight(t)}),this.meshes.forEach(t=>{e&&!e(t)||this.scene.removeMesh(t,!0)}),this.skeletons.forEach(t=>{e&&!e(t)||this.scene.removeSkeleton(t)}),this.animations.forEach(t=>{e&&!e(t)||this.scene.removeAnimation(t)}),this.animationGroups.forEach(t=>{e&&!e(t)||this.scene.removeAnimationGroup(t)}),this.multiMaterials.forEach(t=>{e&&!e(t)||this.scene.removeMultiMaterial(t)}),this.materials.forEach(t=>{e&&!e(t)||this.scene.removeMaterial(t)}),this.morphTargetManagers.forEach(t=>{e&&!e(t)||this.scene.removeMorphTargetManager(t)}),this.geometries.forEach(t=>{e&&!e(t)||this.scene.removeGeometry(t)}),this.transformNodes.forEach(t=>{e&&!e(t)||this.scene.removeTransformNode(t)}),this.actionManagers.forEach(t=>{e&&!e(t)||this.scene.removeActionManager(t)}),this.textures.forEach(t=>{e&&!e(t)||this.scene.removeTexture(t)}),this.reflectionProbes.forEach(t=>{e&&!e(t)||this.scene.removeReflectionProbe(t)})}dispose(){this.cameras.slice(0).forEach(e=>{e.dispose()}),this.cameras.length=0,this.lights.slice(0).forEach(e=>{e.dispose()}),this.lights.length=0,this.meshes.slice(0).forEach(e=>{e.dispose()}),this.meshes.length=0,this.skeletons.slice(0).forEach(e=>{e.dispose()}),this.skeletons.length=0,this.animationGroups.slice(0).forEach(e=>{e.dispose()}),this.animationGroups.length=0,this.multiMaterials.slice(0).forEach(e=>{e.dispose()}),this.multiMaterials.length=0,this.materials.slice(0).forEach(e=>{e.dispose()}),this.materials.length=0,this.geometries.slice(0).forEach(e=>{e.dispose()}),this.geometries.length=0,this.transformNodes.slice(0).forEach(e=>{e.dispose()}),this.transformNodes.length=0,this.actionManagers.slice(0).forEach(e=>{e.dispose()}),this.actionManagers.length=0,this.textures.slice(0).forEach(e=>{e.dispose()}),this.textures.length=0,this.reflectionProbes.slice(0).forEach(e=>{e.dispose()}),this.reflectionProbes.length=0,this.morphTargetManagers.slice(0).forEach(e=>{e.dispose()}),this.morphTargetManagers.length=0,this.environmentTexture&&(this.environmentTexture.dispose(),this.environmentTexture=null);for(const e of this.scene._serializableComponents)e.removeFromContainer(this,!0);this._onContextRestoredObserver&&(this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)}_moveAssets(e,t,i){if(!(!e||!t))for(const s of e){let n=!0;if(i){for(const r of i)if(s===r){n=!1;break}}n&&(t.push(s),s._parentContainer=this)}}moveAllFromScene(e){this._wasAddedToScene=!1,e===void 0&&(e=new e1);for(const t in this)Object.prototype.hasOwnProperty.call(this,t)&&(this[t]=this[t]||(t==="_environmentTexture"?null:[]),this._moveAssets(this.scene[t],this[t],e[t]));this.environmentTexture=this.scene.environmentTexture,this.removeAllFromScene()}createRootMesh(){const e=new F("assetContainerRootMesh",this.scene);return this.meshes.forEach(t=>{t.parent||e.addChild(t)}),this.meshes.unshift(e),e}mergeAnimationsTo(e=Ee.LastCreatedScene,t,i=null){if(!e)return U.Error("No scene available to merge animations to"),[];const s=i||(o=>{let h=null;const l=o.animations.length?o.animations[0].targetProperty:"",c=o.name.split(".").join("").split("_primitive")[0];switch(l){case"position":case"rotationQuaternion":h=e.getTransformNodeByName(o.name)||e.getTransformNodeByName(c);break;case"influence":h=e.getMorphTargetByName(o.name)||e.getMorphTargetByName(c);break;default:h=e.getNodeByName(o.name)||e.getNodeByName(c)}return h});this.getNodes().forEach(o=>{const h=s(o);if(h!==null){for(const l of o.animations){const c=h.animations.filter(u=>u.targetProperty===l.targetProperty);for(const u of c){const f=h.animations.indexOf(u,0);f>-1&&h.animations.splice(f,1)}}h.animations=h.animations.concat(o.animations)}});const r=[];return this.animationGroups.slice().forEach(o=>{r.push(o.clone(o.name,s)),o.animatables.forEach(h=>{h.stop()})}),t.forEach(o=>{const h=s(o.target);h&&(e.beginAnimation(h,o.fromFrame,o.toFrame,o.loopAnimation,o.speedRatio,o.onAnimationEnd?o.onAnimationEnd:void 0,void 0,!0,void 0,o.onAnimationLoop?o.onAnimationLoop:void 0),e.stopAnimation(o.target))}),r}populateRootNodes(){this.rootNodes.length=0,this.meshes.forEach(e=>{!e.parent&&this.rootNodes.indexOf(e)===-1&&this.rootNodes.push(e)}),this.transformNodes.forEach(e=>{!e.parent&&this.rootNodes.indexOf(e)===-1&&this.rootNodes.push(e)}),this.lights.forEach(e=>{!e.parent&&this.rootNodes.indexOf(e)===-1&&this.rootNodes.push(e)}),this.cameras.forEach(e=>{!e.parent&&this.rootNodes.indexOf(e)===-1&&this.rootNodes.push(e)})}addAllAssetsToContainer(e){if(!e)return;const t=[],i=new Set;for(t.push(e);t.length>0;){const s=t.pop();if(s instanceof F?(s.geometry&&this.geometries.indexOf(s.geometry)===-1&&this.geometries.push(s.geometry),this.meshes.push(s)):s instanceof Te?this.transformNodes.push(s):s instanceof Fe?this.lights.push(s):s instanceof ve&&this.cameras.push(s),s instanceof Qe){if(s.material&&this.materials.indexOf(s.material)===-1){this.materials.push(s.material);for(const n of s.material.getActiveTextures())this.textures.indexOf(n)===-1&&this.textures.push(n)}s.skeleton&&this.skeletons.indexOf(s.skeleton)===-1&&this.skeletons.push(s.skeleton),s.morphTargetManager&&this.morphTargetManagers.indexOf(s.morphTargetManager)===-1&&this.morphTargetManagers.push(s.morphTargetManager)}for(const n of s.getChildren())i.has(n)||t.push(n);i.add(s)}this.populateRootNodes()}}const Qh={name:"obj",extensions:".obj"};class xt{static get INVERT_TEXTURE_Y(){return Si.INVERT_TEXTURE_Y}static set INVERT_TEXTURE_Y(e){Si.INVERT_TEXTURE_Y=e}constructor(e){this.name=Qh.name,this.extensions=Qh.extensions,this._assetContainer=null,this._loadingOptions=e||xt._DefaultLoadingOptions}static get _DefaultLoadingOptions(){return{computeNormals:xt.COMPUTE_NORMALS,optimizeNormals:xt.OPTIMIZE_NORMALS,importVertexColors:xt.IMPORT_VERTEX_COLORS,invertY:xt.INVERT_Y,invertTextureY:xt.INVERT_TEXTURE_Y,UVScaling:xt.UV_SCALING,materialLoadingFailsSilently:xt.MATERIAL_LOADING_FAILS_SILENTLY,optimizeWithUV:xt.OPTIMIZE_WITH_UV,skipMaterials:xt.SKIP_MATERIALS,useLegacyBehavior:xt.USE_LEGACY_BEHAVIOR}}_loadMTL(e,t,i,s){const n=t+e;J.LoadFile(n,i,void 0,void 0,!1,(r,o)=>{s(n,o)})}createPlugin(){return new xt(xt._DefaultLoadingOptions)}canDirectLoad(){return!1}importMeshAsync(e,t,i,s){return this._parseSolid(e,t,i,s).then(n=>({meshes:n,particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}))}loadAsync(e,t,i){return this.importMeshAsync(null,e,t,i).then(()=>{})}loadAssetContainerAsync(e,t,i){const s=new i1(e);return this._assetContainer=s,this.importMeshAsync(null,e,t,i).then(n=>(n.meshes.forEach(r=>s.meshes.push(r)),n.meshes.forEach(r=>{const o=r.material;o&&s.materials.indexOf(o)==-1&&(s.materials.push(o),o.getActiveTextures().forEach(l=>{s.textures.indexOf(l)==-1&&s.textures.push(l)}))}),this._assetContainer=null,s)).catch(n=>{throw this._assetContainer=null,n})}_parseSolid(e,t,i,s){let n="";const r=new Si,o=[],h=[];i=i.replace(/#.*$/gm,"").trim(),new He(o,h,this._loadingOptions).parse(e,i,t,this._assetContainer,u=>{n=u});const c=[];return n!==""&&!this._loadingOptions.skipMaterials&&c.push(new Promise((u,f)=>{this._loadMTL(n,s,d=>{try{r.parseMTL(t,d,s,this._assetContainer);for(let _=0;_<r.materials.length;_++){let p=0;const g=[];let m;for(;(m=o.indexOf(r.materials[_].name,p))>-1;)g.push(m),p=m+1;if(m===-1&&g.length===0)r.materials[_].dispose();else for(let b=0;b<g.length;b++){const I=h[g[b]],T=r.materials[_];I.material=T,I.getTotalIndices()||(T.pointsCloud=!0)}}u()}catch(_){J.Warn("Error processing MTL file: '".concat(n,"'")),this._loadingOptions.materialLoadingFailsSilently?u():f(_)}},(d,_)=>{J.Warn("Error downloading MTL file: '".concat(n,"'")),this._loadingOptions.materialLoadingFailsSilently?u():f(_)})})),Promise.all(c).then(()=>{const u=f=>{var d,_;return!!((_=(d=f._internalMetadata)==null?void 0:d._isLine)!=null&&_)};return h.forEach(f=>{var d,_;if(u(f)){let p=(d=f.material)!=null?d:new ee(f.name+"_line",t);p.getBindedMeshes().filter(m=>!u(m)).length>0&&(p=(_=p.clone(p.name+"_line"))!=null?_:p),p.wireframe=!0,f.material=p,f._internalMetadata&&(f._internalMetadata._isLine=void 0)}}),h})}}xt.OPTIMIZE_WITH_UV=!0;xt.INVERT_Y=!1;xt.IMPORT_VERTEX_COLORS=!1;xt.COMPUTE_NORMALS=!1;xt.OPTIMIZE_NORMALS=!1;xt.UV_SCALING=new oe(1,1);xt.SKIP_MATERIALS=!1;xt.MATERIAL_LOADING_FAILS_SILENTLY=!0;xt.USE_LEGACY_BEHAVIOR=!1;Gc(new xt);class Ue{constructor(e,t,i=Number.MAX_VALUE,s=Le){this.origin=e,this.direction=t,this.length=i,this.epsilon=s}clone(){return new Ue(this.origin.clone(),this.direction.clone(),this.length)}intersectsBoxMinMax(e,t,i=0){const s=Ue._TmpVector3[0].copyFromFloats(e.x-i,e.y-i,e.z-i),n=Ue._TmpVector3[1].copyFromFloats(t.x+i,t.y+i,t.z+i);let r=0,o=Number.MAX_VALUE,h,l,c,u;if(Math.abs(this.direction.x)<1e-7){if(this.origin.x<s.x||this.origin.x>n.x)return!1}else if(h=1/this.direction.x,l=(s.x-this.origin.x)*h,c=(n.x-this.origin.x)*h,c===-1/0&&(c=1/0),l>c&&(u=l,l=c,c=u),r=Math.max(l,r),o=Math.min(c,o),r>o)return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.y<s.y||this.origin.y>n.y)return!1}else if(h=1/this.direction.y,l=(s.y-this.origin.y)*h,c=(n.y-this.origin.y)*h,c===-1/0&&(c=1/0),l>c&&(u=l,l=c,c=u),r=Math.max(l,r),o=Math.min(c,o),r>o)return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.z<s.z||this.origin.z>n.z)return!1}else if(h=1/this.direction.z,l=(s.z-this.origin.z)*h,c=(n.z-this.origin.z)*h,c===-1/0&&(c=1/0),l>c&&(u=l,l=c,c=u),r=Math.max(l,r),o=Math.min(c,o),r>o)return!1;return!0}intersectsBox(e,t=0){return this.intersectsBoxMinMax(e.minimum,e.maximum,t)}intersectsSphere(e,t=0){const i=e.center.x-this.origin.x,s=e.center.y-this.origin.y,n=e.center.z-this.origin.z,r=i*i+s*s+n*n,o=e.radius+t,h=o*o;if(r<=h)return!0;const l=i*this.direction.x+s*this.direction.y+n*this.direction.z;return l<0?!1:r-l*l<=h}intersectsTriangle(e,t,i){const s=Ue._TmpVector3[0],n=Ue._TmpVector3[1],r=Ue._TmpVector3[2],o=Ue._TmpVector3[3],h=Ue._TmpVector3[4];t.subtractToRef(e,s),i.subtractToRef(e,n),v.CrossToRef(this.direction,n,r);const l=v.Dot(s,r);if(l===0)return null;const c=1/l;this.origin.subtractToRef(e,o);const u=v.Dot(o,r)*c;if(u<-this.epsilon||u>1+this.epsilon)return null;v.CrossToRef(o,s,h);const f=v.Dot(this.direction,h)*c;if(f<-this.epsilon||u+f>1+this.epsilon)return null;const d=v.Dot(n,h)*c;return d>this.length?null:new za(1-u-f,u,d)}intersectsPlane(e){let t;const i=v.Dot(e.normal,this.direction);if(Math.abs(i)<999999997475243e-21)return null;{const s=v.Dot(e.normal,this.origin);return t=(-e.d-s)/i,t<0?t<-999999997475243e-21?null:0:t}}intersectsAxis(e,t=0){switch(e){case"y":{const i=(this.origin.y-t)/this.direction.y;return i>0?null:new v(this.origin.x+this.direction.x*-i,t,this.origin.z+this.direction.z*-i)}case"x":{const i=(this.origin.x-t)/this.direction.x;return i>0?null:new v(t,this.origin.y+this.direction.y*-i,this.origin.z+this.direction.z*-i)}case"z":{const i=(this.origin.z-t)/this.direction.z;return i>0?null:new v(this.origin.x+this.direction.x*-i,this.origin.y+this.direction.y*-i,t)}default:return null}}intersectsMesh(e,t,i,s=!1,n,r=!1){const o=N.Matrix[0];return e.getWorldMatrix().invertToRef(o),this._tmpRay?Ue.TransformToRef(this,o,this._tmpRay):this._tmpRay=Ue.Transform(this,o),e.intersects(this._tmpRay,t,i,s,n,r)}intersectsMeshes(e,t,i){i?i.length=0:i=[];for(let s=0;s<e.length;s++){const n=this.intersectsMesh(e[s],t);n.hit&&i.push(n)}return i.sort(this._comparePickingInfo),i}_comparePickingInfo(e,t){return e.distance<t.distance?-1:e.distance>t.distance?1:0}intersectionSegment(e,t,i){const s=this.origin,n=N.Vector3[0],r=N.Vector3[1],o=N.Vector3[2],h=N.Vector3[3];t.subtractToRef(e,n),this.direction.scaleToRef(Ue._Rayl,o),s.addToRef(o,r),e.subtractToRef(s,h);const l=v.Dot(n,n),c=v.Dot(n,o),u=v.Dot(o,o),f=v.Dot(n,h),d=v.Dot(o,h),_=l*u-c*c;let p,g=_,m,b=_;_<Ue._Smallnum?(p=0,g=1,m=d,b=u):(p=c*d-u*f,m=l*d-c*f,p<0?(p=0,m=d,b=u):p>g&&(p=g,m=d+c,b=u)),m<0?(m=0,-f<0?p=0:-f>l?p=g:(p=-f,g=l)):m>b&&(m=b,-f+c<0?p=0:-f+c>l?p=g:(p=-f+c,g=l));const I=Math.abs(p)<Ue._Smallnum?0:p/g,T=Math.abs(m)<Ue._Smallnum?0:m/b,x=N.Vector3[4];o.scaleToRef(T,x);const y=N.Vector3[5];n.scaleToRef(I,y),y.addInPlace(h);const R=N.Vector3[6];return y.subtractToRef(x,R),T>0&&T<=this.length&&R.lengthSquared()<i*i?y.length():-1}update(e,t,i,s,n,r,o,h=!1){if(h){Ue._RayDistant||(Ue._RayDistant=Ue.Zero()),Ue._RayDistant.unprojectRayToRef(e,t,i,s,O.IdentityReadOnly,r,o);const l=N.Matrix[0];n.invertToRef(l),Ue.TransformToRef(Ue._RayDistant,l,this)}else this.unprojectRayToRef(e,t,i,s,n,r,o);return this}static Zero(){return new Ue(v.Zero(),v.Zero())}static CreateNew(e,t,i,s,n,r,o){return Ue.Zero().update(e,t,i,s,n,r,o)}static CreateNewFromTo(e,t,i=O.IdentityReadOnly){const s=new Ue(new v(0,0,0),new v(0,0,0));return Ue.CreateFromToToRef(e,t,s,i)}static CreateFromToToRef(e,t,i,s=O.IdentityReadOnly){i.origin.copyFrom(e);const n=t.subtractToRef(e,i.direction),r=Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z);return i.length=r,i.direction.normalize(),Ue.TransformToRef(i,s,i)}static Transform(e,t){const i=new Ue(new v(0,0,0),new v(0,0,0));return Ue.TransformToRef(e,t,i),i}static TransformToRef(e,t,i){v.TransformCoordinatesToRef(e.origin,t,i.origin),v.TransformNormalToRef(e.direction,t,i.direction),i.length=e.length,i.epsilon=e.epsilon;const s=i.direction,n=s.length();if(!(n===0||n===1)){const r=1/n;s.x*=r,s.y*=r,s.z*=r,i.length*=n}return i}unprojectRayToRef(e,t,i,s,n,r,o){const h=N.Matrix[0];n.multiplyToRef(r,h),h.multiplyToRef(o,h),h.invert();const l=Ee.LastCreatedEngine,c=N.Vector3[0];c.x=e/i*2-1,c.y=-(t/s*2-1),c.z=l!=null&&l.useReverseDepthBuffer?1:l!=null&&l.isNDCHalfZRange?0:-1;const u=N.Vector3[1].copyFromFloats(c.x,c.y,1-1e-8),f=N.Vector3[2],d=N.Vector3[3];v._UnprojectFromInvertedMatrixToRef(c,h,f),v._UnprojectFromInvertedMatrixToRef(u,h,d),this.origin.copyFrom(f),d.subtractToRef(f,this.direction),this.direction.normalize()}}Ue._TmpVector3=zi(6,v.Zero);Ue._RayDistant=Ue.Zero();Ue._Smallnum=1e-8;Ue._Rayl=1e9;function ia(a,e,t,i,s,n=!1){const r=Ue.Zero();return sa(a,e,t,i,r,s,n),r}function sa(a,e,t,i,s,n,r=!1,o=!1){const h=a.getEngine();if(!n&&!(n=a.activeCamera))return a;const l=n.viewport,c=h.getRenderHeight(),{x:u,y:f,width:d,height:_}=l.toGlobal(h.getRenderWidth(),c),p=1/h.getHardwareScalingLevel();return e=e*p-u,t=t*p-(c-f-_),s.update(e,t,d,_,i||O.IdentityReadOnly,r?O.IdentityReadOnly:n.getViewMatrix(),n.getProjectionMatrix(),o),a}function s1(a,e,t,i){const s=Ue.Zero();return $c(a,e,t,s,i),s}function $c(a,e,t,i,s){if(!as)return a;const n=a.getEngine();if(!s&&!(s=a.activeCamera))throw new Error("Active camera not set");const r=s.viewport,o=n.getRenderHeight(),{x:h,y:l,width:c,height:u}=r.toGlobal(n.getRenderWidth(),o),f=O.Identity(),d=1/n.getHardwareScalingLevel();return e=e*d-h,t=t*d-(o-l-u),i.update(e,t,c,u,f,f,s.getProjectionMatrix()),a}function Zc(a,e,t,i,s,n,r,o){const h=e(i,t.enableDistantPicking),l=t.intersects(h,s,r,n,i,o);return!l||!l.hit||!s&&a!=null&&l.distance>=a.distance?null:l}function $0(a,e,t,i,s,n){let r=null;const o=!!(a.activeCameras&&a.activeCameras.length>1&&a.cameraToUseForPointers!==a.activeCamera),h=a.cameraToUseForPointers||a.activeCamera,l=Zc;for(let c=0;c<a.meshes.length;c++){const u=a.meshes[c];if(t){if(!t(u,-1))continue}else if(!u.isEnabled()||!u.isVisible||!u.isPickable)continue;const f=o&&u.isWorldMatrixCameraDependent(),d=u.computeWorldMatrix(f,h);if(u.hasThinInstances&&u.thinInstanceEnablePicking){const _=l(r,e,u,d,!0,!0,n);if(_){if(s)return _;const p=N.Matrix[1],g=u.thinInstanceGetWorldMatrices();for(let m=0;m<g.length;m++){if(t&&!t(u,m))continue;g[m].multiplyToRef(d,p);const I=l(r,e,u,p,i,s,n,!0);if(I&&(r=I,r.thinInstanceIndex=m,i))return r}}}else{const _=l(r,e,u,d,i,s,n);if(_&&(r=_,i))return r}}return r||new as}function Qc(a,e,t,i){if(!as)return null;const s=[],n=!!(a.activeCameras&&a.activeCameras.length>1&&a.cameraToUseForPointers!==a.activeCamera),r=a.cameraToUseForPointers||a.activeCamera,o=Zc;for(let h=0;h<a.meshes.length;h++){const l=a.meshes[h];if(t){if(!t(l,-1))continue}else if(!l.isEnabled()||!l.isVisible||!l.isPickable)continue;const c=n&&l.isWorldMatrixCameraDependent(),u=l.computeWorldMatrix(c,r);if(l.hasThinInstances&&l.thinInstanceEnablePicking){if(o(null,e,l,u,!0,!0,i)){const d=N.Matrix[1],_=l.thinInstanceGetWorldMatrices();for(let p=0;p<_.length;p++){if(t&&!t(l,p))continue;_[p].multiplyToRef(u,d);const m=o(null,e,l,d,!1,!1,i,!0);m&&(m.thinInstanceIndex=p,s.push(m))}}}else{const f=o(null,e,l,u,!1,!1,i);f&&s.push(f)}}return s}function n1(a,e,t,i,s,n){if(!as)return null;const r=$0(a,o=>(a._tempPickingRay||(a._tempPickingRay=Ue.Zero()),sa(a,e,t,o,a._tempPickingRay,n||null),a._tempPickingRay),i,s,!0);return r&&(r.ray=ia(a,e,t,O.Identity(),n||null)),r}function r1(a,e,t,i,s,n,r,o=!1){const h=$0(a,(l,c)=>(a._tempPickingRay||(a._tempPickingRay=Ue.Zero()),sa(a,e,t,l,a._tempPickingRay,n||null,!1,c),a._tempPickingRay),i,s,!1,r);return h&&(h.ray=ia(a,e,t,O.Identity(),n||null)),h}function a1(a,e,t,i,s){const n=$0(a,r=>(a._pickWithRayInverseMatrix||(a._pickWithRayInverseMatrix=O.Identity()),r.invertToRef(a._pickWithRayInverseMatrix),a._cachedRayForTransform||(a._cachedRayForTransform=Ue.Zero()),Ue.TransformToRef(e,a._pickWithRayInverseMatrix,a._cachedRayForTransform),a._cachedRayForTransform),t,i,!1,s);return n&&(n.ray=e),n}function o1(a,e,t,i,s,n){return Qc(a,r=>ia(a,e,t,r,s||null),i,n)}function h1(a,e,t,i){return Qc(a,s=>(a._pickWithRayInverseMatrix||(a._pickWithRayInverseMatrix=O.Identity()),s.invertToRef(a._pickWithRayInverseMatrix),a._cachedRayForTransform||(a._cachedRayForTransform=Ue.Zero()),Ue.TransformToRef(e,a._pickWithRayInverseMatrix,a._cachedRayForTransform),a._cachedRayForTransform),t,i)}function Jh(a,e,t=100,i,s){i||(i=a.getWorldMatrix()),e.length=t,s?e.origin.copyFrom(s):e.origin.copyFrom(a.position);const n=N.Vector3[2];n.set(0,0,a._scene.useRightHandedSystem?-1:1);const r=N.Vector3[3];return v.TransformNormalToRef(n,i,r),v.NormalizeToRef(r,e.direction),e}function l1(a,e){e&&(e.prototype.getForwardRay=function(t=100,i,s){return Jh(this,new Ue(v.Zero(),v.Zero(),t),t,i,s)},e.prototype.getForwardRayToRef=function(t,i=100,s,n){return Jh(this,t,i,s,n)}),a&&(O0._IsPickingAvailable=!0,a.prototype.createPickingRay=function(t,i,s,n,r=!1){return ia(this,t,i,s,n,r)})}l1(it,ve);it.prototype.createPickingRayToRef=function(a,e,t,i,s,n=!1,r=!1){return sa(this,a,e,t,i,s,n,r)};it.prototype.createPickingRayInCameraSpace=function(a,e,t){return s1(this,a,e,t)};it.prototype.createPickingRayInCameraSpaceToRef=function(a,e,t,i){return $c(this,a,e,t,i)};it.prototype.pickWithBoundingInfo=function(a,e,t,i,s){return n1(this,a,e,t,i,s)};it.prototype.pick=function(a,e,t,i,s,n,r=!1){return r1(this,a,e,t,i,s,n,r)};it.prototype.pickWithRay=function(a,e,t,i){return a1(this,a,e,t,i)};it.prototype.multiPick=function(a,e,t,i,s){return o1(this,a,e,t,i,s)};it.prototype.multiPickWithRay=function(a,e,t){return h1(this,a,e,t)};class un{constructor(e,t,i,s=""){var h,l;this.defines="",this.onCompiled=null,this.onError=null,this.uniqueId=0,this.onCompileObservable=new Z,this.onErrorObservable=new Z,this.onBindObservable=new Z,this._wasPreviouslyReady=!1,this._isReady=!1,this._compilationError="",this._key="",this._computeSourceCodeOverride="",this._pipelineContext=null,this._computeSourceCode="",this._rawComputeSourceCode="",this._shaderLanguage=1,this.name=e,this._key=s,this._engine=i,this.uniqueId=un._UniqueIdSeed++,this.defines=(h=t.defines)!=null?h:"",this.onError=t.onError,this.onCompiled=t.onCompiled,this._entryPoint=(l=t.entryPoint)!=null?l:"main",this._shaderStore=Me.GetShadersStore(this._shaderLanguage),this._shaderRepository=Me.GetShadersRepository(this._shaderLanguage),this._includeShaderStore=Me.GetIncludesShadersStore(this._shaderLanguage);let n;const r=St()?this._engine.getHostDocument():null;typeof e=="string"?n=e:e.computeSource?n="source:"+e.computeSource:e.computeElement?n=(r==null?void 0:r.getElementById(e.computeElement))||e.computeElement:n=e.compute||e;const o={defines:this.defines.split("\n"),indexParameters:void 0,isFragment:!1,shouldUseHighPrecisionShader:!1,processor:null,supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:this._shaderRepository,includesShadersStore:this._includeShaderStore,version:(this._engine.version*100).toString(),platformName:this._engine.shaderPlatformName,processingContext:null,isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer,processCodeAfterIncludes:(c,u,f)=>{if(!f)return u;for(const d of f){const p=d.replace("#define","").replace(";","").trim().split(" ");if(p.length===2){const g=p[0],m=p[1];(!isNaN(parseInt(m))||!isNaN(parseFloat(m)))&&(u="const ".concat(g," = ").concat(m,";\n")+u)}}return u}};this._loadShader(n,"Compute","",c=>{f0(o),Id(c,o,u=>{this._rawComputeSourceCode=c,t.processFinalCode&&(u=t.processFinalCode(u));const f=d0(u,"",o);this._useFinalCode(f.vertexCode,e)},this._engine)})}_useFinalCode(e,t){if(t){const i=t.computeElement||t.compute||t.spectorName||t;this._computeSourceCode="//#define SHADER_NAME compute:"+i+"\n"+e}else this._computeSourceCode=e;this._prepareEffect()}get key(){return this._key}isReady(){try{return this._isReadyInternal()}catch{return!1}}_isReadyInternal(){return this._isReady?!0:this._pipelineContext?this._pipelineContext.isReady:!1}getEngine(){return this._engine}getPipelineContext(){return this._pipelineContext}getCompilationError(){return this._compilationError}executeWhenCompiled(e){if(this.isReady()){e(this);return}this.onCompileObservable.add(t=>{e(t)}),(!this._pipelineContext||this._pipelineContext.isAsync)&&setTimeout(()=>{this._checkIsReady(null)},16)}_checkIsReady(e){try{if(this._isReadyInternal())return}catch(t){this._processCompilationErrors(t,e);return}setTimeout(()=>{this._checkIsReady(e)},16)}_loadShader(e,t,i,s){if(typeof HTMLElement<"u"&&e instanceof HTMLElement){const r=h0(e);s(r);return}if(e.substring(0,7)==="source:"){s(e.substring(7));return}if(e.substring(0,7)==="base64:"){const r=window.atob(e.substring(7));s(r);return}if(this._shaderStore[e+t+"Shader"]){s(this._shaderStore[e+t+"Shader"]);return}if(i&&this._shaderStore[e+i+"Shader"]){s(this._shaderStore[e+i+"Shader"]);return}let n;e[0]==="."||e[0]==="/"||e.indexOf("http")>-1?n=e:n=this._shaderRepository+e,this._engine._loadFile(n+"."+t.toLowerCase()+".fx",s)}get computeSourceCode(){var e,t;return this._computeSourceCodeOverride?this._computeSourceCodeOverride:(t=(e=this._pipelineContext)==null?void 0:e._getComputeShaderCode())!=null?t:this._computeSourceCode}get rawComputeSourceCode(){return this._rawComputeSourceCode}_prepareEffect(){const e=this.defines,t=this._pipelineContext;this._isReady=!1;try{const i=this._engine;this._pipelineContext=i.createComputePipelineContext(),this._pipelineContext._name=this._key,i._prepareComputePipelineContext(this._pipelineContext,this._computeSourceCodeOverride?this._computeSourceCodeOverride:this._computeSourceCode,this._rawComputeSourceCode,this._computeSourceCodeOverride?null:e,this._entryPoint),i._executeWhenComputeStateIsCompiled(this._pipelineContext,s=>{if(s&&s.numErrors>0){this._processCompilationErrors(s,t);return}this._compilationError="",this._isReady=!0,this.onCompiled&&this.onCompiled(this),this.onCompileObservable.notifyObservers(this),this.onCompileObservable.clear(),t&&this.getEngine()._deleteComputePipelineContext(t)}),this._pipelineContext.isAsync&&this._checkIsReady(t)}catch(i){this._processCompilationErrors(i,t)}}_processCompilationErrors(e,t=null){var i;if(this._compilationError="",U.Error("Unable to compile compute effect:"),this.defines&&U.Error("Defines:\n"+this.defines),un.LogShaderCodeOnCompilationError){const s=(i=this._pipelineContext)==null?void 0:i._getComputeShaderCode();s&&(U.Error("Compute code:"),U.Error(s))}if(typeof e=="string")this._compilationError=e,U.Error("Error: "+this._compilationError);else for(const s of e.messages){let n="";s.line!==void 0&&(n+="Line "+s.line+", "),s.offset!==void 0&&(n+="Offset "+s.offset+", "),s.length!==void 0&&(n+="Length "+s.length+", "),n+=s.type+": "+s.text,this._compilationError&&(this._compilationError+="\n"),this._compilationError+=n,U.Error(n)}t&&(this._pipelineContext=t,this._isReady=!0),this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this)}dispose(){this._pipelineContext&&this._pipelineContext.dispose(),this._engine._releaseComputeEffect(this)}static RegisterShader(e,t){Me.GetShadersStore(1)["".concat(e,"ComputeShader")]=t}}un._UniqueIdSeed=0;un.LogShaderCodeOnCompilationError=!0;class na{getBindGroups(e,t,i){if(!i)throw new Error("WebGPUComputeContext.getBindGroups: bindingsMapping is required until browsers support reflection for wgsl shaders!");if(this._bindGroups.length===0){const s=this._bindGroupEntries.length>0;for(const n in e){const r=e[n],o=i[n],h=o.group,l=o.binding,c=r.type,u=r.object;let f=r.indexInGroupEntries,d=this._bindGroupEntries[h];switch(d||(d=this._bindGroupEntries[h]=[]),c){case 5:{const _=u;f!==void 0&&s?d[f].resource=this._cacheSampler.getSampler(_):(r.indexInGroupEntries=d.length,d.push({binding:l,resource:this._cacheSampler.getSampler(_)}));break}case 0:case 4:{const _=u,p=_._texture._hardwareTexture;f!==void 0&&s?(c===0&&(d[f++].resource=this._cacheSampler.getSampler(_._texture)),d[f].resource=p.view):(r.indexInGroupEntries=d.length,c===0&&d.push({binding:l-1,resource:this._cacheSampler.getSampler(_._texture)}),d.push({binding:l,resource:p.view}));break}case 1:{const _=u,p=_._texture._hardwareTexture;p.textureAdditionalUsages&8||U.Error("computeDispatch: The texture (name=".concat(_.name,", uniqueId=").concat(_.uniqueId,") is not a storage texture!"),50),f!==void 0&&s?d[f].resource=p.viewForWriting:(r.indexInGroupEntries=d.length,d.push({binding:l,resource:p.viewForWriting}));break}case 6:{const p=u.underlyingResource;f!==void 0&&s?d[f].resource=this._device.importExternalTexture({source:p}):(r.indexInGroupEntries=d.length,d.push({binding:l,resource:this._device.importExternalTexture({source:p})}));break}case 2:case 3:case 7:{const _=c===7?u:u.getBuffer(),p=_.underlyingResource;f!==void 0&&s?(d[f].resource.buffer=p,d[f].resource.size=_.capacity):(r.indexInGroupEntries=d.length,d.push({binding:l,resource:{buffer:p,offset:0,size:_.capacity}}));break}}}for(let n=0;n<this._bindGroupEntries.length;++n){const r=this._bindGroupEntries[n];if(!r){this._bindGroups[n]=void 0;continue}this._bindGroups[n]=this._device.createBindGroup({layout:t.getBindGroupLayout(n),entries:r})}this._bindGroups.length=this._bindGroupEntries.length}return this._bindGroups}constructor(e,t){this._device=e,this._cacheSampler=t,this.uniqueId=na._Counter++,this._bindGroupEntries=[],this.clear()}clear(){this._bindGroups=[]}}na._Counter=0;class c1{get isAsync(){return!1}get isReady(){return this.isAsync,!1}constructor(e){this._name="unnamed",this.engine=e}_getComputeShaderCode(){var e;return(e=this.sources)==null?void 0:e.compute}dispose(){}}const el={};Ye.prototype.createComputeContext=function(){return new na(this._device,this._cacheSampler)};Ye.prototype.createComputeEffect=function(a,e){const i=(typeof a=="string"?a:a.computeToken||a.computeSource||a.computeElement||a.compute)+"@"+e.defines;if(this._compiledComputeEffects[i]){const n=this._compiledComputeEffects[i];return e.onCompiled&&n.isReady()&&e.onCompiled(n),n}const s=new un(a,e,this,i);return this._compiledComputeEffects[i]=s,s};Ye.prototype.createComputePipelineContext=function(){return new c1(this)};Ye.prototype.areAllComputeEffectsReady=function(){for(const a in this._compiledComputeEffects)if(!this._compiledComputeEffects[a].isReady())return!1;return!0};Ye.prototype.computeDispatch=function(a,e,t,i,s=1,n=1,r,o){this._computeDispatch(a,e,t,i,s,n,void 0,void 0,r,o)};Ye.prototype.computeDispatchIndirect=function(a,e,t,i,s=0,n,r){this._computeDispatch(a,e,t,void 0,void 0,void 0,i,s,n,r)};Ye.prototype._computeDispatch=function(a,e,t,i,s,n,r,o,h,l){this._endCurrentRenderPass();const c=a._pipelineContext,u=e;c.computePipeline||(c.computePipeline=this._device.createComputePipeline({layout:"auto",compute:c.stage})),l&&this._timestampQuery.startPass(el,this._timestampIndex);const f=this._renderEncoder.beginComputePass(el);f.setPipeline(c.computePipeline);const d=u.getBindGroups(t,c.computePipeline,h);for(let _=0;_<d.length;++_){const p=d[_];p&&f.setBindGroup(_,p)}r!==void 0?f.dispatchWorkgroupsIndirect(r.underlyingResource,o):i+s+n>0&&f.dispatchWorkgroups(i,s,n),f.end(),l&&(this._timestampQuery.endPass(this._timestampIndex,l),this._timestampIndex+=2)};Ye.prototype.releaseComputeEffects=function(){for(const a in this._compiledComputeEffects){const e=this._compiledComputeEffects[a].getPipelineContext();this._deleteComputePipelineContext(e)}this._compiledComputeEffects={}};Ye.prototype._prepareComputePipelineContext=function(a,e,t,i,s){const n=a;this.dbgShowShaderCode&&(U.Log(i),U.Log(e)),n.sources={compute:e,rawCompute:t},n.stage=this._createComputePipelineStageDescriptor(e,i,s)};Ye.prototype._releaseComputeEffect=function(a){this._compiledComputeEffects[a._key]&&(delete this._compiledComputeEffects[a._key],this._deleteComputePipelineContext(a.getPipelineContext()))};Ye.prototype._rebuildComputeEffects=function(){for(const a in this._compiledComputeEffects){const e=this._compiledComputeEffects[a];e._pipelineContext=null,e._wasPreviouslyReady=!1,e._prepareEffect()}};Ye.prototype._executeWhenComputeStateIsCompiled=function(a,e){a.stage.module.getCompilationInfo().then(t=>{const i={numErrors:0,messages:[]};for(const s of t.messages)s.type==="error"&&i.numErrors++,i.messages.push({type:s.type,text:s.message,line:s.lineNum,column:s.linePos,length:s.length,offset:s.offset});e(i)})};Ye.prototype._deleteComputePipelineContext=function(a){a&&a.dispose()};Ye.prototype._createComputePipelineStageDescriptor=function(a,e,t){return e?e="//"+e.split("\n").join("\n//")+"\n":e="",{module:this._device.createShaderModule({code:e+a}),entryPoint:t}};Ye.prototype._debugPushGroup=function(a,e){this._options.enableGPUDebugMarkers&&(e===0||e===1?(e===1&&(this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this._endCurrentRenderPass()),this._renderEncoder.pushDebugGroup(a)):this._currentRenderPass?(this._currentRenderPass.pushDebugGroup(a),this._debugStackRenderPass.push(a)):this._pendingDebugCommands.push(["push",a,e]))};Ye.prototype._debugPopGroup=function(a){this._options.enableGPUDebugMarkers&&(a===0||a===1?(a===1&&(this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this._endCurrentRenderPass()),this._renderEncoder.popDebugGroup()):this._currentRenderPass?(this._currentRenderPass.popDebugGroup(),this._debugStackRenderPass.pop()):this._pendingDebugCommands.push(["pop",null,a]))};Ye.prototype._debugInsertMarker=function(a,e){this._options.enableGPUDebugMarkers&&(e===0||e===1?(e===1&&(this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this._endCurrentRenderPass()),this._renderEncoder.insertDebugMarker(a)):this._currentRenderPass?this._currentRenderPass.insertDebugMarker(a):this._pendingDebugCommands.push(["insert",a,e]))};Ye.prototype._debugFlushPendingCommands=function(){if(this._debugStackRenderPass.length!==0){const a=this._debugStackRenderPass.slice();this._debugStackRenderPass.length=0;for(let e=0;e<a.length;++e)this._debugPushGroup(a[e],2)}for(let a=0;a<this._pendingDebugCommands.length;++a){const[e,t,i]=this._pendingDebugCommands[a];switch(e){case"push":this._debugPushGroup(t,i);break;case"pop":this._debugPopGroup(i);break;case"insert":this._debugInsertMarker(t,i);break}}this._pendingDebugCommands.length=0};Ye.prototype.createDynamicTexture=function(a,e,t,i){const s=new ft(this,4);return s.baseWidth=a,s.baseHeight=e,t&&(a=this.needPOTTextures?fi(a,this._caps.maxTextureSize):a,e=this.needPOTTextures?fi(e,this._caps.maxTextureSize):e),s.width=a,s.height=e,s.isReady=!1,s.generateMipMaps=t,s.samplingMode=i,this.updateTextureSamplingMode(i,s),this._internalTexturesCache.push(s),a&&e&&this._textureHelper.createGPUTextureForInternalTexture(s,a,e),s};Ye.prototype.updateDynamicTexture=function(a,e,t,i=!1,s,n,r){var c;if(!a)return;const o=e.width,h=e.height;let l=a._hardwareTexture;(c=a._hardwareTexture)!=null&&c.underlyingResource||(l=this._textureHelper.createGPUTextureForInternalTexture(a,o,h)),this._textureHelper.updateTexture(e,a,o,h,a.depth,l.format,0,0,t,i,0,0,r),a.generateMipMaps&&this._generateMipmaps(a),a._dynamicTextureSource=e,a._premulAlpha=i,a.invertY=t||!1,a.isReady=!0};Ye.prototype.unBindMultiColorAttachmentFramebuffer=function(a,e=!1,t){t&&t(),this._endCurrentRenderPass(),e||this.generateMipMapsMultiFramebuffer(a),this._currentRenderTarget=null,this._mrtAttachments=[],this._cacheRenderPipeline.setMRT([]),this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments)};Ye.prototype.createMultipleRenderTarget=function(a,e,t){var $,z,k,M,V,q,he,pe,se,ue,me,ne,Ie;let i=!1,s=!0,n=!1,r=!1,o=15,h=1,l=1;const c=0,u=3,f=!1,d=5,_=3553;let p=[],g=[],m=[],b=[],I=[],T=[],x=[],y=[],R=[],E=[],C=!1;const S=this._createHardwareRenderTargetWrapper(!0,!1,a);e!==void 0&&(i=($=e.generateMipMaps)!=null?$:!1,s=(z=e.generateDepthBuffer)!=null?z:!0,n=(k=e.generateStencilBuffer)!=null?k:!1,r=(M=e.generateDepthTexture)!=null?M:!1,h=(V=e.textureCount)!=null?V:1,o=(q=e.depthTextureFormat)!=null?q:15,p=e.types||p,g=e.samplingModes||g,m=e.useSRGBBuffers||m,b=e.formats||b,I=e.targetTypes||I,T=e.faceIndex||T,x=e.layerIndex||x,y=e.layerCounts||y,R=e.labels||R,E=e.creationFlags||E,l=(he=e.samples)!=null?he:l,C=(pe=e.dontCreateTextures)!=null?pe:!1);const w=(se=a.width)!=null?se:a,P=(ue=a.height)!=null?ue:a,G=[],L=[],W=[];S.label=(me=e==null?void 0:e.label)!=null?me:"MultiRenderTargetWrapper",S._generateDepthBuffer=s,S._generateStencilBuffer=n,S._attachments=L,S._defaultAttachments=W;let K=null;(s||n||r)&&!C&&(r||(s&&n?o=13:s?o=14:o=19),K=S.createDepthStencilTexture(0,!1,n,1,o,S.label+"-DepthStencil"));const ce=e!==void 0&&typeof e=="object"&&e.createMipMaps&&!i;for(let Se=0;Se<h;Se++){let Q=g[Se]||u,be=p[Se]||c;const Be=b[Se]||d,ze=(m[Se]||f)&&this._caps.supportSRGBBuffers,Ke=I[Se]||_,Rt=(ne=y[Se])!=null?ne:1,Ct=E[Se];if((be===1&&!this._caps.textureFloatLinearFiltering||be===2&&!this._caps.textureHalfFloatLinearFiltering)&&(Q=1),be===1&&!this._caps.textureFloat&&(be=0,U.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),L.push(Se+1),W.push(t?Se+1:Se===0?1:0),Ke===-1||C)continue;const Ge=new ft(this,6);switch(G[Se]=Ge,Ke){case 34067:Ge.isCube=!0;break;case 32879:Ge.is3D=!0,Ge.baseDepth=Ge.depth=Rt;break;case 35866:Ge.is2DArray=!0,Ge.baseDepth=Ge.depth=Rt;break}Ge.baseWidth=w,Ge.baseHeight=P,Ge.width=w,Ge.height=P,Ge.isReady=!0,Ge.samples=1,Ge.generateMipMaps=i,Ge.samplingMode=Q,Ge.type=be,Ge._cachedWrapU=0,Ge._cachedWrapV=0,Ge._useSRGBBuffer=ze,Ge.format=Be,Ge.label=(Ie=R[Se])!=null?Ie:S.label+"-Texture"+Se,this._internalTexturesCache.push(Ge),ce&&(Ge.generateMipMaps=!0),this._textureHelper.createGPUTextureForInternalTexture(Ge,void 0,void 0,void 0,Ct,!0),ce&&(Ge.generateMipMaps=!1)}return K&&(K.incrementReferences(),G[h]=K,this._internalTexturesCache.push(K)),S.setTextures(G),S.setLayerAndFaceIndices(x,T),C?S._samples=l:this.updateMultipleRenderTargetTextureSampleCount(S,l),S};Ye.prototype.updateMultipleRenderTargetTextureSampleCount=function(a,e){if(!a||!a.textures||a.textures.length===0||a.textures[0].samples===e)return e;const t=a.textures.length;if(t===0)return 1;e=Math.min(e,this.getCaps().maxMSAASamples);for(let s=0;s<t;++s){const r=a.textures[s]._hardwareTexture;r==null||r.releaseMSAATexture(a.getBaseArrayLayer(s))}const i=a._depthStencilTexture===a.textures[t-1];for(let s=0;s<t;++s){const n=a.textures[s];this._textureHelper.createMSAATexture(n,e,!1,a.getBaseArrayLayer(s)),n.samples=e}return a._depthStencilTexture&&!i&&(this._textureHelper.createMSAATexture(a._depthStencilTexture,e),a._depthStencilTexture.samples=e),a._samples=e,e};Ye.prototype.generateMipMapsMultiFramebuffer=function(a){const e=a;if(!e.isMulti)return;const i=e._attachments.length;for(let s=0;s<i;s++){const n=e.textures[s];n.generateMipMaps&&!n.isCube&&!n.is3D&&this._generateMipmaps(n)}};Ye.prototype.resolveMultiFramebuffer=function(a){throw new Error("resolveMultiFramebuffer is not yet implemented in WebGPU!")};Ye.prototype.bindAttachments=function(a){a.length===0||!this._currentRenderTarget||(this._mrtAttachments=a,this._currentRenderPass&&this._cacheRenderPipeline.setMRTAttachments(a))};Ye.prototype.buildTextureLayout=function(a){const e=[];for(let t=0;t<a.length;t++)a[t]?e.push(t+1):e.push(0);return e};Ye.prototype.restoreSingleAttachment=function(){};Ye.prototype.restoreSingleAttachmentForRenderTarget=function(){};function u1(a){return!!(a&&a.underlyingResource!==void 0)}Ye.prototype.updateVideoTexture=function(a,e,t){var s;if(!a||a._isDisabled)return;this._videoTextureSupported===void 0&&(this._videoTextureSupported=!0);let i=a._hardwareTexture;if((s=a._hardwareTexture)!=null&&s.underlyingResource||(i=this._textureHelper.createGPUTextureForInternalTexture(a)),u1(e)){if(e.isReady()){try{this._textureHelper.copyVideoToTexture(e,a,i.format,!t),a.generateMipMaps&&this._generateMipmaps(a)}catch{}a.isReady=!0}}else e&&this.createImageBitmap(e).then(n=>{this._textureHelper.updateTexture(n,a,a.width,a.height,a.depth,i.format,0,0,!t,!1,0,0),a.generateMipMaps&&this._generateMipmaps(a),a.isReady=!0}).catch(()=>{a.isReady=!0})};var f1={value:()=>{}};function Jc(){for(var a=0,e=arguments.length,t={},i;a<e;++a){if(!(i=arguments[a]+"")||i in t||/[\s.]/.test(i))throw new Error("illegal type: "+i);t[i]=[]}return new gr(t)}function gr(a){this._=a}function d1(a,e){return a.trim().split(/^|\s+/).map(function(t){var i="",s=t.indexOf(".");if(s>=0&&(i=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:i}})}gr.prototype=Jc.prototype={constructor:gr,on:function(a,e){var t=this._,i=d1(a+"",t),s,n=-1,r=i.length;if(arguments.length<2){for(;++n<r;)if((s=(a=i[n]).type)&&(s=_1(t[s],a.name)))return s;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++n<r;)if(s=(a=i[n]).type)t[s]=tl(t[s],a.name,e);else if(e==null)for(s in t)t[s]=tl(t[s],a.name,null);return this},copy:function(){var a={},e=this._;for(var t in e)a[t]=e[t].slice();return new gr(a)},call:function(a,e){if((s=arguments.length-2)>0)for(var t=new Array(s),i=0,s,n;i<s;++i)t[i]=arguments[i+2];if(!this._.hasOwnProperty(a))throw new Error("unknown type: "+a);for(n=this._[a],i=0,s=n.length;i<s;++i)n[i].value.apply(e,t)},apply:function(a,e,t){if(!this._.hasOwnProperty(a))throw new Error("unknown type: "+a);for(var i=this._[a],s=0,n=i.length;s<n;++s)i[s].value.apply(e,t)}};function _1(a,e){for(var t=0,i=a.length,s;t<i;++t)if((s=a[t]).name===e)return s.value}function tl(a,e,t){for(var i=0,s=a.length;i<s;++i)if(a[i].name===e){a[i]=f1,a=a.slice(0,i).concat(a.slice(i+1));break}return t!=null&&a.push({name:e,value:t}),a}var Xa="http://www.w3.org/1999/xhtml";const il={svg:"http://www.w3.org/2000/svg",xhtml:Xa,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ra(a){var e=a+="",t=e.indexOf(":");return t>=0&&(e=a.slice(0,t))!=="xmlns"&&(a=a.slice(t+1)),il.hasOwnProperty(e)?{space:il[e],local:a}:a}function p1(a){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===Xa&&e.documentElement.namespaceURI===Xa?e.createElement(a):e.createElementNS(t,a)}}function g1(a){return function(){return this.ownerDocument.createElementNS(a.space,a.local)}}function Z0(a){var e=ra(a);return(e.local?g1:p1)(e)}function m1(){}function Q0(a){return a==null?m1:function(){return this.querySelector(a)}}function v1(a){typeof a!="function"&&(a=Q0(a));for(var e=this._groups,t=e.length,i=new Array(t),s=0;s<t;++s)for(var n=e[s],r=n.length,o=i[s]=new Array(r),h,l,c=0;c<r;++c)(h=n[c])&&(l=a.call(h,h.__data__,c,n))&&("__data__"in h&&(l.__data__=h.__data__),o[c]=l);return new di(i,this._parents)}function b1(a){return a==null?[]:Array.isArray(a)?a:Array.from(a)}function x1(){return[]}function eu(a){return a==null?x1:function(){return this.querySelectorAll(a)}}function y1(a){return function(){return b1(a.apply(this,arguments))}}function T1(a){typeof a=="function"?a=y1(a):a=eu(a);for(var e=this._groups,t=e.length,i=[],s=[],n=0;n<t;++n)for(var r=e[n],o=r.length,h,l=0;l<o;++l)(h=r[l])&&(i.push(a.call(h,h.__data__,l,r)),s.push(h));return new di(i,s)}function tu(a){return function(){return this.matches(a)}}function iu(a){return function(e){return e.matches(a)}}var A1=Array.prototype.find;function R1(a){return function(){return A1.call(this.children,a)}}function I1(){return this.firstElementChild}function E1(a){return this.select(a==null?I1:R1(typeof a=="function"?a:iu(a)))}var C1=Array.prototype.filter;function S1(){return Array.from(this.children)}function M1(a){return function(){return C1.call(this.children,a)}}function P1(a){return this.selectAll(a==null?S1:M1(typeof a=="function"?a:iu(a)))}function w1(a){typeof a!="function"&&(a=tu(a));for(var e=this._groups,t=e.length,i=new Array(t),s=0;s<t;++s)for(var n=e[s],r=n.length,o=i[s]=[],h,l=0;l<r;++l)(h=n[l])&&a.call(h,h.__data__,l,n)&&o.push(h);return new di(i,this._parents)}function su(a){return new Array(a.length)}function D1(){return new di(this._enter||this._groups.map(su),this._parents)}function wr(a,e){this.ownerDocument=a.ownerDocument,this.namespaceURI=a.namespaceURI,this._next=null,this._parent=a,this.__data__=e}wr.prototype={constructor:wr,appendChild:function(a){return this._parent.insertBefore(a,this._next)},insertBefore:function(a,e){return this._parent.insertBefore(a,e)},querySelector:function(a){return this._parent.querySelector(a)},querySelectorAll:function(a){return this._parent.querySelectorAll(a)}};function F1(a){return function(){return a}}function O1(a,e,t,i,s,n){for(var r=0,o,h=e.length,l=n.length;r<l;++r)(o=e[r])?(o.__data__=n[r],i[r]=o):t[r]=new wr(a,n[r]);for(;r<h;++r)(o=e[r])&&(s[r]=o)}function B1(a,e,t,i,s,n,r){var o,h,l=new Map,c=e.length,u=n.length,f=new Array(c),d;for(o=0;o<c;++o)(h=e[o])&&(f[o]=d=r.call(h,h.__data__,o,e)+"",l.has(d)?s[o]=h:l.set(d,h));for(o=0;o<u;++o)d=r.call(a,n[o],o,n)+"",(h=l.get(d))?(i[o]=h,h.__data__=n[o],l.delete(d)):t[o]=new wr(a,n[o]);for(o=0;o<c;++o)(h=e[o])&&l.get(f[o])===h&&(s[o]=h)}function L1(a){return a.__data__}function N1(a,e){if(!arguments.length)return Array.from(this,L1);var t=e?B1:O1,i=this._parents,s=this._groups;typeof a!="function"&&(a=F1(a));for(var n=s.length,r=new Array(n),o=new Array(n),h=new Array(n),l=0;l<n;++l){var c=i[l],u=s[l],f=u.length,d=U1(a.call(c,c&&c.__data__,l,i)),_=d.length,p=o[l]=new Array(_),g=r[l]=new Array(_),m=h[l]=new Array(f);t(c,u,p,g,m,d,e);for(var b=0,I=0,T,x;b<_;++b)if(T=p[b]){for(b>=I&&(I=b+1);!(x=g[I])&&++I<_;);T._next=x||null}}return r=new di(r,i),r._enter=o,r._exit=h,r}function U1(a){return typeof a=="object"&&"length"in a?a:Array.from(a)}function k1(){return new di(this._exit||this._groups.map(su),this._parents)}function V1(a,e,t){var i=this.enter(),s=this,n=this.exit();return typeof a=="function"?(i=a(i),i&&(i=i.selection())):i=i.append(a+""),e!=null&&(s=e(s),s&&(s=s.selection())),t==null?n.remove():t(n),i&&s?i.merge(s).order():s}function G1(a){for(var e=a.selection?a.selection():a,t=this._groups,i=e._groups,s=t.length,n=i.length,r=Math.min(s,n),o=new Array(s),h=0;h<r;++h)for(var l=t[h],c=i[h],u=l.length,f=o[h]=new Array(u),d,_=0;_<u;++_)(d=l[_]||c[_])&&(f[_]=d);for(;h<s;++h)o[h]=t[h];return new di(o,this._parents)}function z1(){for(var a=this._groups,e=-1,t=a.length;++e<t;)for(var i=a[e],s=i.length-1,n=i[s],r;--s>=0;)(r=i[s])&&(n&&r.compareDocumentPosition(n)^4&&n.parentNode.insertBefore(r,n),n=r);return this}function W1(a){a||(a=H1);function e(u,f){return u&&f?a(u.__data__,f.__data__):!u-!f}for(var t=this._groups,i=t.length,s=new Array(i),n=0;n<i;++n){for(var r=t[n],o=r.length,h=s[n]=new Array(o),l,c=0;c<o;++c)(l=r[c])&&(h[c]=l);h.sort(e)}return new di(s,this._parents).order()}function H1(a,e){return a<e?-1:a>e?1:a>=e?0:NaN}function K1(){var a=arguments[0];return arguments[0]=this,a.apply(null,arguments),this}function X1(){return Array.from(this)}function Y1(){for(var a=this._groups,e=0,t=a.length;e<t;++e)for(var i=a[e],s=0,n=i.length;s<n;++s){var r=i[s];if(r)return r}return null}function q1(){let a=0;for(const e of this)++a;return a}function j1(){return!this.node()}function $1(a){for(var e=this._groups,t=0,i=e.length;t<i;++t)for(var s=e[t],n=0,r=s.length,o;n<r;++n)(o=s[n])&&a.call(o,o.__data__,n,s);return this}function Z1(a){return function(){this.removeAttribute(a)}}function Q1(a){return function(){this.removeAttributeNS(a.space,a.local)}}function J1(a,e){return function(){this.setAttribute(a,e)}}function em(a,e){return function(){this.setAttributeNS(a.space,a.local,e)}}function tm(a,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(a):this.setAttribute(a,t)}}function im(a,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(a.space,a.local):this.setAttributeNS(a.space,a.local,t)}}function sm(a,e){var t=ra(a);if(arguments.length<2){var i=this.node();return t.local?i.getAttributeNS(t.space,t.local):i.getAttribute(t)}return this.each((e==null?t.local?Q1:Z1:typeof e=="function"?t.local?im:tm:t.local?em:J1)(t,e))}function nu(a){return a.ownerDocument&&a.ownerDocument.defaultView||a.document&&a||a.defaultView}function nm(a){return function(){this.style.removeProperty(a)}}function rm(a,e,t){return function(){this.style.setProperty(a,e,t)}}function am(a,e,t){return function(){var i=e.apply(this,arguments);i==null?this.style.removeProperty(a):this.style.setProperty(a,i,t)}}function om(a,e,t){return arguments.length>1?this.each((e==null?nm:typeof e=="function"?am:rm)(a,e,t==null?"":t)):fn(this.node(),a)}function fn(a,e){return a.style.getPropertyValue(e)||nu(a).getComputedStyle(a,null).getPropertyValue(e)}function hm(a){return function(){delete this[a]}}function lm(a,e){return function(){this[a]=e}}function cm(a,e){return function(){var t=e.apply(this,arguments);t==null?delete this[a]:this[a]=t}}function um(a,e){return arguments.length>1?this.each((e==null?hm:typeof e=="function"?cm:lm)(a,e)):this.node()[a]}function ru(a){return a.trim().split(/^|\s+/)}function J0(a){return a.classList||new au(a)}function au(a){this._node=a,this._names=ru(a.getAttribute("class")||"")}au.prototype={add:function(a){var e=this._names.indexOf(a);e<0&&(this._names.push(a),this._node.setAttribute("class",this._names.join(" ")))},remove:function(a){var e=this._names.indexOf(a);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(a){return this._names.indexOf(a)>=0}};function ou(a,e){for(var t=J0(a),i=-1,s=e.length;++i<s;)t.add(e[i])}function hu(a,e){for(var t=J0(a),i=-1,s=e.length;++i<s;)t.remove(e[i])}function fm(a){return function(){ou(this,a)}}function dm(a){return function(){hu(this,a)}}function _m(a,e){return function(){(e.apply(this,arguments)?ou:hu)(this,a)}}function pm(a,e){var t=ru(a+"");if(arguments.length<2){for(var i=J0(this.node()),s=-1,n=t.length;++s<n;)if(!i.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?_m:e?fm:dm)(t,e))}function gm(){this.textContent=""}function mm(a){return function(){this.textContent=a}}function vm(a){return function(){var e=a.apply(this,arguments);this.textContent=e==null?"":e}}function bm(a){return arguments.length?this.each(a==null?gm:(typeof a=="function"?vm:mm)(a)):this.node().textContent}function xm(){this.innerHTML=""}function ym(a){return function(){this.innerHTML=a}}function Tm(a){return function(){var e=a.apply(this,arguments);this.innerHTML=e==null?"":e}}function Am(a){return arguments.length?this.each(a==null?xm:(typeof a=="function"?Tm:ym)(a)):this.node().innerHTML}function Rm(){this.nextSibling&&this.parentNode.appendChild(this)}function Im(){return this.each(Rm)}function Em(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Cm(){return this.each(Em)}function Sm(a){var e=typeof a=="function"?a:Z0(a);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function Mm(){return null}function Pm(a,e){var t=typeof a=="function"?a:Z0(a),i=e==null?Mm:typeof e=="function"?e:Q0(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),i.apply(this,arguments)||null)})}function wm(){var a=this.parentNode;a&&a.removeChild(this)}function Dm(){return this.each(wm)}function Fm(){var a=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(a,this.nextSibling):a}function Om(){var a=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(a,this.nextSibling):a}function Bm(a){return this.select(a?Om:Fm)}function Lm(a){return arguments.length?this.property("__data__",a):this.node().__data__}function Nm(a){return function(e){a.call(this,e,this.__data__)}}function Um(a){return a.trim().split(/^|\s+/).map(function(e){var t="",i=e.indexOf(".");return i>=0&&(t=e.slice(i+1),e=e.slice(0,i)),{type:e,name:t}})}function km(a){return function(){var e=this.__on;if(e){for(var t=0,i=-1,s=e.length,n;t<s;++t)n=e[t],(!a.type||n.type===a.type)&&n.name===a.name?this.removeEventListener(n.type,n.listener,n.options):e[++i]=n;++i?e.length=i:delete this.__on}}}function Vm(a,e,t){return function(){var i=this.__on,s,n=Nm(e);if(i){for(var r=0,o=i.length;r<o;++r)if((s=i[r]).type===a.type&&s.name===a.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=n,s.options=t),s.value=e;return}}this.addEventListener(a.type,n,t),s={type:a.type,name:a.name,value:e,listener:n,options:t},i?i.push(s):this.__on=[s]}}function Gm(a,e,t){var i=Um(a+""),s,n=i.length,r;if(arguments.length<2){var o=this.node().__on;if(o){for(var h=0,l=o.length,c;h<l;++h)for(s=0,c=o[h];s<n;++s)if((r=i[s]).type===c.type&&r.name===c.name)return c.value}return}for(o=e?Vm:km,s=0;s<n;++s)this.each(o(i[s],e,t));return this}function lu(a,e,t){var i=nu(a),s=i.CustomEvent;typeof s=="function"?s=new s(e,t):(s=i.document.createEvent("Event"),t?(s.initEvent(e,t.bubbles,t.cancelable),s.detail=t.detail):s.initEvent(e,!1,!1)),a.dispatchEvent(s)}function zm(a,e){return function(){return lu(this,a,e)}}function Wm(a,e){return function(){return lu(this,a,e.apply(this,arguments))}}function Hm(a,e){return this.each((typeof e=="function"?Wm:zm)(a,e))}function*Km(){for(var a=this._groups,e=0,t=a.length;e<t;++e)for(var i=a[e],s=0,n=i.length,r;s<n;++s)(r=i[s])&&(yield r)}var cu=[null];function di(a,e){this._groups=a,this._parents=e}function Qn(){return new di([[document.documentElement]],cu)}function Xm(){return this}di.prototype=Qn.prototype={constructor:di,select:v1,selectAll:T1,selectChild:E1,selectChildren:P1,filter:w1,data:N1,enter:D1,exit:k1,join:V1,merge:G1,selection:Xm,order:z1,sort:W1,call:K1,nodes:X1,node:Y1,size:q1,empty:j1,each:$1,attr:sm,style:om,property:um,classed:pm,text:bm,html:Am,raise:Im,lower:Cm,append:Sm,insert:Pm,remove:Dm,clone:Bm,datum:Lm,on:Gm,dispatch:Hm,[Symbol.iterator]:Km};function Ym(a){return typeof a=="string"?new di([[document.querySelector(a)]],[document.documentElement]):new di([[a]],cu)}function uu(a){return Ym(Z0(a).call(document.documentElement))}function eo(a,e,t){a.prototype=e.prototype=t,t.constructor=a}function fu(a,e){var t=Object.create(a.prototype);for(var i in e)t[i]=e[i];return t}function Jn(){}var kn=.7,Dr=1/kn,an="\\s*([+-]?\\d+)\\s*",Vn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ki="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",qm=/^#([0-9a-f]{3,8})$/,jm=new RegExp("^rgb\\(".concat(an,",").concat(an,",").concat(an,"\\)$")),$m=new RegExp("^rgb\\(".concat(Ki,",").concat(Ki,",").concat(Ki,"\\)$")),Zm=new RegExp("^rgba\\(".concat(an,",").concat(an,",").concat(an,",").concat(Vn,"\\)$")),Qm=new RegExp("^rgba\\(".concat(Ki,",").concat(Ki,",").concat(Ki,",").concat(Vn,"\\)$")),Jm=new RegExp("^hsl\\(".concat(Vn,",").concat(Ki,",").concat(Ki,"\\)$")),e2=new RegExp("^hsla\\(".concat(Vn,",").concat(Ki,",").concat(Ki,",").concat(Vn,"\\)$")),sl={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};eo(Jn,Gn,{copy(a){return Object.assign(new this.constructor,this,a)},displayable(){return this.rgb().displayable()},hex:nl,formatHex:nl,formatHex8:t2,formatHsl:i2,formatRgb:rl,toString:rl});function nl(){return this.rgb().formatHex()}function t2(){return this.rgb().formatHex8()}function i2(){return du(this).formatHsl()}function rl(){return this.rgb().formatRgb()}function Gn(a){var e,t;return a=(a+"").trim().toLowerCase(),(e=qm.exec(a))?(t=e[1].length,e=parseInt(e[1],16),t===6?al(e):t===3?new ai(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?lr(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?lr(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=jm.exec(a))?new ai(e[1],e[2],e[3],1):(e=$m.exec(a))?new ai(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Zm.exec(a))?lr(e[1],e[2],e[3],e[4]):(e=Qm.exec(a))?lr(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Jm.exec(a))?ll(e[1],e[2]/100,e[3]/100,1):(e=e2.exec(a))?ll(e[1],e[2]/100,e[3]/100,e[4]):sl.hasOwnProperty(a)?al(sl[a]):a==="transparent"?new ai(NaN,NaN,NaN,0):null}function al(a){return new ai(a>>16&255,a>>8&255,a&255,1)}function lr(a,e,t,i){return i<=0&&(a=e=t=NaN),new ai(a,e,t,i)}function s2(a){return a instanceof Jn||(a=Gn(a)),a?(a=a.rgb(),new ai(a.r,a.g,a.b,a.opacity)):new ai}function Ya(a,e,t,i){return arguments.length===1?s2(a):new ai(a,e,t,i==null?1:i)}function ai(a,e,t,i){this.r=+a,this.g=+e,this.b=+t,this.opacity=+i}eo(ai,Ya,fu(Jn,{brighter(a){return a=a==null?Dr:Math.pow(Dr,a),new ai(this.r*a,this.g*a,this.b*a,this.opacity)},darker(a){return a=a==null?kn:Math.pow(kn,a),new ai(this.r*a,this.g*a,this.b*a,this.opacity)},rgb(){return this},clamp(){return new ai(Us(this.r),Us(this.g),Us(this.b),Fr(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ol,formatHex:ol,formatHex8:n2,formatRgb:hl,toString:hl}));function ol(){return"#".concat(Bs(this.r)).concat(Bs(this.g)).concat(Bs(this.b))}function n2(){return"#".concat(Bs(this.r)).concat(Bs(this.g)).concat(Bs(this.b)).concat(Bs((isNaN(this.opacity)?1:this.opacity)*255))}function hl(){const a=Fr(this.opacity);return"".concat(a===1?"rgb(":"rgba(").concat(Us(this.r),", ").concat(Us(this.g),", ").concat(Us(this.b)).concat(a===1?")":", ".concat(a,")"))}function Fr(a){return isNaN(a)?1:Math.max(0,Math.min(1,a))}function Us(a){return Math.max(0,Math.min(255,Math.round(a)||0))}function Bs(a){return a=Us(a),(a<16?"0":"")+a.toString(16)}function ll(a,e,t,i){return i<=0?a=e=t=NaN:t<=0||t>=1?a=e=NaN:e<=0&&(a=NaN),new Mi(a,e,t,i)}function du(a){if(a instanceof Mi)return new Mi(a.h,a.s,a.l,a.opacity);if(a instanceof Jn||(a=Gn(a)),!a)return new Mi;if(a instanceof Mi)return a;a=a.rgb();var e=a.r/255,t=a.g/255,i=a.b/255,s=Math.min(e,t,i),n=Math.max(e,t,i),r=NaN,o=n-s,h=(n+s)/2;return o?(e===n?r=(t-i)/o+(t<i)*6:t===n?r=(i-e)/o+2:r=(e-t)/o+4,o/=h<.5?n+s:2-n-s,r*=60):o=h>0&&h<1?0:r,new Mi(r,o,h,a.opacity)}function r2(a,e,t,i){return arguments.length===1?du(a):new Mi(a,e,t,i==null?1:i)}function Mi(a,e,t,i){this.h=+a,this.s=+e,this.l=+t,this.opacity=+i}eo(Mi,r2,fu(Jn,{brighter(a){return a=a==null?Dr:Math.pow(Dr,a),new Mi(this.h,this.s,this.l*a,this.opacity)},darker(a){return a=a==null?kn:Math.pow(kn,a),new Mi(this.h,this.s,this.l*a,this.opacity)},rgb(){var a=this.h%360+(this.h<0)*360,e=isNaN(a)||isNaN(this.s)?0:this.s,t=this.l,i=t+(t<.5?t:1-t)*e,s=2*t-i;return new ai(Ea(a>=240?a-240:a+120,s,i),Ea(a,s,i),Ea(a<120?a+240:a-120,s,i),this.opacity)},clamp(){return new Mi(cl(this.h),cr(this.s),cr(this.l),Fr(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const a=Fr(this.opacity);return"".concat(a===1?"hsl(":"hsla(").concat(cl(this.h),", ").concat(cr(this.s)*100,"%, ").concat(cr(this.l)*100,"%").concat(a===1?")":", ".concat(a,")"))}}));function cl(a){return a=(a||0)%360,a<0?a+360:a}function cr(a){return Math.max(0,Math.min(1,a||0))}function Ea(a,e,t){return(a<60?e+(t-e)*a/60:a<180?t:a<240?e+(t-e)*(240-a)/60:e)*255}const _u=a=>()=>a;function a2(a,e){return function(t){return a+t*e}}function o2(a,e,t){return a=Math.pow(a,t),e=Math.pow(e,t)-a,t=1/t,function(i){return Math.pow(a+i*e,t)}}function h2(a){return(a=+a)==1?pu:function(e,t){return t-e?o2(e,t,a):_u(isNaN(e)?t:e)}}function pu(a,e){var t=e-a;return t?a2(a,t):_u(isNaN(a)?e:a)}const ul=function a(e){var t=h2(e);function i(s,n){var r=t((s=Ya(s)).r,(n=Ya(n)).r),o=t(s.g,n.g),h=t(s.b,n.b),l=pu(s.opacity,n.opacity);return function(c){return s.r=r(c),s.g=o(c),s.b=h(c),s.opacity=l(c),s+""}}return i.gamma=a,i}(1);function bs(a,e){return a=+a,e=+e,function(t){return a*(1-t)+e*t}}var qa=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ca=new RegExp(qa.source,"g");function l2(a){return function(){return a}}function c2(a){return function(e){return a(e)+""}}function u2(a,e){var t=qa.lastIndex=Ca.lastIndex=0,i,s,n,r=-1,o=[],h=[];for(a=a+"",e=e+"";(i=qa.exec(a))&&(s=Ca.exec(e));)(n=s.index)>t&&(n=e.slice(t,n),o[r]?o[r]+=n:o[++r]=n),(i=i[0])===(s=s[0])?o[r]?o[r]+=s:o[++r]=s:(o[++r]=null,h.push({i:r,x:bs(i,s)})),t=Ca.lastIndex;return t<e.length&&(n=e.slice(t),o[r]?o[r]+=n:o[++r]=n),o.length<2?h[0]?c2(h[0].x):l2(e):(e=h.length,function(l){for(var c=0,u;c<e;++c)o[(u=h[c]).i]=u.x(l);return o.join("")})}var fl=180/Math.PI,ja={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function gu(a,e,t,i,s,n){var r,o,h;return(r=Math.sqrt(a*a+e*e))&&(a/=r,e/=r),(h=a*t+e*i)&&(t-=a*h,i-=e*h),(o=Math.sqrt(t*t+i*i))&&(t/=o,i/=o,h/=o),a*i<e*t&&(a=-a,e=-e,h=-h,r=-r),{translateX:s,translateY:n,rotate:Math.atan2(e,a)*fl,skewX:Math.atan(h)*fl,scaleX:r,scaleY:o}}var ur;function f2(a){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(a+"");return e.isIdentity?ja:gu(e.a,e.b,e.c,e.d,e.e,e.f)}function d2(a){return a==null||(ur||(ur=document.createElementNS("http://www.w3.org/2000/svg","g")),ur.setAttribute("transform",a),!(a=ur.transform.baseVal.consolidate()))?ja:(a=a.matrix,gu(a.a,a.b,a.c,a.d,a.e,a.f))}function mu(a,e,t,i){function s(l){return l.length?l.pop()+" ":""}function n(l,c,u,f,d,_){if(l!==u||c!==f){var p=d.push("translate(",null,e,null,t);_.push({i:p-4,x:bs(l,u)},{i:p-2,x:bs(c,f)})}else(u||f)&&d.push("translate("+u+e+f+t)}function r(l,c,u,f){l!==c?(l-c>180?c+=360:c-l>180&&(l+=360),f.push({i:u.push(s(u)+"rotate(",null,i)-2,x:bs(l,c)})):c&&u.push(s(u)+"rotate("+c+i)}function o(l,c,u,f){l!==c?f.push({i:u.push(s(u)+"skewX(",null,i)-2,x:bs(l,c)}):c&&u.push(s(u)+"skewX("+c+i)}function h(l,c,u,f,d,_){if(l!==u||c!==f){var p=d.push(s(d)+"scale(",null,",",null,")");_.push({i:p-4,x:bs(l,u)},{i:p-2,x:bs(c,f)})}else(u!==1||f!==1)&&d.push(s(d)+"scale("+u+","+f+")")}return function(l,c){var u=[],f=[];return l=a(l),c=a(c),n(l.translateX,l.translateY,c.translateX,c.translateY,u,f),r(l.rotate,c.rotate,u,f),o(l.skewX,c.skewX,u,f),h(l.scaleX,l.scaleY,c.scaleX,c.scaleY,u,f),l=c=null,function(d){for(var _=-1,p=f.length,g;++_<p;)u[(g=f[_]).i]=g.x(d);return u.join("")}}}var _2=mu(f2,"px, ","px)","deg)"),p2=mu(d2,", ",")",")"),dn=0,An=0,yn=0,vu=1e3,Or,Rn,Br=0,Gs=0,aa=0,zn=typeof performance=="object"&&performance.now?performance:Date,bu=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(a){setTimeout(a,17)};function to(){return Gs||(bu(g2),Gs=zn.now()+aa)}function g2(){Gs=0}function Lr(){this._call=this._time=this._next=null}Lr.prototype=xu.prototype={constructor:Lr,restart:function(a,e,t){if(typeof a!="function")throw new TypeError("callback is not a function");t=(t==null?to():+t)+(e==null?0:+e),!this._next&&Rn!==this&&(Rn?Rn._next=this:Or=this,Rn=this),this._call=a,this._time=t,$a()},stop:function(){this._call&&(this._call=null,this._time=1/0,$a())}};function xu(a,e,t){var i=new Lr;return i.restart(a,e,t),i}function m2(){to(),++dn;for(var a=Or,e;a;)(e=Gs-a._time)>=0&&a._call.call(void 0,e),a=a._next;--dn}function dl(){Gs=(Br=zn.now())+aa,dn=An=0;try{m2()}finally{dn=0,b2(),Gs=0}}function v2(){var a=zn.now(),e=a-Br;e>vu&&(aa-=e,Br=a)}function b2(){for(var a,e=Or,t,i=1/0;e;)e._call?(i>e._time&&(i=e._time),a=e,e=e._next):(t=e._next,e._next=null,e=a?a._next=t:Or=t);Rn=a,$a(i)}function $a(a){if(!dn){An&&(An=clearTimeout(An));var e=a-Gs;e>24?(a<1/0&&(An=setTimeout(dl,a-zn.now()-aa)),yn&&(yn=clearInterval(yn))):(yn||(Br=zn.now(),yn=setInterval(v2,vu)),dn=1,bu(dl))}}function _l(a,e,t){var i=new Lr;return e=e==null?0:+e,i.restart(s=>{i.stop(),a(s+e)},e,t),i}var x2=Jc("start","end","cancel","interrupt"),y2=[],yu=0,pl=1,Za=2,mr=3,gl=4,Qa=5,vr=6;function oa(a,e,t,i,s,n){var r=a.__transition;if(!r)a.__transition={};else if(t in r)return;T2(a,t,{name:e,index:i,group:s,on:x2,tween:y2,time:n.time,delay:n.delay,duration:n.duration,ease:n.ease,timer:null,state:yu})}function io(a,e){var t=Oi(a,e);if(t.state>yu)throw new Error("too late; already scheduled");return t}function Xi(a,e){var t=Oi(a,e);if(t.state>mr)throw new Error("too late; already running");return t}function Oi(a,e){var t=a.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function T2(a,e,t){var i=a.__transition,s;i[e]=t,t.timer=xu(n,0,t.time);function n(l){t.state=pl,t.timer.restart(r,t.delay,t.time),t.delay<=l&&r(l-t.delay)}function r(l){var c,u,f,d;if(t.state!==pl)return h();for(c in i)if(d=i[c],d.name===t.name){if(d.state===mr)return _l(r);d.state===gl?(d.state=vr,d.timer.stop(),d.on.call("interrupt",a,a.__data__,d.index,d.group),delete i[c]):+c<e&&(d.state=vr,d.timer.stop(),d.on.call("cancel",a,a.__data__,d.index,d.group),delete i[c])}if(_l(function(){t.state===mr&&(t.state=gl,t.timer.restart(o,t.delay,t.time),o(l))}),t.state=Za,t.on.call("start",a,a.__data__,t.index,t.group),t.state===Za){for(t.state=mr,s=new Array(f=t.tween.length),c=0,u=-1;c<f;++c)(d=t.tween[c].value.call(a,a.__data__,t.index,t.group))&&(s[++u]=d);s.length=u+1}}function o(l){for(var c=l<t.duration?t.ease.call(null,l/t.duration):(t.timer.restart(h),t.state=Qa,1),u=-1,f=s.length;++u<f;)s[u].call(a,c);t.state===Qa&&(t.on.call("end",a,a.__data__,t.index,t.group),h())}function h(){t.state=vr,t.timer.stop(),delete i[e];for(var l in i)return;delete a.__transition}}function A2(a,e){var t=a.__transition,i,s,n=!0,r;if(t){e=e==null?null:e+"";for(r in t){if((i=t[r]).name!==e){n=!1;continue}s=i.state>Za&&i.state<Qa,i.state=vr,i.timer.stop(),i.on.call(s?"interrupt":"cancel",a,a.__data__,i.index,i.group),delete t[r]}n&&delete a.__transition}}function R2(a){return this.each(function(){A2(this,a)})}function I2(a,e){var t,i;return function(){var s=Xi(this,a),n=s.tween;if(n!==t){i=t=n;for(var r=0,o=i.length;r<o;++r)if(i[r].name===e){i=i.slice(),i.splice(r,1);break}}s.tween=i}}function E2(a,e,t){var i,s;if(typeof t!="function")throw new Error;return function(){var n=Xi(this,a),r=n.tween;if(r!==i){s=(i=r).slice();for(var o={name:e,value:t},h=0,l=s.length;h<l;++h)if(s[h].name===e){s[h]=o;break}h===l&&s.push(o)}n.tween=s}}function C2(a,e){var t=this._id;if(a+="",arguments.length<2){for(var i=Oi(this.node(),t).tween,s=0,n=i.length,r;s<n;++s)if((r=i[s]).name===a)return r.value;return null}return this.each((e==null?I2:E2)(t,a,e))}function so(a,e,t){var i=a._id;return a.each(function(){var s=Xi(this,i);(s.value||(s.value={}))[e]=t.apply(this,arguments)}),function(s){return Oi(s,i).value[e]}}function Tu(a,e){var t;return(typeof e=="number"?bs:e instanceof Gn?ul:(t=Gn(e))?(e=t,ul):u2)(a,e)}function S2(a){return function(){this.removeAttribute(a)}}function M2(a){return function(){this.removeAttributeNS(a.space,a.local)}}function P2(a,e,t){var i,s=t+"",n;return function(){var r=this.getAttribute(a);return r===s?null:r===i?n:n=e(i=r,t)}}function w2(a,e,t){var i,s=t+"",n;return function(){var r=this.getAttributeNS(a.space,a.local);return r===s?null:r===i?n:n=e(i=r,t)}}function D2(a,e,t){var i,s,n;return function(){var r,o=t(this),h;return o==null?void this.removeAttribute(a):(r=this.getAttribute(a),h=o+"",r===h?null:r===i&&h===s?n:(s=h,n=e(i=r,o)))}}function F2(a,e,t){var i,s,n;return function(){var r,o=t(this),h;return o==null?void this.removeAttributeNS(a.space,a.local):(r=this.getAttributeNS(a.space,a.local),h=o+"",r===h?null:r===i&&h===s?n:(s=h,n=e(i=r,o)))}}function O2(a,e){var t=ra(a),i=t==="transform"?p2:Tu;return this.attrTween(a,typeof e=="function"?(t.local?F2:D2)(t,i,so(this,"attr."+a,e)):e==null?(t.local?M2:S2)(t):(t.local?w2:P2)(t,i,e))}function B2(a,e){return function(t){this.setAttribute(a,e.call(this,t))}}function L2(a,e){return function(t){this.setAttributeNS(a.space,a.local,e.call(this,t))}}function N2(a,e){var t,i;function s(){var n=e.apply(this,arguments);return n!==i&&(t=(i=n)&&L2(a,n)),t}return s._value=e,s}function U2(a,e){var t,i;function s(){var n=e.apply(this,arguments);return n!==i&&(t=(i=n)&&B2(a,n)),t}return s._value=e,s}function k2(a,e){var t="attr."+a;if(arguments.length<2)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;var i=ra(a);return this.tween(t,(i.local?N2:U2)(i,e))}function V2(a,e){return function(){io(this,a).delay=+e.apply(this,arguments)}}function G2(a,e){return e=+e,function(){io(this,a).delay=e}}function z2(a){var e=this._id;return arguments.length?this.each((typeof a=="function"?V2:G2)(e,a)):Oi(this.node(),e).delay}function W2(a,e){return function(){Xi(this,a).duration=+e.apply(this,arguments)}}function H2(a,e){return e=+e,function(){Xi(this,a).duration=e}}function K2(a){var e=this._id;return arguments.length?this.each((typeof a=="function"?W2:H2)(e,a)):Oi(this.node(),e).duration}function X2(a,e){if(typeof e!="function")throw new Error;return function(){Xi(this,a).ease=e}}function Y2(a){var e=this._id;return arguments.length?this.each(X2(e,a)):Oi(this.node(),e).ease}function q2(a,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Xi(this,a).ease=t}}function j2(a){if(typeof a!="function")throw new Error;return this.each(q2(this._id,a))}function $2(a){typeof a!="function"&&(a=tu(a));for(var e=this._groups,t=e.length,i=new Array(t),s=0;s<t;++s)for(var n=e[s],r=n.length,o=i[s]=[],h,l=0;l<r;++l)(h=n[l])&&a.call(h,h.__data__,l,n)&&o.push(h);return new hs(i,this._parents,this._name,this._id)}function Z2(a){if(a._id!==this._id)throw new Error;for(var e=this._groups,t=a._groups,i=e.length,s=t.length,n=Math.min(i,s),r=new Array(i),o=0;o<n;++o)for(var h=e[o],l=t[o],c=h.length,u=r[o]=new Array(c),f,d=0;d<c;++d)(f=h[d]||l[d])&&(u[d]=f);for(;o<i;++o)r[o]=e[o];return new hs(r,this._parents,this._name,this._id)}function Q2(a){return(a+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||e==="start"})}function J2(a,e,t){var i,s,n=Q2(e)?io:Xi;return function(){var r=n(this,a),o=r.on;o!==i&&(s=(i=o).copy()).on(e,t),r.on=s}}function ev(a,e){var t=this._id;return arguments.length<2?Oi(this.node(),t).on.on(a):this.each(J2(t,a,e))}function tv(a){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==a)return;e&&e.removeChild(this)}}function iv(){return this.on("end.remove",tv(this._id))}function sv(a){var e=this._name,t=this._id;typeof a!="function"&&(a=Q0(a));for(var i=this._groups,s=i.length,n=new Array(s),r=0;r<s;++r)for(var o=i[r],h=o.length,l=n[r]=new Array(h),c,u,f=0;f<h;++f)(c=o[f])&&(u=a.call(c,c.__data__,f,o))&&("__data__"in c&&(u.__data__=c.__data__),l[f]=u,oa(l[f],e,t,f,l,Oi(c,t)));return new hs(n,this._parents,e,t)}function nv(a){var e=this._name,t=this._id;typeof a!="function"&&(a=eu(a));for(var i=this._groups,s=i.length,n=[],r=[],o=0;o<s;++o)for(var h=i[o],l=h.length,c,u=0;u<l;++u)if(c=h[u]){for(var f=a.call(c,c.__data__,u,h),d,_=Oi(c,t),p=0,g=f.length;p<g;++p)(d=f[p])&&oa(d,e,t,p,f,_);n.push(f),r.push(c)}return new hs(n,r,e,t)}var rv=Qn.prototype.constructor;function av(){return new rv(this._groups,this._parents)}function ov(a,e){var t,i,s;return function(){var n=fn(this,a),r=(this.style.removeProperty(a),fn(this,a));return n===r?null:n===t&&r===i?s:s=e(t=n,i=r)}}function Au(a){return function(){this.style.removeProperty(a)}}function hv(a,e,t){var i,s=t+"",n;return function(){var r=fn(this,a);return r===s?null:r===i?n:n=e(i=r,t)}}function lv(a,e,t){var i,s,n;return function(){var r=fn(this,a),o=t(this),h=o+"";return o==null&&(h=o=(this.style.removeProperty(a),fn(this,a))),r===h?null:r===i&&h===s?n:(s=h,n=e(i=r,o))}}function cv(a,e){var t,i,s,n="style."+e,r="end."+n,o;return function(){var h=Xi(this,a),l=h.on,c=h.value[n]==null?o||(o=Au(e)):void 0;(l!==t||s!==c)&&(i=(t=l).copy()).on(r,s=c),h.on=i}}function uv(a,e,t){var i=(a+="")=="transform"?_2:Tu;return e==null?this.styleTween(a,ov(a,i)).on("end.style."+a,Au(a)):typeof e=="function"?this.styleTween(a,lv(a,i,so(this,"style."+a,e))).each(cv(this._id,a)):this.styleTween(a,hv(a,i,e),t).on("end.style."+a,null)}function fv(a,e,t){return function(i){this.style.setProperty(a,e.call(this,i),t)}}function dv(a,e,t){var i,s;function n(){var r=e.apply(this,arguments);return r!==s&&(i=(s=r)&&fv(a,r,t)),i}return n._value=e,n}function _v(a,e,t){var i="style."+(a+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(e==null)return this.tween(i,null);if(typeof e!="function")throw new Error;return this.tween(i,dv(a,e,t==null?"":t))}function pv(a){return function(){this.textContent=a}}function gv(a){return function(){var e=a(this);this.textContent=e==null?"":e}}function mv(a){return this.tween("text",typeof a=="function"?gv(so(this,"text",a)):pv(a==null?"":a+""))}function vv(a){return function(e){this.textContent=a.call(this,e)}}function bv(a){var e,t;function i(){var s=a.apply(this,arguments);return s!==t&&(e=(t=s)&&vv(s)),e}return i._value=a,i}function xv(a){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(a==null)return this.tween(e,null);if(typeof a!="function")throw new Error;return this.tween(e,bv(a))}function yv(){for(var a=this._name,e=this._id,t=Ru(),i=this._groups,s=i.length,n=0;n<s;++n)for(var r=i[n],o=r.length,h,l=0;l<o;++l)if(h=r[l]){var c=Oi(h,e);oa(h,a,t,l,r,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new hs(i,this._parents,a,t)}function Tv(){var a,e,t=this,i=t._id,s=t.size();return new Promise(function(n,r){var o={value:r},h={value:function(){--s===0&&n()}};t.each(function(){var l=Xi(this,i),c=l.on;c!==a&&(e=(a=c).copy(),e._.cancel.push(o),e._.interrupt.push(o),e._.end.push(h)),l.on=e}),s===0&&n()})}var Av=0;function hs(a,e,t,i){this._groups=a,this._parents=e,this._name=t,this._id=i}function Ru(){return++Av}var es=Qn.prototype;hs.prototype={constructor:hs,select:sv,selectAll:nv,selectChild:es.selectChild,selectChildren:es.selectChildren,filter:$2,merge:Z2,selection:av,transition:yv,call:es.call,nodes:es.nodes,node:es.node,size:es.size,empty:es.empty,each:es.each,on:ev,attr:O2,attrTween:k2,style:uv,styleTween:_v,text:mv,textTween:xv,remove:iv,tween:C2,delay:z2,duration:K2,ease:Y2,easeVarying:j2,end:Tv,[Symbol.iterator]:es[Symbol.iterator]};function Rv(a){return((a*=2)<=1?a*a*a:(a-=2)*a*a+2)/2}var Iv={time:null,delay:0,duration:250,ease:Rv};function Ev(a,e){for(var t;!(t=a.__transition)||!(t=t[e]);)if(!(a=a.parentNode))throw new Error("transition ".concat(e," not found"));return t}function Cv(a){var e,t;a instanceof hs?(e=a._id,a=a._name):(e=Ru(),(t=Iv).time=to(),a=a==null?null:a+"");for(var i=this._groups,s=i.length,n=0;n<s;++n)for(var r=i[n],o=r.length,h,l=0;l<o;++l)(h=r[l])&&oa(h,a,e,l,r,t||Ev(h,e));return new hs(i,this._parents,a,e)}Qn.prototype.interrupt=R2;Qn.prototype.transition=Cv;function In(a,e,t){this.k=a,this.x=e,this.y=t}In.prototype={constructor:In,scale:function(a){return a===1?this:new In(this.k*a,this.x,this.y)},translate:function(a,e){return a===0&e===0?this:new In(this.k,this.x+this.k*a,this.y+this.k*e)},apply:function(a){return[a[0]*this.k+this.x,a[1]*this.k+this.y]},applyX:function(a){return a*this.k+this.x},applyY:function(a){return a*this.k+this.y},invert:function(a){return[(a[0]-this.x)/this.k,(a[1]-this.y)/this.k]},invertX:function(a){return(a-this.x)/this.k},invertY:function(a){return(a-this.y)/this.k},rescaleX:function(a){return a.copy().domain(a.range().map(this.invertX,this).map(a.invert,a))},rescaleY:function(a){return a.copy().domain(a.range().map(this.invertY,this).map(a.invert,a))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};In.prototype;function Iu(a){let e=a.pathArray;const t=a.closeArray||!1,i=a.closePath||!1,s=a.invertUV||!1,n=Math.floor(e[0].length/2);let r=a.offset||n;r=r>n?n:Math.floor(r);const o=a.sideOrientation===0?0:a.sideOrientation||j.DEFAULTSIDE,h=a.uvs,l=a.colors,c=[],u=[],f=[],d=[],_=[],p=[],g=[],m=[];let b;const I=[],T=[];let x,y,R;if(e.length<2){const Q=[],be=[];for(y=0;y<e[0].length-r;y++)Q.push(e[0][y]),be.push(e[0][y+r]);e=[Q,be]}let E=0;const C=i?1:0,S=t?1:0;let w,P;b=e[0].length;let G,L;for(x=0;x<e.length+S;x++){for(g[x]=0,_[x]=[0],w=x===e.length?e[0]:e[x],P=w.length,b=b<P?b:P,R=0;R<P;)c.push(w[R].x,w[R].y,w[R].z),R>0&&(G=w[R].subtract(w[R-1]).length(),L=G+g[x],_[x].push(L),g[x]=L),R++;i&&(R--,c.push(w[0].x,w[0].y,w[0].z),G=w[R].subtract(w[0]).length(),L=G+g[x],_[x].push(L),g[x]=L),I[x]=P+C,T[x]=E,E+=P+C}let W,K,ce=null,$=null;for(y=0;y<b+C;y++)for(m[y]=0,p[y]=[0],x=0;x<e.length-1+S;x++)W=e[x],K=x===e.length-1?e[0]:e[x+1],y===b?(ce=W[0],$=K[0]):(ce=W[y],$=K[y]),G=$.subtract(ce).length(),L=G+m[y],p[y].push(L),m[y]=L;let z,k;if(h)for(x=0;x<h.length;x++)d.push(h[x].x,h[x].y);else for(x=0;x<e.length+S;x++)for(y=0;y<b+C;y++)z=g[x]!=0?_[x][y]/g[x]:0,k=m[y]!=0?p[y][x]/m[y]:0,s?d.push(k,z):d.push(z,k);x=0;let M=0,V=I[x]-1,q=I[x+1]-1,he=V<q?V:q,pe=T[1]-T[0];const se=I.length-1;for(;M<=he&&x<se;)u.push(M,M+pe,M+1),u.push(M+pe+1,M+1,M+pe),M+=1,M===he&&(x++,pe=T[x+1]-T[x],V=I[x]-1,q=I[x+1]-1,M=T[x],he=V<q?V+M:q+M);if(j.ComputeNormals(c,u,f),i){let Q=0,be=0;for(x=0;x<e.length;x++){Q=T[x]*3,x+1<e.length?be=(T[x+1]-1)*3:be=f.length-3,f[Q]=(f[Q]+f[be])*.5,f[Q+1]=(f[Q+1]+f[be+1])*.5,f[Q+2]=(f[Q+2]+f[be+2])*.5;const Be=Math.sqrt(f[Q]*f[Q]+f[Q+1]*f[Q+1]+f[Q+2]*f[Q+2]);f[Q]/=Be,f[Q+1]/=Be,f[Q+2]/=Be,f[be]=f[Q],f[be+1]=f[Q+1],f[be+2]=f[Q+2]}}if(t){let Q=T[0]*3,be=T[e.length]*3;for(y=0;y<b+C;y++){f[Q]=(f[Q]+f[be])*.5,f[Q+1]=(f[Q+1]+f[be+1])*.5,f[Q+2]=(f[Q+2]+f[be+2])*.5;const Be=Math.sqrt(f[Q]*f[Q]+f[Q+1]*f[Q+1]+f[Q+2]*f[Q+2]);f[Q]/=Be,f[Q+1]/=Be,f[Q+2]/=Be,f[be]=f[Q],f[be+1]=f[Q+1],f[be+2]=f[Q+2],Q+=3,be+=3}}j._ComputeSides(o,c,u,f,d,a.frontUVs,a.backUVs);let ue=null;if(l){ue=new Float32Array(l.length*4);for(let Q=0;Q<l.length;Q++)ue[Q*4]=l[Q].r,ue[Q*4+1]=l[Q].g,ue[Q*4+2]=l[Q].b,ue[Q*4+3]=l[Q].a}const me=new j,ne=new Float32Array(c),Ie=new Float32Array(f),Se=new Float32Array(d);return me.indices=u,me.positions=ne,me.normals=Ie,me.uvs=Se,ue&&me.set(ue,A.ColorKind),i&&(me._idx=T),me}function zs(a,e,t=null){const i=e.pathArray,s=e.closeArray,n=e.closePath,r=F._GetDefaultSideOrientation(e.sideOrientation),o=e.instance,h=e.updatable;if(o){const l=N.Vector3[0].setAll(Number.MAX_VALUE),c=N.Vector3[1].setAll(-Number.MAX_VALUE),u=d=>{let _=i[0].length;const p=o;let g=0;const m=p._originalBuilderSideOrientation===F.DOUBLESIDE?2:1;for(let b=1;b<=m;++b)for(let I=0;I<i.length;++I){const T=i[I],x=T.length;_=_<x?_:x;for(let y=0;y<_;++y){const R=T[y];d[g]=R.x,d[g+1]=R.y,d[g+2]=R.z,l.minimizeInPlaceFromFloats(R.x,R.y,R.z),c.maximizeInPlaceFromFloats(R.x,R.y,R.z),g+=3}if(p._creationDataStorage&&p._creationDataStorage.closePath){const y=T[0];d[g]=y.x,d[g+1]=y.y,d[g+2]=y.z,g+=3}}},f=o.getVerticesData(A.PositionKind);if(u(f),o.hasBoundingInfo?o.getBoundingInfo().reConstruct(l,c,o._worldMatrix):o.buildBoundingInfo(l,c,o._worldMatrix),o.updateVerticesData(A.PositionKind,f,!1,!1),e.colors){const d=o.getVerticesData(A.ColorKind);for(let _=0,p=0;_<e.colors.length;_++,p+=4){const g=e.colors[_];d[p]=g.r,d[p+1]=g.g,d[p+2]=g.b,d[p+3]=g.a}o.updateVerticesData(A.ColorKind,d,!1,!1)}if(e.uvs){const d=o.getVerticesData(A.UVKind);for(let _=0;_<e.uvs.length;_++)d[_*2]=e.uvs[_].x,d[_*2+1]=e.uvs[_].y;o.updateVerticesData(A.UVKind,d,!1,!1)}if(!o.areNormalsFrozen||o.isFacetDataEnabled){const d=o.getIndices(),_=o.getVerticesData(A.NormalKind),p=o.isFacetDataEnabled?o.getFacetDataParameters():null;if(j.ComputeNormals(f,d,_,p),o._creationDataStorage&&o._creationDataStorage.closePath){let g=0,m=0;for(let b=0;b<i.length;b++)g=o._creationDataStorage.idx[b]*3,b+1<i.length?m=(o._creationDataStorage.idx[b+1]-1)*3:m=_.length-3,_[g]=(_[g]+_[m])*.5,_[g+1]=(_[g+1]+_[m+1])*.5,_[g+2]=(_[g+2]+_[m+2])*.5,_[m]=_[g],_[m+1]=_[g+1],_[m+2]=_[g+2]}o.areNormalsFrozen||o.updateVerticesData(A.NormalKind,_,!1,!1)}return o}else{const l=new F(a,t);l._originalBuilderSideOrientation=r,l._creationDataStorage=new Uc;const c=Iu(e);return n&&(l._creationDataStorage.idx=c._idx),l._creationDataStorage.closePath=n,l._creationDataStorage.closeArray=s,c.applyToMesh(l,h),l}}j.CreateRibbon=Iu;F.CreateRibbon=(a,e,t=!1,i,s,n,r=!1,o,h)=>zs(a,{pathArray:e,closeArray:t,closePath:i,offset:s,updatable:r,sideOrientation:o,instance:h},n);function Eu(a){const e=[],t=[],i=[],s=[],n=a.radius||.5,r=a.tessellation||64,o=a.arc&&(a.arc<=0||a.arc>1)?1:a.arc||1,h=a.sideOrientation===0?0:a.sideOrientation||j.DEFAULTSIDE;e.push(0,0,0),s.push(.5,.5);const l=Math.PI*2*o,c=o===1?l/r:l/(r-1);let u=0;for(let _=0;_<r;_++){const p=Math.cos(u),g=Math.sin(u),m=(p+1)/2,b=(1-g)/2;e.push(n*p,n*g,0),s.push(m,b),u+=c}o===1&&(e.push(e[3],e[4],e[5]),s.push(s[2],s[3]));const f=e.length/3;for(let _=1;_<f-1;_++)t.push(_+1,0,_);j.ComputeNormals(e,t,i),j._ComputeSides(h,e,t,i,s,a.frontUVs,a.backUVs);const d=new j;return d.indices=t,d.positions=e,d.normals=i,d.uvs=s,d}function Cu(a,e={},t=null){const i=new F(a,t);return e.sideOrientation=F._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,Eu(e).applyToMesh(i,e.updatable),i}j.CreateDisc=Eu;F.CreateDisc=(a,e,t,i=null,s,n)=>Cu(a,{radius:e,tessellation:t,sideOrientation:n,updatable:s},i);F._GroundMeshParser=(a,e)=>er.Parse(a,e);class er extends F{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=N.Matrix[5];i.invertToRef(s);const n=N.Vector3[8];if(v.TransformCoordinatesFromFloatsToRef(e,0,t,s,n),e=n.x,t=n.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 r=this._getFacetAt(e,t),o=-(r.x*e+r.z*t+r.w)/r.y;return v.TransformCoordinatesFromFloatsToRef(0,o,0,i,n),n.y}getNormalAtCoordinates(e,t){const i=new v(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,i),i}getNormalAtCoordinatesToRef(e,t,i){const s=this.getWorldMatrix(),n=N.Matrix[5];s.invertToRef(n);const r=N.Vector3[8];if(v.TransformCoordinatesFromFloatsToRef(e,0,t,n,r),e=r.x,t=r.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 v.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),n=this._heightQuads[s*this._subdivisionsX+i];let r;return t<n.slope.x*e+n.slope.y?r=n.facet1:r=n.facet2,r}_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 n={slope:oe.Zero(),facet1:new Pe(0,0,0,0),facet2:new Pe(0,0,0,0)};this._heightQuads[i*e+s]=n}return this}_computeHeightQuads(){const e=this.getVerticesData(A.PositionKind);if(!e)return this;const t=N.Vector3[3],i=N.Vector3[2],s=N.Vector3[1],n=N.Vector3[0],r=N.Vector3[4],o=N.Vector3[5],h=N.Vector3[6],l=N.Vector3[7],c=N.Vector3[8];let u=0,f=0,d=0,_=0,p=0,g=0,m=0;const b=this._subdivisionsX,I=this._subdivisionsY;for(let T=0;T<I;T++)for(let x=0;x<b;x++){u=x*3,f=T*(b+1)*3,d=(T+1)*(b+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],n.x=e[d+u+3],n.y=e[d+u+4],n.z=e[d+u+5],_=(n.z-t.z)/(n.x-t.x),p=t.z-_*t.x,i.subtractToRef(t,r),s.subtractToRef(t,o),n.subtractToRef(t,h),v.CrossToRef(h,o,l),v.CrossToRef(r,h,c),l.normalize(),c.normalize(),g=-(l.x*t.x+l.y*t.y+l.z*t.z),m=-(c.x*i.x+c.y*i.y+c.z*i.z);const y=this._heightQuads[T*b+x];y.slope.copyFromFloats(_,p),y.facet1.copyFromFloats(l.x,l.y,l.z,g),y.facet2.copyFromFloats(c.x,c.y,c.z,m)}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 er(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 Su(a){const e=[],t=[],i=[],s=[];let n,r;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(n=0;n<=c;n++)for(r=0;r<=l;r++){const f=new v(r*o/l-o/2,0,(c-n)*h/c-h/2),d=new v(0,1,0);t.push(f.x,f.y,f.z),i.push(d.x,d.y,d.z),s.push(r/l,1-n/c)}for(n=0;n<c;n++)for(r=0;r<l;r++)e.push(r+1+(n+1)*(l+1)),e.push(r+1+n*(l+1)),e.push(r+n*(l+1)),e.push(r+(n+1)*(l+1)),e.push(r+1+(n+1)*(l+1)),e.push(r+n*(l+1));const u=new j;return u.indices=e,u.positions=t,u.normals=i,u.uvs=s,u}function Mu(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,n=a.subdivisions||{w:1,h:1},r=a.precision||{w:1,h:1},o=[],h=[],l=[],c=[];let u,f,d,_;n.h=n.h<1?1:n.h,n.w=n.w<1?1:n.w,r.w=r.w<1?1:r.w,r.h=r.h<1?1:r.h;const p={w:(i-e)/n.w,h:(s-t)/n.h};function g(b,I,T,x){const y=h.length/3,R=r.w+1;for(u=0;u<r.h;u++)for(f=0;f<r.w;f++){const S=[y+f+u*R,y+(f+1)+u*R,y+(f+1)+(u+1)*R,y+f+(u+1)*R];o.push(S[1]),o.push(S[2]),o.push(S[3]),o.push(S[0]),o.push(S[1]),o.push(S[3])}const E=v.Zero(),C=new v(0,1,0);for(u=0;u<=r.h;u++)for(E.z=u*(x-I)/r.h+I,f=0;f<=r.w;f++)E.x=f*(T-b)/r.w+b,E.y=0,h.push(E.x,E.y,E.z),l.push(C.x,C.y,C.z),c.push(f/r.w,u/r.h)}for(d=0;d<n.h;d++)for(_=0;_<n.w;_++)g(e+_*p.w,t+d*p.h,e+(_+1)*p.w,t+(d+1)*p.h);const m=new j;return m.indices=o,m.positions=h,m.normals=l,m.uvs=c,m}function Pu(a){const e=[],t=[],i=[],s=[];let n,r;const o=a.colorFilter||new de(.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(n=0;n<=a.subdivisions;n++)for(r=0;r<=a.subdivisions;r++){const u=new v(r*a.width/a.subdivisions-a.width/2,0,(a.subdivisions-n)*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,_=(f+d*a.bufferWidth)*4;let p=a.buffer[_]/255,g=a.buffer[_+1]/255,m=a.buffer[_+2]/255;const b=a.buffer[_+3]/255;l&&(p=1-p,g=1-g,m=1-m);const I=p*o.r+g*o.g+m*o.b;b>=h?u.y=a.minHeight+(a.maxHeight-a.minHeight)*I:u.y=a.minHeight-Le,a.heightBuffer&&(a.heightBuffer[n*(a.subdivisions+1)+r]=u.y),t.push(u.x,u.y,u.z),i.push(0,0,0),s.push(r/a.subdivisions,1-n/a.subdivisions)}for(n=0;n<a.subdivisions;n++)for(r=0;r<a.subdivisions;r++){const u=r+1+(n+1)*(a.subdivisions+1),f=r+1+n*(a.subdivisions+1),d=r+n*(a.subdivisions+1),_=r+(n+1)*(a.subdivisions+1),p=t[u*3+1]>=a.minHeight,g=t[f*3+1]>=a.minHeight,m=t[d*3+1]>=a.minHeight;p&&g&&m&&(e.push(u),e.push(f),e.push(d)),t[_*3+1]>=a.minHeight&&p&&m&&(e.push(_),e.push(u),e.push(d))}j.ComputeNormals(t,e,i);const c=new j;return c.indices=e,c.positions=t,c.normals=i,c.uvs=s,c}function wu(a,e={},t){const i=new er(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,Su(e).applyToMesh(i,e.updatable),i._setReady(!0),i}function Du(a,e,t=null){const i=new F(a,t);return Mu(e).applyToMesh(i,e.updatable),i}function Fu(a,e,t={},i=null){const s=t.width||10,n=t.height||10,r=t.subdivisions||1,o=t.minHeight||0,h=t.maxHeight||1,l=t.colorFilter||new de(.3,.59,.11),c=t.alphaFilter||0,u=t.updatable,f=t.onReady;i=i||Ee.LastCreatedScene;const d=new er(a,i);d._subdivisionsX=r,d._subdivisionsY=r,d._width=s,d._height=n,d._maxX=d._width/2,d._maxZ=d._height/2,d._minX=-d._maxX,d._minZ=-d._maxZ,d._setReady(!1);let _;t.passHeightBufferInCallback&&(_=new Float32Array((r+1)*(r+1)));const p=(g,m,b)=>{Pu({width:s,height:n,subdivisions:r,minHeight:o,maxHeight:h,colorFilter:l,buffer:g,bufferWidth:m,bufferHeight:b,alphaFilter:c,heightBuffer:_}).applyToMesh(d,u),f&&f(d,_),d._setReady(!0)};if(typeof e=="string"){const g=m=>{const b=m.width,I=m.height;if(i.isDisposed)return;const T=i==null?void 0:i.getEngine().resizeImageBitmap(m,b,I);p(T,b,I)};J.LoadImage(e,g,t.onError?t.onError:()=>{},i.offlineProvider)}else p(e.data,e.width,e.height);return d}j.CreateGround=Su;j.CreateTiledGround=Mu;j.CreateGroundFromHeightMap=Pu;F.CreateGround=(a,e,t,i,s,n)=>wu(a,{width:e,height:t,subdivisions:i,updatable:n},s);F.CreateTiledGround=(a,e,t,i,s,n,r,o,h)=>Du(a,{xmin:e,zmin:t,xmax:i,zmax:s,subdivisions:n,precision:r,updatable:h},o);F.CreateGroundFromHeightMap=(a,e,t,i,s,n,r,o,h,l,c)=>Fu(a,e,{width:t,height:i,subdivisions:s,minHeight:n,maxHeight:r,updatable:h,onReady:l,alphaFilter:c},o);function Ou(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 n=[];const r=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 _=f[c],p=d[u],g=[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],g=[-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 R=[[1,1,1],[-1,1,1],[-1,1,-1],[1,1,-1]],E=[[-1,-1,1],[1,-1,1],[1,-1,-1],[-1,-1,-1]];const C=[17,18,19,16],S=[22,23,20,21];for(;_>0;)R.unshift(R.pop()),C.unshift(C.pop()),_--;for(;p>0;)E.unshift(E.pop()),S.unshift(S.pop()),p--;R=R.flat(),E=E.flat(),g=g.concat(R).concat(E),t.push(C[0],C[2],C[3],C[0],C[1],C[2]),t.push(S[0],S[2],S[3],S[0],S[1],S[2])}const m=[r/2,o/2,h/2];n=g.reduce((R,E,C)=>R.concat(E*m[C%3]),[]);const b=a.sideOrientation===0?0:a.sideOrientation||j.DEFAULTSIDE,I=a.faceUV||new Array(6),T=a.faceColors,x=[];for(let R=0;R<6;R++)I[R]===void 0&&(I[R]=new Pe(0,0,1,1)),T&&T[R]===void 0&&(T[R]=new H(1,1,1,1));for(let R=0;R<6;R++)if(s.push(I[R].z,I[R].w),s.push(I[R].x,I[R].w),s.push(I[R].x,I[R].y),s.push(I[R].z,I[R].y),T)for(let E=0;E<4;E++)x.push(T[R].r,T[R].g,T[R].b,T[R].a);j._ComputeSides(b,n,t,i,s,a.frontUVs,a.backUVs);const y=new j;if(y.indices=t,y.positions=n,y.normals=i,y.uvs=s,T){const R=b===j.DOUBLESIDE?x.concat(x):x;y.colors=R}return y}function Bu(a,e={},t=null){const i=new F(a,t);return e.sideOrientation=F._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,Ou(e).applyToMesh(i,e.updatable),i}j.CreateBox=Ou;F.CreateBox=(a,e,t=null,i,s)=>Bu(a,{size:e,sideOrientation:s,updatable:i},t);function Mn(a){const e=a.pattern||F.NO_FLIP,t=a.tileWidth||a.tileSize||1,i=a.tileHeight||a.tileSize||1,s=a.alignHorizontal||0,n=a.alignVertical||0,r=a.width||a.size||1,o=Math.floor(r/t);let h=r-o*t;const l=a.height||a.size||1,c=Math.floor(l/i);let u=l-c*i;const f=t*o/2,d=i*c/2;let _=0,p=0,g=0,m=0,b=0,I=0;if(h>0||u>0){switch(g=-f,m=-d,b=f,I=d,s){case F.CENTER:h/=2,g-=h,b+=h;break;case F.LEFT:b+=h,_=-h/2;break;case F.RIGHT:g-=h,_=h/2;break}switch(n){case F.CENTER:u/=2,m-=u,I+=u;break;case F.BOTTOM:I+=u,p=-u/2;break;case F.TOP:m-=u,p=u/2;break}}const T=[],x=[],y=[];y[0]=[0,0,1,0,1,1,0,1],y[1]=[0,0,1,0,1,1,0,1],(e===F.ROTATE_TILE||e===F.ROTATE_ROW)&&(y[1]=[1,1,0,1,0,0,1,0]),(e===F.FLIP_TILE||e===F.FLIP_ROW)&&(y[1]=[1,0,0,0,0,1,1,1]),(e===F.FLIP_N_ROTATE_TILE||e===F.FLIP_N_ROTATE_ROW)&&(y[1]=[0,1,1,1,1,0,0,0]);let R=[];const E=[],C=[];let S=0;for(let L=0;L<c;L++)for(let W=0;W<o;W++)T.push(-f+W*t+_,-d+L*i+p,0),T.push(-f+(W+1)*t+_,-d+L*i+p,0),T.push(-f+(W+1)*t+_,-d+(L+1)*i+p,0),T.push(-f+W*t+_,-d+(L+1)*i+p,0),C.push(S,S+1,S+3,S+1,S+2,S+3),e===F.FLIP_TILE||e===F.ROTATE_TILE||e===F.FLIP_N_ROTATE_TILE?R=R.concat(y[(W%2+L%2)%2]):e===F.FLIP_ROW||e===F.ROTATE_ROW||e===F.FLIP_N_ROTATE_ROW?R=R.concat(y[L%2]):R=R.concat(y[0]),E.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),x.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1),S+=4;if(h>0||u>0){const L=u>0&&(n===F.CENTER||n===F.TOP),W=u>0&&(n===F.CENTER||n===F.BOTTOM),K=h>0&&(s===F.CENTER||s===F.RIGHT),ce=h>0&&(s===F.CENTER||s===F.LEFT);let $=[],z,k,M,V;if(L&&K&&(T.push(g+_,m+p,0),T.push(-f+_,m+p,0),T.push(-f+_,m+u+p,0),T.push(g+_,m+u+p,0),C.push(S,S+1,S+3,S+1,S+2,S+3),S+=4,z=1-h/t,k=1-u/i,M=1,V=1,$=[z,k,M,k,M,V,z,V],e===F.ROTATE_ROW&&($=[1-z,1-k,1-M,1-k,1-M,1-V,1-z,1-V]),e===F.FLIP_ROW&&($=[1-z,k,1-M,k,1-M,V,1-z,V]),e===F.FLIP_N_ROTATE_ROW&&($=[z,1-k,M,1-k,M,1-V,z,1-V]),R=R.concat($),E.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),x.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),L&&ce&&(T.push(f+_,m+p,0),T.push(b+_,m+p,0),T.push(b+_,m+u+p,0),T.push(f+_,m+u+p,0),C.push(S,S+1,S+3,S+1,S+2,S+3),S+=4,z=0,k=1-u/i,M=h/t,V=1,$=[z,k,M,k,M,V,z,V],(e===F.ROTATE_ROW||e===F.ROTATE_TILE&&o%2===0)&&($=[1-z,1-k,1-M,1-k,1-M,1-V,1-z,1-V]),(e===F.FLIP_ROW||e===F.FLIP_TILE&&o%2===0)&&($=[1-z,k,1-M,k,1-M,V,1-z,V]),(e===F.FLIP_N_ROTATE_ROW||e===F.FLIP_N_ROTATE_TILE&&o%2===0)&&($=[z,1-k,M,1-k,M,1-V,z,1-V]),R=R.concat($),E.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),x.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),W&&K&&(T.push(g+_,d+p,0),T.push(-f+_,d+p,0),T.push(-f+_,I+p,0),T.push(g+_,I+p,0),C.push(S,S+1,S+3,S+1,S+2,S+3),S+=4,z=1-h/t,k=0,M=1,V=u/i,$=[z,k,M,k,M,V,z,V],(e===F.ROTATE_ROW&&c%2===1||e===F.ROTATE_TILE&&c%1===0)&&($=[1-z,1-k,1-M,1-k,1-M,1-V,1-z,1-V]),(e===F.FLIP_ROW&&c%2===1||e===F.FLIP_TILE&&c%2===0)&&($=[1-z,k,1-M,k,1-M,V,1-z,V]),(e===F.FLIP_N_ROTATE_ROW&&c%2===1||e===F.FLIP_N_ROTATE_TILE&&c%2===0)&&($=[z,1-k,M,1-k,M,1-V,z,1-V]),R=R.concat($),E.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),x.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),W&&ce&&(T.push(f+_,d+p,0),T.push(b+_,d+p,0),T.push(b+_,I+p,0),T.push(f+_,I+p,0),C.push(S,S+1,S+3,S+1,S+2,S+3),S+=4,z=0,k=0,M=h/t,V=u/i,$=[z,k,M,k,M,V,z,V],(e===F.ROTATE_ROW&&c%2===1||e===F.ROTATE_TILE&&(c+o)%2===1)&&($=[1-z,1-k,1-M,1-k,1-M,1-V,1-z,1-V]),(e===F.FLIP_ROW&&c%2===1||e===F.FLIP_TILE&&(c+o)%2===1)&&($=[1-z,k,1-M,k,1-M,V,1-z,V]),(e===F.FLIP_N_ROTATE_ROW&&c%2===1||e===F.FLIP_N_ROTATE_TILE&&(c+o)%2===1)&&($=[z,1-k,M,1-k,M,1-V,z,1-V]),R=R.concat($),E.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),x.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),L){const q=[];z=0,k=1-u/i,M=1,V=1,q[0]=[z,k,M,k,M,V,z,V],q[1]=[z,k,M,k,M,V,z,V],(e===F.ROTATE_TILE||e===F.ROTATE_ROW)&&(q[1]=[1-z,1-k,1-M,1-k,1-M,1-V,1-z,1-V]),(e===F.FLIP_TILE||e===F.FLIP_ROW)&&(q[1]=[1-z,k,1-M,k,1-M,V,1-z,V]),(e===F.FLIP_N_ROTATE_TILE||e===F.FLIP_N_ROTATE_ROW)&&(q[1]=[z,1-k,M,1-k,M,1-V,z,1-V]);for(let he=0;he<o;he++)T.push(-f+he*t+_,m+p,0),T.push(-f+(he+1)*t+_,m+p,0),T.push(-f+(he+1)*t+_,m+u+p,0),T.push(-f+he*t+_,m+u+p,0),C.push(S,S+1,S+3,S+1,S+2,S+3),S+=4,e===F.FLIP_TILE||e===F.ROTATE_TILE||e===F.FLIP_N_ROTATE_TILE?R=R.concat(q[(he+1)%2]):e===F.FLIP_ROW||e===F.ROTATE_ROW||e===F.FLIP_N_ROTATE_ROW?R=R.concat(q[1]):R=R.concat(q[0]),E.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),x.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(W){const q=[];z=0,k=0,M=1,V=u/i,q[0]=[z,k,M,k,M,V,z,V],q[1]=[z,k,M,k,M,V,z,V],(e===F.ROTATE_TILE||e===F.ROTATE_ROW)&&(q[1]=[1-z,1-k,1-M,1-k,1-M,1-V,1-z,1-V]),(e===F.FLIP_TILE||e===F.FLIP_ROW)&&(q[1]=[1-z,k,1-M,k,1-M,V,1-z,V]),(e===F.FLIP_N_ROTATE_TILE||e===F.FLIP_N_ROTATE_ROW)&&(q[1]=[z,1-k,M,1-k,M,1-V,z,1-V]);for(let he=0;he<o;he++)T.push(-f+he*t+_,I-u+p,0),T.push(-f+(he+1)*t+_,I-u+p,0),T.push(-f+(he+1)*t+_,I+p,0),T.push(-f+he*t+_,I+p,0),C.push(S,S+1,S+3,S+1,S+2,S+3),S+=4,e===F.FLIP_TILE||e===F.ROTATE_TILE||e===F.FLIP_N_ROTATE_TILE?R=R.concat(q[(he+c)%2]):e===F.FLIP_ROW||e===F.ROTATE_ROW||e===F.FLIP_N_ROTATE_ROW?R=R.concat(q[c%2]):R=R.concat(q[0]),E.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),x.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(K){const q=[];z=1-h/t,k=0,M=1,V=1,q[0]=[z,k,M,k,M,V,z,V],q[1]=[z,k,M,k,M,V,z,V],(e===F.ROTATE_TILE||e===F.ROTATE_ROW)&&(q[1]=[1-z,1-k,1-M,1-k,1-M,1-V,1-z,1-V]),(e===F.FLIP_TILE||e===F.FLIP_ROW)&&(q[1]=[1-z,k,1-M,k,1-M,V,1-z,V]),(e===F.FLIP_N_ROTATE_TILE||e===F.FLIP_N_ROTATE_ROW)&&(q[1]=[z,1-k,M,1-k,M,1-V,z,1-V]);for(let he=0;he<c;he++)T.push(g+_,-d+he*i+p,0),T.push(g+h+_,-d+he*i+p,0),T.push(g+h+_,-d+(he+1)*i+p,0),T.push(g+_,-d+(he+1)*i+p,0),C.push(S,S+1,S+3,S+1,S+2,S+3),S+=4,e===F.FLIP_TILE||e===F.ROTATE_TILE||e===F.FLIP_N_ROTATE_TILE?R=R.concat(q[(he+1)%2]):e===F.FLIP_ROW||e===F.ROTATE_ROW||e===F.FLIP_N_ROTATE_ROW?R=R.concat(q[he%2]):R=R.concat(q[0]),E.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),x.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(ce){const q=[];z=0,k=0,M=h/i,V=1,q[0]=[z,k,M,k,M,V,z,V],q[1]=[z,k,M,k,M,V,z,V],(e===F.ROTATE_TILE||e===F.ROTATE_ROW)&&(q[1]=[1-z,1-k,1-M,1-k,1-M,1-V,1-z,1-V]),(e===F.FLIP_TILE||e===F.FLIP_ROW)&&(q[1]=[1-z,k,1-M,k,1-M,V,1-z,V]),(e===F.FLIP_N_ROTATE_TILE||e===F.FLIP_N_ROTATE_ROW)&&(q[1]=[z,1-k,M,1-k,M,1-V,z,1-V]);for(let he=0;he<c;he++)T.push(b-h+_,-d+he*i+p,0),T.push(b+_,-d+he*i+p,0),T.push(b+_,-d+(he+1)*i+p,0),T.push(b-h+_,-d+(he+1)*i+p,0),C.push(S,S+1,S+3,S+1,S+2,S+3),S+=4,e===F.FLIP_TILE||e===F.ROTATE_TILE||e===F.FLIP_N_ROTATE_TILE?R=R.concat(q[(he+o)%2]):e===F.FLIP_ROW||e===F.ROTATE_ROW||e===F.FLIP_N_ROTATE_ROW?R=R.concat(q[he%2]):R=R.concat(q[0]),E.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),x.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}}const w=a.sideOrientation===0?0:a.sideOrientation||j.DEFAULTSIDE;j._ComputeSides(w,T,C,x,R,a.frontUVs,a.backUVs);const P=new j;P.indices=C,P.positions=T,P.normals=x,P.uvs=R;const G=w===j.DOUBLESIDE?E.concat(E):E;return P.colors=G,P}function Sv(a,e,t=null){const i=new F(a,t);return e.sideOrientation=F._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,Mn(e).applyToMesh(i,e.updatable),i}j.CreateTiledPlane=Mn;function Lu(a){const t=a.faceUV||new Array(6),i=a.faceColors,s=a.pattern||F.NO_FLIP,n=a.width||a.size||1,r=a.height||a.size||1,o=a.depth||a.size||1,h=a.tileWidth||a.tileSize||1,l=a.tileHeight||a.tileSize||1,c=a.alignHorizontal||0,u=a.alignVertical||0,f=a.sideOrientation===0?0:a.sideOrientation||j.DEFAULTSIDE;for(let M=0;M<6;M++)t[M]===void 0&&(t[M]=new Pe(0,0,1,1)),i&&i[M]===void 0&&(i[M]=new H(1,1,1,1));const d=n/2,_=r/2,p=o/2,g=[];for(let M=0;M<2;M++)g[M]=Mn({pattern:s,tileWidth:h,tileHeight:l,width:n,height:r,alignVertical:u,alignHorizontal:c,sideOrientation:f});for(let M=2;M<4;M++)g[M]=Mn({pattern:s,tileWidth:h,tileHeight:l,width:o,height:r,alignVertical:u,alignHorizontal:c,sideOrientation:f});let m=u;u===F.BOTTOM?m=F.TOP:u===F.TOP&&(m=F.BOTTOM);for(let M=4;M<6;M++)g[M]=Mn({pattern:s,tileWidth:h,tileHeight:l,width:n,height:o,alignVertical:m,alignHorizontal:c,sideOrientation:f});let b=[],I=[],T=[],x=[];const y=[],R=[],E=[],C=[];let S=0,w=0;for(let M=0;M<6;M++){const V=g[M].positions.length;R[M]=[],E[M]=[];for(let q=0;q<V/3;q++)R[M].push(new v(g[M].positions[3*q],g[M].positions[3*q+1],g[M].positions[3*q+2])),E[M].push(new v(g[M].normals[3*q],g[M].normals[3*q+1],g[M].normals[3*q+2]));S=g[M].uvs.length,C[M]=[];for(let q=0;q<S;q+=2)C[M][q]=t[M].x+(t[M].z-t[M].x)*g[M].uvs[q],C[M][q+1]=t[M].y+(t[M].w-t[M].y)*g[M].uvs[q+1];if(T=T.concat(C[M]),x=x.concat(g[M].indices.map(q=>q+w)),w+=R[M].length,i)for(let q=0;q<4;q++)y.push(i[M].r,i[M].g,i[M].b,i[M].a)}const P=new v(0,0,p),G=O.RotationY(Math.PI);b=R[0].map(M=>v.TransformNormal(M,G).add(P)).map(M=>[M.x,M.y,M.z]).reduce((M,V)=>M.concat(V),[]),I=E[0].map(M=>v.TransformNormal(M,G)).map(M=>[M.x,M.y,M.z]).reduce((M,V)=>M.concat(V),[]),b=b.concat(R[1].map(M=>M.subtract(P)).map(M=>[M.x,M.y,M.z]).reduce((M,V)=>M.concat(V),[])),I=I.concat(E[1].map(M=>[M.x,M.y,M.z]).reduce((M,V)=>M.concat(V),[]));const L=new v(d,0,0),W=O.RotationY(-Math.PI/2);b=b.concat(R[2].map(M=>v.TransformNormal(M,W).add(L)).map(M=>[M.x,M.y,M.z]).reduce((M,V)=>M.concat(V),[])),I=I.concat(E[2].map(M=>v.TransformNormal(M,W)).map(M=>[M.x,M.y,M.z]).reduce((M,V)=>M.concat(V),[]));const K=O.RotationY(Math.PI/2);b=b.concat(R[3].map(M=>v.TransformNormal(M,K).subtract(L)).map(M=>[M.x,M.y,M.z]).reduce((M,V)=>M.concat(V),[])),I=I.concat(E[3].map(M=>v.TransformNormal(M,K)).map(M=>[M.x,M.y,M.z]).reduce((M,V)=>M.concat(V),[]));const ce=new v(0,_,0),$=O.RotationX(Math.PI/2);b=b.concat(R[4].map(M=>v.TransformNormal(M,$).add(ce)).map(M=>[M.x,M.y,M.z]).reduce((M,V)=>M.concat(V),[])),I=I.concat(E[4].map(M=>v.TransformNormal(M,$)).map(M=>[M.x,M.y,M.z]).reduce((M,V)=>M.concat(V),[]));const z=O.RotationX(-Math.PI/2);b=b.concat(R[5].map(M=>v.TransformNormal(M,z).subtract(ce)).map(M=>[M.x,M.y,M.z]).reduce((M,V)=>M.concat(V),[])),I=I.concat(E[5].map(M=>v.TransformNormal(M,z)).map(M=>[M.x,M.y,M.z]).reduce((M,V)=>M.concat(V),[])),j._ComputeSides(f,b,x,I,T);const k=new j;if(k.indices=x,k.positions=b,k.normals=I,k.uvs=T,i){const M=f===j.DOUBLESIDE?y.concat(y):y;k.colors=M}return k}function Mv(a,e,t=null){const i=new F(a,t);return e.sideOrientation=F._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,Lu(e).applyToMesh(i,e.updatable),i}j.CreateTiledBox=Lu;function Nu(a){const e=(a.segments||32)|0,t=a.diameterX||a.diameter||1,i=a.diameterY||a.diameter||1,s=a.diameterZ||a.diameter||1,n=a.arc&&(a.arc<=0||a.arc>1)?1:a.arc||1,r=a.slice&&a.slice<=0?1:a.slice||1,o=a.sideOrientation===0?0:a.sideOrientation||j.DEFAULTSIDE,h=!!a.dedupTopBottomIndices,l=new v(t/2,i/2,s/2),c=2+e,u=2*c,f=[],d=[],_=[],p=[];for(let m=0;m<=c;m++){const b=m/c,I=b*Math.PI*r;for(let T=0;T<=u;T++){const x=T/u,y=x*Math.PI*2*n,R=O.RotationZ(-I),E=O.RotationY(y),C=v.TransformCoordinates(v.Up(),R),S=v.TransformCoordinates(C,E),w=S.multiply(l),P=S.divide(l).normalize();d.push(w.x,w.y,w.z),_.push(P.x,P.y,P.z),p.push(x,b)}if(m>0){const T=d.length/3;for(let x=T-2*(u+1);x+u+2<T;x++)h?(m>1&&(f.push(x),f.push(x+1),f.push(x+u+1)),(m<c||r<1)&&(f.push(x+u+1),f.push(x+1),f.push(x+u+2))):(f.push(x),f.push(x+1),f.push(x+u+1),f.push(x+u+1),f.push(x+1),f.push(x+u+2))}}j._ComputeSides(o,d,f,_,p,a.frontUVs,a.backUVs);const g=new j;return g.indices=f,g.positions=d,g.normals=_,g.uvs=p,g}function Uu(a,e={},t=null){const i=new F(a,t);return e.sideOrientation=F._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,Nu(e).applyToMesh(i,e.updatable),i}j.CreateSphere=Nu;F.CreateSphere=(a,e,t,i,s,n)=>Uu(a,{segments:e,diameterX:t,diameterY:t,diameterZ:t,sideOrientation:n,updatable:s},i);function ku(a){const e=a.height||2;let t=a.diameterTop===0?0:a.diameterTop||a.diameter||1,i=a.diameterBottom===0?0:a.diameterBottom||a.diameter||1;t=t||1e-5,i=i||1e-5;const s=(a.tessellation||24)|0,n=(a.subdivisions||1)|0,r=!!a.hasRings,o=!!a.enclose,h=a.cap===0?0:a.cap||F.CAP_ALL,l=a.arc&&(a.arc<=0||a.arc>1)?1:a.arc||1,c=a.sideOrientation===0?0:a.sideOrientation||j.DEFAULTSIDE,u=a.faceUV||new Array(3),f=a.faceColors,d=l!==1&&o?2:0,_=r?n:1,p=2+(1+d)*_;let g;for(g=0;g<p;g++)f&&f[g]===void 0&&(f[g]=new H(1,1,1,1));for(g=0;g<p;g++)u&&u[g]===void 0&&(u[g]=new Pe(0,0,1,1));const m=[],b=[],I=[],T=[],x=[],y=Math.PI*2*l/s;let R,E,C;const S=(i-t)/2/e,w=v.Zero(),P=v.Zero(),G=v.Zero(),L=v.Zero(),W=v.Zero(),K=Gt.Y;let ce,$,z,k=1,M=1,V=0,q=0;for(ce=0;ce<=n;ce++)for(E=ce/n,C=(E*(t-i)+i)/2,k=r&&ce!==0&&ce!==n?2:1,z=0;z<k;z++){for(r&&(M+=z),o&&(M+=2*z),$=0;$<=s;$++)R=$*y,w.x=Math.cos(-R)*C,w.y=-e/2+E*e,w.z=Math.sin(-R)*C,t===0&&ce===n?(P.x=I[I.length-(s+1)*3],P.y=I[I.length-(s+1)*3+1],P.z=I[I.length-(s+1)*3+2]):(P.x=w.x,P.z=w.z,P.y=Math.sqrt(P.x*P.x+P.z*P.z)*S,P.normalize()),$===0&&(G.copyFrom(w),L.copyFrom(P)),b.push(w.x,w.y,w.z),I.push(P.x,P.y,P.z),r?q=V!==M?u[M].y:u[M].w:q=u[M].y+(u[M].w-u[M].y)*E,T.push(u[M].x+(u[M].z-u[M].x)*$/s,q),f&&x.push(f[M].r,f[M].g,f[M].b,f[M].a);l!==1&&o&&(b.push(w.x,w.y,w.z),b.push(0,w.y,0),b.push(0,w.y,0),b.push(G.x,G.y,G.z),v.CrossToRef(K,P,W),W.normalize(),I.push(W.x,W.y,W.z,W.x,W.y,W.z),v.CrossToRef(L,K,W),W.normalize(),I.push(W.x,W.y,W.z,W.x,W.y,W.z),r?q=V!==M?u[M+1].y:u[M+1].w:q=u[M+1].y+(u[M+1].w-u[M+1].y)*E,T.push(u[M+1].x,q),T.push(u[M+1].z,q),r?q=V!==M?u[M+2].y:u[M+2].w:q=u[M+2].y+(u[M+2].w-u[M+2].y)*E,T.push(u[M+2].x,q),T.push(u[M+2].z,q),f&&(x.push(f[M+1].r,f[M+1].g,f[M+1].b,f[M+1].a),x.push(f[M+1].r,f[M+1].g,f[M+1].b,f[M+1].a),x.push(f[M+2].r,f[M+2].g,f[M+2].b,f[M+2].a),x.push(f[M+2].r,f[M+2].g,f[M+2].b,f[M+2].a))),V!==M&&(V=M)}const he=l!==1&&o?s+4:s;for(ce=0,M=0;M<n;M++){let ue=0,me=0,ne=0,Ie=0;for($=0;$<s;$++)ue=ce*(he+1)+$,me=(ce+1)*(he+1)+$,ne=ce*(he+1)+($+1),Ie=(ce+1)*(he+1)+($+1),m.push(ue,me,ne),m.push(Ie,ne,me);l!==1&&o&&(m.push(ue+2,me+2,ne+2),m.push(Ie+2,ne+2,me+2),m.push(ue+4,me+4,ne+4),m.push(Ie+4,ne+4,me+4)),ce=r?ce+2:ce+1}const pe=ue=>{const me=ue?t/2:i/2;if(me===0)return;let ne,Ie,Se;const Q=ue?u[p-1]:u[0];let be=null;f&&(be=ue?f[p-1]:f[0]);const Be=b.length/3,ze=ue?e/2:-e/2,Ke=new v(0,ze,0);b.push(Ke.x,Ke.y,Ke.z),I.push(0,ue?1:-1,0);const Rt=Q.y+(Q.w-Q.y)*.5;T.push(Q.x+(Q.z-Q.x)*.5,Rt),be&&x.push(be.r,be.g,be.b,be.a);const Ct=new oe(.5,.5);for(Se=0;Se<=s;Se++){ne=Math.PI*2*Se*l/s;const Ge=Math.cos(-ne),Jt=Math.sin(-ne);Ie=new v(Ge*me,ze,Jt*me);const Wt=new oe(Ge*Ct.x+.5,Jt*Ct.y+.5);b.push(Ie.x,Ie.y,Ie.z),I.push(0,ue?1:-1,0);const ji=Q.y+(Q.w-Q.y)*Wt.y;T.push(Q.x+(Q.z-Q.x)*Wt.x,ji),be&&x.push(be.r,be.g,be.b,be.a)}for(Se=0;Se<s;Se++)ue?(m.push(Be),m.push(Be+(Se+2)),m.push(Be+(Se+1))):(m.push(Be),m.push(Be+(Se+1)),m.push(Be+(Se+2)))};(h===F.CAP_START||h===F.CAP_ALL)&&pe(!1),(h===F.CAP_END||h===F.CAP_ALL)&&pe(!0),j._ComputeSides(c,b,m,I,T,a.frontUVs,a.backUVs);const se=new j;return se.indices=m,se.positions=b,se.normals=I,se.uvs=T,f&&(se.colors=x),se}function Vu(a,e={},t){const i=new F(a,t);return e.sideOrientation=F._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,ku(e).applyToMesh(i,e.updatable),i}j.CreateCylinder=ku;F.CreateCylinder=(a,e,t,i,s,n,r,o,h)=>((r===void 0||!(r instanceof it))&&(r!==void 0&&(h=o||F.DEFAULTSIDE,o=r),r=n,n=1),Vu(a,{height:e,diameterTop:t,diameterBottom:i,tessellation:s,subdivisions:n,sideOrientation:h,updatable:o},r));function Gu(a){const e=[],t=[],i=[],s=[],n=a.diameter||1,r=a.thickness||.5,o=(a.tessellation||16)|0,h=a.sideOrientation===0?0:a.sideOrientation||j.DEFAULTSIDE,l=o+1;for(let u=0;u<=o;u++){const f=u/o,d=u*Math.PI*2/o-Math.PI/2,_=O.Translation(n/2,0,0).multiply(O.RotationY(d));for(let p=0;p<=o;p++){const g=1-p/o,m=p*Math.PI*2/o+Math.PI,b=Math.cos(m),I=Math.sin(m);let T=new v(b,I,0),x=T.scale(r/2);const y=new oe(f,g);x=v.TransformCoordinates(x,_),T=v.TransformNormal(T,_),t.push(x.x,x.y,x.z),i.push(T.x,T.y,T.z),s.push(y.x,y.y);const R=(u+1)%l,E=(p+1)%l;e.push(u*l+p),e.push(u*l+E),e.push(R*l+p),e.push(u*l+E),e.push(R*l+E),e.push(R*l+p)}}j._ComputeSides(h,t,e,i,s,a.frontUVs,a.backUVs);const c=new j;return c.indices=e,c.positions=t,c.normals=i,c.uvs=s,c}function zu(a,e={},t){const i=new F(a,t);return e.sideOrientation=F._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,Gu(e).applyToMesh(i,e.updatable),i}j.CreateTorus=Gu;F.CreateTorus=(a,e,t,i,s,n,r)=>zu(a,{diameter:e,thickness:t,tessellation:i,sideOrientation:r,updatable:n},s);function Wu(a){const e=[],t=[],i=[],s=[],n=a.radius||2,r=a.tube||.5,o=a.radialSegments||32,h=a.tubularSegments||32,l=a.p||2,c=a.q||3,u=a.sideOrientation===0?0:a.sideOrientation||j.DEFAULTSIDE,f=g=>{const m=Math.cos(g),b=Math.sin(g),I=c/l*g,T=Math.cos(I),x=n*(2+T)*.5*m,y=n*(2+T)*b*.5,R=n*Math.sin(I)*.5;return new v(x,y,R)};let d,_;for(d=0;d<=o;d++){const m=d%o/o*2*l*Math.PI,b=f(m),I=f(m+.01),T=I.subtract(b);let x=I.add(b);const y=v.Cross(T,x);for(x=v.Cross(y,T),y.normalize(),x.normalize(),_=0;_<h;_++){const E=_%h/h*2*Math.PI,C=-r*Math.cos(E),S=r*Math.sin(E);t.push(b.x+C*x.x+S*y.x),t.push(b.y+C*x.y+S*y.y),t.push(b.z+C*x.z+S*y.z),s.push(d/o),s.push(_/h)}}for(d=0;d<o;d++)for(_=0;_<h;_++){const g=(_+1)%h,m=d*h+_,b=(d+1)*h+_,I=(d+1)*h+g,T=d*h+g;e.push(T),e.push(b),e.push(m),e.push(T),e.push(I),e.push(b)}j.ComputeNormals(t,e,i),j._ComputeSides(u,t,e,i,s,a.frontUVs,a.backUVs);const p=new j;return p.indices=e,p.positions=t,p.normals=i,p.uvs=s,p}function Hu(a,e={},t){const i=new F(a,t);return e.sideOrientation=F._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,Wu(e).applyToMesh(i,e.updatable),i}j.CreateTorusKnot=Wu;F.CreateTorusKnot=(a,e,t,i,s,n,r,o,h,l)=>Hu(a,{radius:e,tube:t,radialSegments:i,tubularSegments:s,p:n,q:r,sideOrientation:l,updatable:h},o);function Ku(a){const e=[],t=[],i=a.lines,s=a.colors,n=[];let r=0;for(let h=0;h<i.length;h++){const l=i[h];for(let c=0;c<l.length;c++){const{x:u,y:f,z:d}=l[c];if(t.push(u,f,d),s){const _=s[h],{r:p,g,b:m,a:b}=_[c];n.push(p,g,m,b)}c>0&&(e.push(r-1),e.push(r)),r++}}const o=new j;return o.indices=e,o.positions=t,s&&(o.colors=n),o}function Xu(a){const e=a.dashSize||3,t=a.gapSize||1,i=a.dashNb||200,s=a.points,n=[],r=[],o=v.Zero();let h=0,l=0,c=0,u=0,f=0,d=0,_=0;for(_=0;_<s.length-1;_++)s[_+1].subtractToRef(s[_],o),h+=o.length();for(c=h/i,u=e*c/(e+t),_=0;_<s.length-1;_++){s[_+1].subtractToRef(s[_],o),l=Math.floor(o.length()/c),o.normalize();for(let g=0;g<l;g++)f=c*g,n.push(s[_].x+f*o.x,s[_].y+f*o.y,s[_].z+f*o.z),n.push(s[_].x+(f+u)*o.x,s[_].y+(f+u)*o.y,s[_].z+(f+u)*o.z),r.push(d,d+1),d+=2}const p=new j;return p.positions=n,p.indices=r,p}function Yu(a,e,t=null){const i=e.instance,s=e.lines,n=e.colors;if(i){const l=i.getVerticesData(A.PositionKind);let c,u;n&&(c=i.getVerticesData(A.ColorKind));let f=0,d=0;for(let _=0;_<s.length;_++){const p=s[_];for(let g=0;g<p.length;g++)l[f]=p[g].x,l[f+1]=p[g].y,l[f+2]=p[g].z,n&&c&&(u=n[_],c[d]=u[g].r,c[d+1]=u[g].g,c[d+2]=u[g].b,c[d+3]=u[g].a,d+=4),f+=3}return i.updateVerticesData(A.PositionKind,l,!1,!1),n&&c&&i.updateVerticesData(A.ColorKind,c,!1,!1),i.refreshBoundingInfo(),i}const r=!!n,o=new Hi(a,t,null,void 0,void 0,r,e.useVertexAlpha,e.material);return Ku(e).applyToMesh(o,e.updatable),o}function qu(a,e,t=null){const i=e.colors?[e.colors]:null;return Yu(a,{lines:[e.points],updatable:e.updatable,instance:e.instance,colors:i,useVertexAlpha:e.useVertexAlpha,material:e.material},t)}function ju(a,e,t=null){const i=e.points,s=e.instance,n=e.gapSize||1,r=e.dashSize||3;if(s){const l=c=>{const u=v.Zero(),f=c.length/6;let d=0,_=0,p=0,g=0,m=0,b=0,I=0,T=0;for(I=0;I<i.length-1;I++)i[I+1].subtractToRef(i[I],u),d+=u.length();p=d/f;const x=s._creationDataStorage.dashSize,y=s._creationDataStorage.gapSize;for(g=x*p/(x+y),I=0;I<i.length-1;I++)for(i[I+1].subtractToRef(i[I],u),_=Math.floor(u.length()/p),u.normalize(),T=0;T<_&&b<c.length;)m=p*T,c[b]=i[I].x+m*u.x,c[b+1]=i[I].y+m*u.y,c[b+2]=i[I].z+m*u.z,c[b+3]=i[I].x+(m+g)*u.x,c[b+4]=i[I].y+(m+g)*u.y,c[b+5]=i[I].z+(m+g)*u.z,b+=6,T++;for(;b<c.length;)c[b]=i[I].x,c[b+1]=i[I].y,c[b+2]=i[I].z,b+=3};return(e.dashNb||e.dashSize||e.gapSize||e.useVertexAlpha||e.material)&&U.Warn("You have used an option other than points with the instance option. Please be aware that these other options will be ignored."),s.updateMeshPositions(l,!1),s}const o=new Hi(a,t,null,void 0,void 0,void 0,e.useVertexAlpha,e.material);return Xu(e).applyToMesh(o,e.updatable),o._creationDataStorage=new Uc,o._creationDataStorage.dashSize=r,o._creationDataStorage.gapSize=n,o}j.CreateLineSystem=Ku;j.CreateDashedLines=Xu;F.CreateLines=(a,e,t=null,i=!1,s=null)=>qu(a,{points:e,updatable:i,instance:s},t);F.CreateDashedLines=(a,e,t,i,s,n=null,r,o)=>ju(a,{points:e,dashSize:t,gapSize:i,dashNb:s,updatable:r,instance:o},n);class Pv extends oe{constructor(e,t){super(e.x,e.y),this.index=t}}class Sa{constructor(){this.elements=[]}add(e){const t=[];return e.forEach(i=>{const s=new Pv(i,this.elements.length);t.push(s),this.elements.push(s)}),t}computeBounds(){const e=new oe(this.elements[0].x,this.elements[0].y),t=new oe(this.elements[0].x,this.elements[0].y);return this.elements.forEach(i=>{i.x<e.x?e.x=i.x:i.x>t.x&&(t.x=i.x),i.y<e.y?e.y=i.y:i.y>t.y&&(t.y=i.y)}),{min:e,max:t,width:t.x-e.x,height:t.y-e.y}}}class wv{_addToepoint(e){for(const t of e)this._epoints.push(t.x,t.y)}constructor(e,t,i,s=earcut){this._points=new Sa,this._outlinepoints=new Sa,this._holes=new Array,this._epoints=new Array,this._eholes=new Array,this.bjsEarcut=s,this._name=e,this._scene=i||Ee.LastCreatedScene;let n;t instanceof Gr?n=t.getPoints():n=t,this._addToepoint(n),this._points.add(n),this._outlinepoints.add(n),typeof this.bjsEarcut>"u"&&U.Warn("Earcut was not found, the polygon will not be built.")}addHole(e){this._points.add(e);const t=new Sa;return t.add(e),this._holes.push(t),this._eholes.push(this._epoints.length/2),this._addToepoint(e),this}build(e=!1,t=0,i=2){const s=new F(this._name,this._scene),n=this.buildVertexData(t,i);return s.setVerticesData(A.PositionKind,n.positions,e),s.setVerticesData(A.NormalKind,n.normals,e),s.setVerticesData(A.UVKind,n.uvs,e),s.setIndices(n.indices),s}buildVertexData(e=0,t=2){const i=new j,s=[],n=[],r=[],o=this._points.computeBounds();this._points.elements.forEach(c=>{s.push(0,1,0),n.push(c.x,0,c.y),r.push((c.x-o.min.x)/o.width,(c.y-o.min.y)/o.height)});const h=[],l=this.bjsEarcut(this._epoints,this._eholes,2);for(let c=0;c<l.length;c++)h.push(l[c]);if(e>0){const c=n.length/3;this._points.elements.forEach(f=>{s.push(0,-1,0),n.push(f.x,-e,f.y),r.push(1-(f.x-o.min.x)/o.width,1-(f.y-o.min.y)/o.height)});const u=h.length;for(let f=0;f<u;f+=3){const d=h[f+0],_=h[f+1],p=h[f+2];h.push(p+c),h.push(_+c),h.push(d+c)}this._addSide(n,s,r,h,o,this._outlinepoints,e,!1,t),this._holes.forEach(f=>{this._addSide(n,s,r,h,o,f,e,!0,t)})}return i.indices=h,i.positions=n,i.normals=s,i.uvs=r,i}_addSide(e,t,i,s,n,r,o,h,l){let c=e.length/3,u=0;for(let f=0;f<r.elements.length;f++){const d=r.elements[f],_=r.elements[(f+1)%r.elements.length];e.push(d.x,0,d.y),e.push(d.x,-o,d.y),e.push(_.x,0,_.y),e.push(_.x,-o,_.y);const p=r.elements[(f+r.elements.length-1)%r.elements.length],g=r.elements[(f+2)%r.elements.length];let m=new v(-(_.y-d.y),0,_.x-d.x),b=new v(-(d.y-p.y),0,d.x-p.x),I=new v(-(g.y-_.y),0,g.x-_.x);h||(m=m.scale(-1),b=b.scale(-1),I=I.scale(-1));const T=m.normalizeToNew();let x=b.normalizeToNew(),y=I.normalizeToNew();const R=v.Dot(x,T);R>l?R<Le-1?x=new v(d.x,0,d.y).subtract(new v(_.x,0,_.y)).normalize():x=b.add(m).normalize():x=T;const E=v.Dot(I,m);E>l?E<Le-1?y=new v(_.x,0,_.y).subtract(new v(d.x,0,d.y)).normalize():y=I.add(m).normalize():y=T,i.push(u/n.width,0),i.push(u/n.width,1),u+=m.length(),i.push(u/n.width,0),i.push(u/n.width,1),t.push(x.x,x.y,x.z),t.push(x.x,x.y,x.z),t.push(y.x,y.y,y.z),t.push(y.x,y.y,y.z),h?(s.push(c),s.push(c+2),s.push(c+1),s.push(c+1),s.push(c+2),s.push(c+3)):(s.push(c),s.push(c+1),s.push(c+2),s.push(c+1),s.push(c+3),s.push(c+2)),c+=4}}}function $u(a,e,t,i,s,n,r){const o=t||new Array(3),h=i,l=[],c=r||!1;for(let C=0;C<3;C++)o[C]===void 0&&(o[C]=new Pe(0,0,1,1)),h&&h[C]===void 0&&(h[C]=new H(1,1,1,1));const u=a.getVerticesData(A.PositionKind),f=a.getVerticesData(A.NormalKind),d=a.getVerticesData(A.UVKind),_=a.getIndices(),p=u.length/9;let g=0,m=0,b=0,I=0,T=0;const x=[0];if(c)for(let C=p;C<u.length/3;C+=4)m=u[3*(C+2)]-u[3*C],b=u[3*(C+2)+2]-u[3*C+2],I=Math.sqrt(m*m+b*b),T+=I,x.push(T);let y=0,R=0;for(let C=0;C<f.length;C+=3)Math.abs(f[C+1])<.001&&(R=1),Math.abs(f[C+1]-1)<.001&&(R=0),Math.abs(f[C+1]+1)<.001&&(R=2),y=C/3,R===1?(g=y-p,g%4<1.5?c?d[2*y]=o[R].x+(o[R].z-o[R].x)*x[Math.floor(g/4)]/T:d[2*y]=o[R].x:c?d[2*y]=o[R].x+(o[R].z-o[R].x)*x[Math.floor(g/4)+1]/T:d[2*y]=o[R].z,g%2===0?d[2*y+1]=o[R].w:d[2*y+1]=o[R].y):(d[2*y]=(1-d[2*y])*o[R].x+d[2*y]*o[R].z,d[2*y+1]=(1-d[2*y+1])*o[R].y+d[2*y+1]*o[R].w),h&&l.push(h[R].r,h[R].g,h[R].b,h[R].a);j._ComputeSides(e,u,_,f,d,s,n);const E=new j;if(E.indices=_,E.positions=u,E.normals=f,E.uvs=d,h){const C=e===j.DOUBLESIDE?l.concat(l):l;E.colors=C}return E}function no(a,e,t=null,i=earcut){e.sideOrientation=F._GetDefaultSideOrientation(e.sideOrientation);const s=e.shape,n=e.holes||[],r=e.depth||0,o=e.smoothingThreshold||2,h=[];let l=[];for(let _=0;_<s.length;_++)h[_]=new oe(s[_].x,s[_].z);h[0].equalsWithEpsilon(h[h.length-1],1e-8)&&h.pop();const u=new wv(a,h,t||Ee.LastCreatedScene,i);for(let _=0;_<n.length;_++){l=[];for(let p=0;p<n[_].length;p++)l.push(new oe(n[_][p].x,n[_][p].z));u.addHole(l)}const f=u.build(!1,r,o);return f._originalBuilderSideOrientation=e.sideOrientation,$u(f,e.sideOrientation,e.faceUV,e.faceColors,e.frontUVs,e.backUVs,e.wrap).applyToMesh(f,e.updatable),f}function ro(a,e,t=null,i=earcut){return no(a,e,t,i)}j.CreatePolygon=$u;F.CreatePolygon=(a,e,t,i,s,n,r=earcut)=>no(a,{shape:e,holes:i,updatable:s,sideOrientation:n},t,r);F.ExtrudePolygon=(a,e,t,i,s,n,r,o=earcut)=>ro(a,{shape:e,holes:s,depth:t,updatable:n,sideOrientation:r},i,o);function Zu(a,e,t=null){const i=e.path,s=e.shape,n=e.scale||1,r=e.rotation||0,o=e.cap===0?0:e.cap||F.NO_CAP,h=e.updatable,l=F._GetDefaultSideOrientation(e.sideOrientation),c=e.instance||null,u=e.invertUV||!1,f=e.closeShape||!1,d=e.closePath||!1;return Ju(a,s,i,n,r,null,null,d,f,o,!1,t,!!h,l,c,u,e.frontUVs||null,e.backUVs||null,e.firstNormal||null,!!e.adjustFrame)}function Qu(a,e,t=null){const i=e.path,s=e.shape,n=e.scaleFunction||(()=>1),r=e.rotationFunction||(()=>0),o=e.closePath||e.ribbonCloseArray||!1,h=e.closeShape||e.ribbonClosePath||!1,l=e.cap===0?0:e.cap||F.NO_CAP,c=e.updatable,u=e.firstNormal||null,f=e.adjustFrame||!1,d=F._GetDefaultSideOrientation(e.sideOrientation),_=e.instance,p=e.invertUV||!1;return Ju(a,s,i,null,null,n,r,o,h,l,!0,t,!!c,d,_||null,p,e.frontUVs||null,e.backUVs||null,u,f)}function Ju(a,e,t,i,s,n,r,o,h,l,c,u,f,d,_,p,g,m,b,I){const T=(C,S,w,P,G,L,W,K,ce,$,z)=>{const k=w.getTangents(),M=w.getNormals(),V=w.getBinormals(),q=w.getDistances();if(z){for(let Q=0;Q<k.length;Q++)if(k[Q].x==0&&k[Q].y==0&&k[Q].z==0&&k[Q].copyFrom(k[Q-1]),M[Q].x==0&&M[Q].y==0&&M[Q].z==0&&M[Q].copyFrom(M[Q-1]),V[Q].x==0&&V[Q].y==0&&V[Q].z==0&&V[Q].copyFrom(V[Q-1]),Q>0){let be=k[Q-1];v.Dot(be,k[Q])<0&&k[Q].scaleInPlace(-1),be=M[Q-1],v.Dot(be,M[Q])<0&&M[Q].scaleInPlace(-1),be=V[Q-1],v.Dot(be,V[Q])<0&&V[Q].scaleInPlace(-1)}}let he=0;const pe=()=>G!==null?G:1,ue=$&&K?K:()=>L!==null?L:0,me=$&&W?W:pe;let ne=ce===F.NO_CAP||ce===F.CAP_END?0:2;const Ie=N.Matrix[0];for(let Q=0;Q<S.length;Q++){const be=[],Be=ue(Q,q[Q]),ze=me(Q,q[Q]);O.RotationAxisToRef(k[Q],he,Ie);for(let Ke=0;Ke<C.length;Ke++){const Rt=k[Q].scale(C[Ke].z).add(M[Q].scale(C[Ke].x)).add(V[Q].scale(C[Ke].y)),Ct=v.Zero();v.TransformCoordinatesToRef(Rt,Ie,Ct),Ct.scaleInPlace(ze).addInPlace(S[Q]),be[Ke]=Ct}P[ne]=be,he+=Be,ne++}const Se=Q=>{const be=Array(),Be=v.Zero();let ze;for(ze=0;ze<Q.length;ze++)Be.addInPlace(Q[ze]);for(Be.scaleInPlace(1/Q.length),ze=0;ze<Q.length;ze++)be.push(Be);return be};switch(ce){case F.NO_CAP:break;case F.CAP_START:P[0]=Se(P[2]),P[1]=P[2];break;case F.CAP_END:P[ne]=P[ne-1],P[ne+1]=Se(P[ne-1]);break;case F.CAP_ALL:P[0]=Se(P[2]),P[1]=P[2],P[ne]=P[ne-1],P[ne+1]=Se(P[ne-1]);break}return P};let x,y;if(_){const C=_._creationDataStorage;return x=b?C.path3D.update(t,b):C.path3D.update(t),y=T(e,t,C.path3D,C.pathArray,i,s,n,r,C.cap,c,I),_=zs("",{pathArray:y,closeArray:!1,closePath:!1,offset:0,updatable:!1,sideOrientation:0,instance:_},u||void 0),_}x=b?new Fn(t,b):new Fn(t);const R=new Array;l=l<0||l>3?0:l,y=T(e,t,x,R,i,s,n,r,l,c,I);const E=zs(a,{pathArray:y,closeArray:o,closePath:h,updatable:f,sideOrientation:d,invertUV:p,frontUVs:g||void 0,backUVs:m||void 0},u);return E._creationDataStorage.pathArray=y,E._creationDataStorage.path3D=x,E._creationDataStorage.cap=l,E}F.ExtrudeShape=(a,e,t,i,s,n,r=null,o,h,l)=>{const c={shape:e,path:t,scale:i,rotation:s,cap:n===0?0:n||F.NO_CAP,sideOrientation:h,instance:l,updatable:o};return Zu(a,c,r)};F.ExtrudeShapeCustom=(a,e,t,i,s,n,r,o,h,l,c,u)=>{const f={shape:e,path:t,scaleFunction:i,rotationFunction:s,ribbonCloseArray:n,ribbonClosePath:r,cap:o===0?0:o||F.NO_CAP,sideOrientation:c,instance:u,updatable:l};return Qu(a,f,h)};function ef(a,e,t=null){const i=e.arc?e.arc<=0||e.arc>1?1:e.arc:1,s=e.closed===void 0?!0:e.closed,n=e.shape,r=e.radius||1,o=e.tessellation||64,h=e.clip||0,l=e.updatable,c=F._GetDefaultSideOrientation(e.sideOrientation),u=e.cap||F.NO_CAP,f=Math.PI*2,d=[],_=e.invertUV||!1;let p=0,g=0;const m=f/o*i;let b,I;for(p=0;p<=o-h;p++){for(I=[],(u==F.CAP_START||u==F.CAP_ALL)&&(I.push(new v(0,n[0].y,0)),I.push(new v(Math.cos(p*m)*n[0].x*r,n[0].y,Math.sin(p*m)*n[0].x*r))),g=0;g<n.length;g++)b=new v(Math.cos(p*m)*n[g].x*r,n[g].y,Math.sin(p*m)*n[g].x*r),I.push(b);(u==F.CAP_END||u==F.CAP_ALL)&&(I.push(new v(Math.cos(p*m)*n[n.length-1].x*r,n[n.length-1].y,Math.sin(p*m)*n[n.length-1].x*r)),I.push(new v(0,n[n.length-1].y,0))),d.push(I)}return zs(a,{pathArray:d,closeArray:s,sideOrientation:c,updatable:l,invertUV:_,frontUVs:e.frontUVs,backUVs:e.backUVs},t)}F.CreateLathe=(a,e,t,i,s,n,r)=>ef(a,{shape:e,radius:t,tessellation:i,sideOrientation:r,updatable:n},s);function tf(a){const e=[],t=[],i=[],s=[],n=a.width||a.size||1,r=a.height||a.size||1,o=a.sideOrientation===0?0:a.sideOrientation||j.DEFAULTSIDE,h=n/2,l=r/2;t.push(-h,-l,0),i.push(0,0,-1),s.push(0,0),t.push(h,-l,0),i.push(0,0,-1),s.push(1,0),t.push(h,l,0),i.push(0,0,-1),s.push(1,1),t.push(-h,l,0),i.push(0,0,-1),s.push(0,1),e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),j._ComputeSides(o,t,e,i,s,a.frontUVs,a.backUVs);const c=new j;return c.indices=e,c.positions=t,c.normals=i,c.uvs=s,c}function sf(a,e={},t=null){const i=new F(a,t);return e.sideOrientation=F._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,tf(e).applyToMesh(i,e.updatable),e.sourcePlane&&(i.translate(e.sourcePlane.normal,-e.sourcePlane.d),i.setDirection(e.sourcePlane.normal.scale(-1))),i}j.CreatePlane=tf;F.CreatePlane=(a,e,t,i,s)=>sf(a,{size:e,width:e,height:e,sideOrientation:s,updatable:i},t);function nf(a,e,t=null){const i=e.path;let s=e.instance,n=1;e.radius!==void 0?n=e.radius:s&&(n=s._creationDataStorage.radius);const r=e.tessellation||64,o=e.radiusFunction||null;let h=e.cap||F.NO_CAP;const l=e.invertUV||!1,c=e.updatable,u=F._GetDefaultSideOrientation(e.sideOrientation);e.arc=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1;const f=(m,b,I,T,x,y,R,E)=>{const C=b.getTangents(),S=b.getNormals(),w=b.getDistances(),G=Math.PI*2/x*E,W=y||(()=>T);let K,ce,$,z;const k=N.Matrix[0];let M=R===F.NO_CAP||R===F.CAP_END?0:2;for(let q=0;q<m.length;q++){ce=W(q,w[q]),K=Array(),$=S[q];for(let he=0;he<x;he++)O.RotationAxisToRef(C[q],G*he,k),z=K[he]?K[he]:v.Zero(),v.TransformCoordinatesToRef($,k,z),z.scaleInPlace(ce).addInPlace(m[q]),K[he]=z;I[M]=K,M++}const V=(q,he)=>{const pe=Array();for(let se=0;se<q;se++)pe.push(m[he]);return pe};switch(R){case F.NO_CAP:break;case F.CAP_START:I[0]=V(x,0),I[1]=I[2].slice(0);break;case F.CAP_END:I[M]=I[M-1].slice(0),I[M+1]=V(x,m.length-1);break;case F.CAP_ALL:I[0]=V(x,0),I[1]=I[2].slice(0),I[M]=I[M-1].slice(0),I[M+1]=V(x,m.length-1);break}return I};let d,_;if(s){const m=s._creationDataStorage,b=e.arc||m.arc;return d=m.path3D.update(i),_=f(i,d,m.pathArray,n,m.tessellation,o,m.cap,b),s=zs("",{pathArray:_,instance:s}),m.path3D=d,m.pathArray=_,m.arc=b,m.radius=n,s}d=new Fn(i);const p=new Array;h=h<0||h>3?0:h,_=f(i,d,p,n,r,o,h,e.arc);const g=zs(a,{pathArray:_,closePath:!0,closeArray:!1,updatable:c,sideOrientation:u,invertUV:l,frontUVs:e.frontUVs,backUVs:e.backUVs},t);return g._creationDataStorage.pathArray=_,g._creationDataStorage.path3D=d,g._creationDataStorage.tessellation=r,g._creationDataStorage.cap=h,g._creationDataStorage.arc=e.arc,g._creationDataStorage.radius=n,g}F.CreateTube=(a,e,t,i,s,n,r,o,h,l)=>nf(a,{path:e,radius:t,tessellation:i,radiusFunction:s,arc:1,cap:n,updatable:o,sideOrientation:h,instance:l},r);function rf(a){const e=[];e[0]={vertex:[[0,0,1.732051],[1.632993,0,-.5773503],[-.8164966,1.414214,-.5773503],[-.8164966,-1.414214,-.5773503]],face:[[0,1,2],[0,2,3],[0,3,1],[1,3,2]]},e[1]={vertex:[[0,0,1.414214],[1.414214,0,0],[0,1.414214,0],[-1.414214,0,0],[0,-1.414214,0],[0,0,-1.414214]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,1],[1,4,5],[1,5,2],[2,5,3],[3,5,4]]},e[2]={vertex:[[0,0,1.070466],[.7136442,0,.7978784],[-.3568221,.618034,.7978784],[-.3568221,-.618034,.7978784],[.7978784,.618034,.3568221],[.7978784,-.618034,.3568221],[-.9341724,.381966,.3568221],[.1362939,1,.3568221],[.1362939,-1,.3568221],[-.9341724,-.381966,.3568221],[.9341724,.381966,-.3568221],[.9341724,-.381966,-.3568221],[-.7978784,.618034,-.3568221],[-.1362939,1,-.3568221],[-.1362939,-1,-.3568221],[-.7978784,-.618034,-.3568221],[.3568221,.618034,-.7978784],[.3568221,-.618034,-.7978784],[-.7136442,0,-.7978784],[0,0,-1.070466]],face:[[0,1,4,7,2],[0,2,6,9,3],[0,3,8,5,1],[1,5,11,10,4],[2,7,13,12,6],[3,9,15,14,8],[4,10,16,13,7],[5,8,14,17,11],[6,12,18,15,9],[10,11,17,19,16],[12,13,16,19,18],[14,15,18,19,17]]},e[3]={vertex:[[0,0,1.175571],[1.051462,0,.5257311],[.3249197,1,.5257311],[-.8506508,.618034,.5257311],[-.8506508,-.618034,.5257311],[.3249197,-1,.5257311],[.8506508,.618034,-.5257311],[.8506508,-.618034,-.5257311],[-.3249197,1,-.5257311],[-1.051462,0,-.5257311],[-.3249197,-1,-.5257311],[0,0,-1.175571]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,5],[0,5,1],[1,5,7],[1,7,6],[1,6,2],[2,6,8],[2,8,3],[3,8,9],[3,9,4],[4,9,10],[4,10,5],[5,10,7],[6,7,11],[6,11,8],[7,10,11],[8,11,9],[9,11,10]]},e[4]={vertex:[[0,0,1.070722],[.7148135,0,.7971752],[-.104682,.7071068,.7971752],[-.6841528,.2071068,.7971752],[-.104682,-.7071068,.7971752],[.6101315,.7071068,.5236279],[1.04156,.2071068,.1367736],[.6101315,-.7071068,.5236279],[-.3574067,1,.1367736],[-.7888348,-.5,.5236279],[-.9368776,.5,.1367736],[-.3574067,-1,.1367736],[.3574067,1,-.1367736],[.9368776,-.5,-.1367736],[.7888348,.5,-.5236279],[.3574067,-1,-.1367736],[-.6101315,.7071068,-.5236279],[-1.04156,-.2071068,-.1367736],[-.6101315,-.7071068,-.5236279],[.104682,.7071068,-.7971752],[.6841528,-.2071068,-.7971752],[.104682,-.7071068,-.7971752],[-.7148135,0,-.7971752],[0,0,-1.070722]],face:[[0,2,3],[1,6,5],[4,9,11],[7,15,13],[8,16,10],[12,14,19],[17,22,18],[20,21,23],[0,1,5,2],[0,3,9,4],[0,4,7,1],[1,7,13,6],[2,5,12,8],[2,8,10,3],[3,10,17,9],[4,11,15,7],[5,6,14,12],[6,13,20,14],[8,12,19,16],[9,17,18,11],[10,16,22,17],[11,18,21,15],[13,15,21,20],[14,20,23,19],[16,19,23,22],[18,22,23,21]]},e[5]={vertex:[[0,0,1.322876],[1.309307,0,.1889822],[-.9819805,.8660254,.1889822],[.1636634,-1.299038,.1889822],[.3273268,.8660254,-.9449112],[-.8183171,-.4330127,-.9449112]],face:[[0,3,1],[2,4,5],[0,1,4,2],[0,2,5,3],[1,3,5,4]]},e[6]={vertex:[[0,0,1.159953],[1.013464,0,.5642542],[-.3501431,.9510565,.5642542],[-.7715208,-.6571639,.5642542],[.6633206,.9510565,-.03144481],[.8682979,-.6571639,-.3996071],[-1.121664,.2938926,-.03144481],[-.2348831,-1.063314,-.3996071],[.5181548,.2938926,-.9953061],[-.5850262,-.112257,-.9953061]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,9,7],[5,7,9,8],[0,3,7,5,1],[2,4,8,9,6]]},e[7]={vertex:[[0,0,1.118034],[.8944272,0,.6708204],[-.2236068,.8660254,.6708204],[-.7826238,-.4330127,.6708204],[.6708204,.8660254,.2236068],[1.006231,-.4330127,-.2236068],[-1.006231,.4330127,.2236068],[-.6708204,-.8660254,-.2236068],[.7826238,.4330127,-.6708204],[.2236068,-.8660254,-.6708204],[-.8944272,0,-.6708204],[0,0,-1.118034]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,10,7],[5,9,11,8],[7,10,11,9],[0,3,7,9,5,1],[2,4,8,11,10,6]]},e[8]={vertex:[[-.729665,.670121,.319155],[-.655235,-.29213,-.754096],[-.093922,-.607123,.537818],[.702196,.595691,.485187],[.776626,-.36656,-.588064]],face:[[1,4,2],[0,1,2],[3,0,2],[4,3,2],[4,1,0,3]]},e[9]={vertex:[[-.868849,-.100041,.61257],[-.329458,.976099,.28078],[-.26629,-.013796,-.477654],[-.13392,-1.034115,.229829],[.738834,.707117,-.307018],[.859683,-.535264,-.338508]],face:[[3,0,2],[5,3,2],[4,5,2],[1,4,2],[0,1,2],[0,3,5,4,1]]},e[10]={vertex:[[-.610389,.243975,.531213],[-.187812,-.48795,-.664016],[-.187812,.9759,-.664016],[.187812,-.9759,.664016],[.798201,.243975,.132803]],face:[[1,3,0],[3,4,0],[3,1,4],[0,2,1],[0,4,2],[2,4,1]]},e[11]={vertex:[[-1.028778,.392027,-.048786],[-.640503,-.646161,.621837],[-.125162,-.395663,-.540059],[.004683,.888447,-.651988],[.125161,.395663,.540059],[.632925,-.791376,.433102],[1.031672,.157063,-.354165]],face:[[3,2,0],[2,1,0],[2,5,1],[0,4,3],[0,1,4],[4,1,5],[2,3,6],[3,4,6],[5,2,6],[4,5,6]]},e[12]={vertex:[[-.669867,.334933,-.529576],[-.669867,.334933,.529577],[-.4043,1.212901,0],[-.334933,-.669867,-.529576],[-.334933,-.669867,.529577],[.334933,.669867,-.529576],[.334933,.669867,.529577],[.4043,-1.212901,0],[.669867,-.334933,-.529576],[.669867,-.334933,.529577]],face:[[8,9,7],[6,5,2],[3,8,7],[5,0,2],[4,3,7],[0,1,2],[9,4,7],[1,6,2],[9,8,5,6],[8,3,0,5],[3,4,1,0],[4,9,6,1]]},e[13]={vertex:[[-.931836,.219976,-.264632],[-.636706,.318353,.692816],[-.613483,-.735083,-.264632],[-.326545,.979634,0],[-.318353,-.636706,.692816],[-.159176,.477529,-.856368],[.159176,-.477529,-.856368],[.318353,.636706,.692816],[.326545,-.979634,0],[.613482,.735082,-.264632],[.636706,-.318353,.692816],[.931835,-.219977,-.264632]],face:[[11,10,8],[7,9,3],[6,11,8],[9,5,3],[2,6,8],[5,0,3],[4,2,8],[0,1,3],[10,4,8],[1,7,3],[10,11,9,7],[11,6,5,9],[6,2,0,5],[2,4,1,0],[4,10,7,1]]},e[14]={vertex:[[-.93465,.300459,-.271185],[-.838689,-.260219,-.516017],[-.711319,.717591,.128359],[-.710334,-.156922,.080946],[-.599799,.556003,-.725148],[-.503838,-.004675,-.969981],[-.487004,.26021,.48049],[-.460089,-.750282,-.512622],[-.376468,.973135,-.325605],[-.331735,-.646985,.084342],[-.254001,.831847,.530001],[-.125239,-.494738,-.966586],[.029622,.027949,.730817],[.056536,-.982543,-.262295],[.08085,1.087391,.076037],[.125583,-.532729,.485984],[.262625,.599586,.780328],[.391387,-.726999,-.716259],[.513854,-.868287,.139347],[.597475,.85513,.326364],[.641224,.109523,.783723],[.737185,-.451155,.538891],[.848705,-.612742,-.314616],[.976075,.365067,.32976],[1.072036,-.19561,.084927]],face:[[15,18,21],[12,20,16],[6,10,2],[3,0,1],[9,7,13],[2,8,4,0],[0,4,5,1],[1,5,11,7],[7,11,17,13],[13,17,22,18],[18,22,24,21],[21,24,23,20],[20,23,19,16],[16,19,14,10],[10,14,8,2],[15,9,13,18],[12,15,21,20],[6,12,16,10],[3,6,2,0],[9,3,1,7],[9,15,12,6,3],[22,17,11,5,4,8,14,19,23,24]]};const t=a.type&&(a.type<0||a.type>=e.length)?0:a.type||0,i=a.size,s=a.sizeX||i||1,n=a.sizeY||i||1,r=a.sizeZ||i||1,o=a.custom||e[t],h=o.face.length,l=a.faceUV||new Array(h),c=a.faceColors,u=a.flat===void 0?!0:a.flat,f=a.sideOrientation===0?0:a.sideOrientation||j.DEFAULTSIDE,d=[],_=[],p=[],g=[],m=[];let b=0,I=0;const T=[];let x=0,y=0,R,E,C,S,w,P;if(u)for(y=0;y<h;y++)c&&c[y]===void 0&&(c[y]=new H(1,1,1,1)),l&&l[y]===void 0&&(l[y]=new Pe(0,0,1,1));if(u)for(y=0;y<h;y++){const L=o.face[y].length;for(C=2*Math.PI/L,S=.5*Math.tan(C/2),w=.5,x=0;x<L;x++)d.push(o.vertex[o.face[y][x]][0]*s,o.vertex[o.face[y][x]][1]*n,o.vertex[o.face[y][x]][2]*r),T.push(b),b++,R=l[y].x+(l[y].z-l[y].x)*(.5+S),E=l[y].y+(l[y].w-l[y].y)*(w-.5),g.push(R,E),P=S*Math.cos(C)-w*Math.sin(C),w=S*Math.sin(C)+w*Math.cos(C),S=P,c&&m.push(c[y].r,c[y].g,c[y].b,c[y].a);for(x=0;x<L-2;x++)_.push(T[0+I],T[x+2+I],T[x+1+I]);I+=L}else{for(x=0;x<o.vertex.length;x++)d.push(o.vertex[x][0]*s,o.vertex[x][1]*n,o.vertex[x][2]*r),g.push(0,0);for(y=0;y<h;y++)for(x=0;x<o.face[y].length-2;x++)_.push(o.face[y][0],o.face[y][x+2],o.face[y][x+1])}j.ComputeNormals(d,_,p),j._ComputeSides(f,d,_,p,g,a.frontUVs,a.backUVs);const G=new j;return G.positions=d,G.indices=_,G.normals=p,G.uvs=g,c&&u&&(G.colors=m),G}function ao(a,e={},t=null){const i=new F(a,t);return e.sideOrientation=F._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,rf(e).applyToMesh(i,e.updatable),i}j.CreatePolyhedron=rf;F.CreatePolyhedron=(a,e,t)=>ao(a,e,t);function af(a){const e=a.sideOrientation||j.DEFAULTSIDE,t=a.radius||1,i=a.flat===void 0?!0:a.flat,s=(a.subdivisions||4)|0,n=a.radiusX||t,r=a.radiusY||t,o=a.radiusZ||t,h=(1+Math.sqrt(5))/2,l=[-1,h,-0,1,h,0,-1,-h,0,1,-h,0,0,-1,-h,0,1,-h,0,-1,h,0,1,h,h,0,1,h,0,-1,-h,0,1,-h,0,-1],c=[0,11,5,0,5,1,0,1,7,0,7,10,12,22,23,1,5,20,5,11,4,23,22,13,22,18,6,7,1,8,14,21,4,14,4,2,16,13,6,15,6,19,3,8,9,4,21,5,13,17,23,6,13,22,19,6,18,9,8,1],u=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],f=[5,1,3,1,6,4,0,0,5,3,4,2,2,2,4,0,2,0,1,1,6,0,6,2,0,4,3,3,4,4,3,1,4,2,4,4,0,2,1,1,2,2,3,3,1,3,2,4],d=138/1024,_=239/1024,p=60/1024,g=26/1024,m=-40/1024,b=20/1024,I=[0,0,0,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0],T=[],x=[],y=[],R=[];let E=0;const C=new Array(3),S=new Array(3);let w;for(w=0;w<3;w++)C[w]=v.Zero(),S[w]=oe.Zero();for(let G=0;G<20;G++){for(w=0;w<3;w++){const W=c[3*G+w];C[w].copyFromFloats(l[3*u[W]],l[3*u[W]+1],l[3*u[W]+2]),C[w].normalize(),S[w].copyFromFloats(f[2*W]*d+p+I[G]*m,f[2*W+1]*_+g+I[G]*b)}const L=(W,K,ce,$)=>{const z=v.Lerp(C[0],C[2],K/s),k=v.Lerp(C[1],C[2],K/s),M=s===K?C[2]:v.Lerp(z,k,W/(s-K));M.normalize();let V;if(i){const se=v.Lerp(C[0],C[2],$/s),ue=v.Lerp(C[1],C[2],$/s);V=v.Lerp(se,ue,ce/(s-$))}else V=new v(M.x,M.y,M.z);V.x/=n,V.y/=r,V.z/=o,V.normalize();const q=oe.Lerp(S[0],S[2],K/s),he=oe.Lerp(S[1],S[2],K/s),pe=s===K?S[2]:oe.Lerp(q,he,W/(s-K));x.push(M.x*n,M.y*r,M.z*o),y.push(V.x,V.y,V.z),R.push(pe.x,pe.y),T.push(E),E++};for(let W=0;W<s;W++)for(let K=0;K+W<s;K++)L(K,W,K+1/3,W+1/3),L(K+1,W,K+1/3,W+1/3),L(K,W+1,K+1/3,W+1/3),K+W+1<s&&(L(K+1,W,K+2/3,W+2/3),L(K+1,W+1,K+2/3,W+2/3),L(K,W+1,K+2/3,W+2/3))}j._ComputeSides(e,x,T,y,R,a.frontUVs,a.backUVs);const P=new j;return P.indices=T,P.positions=x,P.normals=y,P.uvs=R,P}function of(a,e={},t=null){const i=new F(a,t);return e.sideOrientation=F._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,af(e).applyToMesh(i,e.updatable),i}j.CreateIcoSphere=af;F.CreateIcoSphere=(a,e,t)=>of(a,e,t);const Dv=new v(1,0,0),Fv=new v(-1,0,0),Ov=new v(0,1,0),Bv=new v(0,-1,0),Lv=new v(0,0,1),Nv=new v(0,0,-1);class Nr{constructor(e=v.Zero(),t=v.Up(),i=oe.Zero(),s=0,n=0,r=null,o=null,h=null,l=null){this.position=e,this.normal=t,this.uv=i,this.vertexIdx=s,this.vertexIdxForBones=n,this.localPositionOverride=r,this.localNormalOverride=o,this.matrixIndicesOverride=h,this.matrixWeightsOverride=l}clone(){var e,t,i,s;return new Nr(this.position.clone(),this.normal.clone(),this.uv.clone(),this.vertexIdx,this.vertexIdxForBones,(e=this.localPositionOverride)==null?void 0:e.slice(),(t=this.localNormalOverride)==null?void 0:t.slice(),(i=this.matrixIndicesOverride)==null?void 0:i.slice(),(s=this.matrixWeightsOverride)==null?void 0:s.slice())}}function hf(a,e,t){var K,ce,$,z;const i=!!e.skeleton,s=t.localMode||i,n=e.getIndices(),r=i?e.getPositionData(!0,!0):e.getVerticesData(A.PositionKind),o=i?e.getNormalsData(!0,!0):e.getVerticesData(A.NormalKind),h=s?i?e.getVerticesData(A.PositionKind):r:null,l=s?i?e.getVerticesData(A.NormalKind):o:null,c=e.getVerticesData(A.UVKind),u=i?e.getVerticesData(A.MatricesIndicesKind):null,f=i?e.getVerticesData(A.MatricesWeightsKind):null,d=i?e.getVerticesData(A.MatricesIndicesExtraKind):null,_=i?e.getVerticesData(A.MatricesWeightsExtraKind):null,p=t.position||v.Zero();let g=t.normal||v.Up();const m=t.size||v.One(),b=t.angle||0;if(!g){const k=new v(0,0,1),M=e.getScene().activeCamera,V=v.TransformCoordinates(k,M.getWorldMatrix());g=M.globalPosition.subtract(V)}const I=-Math.atan2(g.z,g.x)-Math.PI/2,T=Math.sqrt(g.x*g.x+g.z*g.z),x=Math.atan2(g.y,T),y=new j;y.indices=[],y.positions=[],y.normals=[],y.uvs=[],y.matricesIndices=i?[]:null,y.matricesWeights=i?[]:null,y.matricesIndicesExtra=d?[]:null,y.matricesWeightsExtra=_?[]:null;let R=0;const E=(k,M)=>{const V=new Nr;if(!n||!r||!o)return V;const q=n[k];if(V.vertexIdx=q*3,V.vertexIdxForBones=q*4,V.position=new v(r[q*3],r[q*3+1],r[q*3+2]),v.TransformCoordinatesToRef(V.position,M,V.position),V.normal=new v(o[q*3],o[q*3+1],o[q*3+2]),v.TransformNormalToRef(V.normal,M,V.normal),t.captureUVS&&c){const he=c[q*2+1];V.uv=new oe(c[q*2],he)}return V},C=[0,0,0,0],S=(k,M)=>{if(k.length===0)return k;const V=.5*Math.abs(v.Dot(m,M)),q=(se,ue,me,ne)=>{for(let Ie=0;Ie<ne;++Ie)if(se[me+Ie]===ue)return me+Ie;return-1},he=(se,ue)=>{var Vt,Yt,$i,tr,ho,lo,co,uo,fo,_o,po,go,mo,vo,bo,xo;const me=v.GetClipFactor(se.position,ue.position,M,V);let ne=C,Ie=C;if(u&&f){const mn=se.matrixIndicesOverride?0:se.vertexIdxForBones,ua=(Vt=se.matrixIndicesOverride)!=null?Vt:u,yo=(Yt=se.matrixWeightsOverride)!=null?Yt:f,fa=ue.matrixIndicesOverride?0:ue.vertexIdxForBones,To=($i=ue.matrixIndicesOverride)!=null?$i:u,Ao=(tr=ue.matrixWeightsOverride)!=null?tr:f;ne=[0,0,0,0],Ie=[0,0,0,0];let Es=0;for(let Ai=0;Ai<4;++Ai)if(yo[mn+Ai]>0){const vn=q(To,ua[mn+Ai],fa,4);ne[Es]=ua[mn+Ai],Ie[Es]=Rr(yo[mn+Ai],vn>=0?Ao[vn]:0,me),Es++}for(let Ai=0;Ai<4&&Es<4;++Ai){const vn=To[fa+Ai];q(ua,vn,mn,4)===-1&&(ne[Es]=vn,Ie[Es]=Rr(0,Ao[fa+Ai],me),Es++)}const ir=Ie[0]+Ie[1]+Ie[2]+Ie[3];Ie[0]/=ir,Ie[1]/=ir,Ie[2]/=ir,Ie[3]/=ir}const Se=se.localPositionOverride?se.localPositionOverride[0]:(ho=h==null?void 0:h[se.vertexIdx])!=null?ho:0,Q=se.localPositionOverride?se.localPositionOverride[1]:(lo=h==null?void 0:h[se.vertexIdx+1])!=null?lo:0,be=se.localPositionOverride?se.localPositionOverride[2]:(co=h==null?void 0:h[se.vertexIdx+2])!=null?co:0,Be=ue.localPositionOverride?ue.localPositionOverride[0]:(uo=h==null?void 0:h[ue.vertexIdx])!=null?uo:0,ze=ue.localPositionOverride?ue.localPositionOverride[1]:(fo=h==null?void 0:h[ue.vertexIdx+1])!=null?fo:0,Ke=ue.localPositionOverride?ue.localPositionOverride[2]:(_o=h==null?void 0:h[ue.vertexIdx+2])!=null?_o:0,Rt=se.localNormalOverride?se.localNormalOverride[0]:(po=l==null?void 0:l[se.vertexIdx])!=null?po:0,Ct=se.localNormalOverride?se.localNormalOverride[1]:(go=l==null?void 0:l[se.vertexIdx+1])!=null?go:0,Ge=se.localNormalOverride?se.localNormalOverride[2]:(mo=l==null?void 0:l[se.vertexIdx+2])!=null?mo:0,Jt=ue.localNormalOverride?ue.localNormalOverride[0]:(vo=l==null?void 0:l[ue.vertexIdx])!=null?vo:0,Wt=ue.localNormalOverride?ue.localNormalOverride[1]:(bo=l==null?void 0:l[ue.vertexIdx+1])!=null?bo:0,ji=ue.localNormalOverride?ue.localNormalOverride[2]:(xo=l==null?void 0:l[ue.vertexIdx+2])!=null?xo:0,Is=Rt+(Jt-Rt)*me,Ti=Ct+(Wt-Ct)*me,Ht=Ge+(ji-Ge)*me,oi=Math.sqrt(Is*Is+Ti*Ti+Ht*Ht);return new Nr(v.Lerp(se.position,ue.position,me),v.Lerp(se.normal,ue.normal,me).normalize(),oe.Lerp(se.uv,ue.uv,me),-1,-1,h?[Se+(Be-Se)*me,Q+(ze-Q)*me,be+(Ke-be)*me]:null,l?[Is/oi,Ti/oi,Ht/oi]:null,ne,Ie)};let pe=null;k.length>3&&(pe=[]);for(let se=0;se<k.length;se+=3){let ue=0,me=null,ne=null,Ie=null,Se=null;const Q=v.Dot(k[se].position,M)-V,be=v.Dot(k[se+1].position,M)-V,Be=v.Dot(k[se+2].position,M)-V,ze=Q>0,Ke=be>0,Rt=Be>0;switch(ue=(ze?1:0)+(Ke?1:0)+(Rt?1:0),ue){case 0:k.length>3?(pe.push(k[se]),pe.push(k[se+1]),pe.push(k[se+2])):pe=k;break;case 1:if(pe=pe!=null?pe:new Array,ze&&(me=k[se+1],ne=k[se+2],Ie=he(k[se],me),Se=he(k[se],ne)),Ke){me=k[se],ne=k[se+2],Ie=he(k[se+1],me),Se=he(k[se+1],ne),pe.push(Ie),pe.push(ne.clone()),pe.push(me.clone()),pe.push(ne.clone()),pe.push(Ie.clone()),pe.push(Se);break}Rt&&(me=k[se],ne=k[se+1],Ie=he(k[se+2],me),Se=he(k[se+2],ne)),me&&ne&&Ie&&Se&&(pe.push(me.clone()),pe.push(ne.clone()),pe.push(Ie),pe.push(Se),pe.push(Ie.clone()),pe.push(ne.clone()));break;case 2:pe=pe!=null?pe:new Array,ze||(me=k[se].clone(),ne=he(me,k[se+1]),Ie=he(me,k[se+2]),pe.push(me),pe.push(ne),pe.push(Ie)),Ke||(me=k[se+1].clone(),ne=he(me,k[se+2]),Ie=he(me,k[se]),pe.push(me),pe.push(ne),pe.push(Ie)),Rt||(me=k[se+2].clone(),ne=he(me,k[se]),Ie=he(me,k[se+1]),pe.push(me),pe.push(ne),pe.push(Ie));break}}return pe},w=e instanceof F?e:null,P=w==null?void 0:w._thinInstanceDataStorage.matrixData,G=(w==null?void 0:w.thinInstanceCount)||1,L=N.Matrix[0];L.copyFrom(O.IdentityReadOnly);for(let k=0;k<G;++k){if(w!=null&&w.hasThinInstances&&P){const se=k*16;L.setRowFromFloats(0,P[se+0],P[se+1],P[se+2],P[se+3]),L.setRowFromFloats(1,P[se+4],P[se+5],P[se+6],P[se+7]),L.setRowFromFloats(2,P[se+8],P[se+9],P[se+10],P[se+11]),L.setRowFromFloats(3,P[se+12],P[se+13],P[se+14],P[se+15])}const M=O.RotationYawPitchRoll(I,x,b).multiply(O.Translation(p.x,p.y,p.z)),V=O.Invert(M),q=e.getWorldMatrix(),he=L.multiply(q).multiply(V),pe=new Array(3);for(let se=0;se<n.length;se+=3){let ue=pe;if(ue[0]=E(se,he),ue[1]=E(se+1,he),ue[2]=E(se+2,he),!(t.cullBackFaces&&-ue[0].normal.z<=0&&-ue[1].normal.z<=0&&-ue[2].normal.z<=0)&&(ue=S(ue,Dv),!!ue&&(ue=S(ue,Fv),!!ue&&(ue=S(ue,Ov),!!ue&&(ue=S(ue,Bv),!!ue&&(ue=S(ue,Lv),!!ue&&(ue=S(ue,Nv),!!ue)))))))for(let me=0;me<ue.length;me++){const ne=ue[me];if(y.indices.push(R),s?(ne.localPositionOverride?(y.positions[R*3]=ne.localPositionOverride[0],y.positions[R*3+1]=ne.localPositionOverride[1],y.positions[R*3+2]=ne.localPositionOverride[2]):h&&(y.positions[R*3]=h[ne.vertexIdx],y.positions[R*3+1]=h[ne.vertexIdx+1],y.positions[R*3+2]=h[ne.vertexIdx+2]),ne.localNormalOverride?(y.normals[R*3]=ne.localNormalOverride[0],y.normals[R*3+1]=ne.localNormalOverride[1],y.normals[R*3+2]=ne.localNormalOverride[2]):l&&(y.normals[R*3]=l[ne.vertexIdx],y.normals[R*3+1]=l[ne.vertexIdx+1],y.normals[R*3+2]=l[ne.vertexIdx+2])):(ne.position.toArray(y.positions,R*3),ne.normal.toArray(y.normals,R*3)),y.matricesIndices&&y.matricesWeights&&(ne.matrixIndicesOverride?(y.matricesIndices[R*4]=ne.matrixIndicesOverride[0],y.matricesIndices[R*4+1]=ne.matrixIndicesOverride[1],y.matricesIndices[R*4+2]=ne.matrixIndicesOverride[2],y.matricesIndices[R*4+3]=ne.matrixIndicesOverride[3]):(u&&(y.matricesIndices[R*4]=u[ne.vertexIdxForBones],y.matricesIndices[R*4+1]=u[ne.vertexIdxForBones+1],y.matricesIndices[R*4+2]=u[ne.vertexIdxForBones+2],y.matricesIndices[R*4+3]=u[ne.vertexIdxForBones+3]),d&&y.matricesIndicesExtra&&(y.matricesIndicesExtra[R*4]=d[ne.vertexIdxForBones],y.matricesIndicesExtra[R*4+1]=d[ne.vertexIdxForBones+1],y.matricesIndicesExtra[R*4+2]=d[ne.vertexIdxForBones+2],y.matricesIndicesExtra[R*4+3]=d[ne.vertexIdxForBones+3])),ne.matrixWeightsOverride?(y.matricesWeights[R*4]=ne.matrixWeightsOverride[0],y.matricesWeights[R*4+1]=ne.matrixWeightsOverride[1],y.matricesWeights[R*4+2]=ne.matrixWeightsOverride[2],y.matricesWeights[R*4+3]=ne.matrixWeightsOverride[3]):(f&&(y.matricesWeights[R*4]=f[ne.vertexIdxForBones],y.matricesWeights[R*4+1]=f[ne.vertexIdxForBones+1],y.matricesWeights[R*4+2]=f[ne.vertexIdxForBones+2],y.matricesWeights[R*4+3]=f[ne.vertexIdxForBones+3]),_&&y.matricesWeightsExtra&&(y.matricesWeightsExtra[R*4]=_[ne.vertexIdxForBones],y.matricesWeightsExtra[R*4+1]=_[ne.vertexIdxForBones+1],y.matricesWeightsExtra[R*4+2]=_[ne.vertexIdxForBones+2],y.matricesWeightsExtra[R*4+3]=_[ne.vertexIdxForBones+3]))),t.captureUVS)ne.uv.toArray(y.uvs,R*2);else{y.uvs.push(.5+ne.position.x/m.x);const Ie=.5+ne.position.y/m.y;y.uvs.push(Ie)}R++}}}y.indices.length===0&&(y.indices=null),y.positions.length===0&&(y.positions=null),y.normals.length===0&&(y.normals=null),y.uvs.length===0&&(y.uvs=null),((K=y.matricesIndices)==null?void 0:K.length)===0&&(y.matricesIndices=null),((ce=y.matricesWeights)==null?void 0:ce.length)===0&&(y.matricesWeights=null),(($=y.matricesIndicesExtra)==null?void 0:$.length)===0&&(y.matricesIndicesExtra=null),((z=y.matricesWeightsExtra)==null?void 0:z.length)===0&&(y.matricesWeightsExtra=null);const W=new F(a,e.getScene());return y.applyToMesh(W),s?(W.skeleton=e.skeleton,W.parent=e):(W.position=p.clone(),W.rotation=new v(x,I,b)),W.computeWorldMatrix(!0),W.refreshBoundingInfo(!0,!0),W}F.CreateDecal=(a,e,t,i,s,n)=>hf(a,e,{position:t,normal:i,size:s,angle:n});function lf(a={subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6}){const e=Math.max(a.subdivisions?a.subdivisions:2,1)|0,t=Math.max(a.tessellation?a.tessellation:16,3)|0,i=Math.max(a.height?a.height:1,0),s=Math.max(a.radius?a.radius:.25,0),n=Math.max(a.capSubdivisions?a.capSubdivisions:6,1)|0,r=t,o=e,h=Math.max(a.radiusTop?a.radiusTop:s,0),l=Math.max(a.radiusBottom?a.radiusBottom:s,0),c=i-(h+l),u=0,f=2*Math.PI,d=Math.max(a.topCapSubdivisions?a.topCapSubdivisions:n,1),_=Math.max(a.bottomCapSubdivisions?a.bottomCapSubdivisions:n,1),p=Math.acos((l-h)/i);let g=[];const m=[],b=[],I=[];let T=0;const x=[],y=c*.5,R=Math.PI*.5;let E,C;const S=v.Zero(),w=v.Zero(),P=Math.cos(p),G=Math.sin(p),L=new oe(h*G,y+h*P).subtract(new oe(l*G,-y+l*P)).length(),W=h*p+L+l*(R-p);let K=0;for(C=0;C<=d;C++){const k=[],M=R-p*(C/d);K+=h*p/d;const V=Math.cos(M),q=Math.sin(M),he=V*h;for(E=0;E<=r;E++){const pe=E/r,se=pe*f+u,ue=Math.sin(se),me=Math.cos(se);w.x=he*ue,w.y=y+q*h,w.z=he*me,m.push(w.x,w.y,w.z),S.set(V*ue,q,V*me),b.push(S.x,S.y,S.z),I.push(pe,1-K/W),k.push(T),T++}x.push(k)}const ce=i-h-l+P*h-P*l,$=G*(l-h)/ce;for(C=1;C<=o;C++){const k=[];K+=L/o;const M=G*(C*(l-h)/o+h);for(E=0;E<=r;E++){const V=E/r,q=V*f+u,he=Math.sin(q),pe=Math.cos(q);w.x=M*he,w.y=y+P*h-C*ce/o,w.z=M*pe,m.push(w.x,w.y,w.z),S.set(he,$,pe).normalize(),b.push(S.x,S.y,S.z),I.push(V,1-K/W),k.push(T),T++}x.push(k)}for(C=1;C<=_;C++){const k=[],M=R-p-(Math.PI-p)*(C/_);K+=l*p/_;const V=Math.cos(M),q=Math.sin(M),he=V*l;for(E=0;E<=r;E++){const pe=E/r,se=pe*f+u,ue=Math.sin(se),me=Math.cos(se);w.x=he*ue,w.y=-y+q*l,w.z=he*me,m.push(w.x,w.y,w.z),S.set(V*ue,q,V*me),b.push(S.x,S.y,S.z),I.push(pe,1-K/W),k.push(T),T++}x.push(k)}for(E=0;E<r;E++)for(C=0;C<d+o+_;C++){const k=x[C][E],M=x[C+1][E],V=x[C+1][E+1],q=x[C][E+1];g.push(k),g.push(M),g.push(q),g.push(M),g.push(V),g.push(q)}if(g=g.reverse(),a.orientation&&!a.orientation.equals(v.Up())){const k=new O;a.orientation.clone().scale(Math.PI*.5).cross(v.Up()).toQuaternion().toRotationMatrix(k);const M=v.Zero();for(let V=0;V<m.length;V+=3)M.set(m[V],m[V+1],m[V+2]),v.TransformCoordinatesToRef(M.clone(),k,M),m[V]=M.x,m[V+1]=M.y,m[V+2]=M.z}const z=new j;return z.positions=m,z.normals=b,z.uvs=I,z.indices=g,z}function cf(a,e={orientation:v.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6,updatable:!1},t=null){const i=new F(a,t);return lf(e).applyToMesh(i,e.updatable),i}F.CreateCapsule=(a,e,t)=>cf(a,e,t);j.CreateCapsule=lf;class at{constructor(e=0,t=0){this.x=e,this.y=t,e!==Math.floor(e)&&(e=Math.floor(e),U.Warn("x is not an integer, floor(x) used")),t!==Math.floor(t)&&(t=Math.floor(t),U.Warn("y is not an integer, floor(y) used"))}clone(){return new at(this.x,this.y)}rotate60About(e){const t=this.x;return this.x=e.x+e.y-this.y,this.y=t+this.y-e.x,this}rotateNeg60About(e){const t=this.x;return this.x=t+this.y-e.y,this.y=e.x+e.y-t,this}rotate120(e,t){e!==Math.floor(e)&&(e=Math.floor(e),U.Warn("m not an integer only floor(m) used")),t!==Math.floor(t)&&(t=Math.floor(t),U.Warn("n not an integer only floor(n) used"));const i=this.x;return this.x=e-i-this.y,this.y=t+i,this}rotateNeg120(e,t){e!==Math.floor(e)&&(e=Math.floor(e),U.Warn("m is not an integer, floor(m) used")),t!==Math.floor(t)&&(t=Math.floor(t),U.Warn("n is not an integer, floor(n) used"));const i=this.x;return this.x=this.y-t,this.y=e+t-i-this.y,this}toCartesianOrigin(e,t){const i=v.Zero();return i.x=e.x+2*this.x*t+this.y*t,i.y=e.y+Math.sqrt(3)*this.y*t,i}static Zero(){return new at(0,0)}}class uf{constructor(){this.cartesian=[],this.vertices=[],this.max=[],this.min=[],this.closestTo=[],this.innerFacets=[],this.isoVecsABOB=[],this.isoVecsOBOA=[],this.isoVecsBAOA=[],this.vertexTypes=[],this.IDATA=new Ja("icosahedron","Regular",[[0,yt,-1],[-yt,1,0],[-1,0,-yt],[1,0,-yt],[yt,1,0],[0,yt,1],[-1,0,yt],[-yt,-1,0],[0,-yt,-1],[yt,-1,0],[1,0,yt],[0,-yt,1]],[[0,2,1],[0,3,2],[0,4,3],[0,5,4],[0,1,5],[7,6,1],[8,7,2],[9,8,3],[10,9,4],[6,10,5],[2,7,1],[3,8,2],[4,9,3],[5,10,4],[1,6,5],[11,6,7],[11,7,8],[11,8,9],[11,9,10],[11,10,6]])}setIndices(){let e=12;const t={},i=this.m,s=this.n;let n=i,r=1,o=0;s!==0&&(n=Ba(i,s)),r=i/n,o=s/n;let h,l,c,u,f;const d=at.Zero(),_=new at(i,s),p=new at(-s,i+s),g=at.Zero(),m=at.Zero(),b=at.Zero();let I=[],T,x,y,R;const E=[],C=this.vertByDist,S=(w,P,G,L)=>{T=w+"|"+G,x=P+"|"+L,T in t||x in t?T in t&&!(x in t)?t[x]=t[T]:x in t&&!(T in t)&&(t[T]=t[x]):(t[T]=e,t[x]=e,e++),C[G][0]>2?E[t[T]]=[-C[G][0],C[G][1],t[T]]:E[t[T]]=[I[C[G][0]],C[G][1],t[T]]};this.IDATA.edgematch=[[1,"B"],[2,"B"],[3,"B"],[4,"B"],[0,"B"],[10,"O",14,"A"],[11,"O",10,"A"],[12,"O",11,"A"],[13,"O",12,"A"],[14,"O",13,"A"],[0,"O"],[1,"O"],[2,"O"],[3,"O"],[4,"O"],[19,"B",5,"A"],[15,"B",6,"A"],[16,"B",7,"A"],[17,"B",8,"A"],[18,"B",9,"A"]];for(let w=0;w<20;w++){if(I=this.IDATA.face[w],c=I[2],u=I[1],f=I[0],y=d.x+"|"+d.y,T=w+"|"+y,T in t||(t[T]=c,E[c]=[I[C[y][0]],C[y][1]]),y=_.x+"|"+_.y,T=w+"|"+y,T in t||(t[T]=u,E[u]=[I[C[y][0]],C[y][1]]),y=p.x+"|"+p.y,T=w+"|"+y,T in t||(t[T]=f,E[f]=[I[C[y][0]],C[y][1]]),h=this.IDATA.edgematch[w][0],l=this.IDATA.edgematch[w][1],l==="B")for(let P=1;P<n;P++)m.x=i-P*(r+o),m.y=s+P*r,b.x=-P*o,b.y=P*(r+o),y=m.x+"|"+m.y,R=b.x+"|"+b.y,S(w,h,y,R);if(l==="O")for(let P=1;P<n;P++)b.x=-P*o,b.y=P*(r+o),g.x=P*r,g.y=P*o,y=b.x+"|"+b.y,R=g.x+"|"+g.y,S(w,h,y,R);if(h=this.IDATA.edgematch[w][2],l=this.IDATA.edgematch[w][3],l&&l==="A")for(let P=1;P<n;P++)g.x=P*r,g.y=P*o,m.x=i-(n-P)*(r+o),m.y=s+(n-P)*r,y=g.x+"|"+g.y,R=m.x+"|"+m.y,S(w,h,y,R);for(let P=0;P<this.vertices.length;P++)y=this.vertices[P].x+"|"+this.vertices[P].y,T=w+"|"+y,T in t||(t[T]=e++,C[y][0]>2?E[t[T]]=[-C[y][0],C[y][1],t[T]]:E[t[T]]=[I[C[y][0]],C[y][1],t[T]])}this.closestTo=E,this.vecToidx=t}calcCoeffs(){const e=this.m,t=this.n,i=Math.sqrt(3)/3,s=e*e+t*t+e*t;this.coau=(e+t)/s,this.cobu=-t/s,this.coav=-i*(e-t)/s,this.cobv=i*(2*e+t)/s}createInnerFacets(){const e=this.m,t=this.n;for(let i=0;i<t+e+1;i++)for(let s=this.min[i];s<this.max[i]+1;s++)s<this.max[i]&&s<this.max[i+1]+1&&this.innerFacets.push(["|"+s+"|"+i,"|"+s+"|"+(i+1),"|"+(s+1)+"|"+i]),i>0&&s<this.max[i-1]&&s+1<this.max[i]+1&&this.innerFacets.push(["|"+s+"|"+i,"|"+(s+1)+"|"+i,"|"+(s+1)+"|"+(i-1)])}edgeVecsABOB(){const e=this.m,t=this.n,i=new at(-t,e+t);for(let s=1;s<e+t;s++){const n=new at(this.min[s],s),r=new at(this.min[s-1],s-1),o=new at(this.min[s+1],s+1),h=n.clone(),l=r.clone(),c=o.clone();h.rotate60About(i),l.rotate60About(i),c.rotate60About(i);const u=new at(this.max[h.y],h.y),f=new at(this.max[h.y-1],h.y-1),d=new at(this.max[h.y-1]-1,h.y-1);(h.x!==u.x||h.y!==u.y)&&(h.x!==f.x?(this.vertexTypes.push([1,0,0]),this.isoVecsABOB.push([n,f,d]),this.vertexTypes.push([1,0,0]),this.isoVecsABOB.push([n,d,u])):h.y===c.y?(this.vertexTypes.push([1,1,0]),this.isoVecsABOB.push([n,r,f]),this.vertexTypes.push([1,0,1]),this.isoVecsABOB.push([n,f,o])):(this.vertexTypes.push([1,1,0]),this.isoVecsABOB.push([n,r,f]),this.vertexTypes.push([1,0,0]),this.isoVecsABOB.push([n,f,u])))}}mapABOBtoOBOA(){const e=new at(0,0);for(let t=0;t<this.isoVecsABOB.length;t++){const i=[];for(let s=0;s<3;s++)e.x=this.isoVecsABOB[t][s].x,e.y=this.isoVecsABOB[t][s].y,this.vertexTypes[t][s]===0&&e.rotateNeg120(this.m,this.n),i.push(e.clone());this.isoVecsOBOA.push(i)}}mapABOBtoBAOA(){const e=new at(0,0);for(let t=0;t<this.isoVecsABOB.length;t++){const i=[];for(let s=0;s<3;s++)e.x=this.isoVecsABOB[t][s].x,e.y=this.isoVecsABOB[t][s].y,this.vertexTypes[t][s]===1&&e.rotate120(this.m,this.n),i.push(e.clone());this.isoVecsBAOA.push(i)}}MapToFace(e,t){const i=this.IDATA.face[e],s=i[2],n=i[1],r=i[0],o=v.FromArray(this.IDATA.vertex[s]),h=v.FromArray(this.IDATA.vertex[n]),l=v.FromArray(this.IDATA.vertex[r]),c=h.subtract(o),u=l.subtract(o),f=c.scale(this.coau).add(u.scale(this.cobu)),d=c.scale(this.coav).add(u.scale(this.cobv));let _,p=N.Vector3[0];for(let g=0;g<this.cartesian.length;g++)p=f.scale(this.cartesian[g].x).add(d.scale(this.cartesian[g].y)).add(o),p.x,p.y,p.z,_=e+"|"+this.vertices[g].x+"|"+this.vertices[g].y,t.vertex[this.vecToidx[_]]=[p.x,p.y,p.z]}build(e,t){const i=[],s=at.Zero(),n=new at(e,t),r=new at(-t,e+t);i.push(s,n,r);for(let x=t;x<e+1;x++)for(let y=0;y<e+1-x;y++)i.push(new at(y,x));if(t>0){const x=Ba(e,t),y=e/x,R=t/x;for(let C=1;C<x;C++)i.push(new at(C*y,C*R)),i.push(new at(-C*R,C*(y+R))),i.push(new at(e-C*(y+R),t+C*y));const E=e/t;for(let C=1;C<t;C++)for(let S=0;S<C*E;S++)i.push(new at(S,C)),i.push(new at(S,C).rotate120(e,t)),i.push(new at(S,C).rotateNeg120(e,t))}i.sort((x,y)=>x.x-y.x),i.sort((x,y)=>x.y-y.y);const o=new Array(e+t+1),h=new Array(e+t+1);for(let x=0;x<o.length;x++)o[x]=1/0,h[x]=-1/0;let l=0,c=0;const u=i.length;for(let x=0;x<u;x++)c=i[x].x,l=i[x].y,o[l]=Math.min(c,o[l]),h[l]=Math.max(c,h[l]);const f=(x,y)=>{const R=x.clone();return y==="A"&&R.rotateNeg120(e,t),y==="B"&&R.rotate120(e,t),R.x<0?R.y:R.x+R.y},d=[],_=[],p=[],g=[],m={},b=[];let I=-1,T=-1;for(let x=0;x<u;x++)d[x]=i[x].toCartesianOrigin(new at(0,0),.5),_[x]=f(i[x],"O"),p[x]=f(i[x],"A"),g[x]=f(i[x],"B"),_[x]===p[x]&&p[x]===g[x]?(I=3,T=_[x]):_[x]===p[x]?(I=4,T=_[x]):p[x]===g[x]?(I=5,T=p[x]):g[x]===_[x]&&(I=6,T=_[x]),_[x]<p[x]&&_[x]<g[x]&&(I=2,T=_[x]),p[x]<_[x]&&p[x]<g[x]&&(I=1,T=p[x]),g[x]<p[x]&&g[x]<_[x]&&(I=0,T=g[x]),b.push([I,T,i[x].x,i[x].y]);b.sort((x,y)=>x[2]-y[2]),b.sort((x,y)=>x[3]-y[3]),b.sort((x,y)=>x[1]-y[1]),b.sort((x,y)=>x[0]-y[0]);for(let x=0;x<b.length;x++)m[b[x][2]+"|"+b[x][3]]=[b[x][0],b[x][1],x];return this.m=e,this.n=t,this.vertices=i,this.vertByDist=m,this.cartesian=d,this.min=o,this.max=h,this}}class Ja{constructor(e,t,i,s){this.name=e,this.category=t,this.vertex=i,this.face=s}}class ha extends Ja{innerToData(e,t){for(let i=0;i<t.innerFacets.length;i++)this.face.push(t.innerFacets[i].map(s=>t.vecToidx[e+s]))}mapABOBtoDATA(e,t){const i=t.IDATA.edgematch[e][0];for(let s=0;s<t.isoVecsABOB.length;s++){const n=[];for(let r=0;r<3;r++)t.vertexTypes[s][r]===0?n.push(e+"|"+t.isoVecsABOB[s][r].x+"|"+t.isoVecsABOB[s][r].y):n.push(i+"|"+t.isoVecsABOB[s][r].x+"|"+t.isoVecsABOB[s][r].y);this.face.push([t.vecToidx[n[0]],t.vecToidx[n[1]],t.vecToidx[n[2]]])}}mapOBOAtoDATA(e,t){const i=t.IDATA.edgematch[e][0];for(let s=0;s<t.isoVecsOBOA.length;s++){const n=[];for(let r=0;r<3;r++)t.vertexTypes[s][r]===1?n.push(e+"|"+t.isoVecsOBOA[s][r].x+"|"+t.isoVecsOBOA[s][r].y):n.push(i+"|"+t.isoVecsOBOA[s][r].x+"|"+t.isoVecsOBOA[s][r].y);this.face.push([t.vecToidx[n[0]],t.vecToidx[n[1]],t.vecToidx[n[2]]])}}mapBAOAtoDATA(e,t){const i=t.IDATA.edgematch[e][2];for(let s=0;s<t.isoVecsBAOA.length;s++){const n=[];for(let r=0;r<3;r++)t.vertexTypes[s][r]===1?n.push(e+"|"+t.isoVecsBAOA[s][r].x+"|"+t.isoVecsBAOA[s][r].y):n.push(i+"|"+t.isoVecsBAOA[s][r].x+"|"+t.isoVecsBAOA[s][r].y);this.face.push([t.vecToidx[n[0]],t.vecToidx[n[1]],t.vecToidx[n[2]]])}}orderData(e){const t=[];for(let r=0;r<13;r++)t[r]=[];const i=e.closestTo;for(let r=0;r<i.length;r++)i[r][0]>-1?i[r][1]>0&&t[i[r][0]].push([r,i[r][1]]):t[12].push([r,i[r][0]]);const s=[];for(let r=0;r<12;r++)s[r]=r;let n=12;for(let r=0;r<12;r++){t[r].sort((o,h)=>o[1]-h[1]);for(let o=0;o<t[r].length;o++)s[t[r][o][0]]=n++}for(let r=0;r<t[12].length;r++)s[t[12][r][0]]=n++;for(let r=0;r<this.vertex.length;r++)this.vertex[r].push(s[r]);this.vertex.sort((r,o)=>r[3]-o[3]);for(let r=0;r<this.vertex.length;r++)this.vertex[r].pop();for(let r=0;r<this.face.length;r++)for(let o=0;o<this.face[r].length;o++)this.face[r][o]=s[this.face[r][o]];this.sharedNodes=t[12].length,this.poleNodes=this.vertex.length-this.sharedNodes}setOrder(e,t){const i=[],s=[];let n=t.pop();s.push(n);let r=this.face[n].indexOf(e);r=(r+2)%3;let o=this.face[n][r];i.push(o);let h=0;for(;t.length>0;)n=t[h],this.face[n].indexOf(o)>-1?(r=(this.face[n].indexOf(o)+1)%3,o=this.face[n][r],i.push(o),s.push(n),t.splice(h,1),h=0):h++;return this.adjacentFaces.push(i),s}toGoldbergPolyhedronData(){const e=new Ja("GeoDual","Goldberg",[],[]);e.name="GD dual";const t=this.vertex.length,i=new Array(t);for(let l=0;l<t;l++)i[l]=[];for(let l=0;l<this.face.length;l++)for(let c=0;c<3;c++)i[this.face[l][c]].push(l);let s=0,n=0,r=0,o=[],h=[];this.adjacentFaces=[];for(let l=0;l<i.length;l++)e.face[l]=this.setOrder(l,i[l].concat([])),i[l].forEach(c=>{s=0,n=0,r=0,o=this.face[c];for(let u=0;u<3;u++)h=this.vertex[o[u]],s+=h[0],n+=h[1],r+=h[2];e.vertex[c]=[s/3,n/3,r/3]});return e}static BuildGeodesicData(e){const t=new ha("Geodesic-m-n","Geodesic",[[0,yt,-1],[-yt,1,0],[-1,0,-yt],[1,0,-yt],[yt,1,0],[0,yt,1],[-1,0,yt],[-yt,-1,0],[0,-yt,-1],[yt,-1,0],[1,0,yt],[0,-yt,1]],[]);e.setIndices(),e.calcCoeffs(),e.createInnerFacets(),e.edgeVecsABOB(),e.mapABOBtoOBOA(),e.mapABOBtoBAOA();for(let s=0;s<e.IDATA.face.length;s++)e.MapToFace(s,t),t.innerToData(s,e),e.IDATA.edgematch[s][1]==="B"&&t.mapABOBtoDATA(s,e),e.IDATA.edgematch[s][1]==="O"&&t.mapOBOAtoDATA(s,e),e.IDATA.edgematch[s][3]==="A"&&t.mapBAOAtoDATA(s,e);t.orderData(e);const i=1;return t.vertex=t.vertex.map(function(s){const n=s[0],r=s[1],o=s[2],h=Math.sqrt(n*n+r*r+o*o);return s[0]*=i/h,s[1]*=i/h,s[2]*=i/h,s}),t}}function Uv(a,e,t=null){let i=e.m||1;i!==Math.floor(i)&&(i=Math.floor(i),U.Warn("m not an integer only floor(m) used"));let s=e.n||0;if(s!==Math.floor(s)&&(s=Math.floor(s),U.Warn("n not an integer only floor(n) used")),s>i){const l=s;s=i,i=l,U.Warn("n > m therefore m and n swapped")}const n=new uf;n.build(i,s);const o={custom:ha.BuildGeodesicData(n),size:e.size,sizeX:e.sizeX,sizeY:e.sizeY,sizeZ:e.sizeZ,faceUV:e.faceUV,faceColors:e.faceColors,flat:e.flat,updatable:e.updatable,sideOrientation:e.sideOrientation,frontUVs:e.frontUVs,backUVs:e.backUVs};return ao(a,o,t)}F._GoldbergMeshParser=(a,e)=>la.Parse(a,e);class la extends F{constructor(){super(...arguments),this.goldbergData={faceColors:[],faceCenters:[],faceZaxis:[],faceXaxis:[],faceYaxis:[],nbSharedFaces:0,nbUnsharedFaces:0,nbFaces:0,nbFacesAtPole:0,adjacentFaces:[]}}relatedGoldbergFace(e,t){return t===void 0?(e>this.goldbergData.nbUnsharedFaces-1&&(U.Warn("Maximum number of unshared faces used"),e=this.goldbergData.nbUnsharedFaces-1),this.goldbergData.nbUnsharedFaces+e):(e>11&&(U.Warn("Last pole used"),e=11),t>this.goldbergData.nbFacesAtPole-1&&(U.Warn("Maximum number of faces at a pole used"),t=this.goldbergData.nbFacesAtPole-1),12+e*this.goldbergData.nbFacesAtPole+t)}_changeGoldbergFaceColors(e){for(let i=0;i<e.length;i++){const s=e[i][0],n=e[i][1],r=e[i][2];for(let o=s;o<n+1;o++)this.goldbergData.faceColors[o]=r}const t=[];for(let i=0;i<12;i++)for(let s=0;s<5;s++)t.push(this.goldbergData.faceColors[i].r,this.goldbergData.faceColors[i].g,this.goldbergData.faceColors[i].b,this.goldbergData.faceColors[i].a);for(let i=12;i<this.goldbergData.faceColors.length;i++)for(let s=0;s<6;s++)t.push(this.goldbergData.faceColors[i].r,this.goldbergData.faceColors[i].g,this.goldbergData.faceColors[i].b,this.goldbergData.faceColors[i].a);return t}setGoldbergFaceColors(e){const t=this._changeGoldbergFaceColors(e);this.setVerticesData(A.ColorKind,t)}updateGoldbergFaceColors(e){const t=this._changeGoldbergFaceColors(e);this.updateVerticesData(A.ColorKind,t)}_changeGoldbergFaceUVs(e){const t=this.getVerticesData(A.UVKind);for(let i=0;i<e.length;i++){const s=e[i][0],n=e[i][1],r=e[i][2],o=e[i][3],h=e[i][4],l=[],c=[];let u,f;for(let d=0;d<5;d++)u=r.x+o*Math.cos(h+d*Math.PI/2.5),f=r.y+o*Math.sin(h+d*Math.PI/2.5),u<0&&(u=0),u>1&&(u=1),l.push(u,f);for(let d=0;d<6;d++)u=r.x+o*Math.cos(h+d*Math.PI/3),f=r.y+o*Math.sin(h+d*Math.PI/3),u<0&&(u=0),u>1&&(u=1),c.push(u,f);for(let d=s;d<Math.min(12,n+1);d++)for(let _=0;_<5;_++)t[10*d+2*_]=l[2*_],t[10*d+2*_+1]=l[2*_+1];for(let d=Math.max(12,s);d<n+1;d++)for(let _=0;_<6;_++)t[12*d-24+2*_]=c[2*_],t[12*d-23+2*_]=c[2*_+1]}return t}setGoldbergFaceUVs(e){const t=this._changeGoldbergFaceUVs(e);this.setVerticesData(A.UVKind,t)}updateGoldbergFaceUVs(e){const t=this._changeGoldbergFaceUVs(e);this.updateVerticesData(A.UVKind,t)}placeOnGoldbergFaceAt(e,t,i){const s=v.RotationFromAxis(this.goldbergData.faceXaxis[t],this.goldbergData.faceYaxis[t],this.goldbergData.faceZaxis[t]);e.rotation=s,e.position=this.goldbergData.faceCenters[t].add(this.goldbergData.faceXaxis[t].scale(i.x)).add(this.goldbergData.faceYaxis[t].scale(i.y)).add(this.goldbergData.faceZaxis[t].scale(i.z))}serialize(e){super.serialize(e),e.type="GoldbergMesh";const t={};if(t.adjacentFaces=this.goldbergData.adjacentFaces,t.nbSharedFaces=this.goldbergData.nbSharedFaces,t.nbUnsharedFaces=this.goldbergData.nbUnsharedFaces,t.nbFaces=this.goldbergData.nbFaces,t.nbFacesAtPole=this.goldbergData.nbFacesAtPole,this.goldbergData.faceColors){t.faceColors=[];for(const i of this.goldbergData.faceColors)t.faceColors.push(i.asArray())}if(this.goldbergData.faceCenters){t.faceCenters=[];for(const i of this.goldbergData.faceCenters)t.faceCenters.push(i.asArray())}if(this.goldbergData.faceZaxis){t.faceZaxis=[];for(const i of this.goldbergData.faceZaxis)t.faceZaxis.push(i.asArray())}if(this.goldbergData.faceYaxis){t.faceYaxis=[];for(const i of this.goldbergData.faceYaxis)t.faceYaxis.push(i.asArray())}if(this.goldbergData.faceXaxis){t.faceXaxis=[];for(const i of this.goldbergData.faceXaxis)t.faceXaxis.push(i.asArray())}e.goldbergData=t}static Parse(e,t){const i=e.goldbergData;i.faceColors=i.faceColors.map(n=>H.FromArray(n)),i.faceCenters=i.faceCenters.map(n=>v.FromArray(n)),i.faceZaxis=i.faceZaxis.map(n=>v.FromArray(n)),i.faceXaxis=i.faceXaxis.map(n=>v.FromArray(n)),i.faceYaxis=i.faceYaxis.map(n=>v.FromArray(n));const s=new la(e.name,t);return s.goldbergData=i,s}}function kv(a,e){const t=a.size,i=a.sizeX||t||1,s=a.sizeY||t||1,n=a.sizeZ||t||1,r=a.sideOrientation===0?0:a.sideOrientation||j.DEFAULTSIDE,o=[],h=[],l=[],c=[];let u=1/0,f=-1/0,d=1/0,_=-1/0;for(let m=0;m<e.vertex.length;m++)u=Math.min(u,e.vertex[m][0]*i),f=Math.max(f,e.vertex[m][0]*i),d=Math.min(d,e.vertex[m][1]*s),_=Math.max(_,e.vertex[m][1]*s);let p=0;for(let m=0;m<e.face.length;m++){const b=e.face[m],I=v.FromArray(e.vertex[b[0]]),T=v.FromArray(e.vertex[b[2]]),x=v.FromArray(e.vertex[b[1]]),y=T.subtract(I),R=x.subtract(I),E=v.Cross(R,y).normalize();for(let C=0;C<b.length;C++){l.push(E.x,E.y,E.z);const S=e.vertex[b[C]];o.push(S[0]*i,S[1]*s,S[2]*n);const w=(S[1]*s-d)/(_-d);c.push((S[0]*i-u)/(f-u),w)}for(let C=0;C<b.length-2;C++)h.push(p,p+C+2,p+C+1);p+=b.length}j._ComputeSides(r,o,h,l,c);const g=new j;return g.positions=o,g.indices=h,g.normals=l,g.uvs=c,g}function Vv(a,e,t=null){const i=e.size,s=e.sizeX||i||1,n=e.sizeY||i||1,r=e.sizeZ||i||1;let o=e.m||1;o!==Math.floor(o)&&(o=Math.floor(o),U.Warn("m not an integer only floor(m) used"));let h=e.n||0;if(h!==Math.floor(h)&&(h=Math.floor(h),U.Warn("n not an integer only floor(n) used")),h>o){const _=h;h=o,o=_,U.Warn("n > m therefore m and n swapped")}const l=new uf;l.build(o,h);const c=ha.BuildGeodesicData(l),u=c.toGoldbergPolyhedronData(),f=new la(a,t);e.sideOrientation=F._GetDefaultSideOrientation(e.sideOrientation),f._originalBuilderSideOrientation=e.sideOrientation,kv(e,u).applyToMesh(f,e.updatable),f.goldbergData.nbSharedFaces=c.sharedNodes,f.goldbergData.nbUnsharedFaces=c.poleNodes,f.goldbergData.adjacentFaces=c.adjacentFaces,f.goldbergData.nbFaces=f.goldbergData.nbSharedFaces+f.goldbergData.nbUnsharedFaces,f.goldbergData.nbFacesAtPole=(f.goldbergData.nbUnsharedFaces-12)/12;for(let _=0;_<c.vertex.length;_++)f.goldbergData.faceCenters.push(v.FromArray(c.vertex[_])),f.goldbergData.faceCenters[_].x*=s,f.goldbergData.faceCenters[_].y*=n,f.goldbergData.faceCenters[_].z*=r,f.goldbergData.faceColors.push(new H(1,1,1,1));for(let _=0;_<u.face.length;_++){const p=u.face[_],g=v.FromArray(u.vertex[p[0]]),m=v.FromArray(u.vertex[p[2]]),b=v.FromArray(u.vertex[p[1]]),I=m.subtract(g),T=b.subtract(g),x=v.Cross(T,I).normalize(),y=v.Cross(T,x).normalize();f.goldbergData.faceXaxis.push(T.normalize()),f.goldbergData.faceYaxis.push(x),f.goldbergData.faceZaxis.push(y)}return f}class Gv{constructor(e){this._paths=[],this._tempPaths=[],this._holes=[],this._resolution=e}moveTo(e,t){this._currentPath=new Gr(e,t),this._tempPaths.push(this._currentPath)}lineTo(e,t){this._currentPath.addLineTo(e,t)}quadraticCurveTo(e,t,i,s){this._currentPath.addQuadraticCurveTo(e,t,i,s,this._resolution)}bezierCurveTo(e,t,i,s,n,r){this._currentPath.addBezierCurveTo(e,t,i,s,n,r,this._resolution)}extractHoles(){for(const e of this._tempPaths)e.area()>0?this._holes.push(e):this._paths.push(e);if(!this._paths.length&&this._holes.length){const e=this._holes;this._holes=this._paths,this._paths=e}this._tempPaths.length=0}get paths(){return this._paths}get holes(){return this._holes}}function zv(a,e,t,i,s,n){const r=n.glyphs[a]||n.glyphs["?"];if(!r)return null;const o=new Gv(s);if(r.o){const h=r.o.split(" ");for(let l=0,c=h.length;l<c;)switch(h[l++]){case"m":{const f=parseInt(h[l++])*e+t,d=parseInt(h[l++])*e+i;o.moveTo(f,d);break}case"l":{const f=parseInt(h[l++])*e+t,d=parseInt(h[l++])*e+i;o.lineTo(f,d);break}case"q":{const f=parseInt(h[l++])*e+t,d=parseInt(h[l++])*e+i,_=parseInt(h[l++])*e+t,p=parseInt(h[l++])*e+i;o.quadraticCurveTo(_,p,f,d);break}case"b":{const f=parseInt(h[l++])*e+t,d=parseInt(h[l++])*e+i,_=parseInt(h[l++])*e+t,p=parseInt(h[l++])*e+i,g=parseInt(h[l++])*e+t,m=parseInt(h[l++])*e+i;o.bezierCurveTo(_,p,g,m,f,d);break}}}return o.extractHoles(),{offsetX:r.ha*e,shapePath:o}}function Wv(a,e,t,i){const s=Array.from(a),n=e/i.resolution,r=(i.boundingBox.yMax-i.boundingBox.yMin+i.underlineThickness)*n,o=[];let h=0,l=0;for(let c=0;c<s.length;c++){const u=s[c];if(u==="\n")h=0,l-=r;else{const f=zv(u,n,h,l,t,i);f&&(h+=f.offsetX,o.push(f.shapePath))}}return o}function Hv(a,e,t,i={size:50,resolution:8,depth:1},s=null,n=earcut){var c,u;const r=Wv(e,i.size||50,i.resolution||8,t),o=[];let h=0;for(const f of r){if(!f.paths.length)continue;const d=f.holes.slice();for(const _ of f.paths){const p=[],g=[],m=_.getPoints();for(const T of m)g.push(new v(T.x,0,T.y));const b=d.slice();for(const T of b){const x=T.getPoints();let y=!1;for(const E of x)if(_.isPointInside(E)){y=!0;break}if(!y)continue;const R=[];for(const E of x)R.push(new v(E.x,0,E.y));p.push(R),d.splice(d.indexOf(T),1)}if(!p.length&&d.length)for(const T of d){const x=T.getPoints(),y=[];for(const R of x)y.push(new v(R.x,0,R.y));p.push(y)}const I=ro(a,{shape:g,holes:p.length?p:void 0,depth:i.depth||1,faceUV:i.faceUV||((c=i.perLetterFaceUV)==null?void 0:c.call(i,h)),faceColors:i.faceColors||((u=i.perLetterFaceColors)==null?void 0:u.call(i,h)),sideOrientation:F._GetDefaultSideOrientation(i.sideOrientation||F.DOUBLESIDE)},s,n);o.push(I),h++}}const l=F.MergeMeshes(o,!0,!0);if(l){const f=l.getBoundingInfo().boundingBox;l.position.x+=-(f.minimumWorld.x+f.maximumWorld.x)/2,l.position.y+=-(f.minimumWorld.y+f.maximumWorld.y)/2,l.position.z+=-(f.minimumWorld.z+f.maximumWorld.z)/2+f.extendSize.z,l.name=a;const d=new Te("pivot",s);d.rotation.x=-Math.PI/2,l.parent=d,l.bakeCurrentTransformIntoVertices(),l.parent=null,d.dispose()}return l}const Zt={CreateBox:Bu,CreateTiledBox:Mv,CreateSphere:Uu,CreateDisc:Cu,CreateIcoSphere:of,CreateRibbon:zs,CreateCylinder:Vu,CreateTorus:zu,CreateTorusKnot:Hu,CreateLineSystem:Yu,CreateLines:qu,CreateDashedLines:ju,ExtrudeShape:Zu,ExtrudeShapeCustom:Qu,CreateLathe:ef,CreateTiledPlane:Sv,CreatePlane:sf,CreateGround:wu,CreateTiledGround:Du,CreateGroundFromHeightMap:Fu,CreatePolygon:no,ExtrudePolygon:ro,CreateTube:nf,CreatePolyhedron:ao,CreateGeodesic:Uv,CreateGoldberg:Vv,CreateDecal:hf,CreateCapsule:cf,CreateText:Hv};F.prototype.thinInstanceAdd=function(a,e=!0){if(!this.getScene().getEngine().getCaps().instancedArrays)return U.Error("Thin Instances are not supported on this device as Instanced Array extension not supported"),-1;this._thinInstanceUpdateBufferSize("matrix",Array.isArray(a)?a.length:1);const t=this._thinInstanceDataStorage.instancesCount;if(Array.isArray(a))for(let i=0;i<a.length;++i)this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++,a[i],i===a.length-1&&e);else this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++,a,e);return t};F.prototype.thinInstanceAddSelf=function(a=!0){return this.thinInstanceAdd(O.IdentityReadOnly,a)};F.prototype.thinInstanceRegisterAttribute=function(a,e){a===A.ColorKind&&(a=A.ColorInstanceKind),this.removeVerticesData(a),this._thinInstanceInitializeUserStorage(),this._userThinInstanceBuffersStorage.strides[a]=e,this._userThinInstanceBuffersStorage.sizes[a]=e*Math.max(32,this._thinInstanceDataStorage.instancesCount),this._userThinInstanceBuffersStorage.data[a]=new Float32Array(this._userThinInstanceBuffersStorage.sizes[a]),this._userThinInstanceBuffersStorage.vertexBuffers[a]=new A(this.getEngine(),this._userThinInstanceBuffersStorage.data[a],a,!0,!1,e,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[a])};F.prototype.thinInstanceSetMatrixAt=function(a,e,t=!0){if(!this._thinInstanceDataStorage.matrixData||a>=this._thinInstanceDataStorage.instancesCount)return!1;const i=this._thinInstanceDataStorage.matrixData;return e.copyToArray(i,a*16),this._thinInstanceDataStorage.worldMatrices&&(this._thinInstanceDataStorage.worldMatrices[a]=e),t&&(this.thinInstanceBufferUpdated("matrix"),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)),!0};F.prototype.thinInstanceSetAttributeAt=function(a,e,t,i=!0){return a===A.ColorKind&&(a=A.ColorInstanceKind),!this._userThinInstanceBuffersStorage||!this._userThinInstanceBuffersStorage.data[a]||e>=this._thinInstanceDataStorage.instancesCount?!1:(this._thinInstanceUpdateBufferSize(a,0),this._userThinInstanceBuffersStorage.data[a].set(t,e*this._userThinInstanceBuffersStorage.strides[a]),i&&this.thinInstanceBufferUpdated(a),!0)};Object.defineProperty(F.prototype,"thinInstanceCount",{get:function(){return this._thinInstanceDataStorage.instancesCount},set:function(a){var i,s;const e=(s=this._thinInstanceDataStorage.matrixData)!=null?s:(i=this.source)==null?void 0:i._thinInstanceDataStorage.matrixData,t=e?e.length/16:0;a<=t&&(this._thinInstanceDataStorage.instancesCount=a)},enumerable:!0,configurable:!0});F.prototype._thinInstanceCreateMatrixBuffer=function(a,e,t=!0){const i=new ln(this.getEngine(),e,!t,16,!1,!0);for(let s=0;s<4;s++)this.setVerticesBuffer(i.createVertexBuffer(a+s,s*4,4));return i};F.prototype.thinInstanceSetBuffer=function(a,e,t=0,i=!0){var s,n,r;t=t||16,a==="matrix"?((s=this._thinInstanceDataStorage.matrixBuffer)==null||s.dispose(),this._thinInstanceDataStorage.matrixBuffer=null,this._thinInstanceDataStorage.matrixBufferSize=e?e.length:32*t,this._thinInstanceDataStorage.matrixData=e,this._thinInstanceDataStorage.worldMatrices=null,e!==null?(this._thinInstanceDataStorage.instancesCount=e.length/t,this._thinInstanceDataStorage.matrixBuffer=this._thinInstanceCreateMatrixBuffer("world",e,i),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)):(this._thinInstanceDataStorage.instancesCount=0,this.doNotSyncBoundingInfo||this.refreshBoundingInfo())):a==="previousMatrix"?((n=this._thinInstanceDataStorage.previousMatrixBuffer)==null||n.dispose(),this._thinInstanceDataStorage.previousMatrixBuffer=null,this._thinInstanceDataStorage.previousMatrixData=e,e!==null&&(this._thinInstanceDataStorage.previousMatrixBuffer=this._thinInstanceCreateMatrixBuffer("previousWorld",e,i))):(a===A.ColorKind&&(a=A.ColorInstanceKind),e===null?(r=this._userThinInstanceBuffersStorage)!=null&&r.data[a]&&(this.removeVerticesData(a),delete this._userThinInstanceBuffersStorage.data[a],delete this._userThinInstanceBuffersStorage.strides[a],delete this._userThinInstanceBuffersStorage.sizes[a],delete this._userThinInstanceBuffersStorage.vertexBuffers[a]):(this._thinInstanceInitializeUserStorage(),this._userThinInstanceBuffersStorage.data[a]=e,this._userThinInstanceBuffersStorage.strides[a]=t,this._userThinInstanceBuffersStorage.sizes[a]=e.length,this._userThinInstanceBuffersStorage.vertexBuffers[a]=new A(this.getEngine(),e,a,!i,!1,t,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[a])))};F.prototype.thinInstanceBufferUpdated=function(a){var e,t,i;a==="matrix"?(this.thinInstanceAllowAutomaticStaticBufferRecreation&&this._thinInstanceDataStorage.matrixBuffer&&!this._thinInstanceDataStorage.matrixBuffer.isUpdatable()&&this._thinInstanceRecreateBuffer(a),(e=this._thinInstanceDataStorage.matrixBuffer)==null||e.updateDirectly(this._thinInstanceDataStorage.matrixData,0,this._thinInstanceDataStorage.instancesCount)):a==="previousMatrix"?(this.thinInstanceAllowAutomaticStaticBufferRecreation&&this._thinInstanceDataStorage.previousMatrixBuffer&&!this._thinInstanceDataStorage.previousMatrixBuffer.isUpdatable()&&this._thinInstanceRecreateBuffer(a),(t=this._thinInstanceDataStorage.previousMatrixBuffer)==null||t.updateDirectly(this._thinInstanceDataStorage.previousMatrixData,0,this._thinInstanceDataStorage.instancesCount)):(a===A.ColorKind&&(a=A.ColorInstanceKind),(i=this._userThinInstanceBuffersStorage)!=null&&i.vertexBuffers[a]&&(this.thinInstanceAllowAutomaticStaticBufferRecreation&&!this._userThinInstanceBuffersStorage.vertexBuffers[a].isUpdatable()&&this._thinInstanceRecreateBuffer(a),this._userThinInstanceBuffersStorage.vertexBuffers[a].updateDirectly(this._userThinInstanceBuffersStorage.data[a],0)))};F.prototype.thinInstancePartialBufferUpdate=function(a,e,t){var i;a==="matrix"?this._thinInstanceDataStorage.matrixBuffer&&this._thinInstanceDataStorage.matrixBuffer.updateDirectly(e,t):(a===A.ColorKind&&(a=A.ColorInstanceKind),(i=this._userThinInstanceBuffersStorage)!=null&&i.vertexBuffers[a]&&this._userThinInstanceBuffersStorage.vertexBuffers[a].updateDirectly(e,t))};F.prototype.thinInstanceGetWorldMatrices=function(){if(!this._thinInstanceDataStorage.matrixData||!this._thinInstanceDataStorage.matrixBuffer)return[];const a=this._thinInstanceDataStorage.matrixData;if(!this._thinInstanceDataStorage.worldMatrices){this._thinInstanceDataStorage.worldMatrices=[];for(let e=0;e<this._thinInstanceDataStorage.instancesCount;++e)this._thinInstanceDataStorage.worldMatrices[e]=O.FromArray(a,e*16)}return this._thinInstanceDataStorage.worldMatrices};F.prototype.thinInstanceRefreshBoundingInfo=function(a=!1,e=!1,t=!1){if(!this._thinInstanceDataStorage.matrixData||!this._thinInstanceDataStorage.matrixBuffer)return;const i=this._thinInstanceDataStorage.boundingVectors;if(a||!this.rawBoundingInfo){i.length=0,this.refreshBoundingInfo(e,t);const r=this.getBoundingInfo();this.rawBoundingInfo=new ri(r.minimum,r.maximum)}const s=this.getBoundingInfo(),n=this._thinInstanceDataStorage.matrixData;if(i.length===0)for(let r=0;r<s.boundingBox.vectors.length;++r)i.push(s.boundingBox.vectors[r].clone());N.Vector3[0].setAll(Number.POSITIVE_INFINITY),N.Vector3[1].setAll(Number.NEGATIVE_INFINITY);for(let r=0;r<this._thinInstanceDataStorage.instancesCount;++r){O.FromArrayToRef(n,r*16,N.Matrix[0]);for(let o=0;o<i.length;++o)v.TransformCoordinatesToRef(i[o],N.Matrix[0],N.Vector3[2]),N.Vector3[0].minimizeInPlace(N.Vector3[2]),N.Vector3[1].maximizeInPlace(N.Vector3[2])}s.reConstruct(N.Vector3[0],N.Vector3[1]),this._updateBoundingInfo()};F.prototype._thinInstanceRecreateBuffer=function(a,e=!0){var t,i,s,n;a==="matrix"?((t=this._thinInstanceDataStorage.matrixBuffer)==null||t.dispose(),this._thinInstanceDataStorage.matrixBuffer=this._thinInstanceCreateMatrixBuffer("world",this._thinInstanceDataStorage.matrixData,e)):a==="previousMatrix"?this._scene.needsPreviousWorldMatrices&&((i=this._thinInstanceDataStorage.previousMatrixBuffer)==null||i.dispose(),this._thinInstanceDataStorage.previousMatrixBuffer=this._thinInstanceCreateMatrixBuffer("previousWorld",(s=this._thinInstanceDataStorage.previousMatrixData)!=null?s:this._thinInstanceDataStorage.matrixData,e)):(a===A.ColorKind&&(a=A.ColorInstanceKind),(n=this._userThinInstanceBuffersStorage.vertexBuffers[a])==null||n.dispose(),this._userThinInstanceBuffersStorage.vertexBuffers[a]=new A(this.getEngine(),this._userThinInstanceBuffersStorage.data[a],a,!e,!1,this._userThinInstanceBuffersStorage.strides[a],!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[a]))};F.prototype._thinInstanceUpdateBufferSize=function(a,e=1){var h,l,c;a===A.ColorKind&&(a=A.ColorInstanceKind);const t=a==="matrix";if(!t&&(!this._userThinInstanceBuffersStorage||!this._userThinInstanceBuffersStorage.strides[a]))return;const i=t?16:this._userThinInstanceBuffersStorage.strides[a],s=t?this._thinInstanceDataStorage.matrixBufferSize:this._userThinInstanceBuffersStorage.sizes[a];let n=t?this._thinInstanceDataStorage.matrixData:this._userThinInstanceBuffersStorage.data[a];const r=(this._thinInstanceDataStorage.instancesCount+e)*i;let o=s;for(;o<r;)o*=2;if(!n||s!=o){if(!n)n=new Float32Array(o);else{const u=new Float32Array(o);u.set(n,0),n=u}t?((h=this._thinInstanceDataStorage.matrixBuffer)==null||h.dispose(),this._thinInstanceDataStorage.matrixBuffer=this._thinInstanceCreateMatrixBuffer("world",n,!1),this._thinInstanceDataStorage.matrixData=n,this._thinInstanceDataStorage.matrixBufferSize=o,this._scene.needsPreviousWorldMatrices&&!this._thinInstanceDataStorage.previousMatrixData&&((l=this._thinInstanceDataStorage.previousMatrixBuffer)==null||l.dispose(),this._thinInstanceDataStorage.previousMatrixBuffer=this._thinInstanceCreateMatrixBuffer("previousWorld",n,!1))):((c=this._userThinInstanceBuffersStorage.vertexBuffers[a])==null||c.dispose(),this._userThinInstanceBuffersStorage.data[a]=n,this._userThinInstanceBuffersStorage.sizes[a]=o,this._userThinInstanceBuffersStorage.vertexBuffers[a]=new A(this.getEngine(),n,a,!0,!1,i,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[a]))}};F.prototype._thinInstanceInitializeUserStorage=function(){this._userThinInstanceBuffersStorage||(this._userThinInstanceBuffersStorage={data:{},sizes:{},vertexBuffers:{},strides:{}})};F.prototype._disposeThinInstanceSpecificData=function(){var a;(a=this._thinInstanceDataStorage)!=null&&a.matrixBuffer&&(this._thinInstanceDataStorage.matrixBuffer.dispose(),this._thinInstanceDataStorage.matrixBuffer=null)};class si extends Kt{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([Oe(()=>import("./kernelBlur.fragment-BJnJE4Wi.js"),__vite__mapDeps([52,53,3,4,5,6,7,8,9,10])),Oe(()=>import("./kernelBlur.vertex-SB8k7aXt.js"),__vite__mapDeps([54,53,3,4,5,6,7,8,9,10]))]))):t.push(Promise.all([Oe(()=>import("./kernelBlur.fragment-CAduVWsS.js"),__vite__mapDeps([55,56,3,4,5,6,7,8,9,10])),Oe(()=>import("./kernelBlur.vertex-Dciph_cp.js"),__vite__mapDeps([57,56,3,4,5,6,7,8,9,10]))]))}constructor(e,t=null,i,s,n){const r=!!(n!=null&&n.blockCompilation);super({...n,name:e,engine:t||le.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:si.FragmentUrl,uniforms:si.Uniforms,samplers:si.Samplers,vertexUrl:si.VertexUrl,blockCompilation:!0}),this._packedFloat=!1,this._staticDefines="",this.textureWidth=0,this.textureHeight=0,this.options.blockCompilation=r,i!==void 0&&(this.direction=i),s!==void 0&&(this.kernel=s)}set kernel(e){this._idealKernel!==e&&(e=Math.max(e,1),this._idealKernel=e,this._kernel=this._nearestBestKernel(e),this.options.blockCompilation||this._updateParameters())}get kernel(){return this._idealKernel}set packedFloat(e){this._packedFloat!==e&&(this._packedFloat=e,this.options.blockCompilation||this._updateParameters())}get packedFloat(){return this._packedFloat}bind(){super.bind(),this._drawWrapper.effect.setFloat2("delta",1/this.textureWidth*this.direction.x,1/this.textureHeight*this.direction.y)}_updateParameters(e,t){const i=this._kernel,s=(i-1)/2;let n=[],r=[],o=0;for(let g=0;g<i;g++){const m=g/(i-1),b=this._gaussianWeight(m*2-1);n[g]=g-s,r[g]=b,o+=b}for(let g=0;g<r.length;g++)r[g]/=o;const h=[],l=[],c=[];for(let g=0;g<=s;g+=2){const m=Math.min(g+1,Math.floor(s));if(g===m)c.push({o:n[g],w:r[g]});else{const I=m===s,T=r[g]+r[m]*(I?.5:1),x=n[g]+1/(1+r[g]/r[m]);x===0?(c.push({o:n[g],w:r[g]}),c.push({o:n[g+1],w:r[g+1]})):(c.push({o:x,w:T}),c.push({o:-x,w:T}))}}for(let g=0;g<c.length;g++)l[g]=c[g].o,h[g]=c[g].w;n=l,r=h;const u=this.options.engine.getCaps().maxVaryingVectors-(this.options.shaderLanguage===1?1:0),f=Math.max(u,0)-1;let d=Math.min(n.length,f),_="";_+=this._staticDefines,this._staticDefines.indexOf("DOF")!=-1&&(_+="#define CENTER_WEIGHT ".concat(this._glslFloat(r[d-1]),"\n"),d--);for(let g=0;g<d;g++)_+="#define KERNEL_OFFSET".concat(g," ").concat(this._glslFloat(n[g]),"\n"),_+="#define KERNEL_WEIGHT".concat(g," ").concat(this._glslFloat(r[g]),"\n");let p=0;for(let g=f;g<n.length;g++)_+="#define KERNEL_DEP_OFFSET".concat(p," ").concat(this._glslFloat(n[g]),"\n"),_+="#define KERNEL_DEP_WEIGHT".concat(p," ").concat(this._glslFloat(r[g]),"\n"),p++;this.packedFloat&&(_+="#define PACKEDFLOAT 1"),this.options.blockCompilation=!1,this.updateEffect(_,null,null,{varyingCount:d,depCount:p},e,t)}_nearestBestKernel(e){const t=Math.round(e);for(const i of[t,t-1,t+1,t-2,t+2])if(i%2!==0&&Math.floor(i/2)%2===0&&i>0)return Math.max(i,3);return Math.max(t,3)}_gaussianWeight(e){const t=.3333333333333333,i=Math.sqrt(2*Math.PI)*t,s=-(e*e/(2*t*t));return 1/i*Math.exp(s)}_glslFloat(e,t=8){return e.toFixed(t).replace(/0+$/,"")}}si.VertexUrl="kernelBlur";si.FragmentUrl="kernelBlur";si.Uniforms=["delta","direction"];si.Samplers=["circleOfConfusionSampler"];class As extends mt{get direction(){return this._effectWrapper.direction}set direction(e){this._effectWrapper.direction=e}set kernel(e){this._effectWrapper.kernel=e}get kernel(){return this._effectWrapper.kernel}set packedFloat(e){this._effectWrapper.packedFloat=e}get packedFloat(){return this._effectWrapper.packedFloat}getClassName(){return"BlurPostProcess"}constructor(e,t,i,s,n=null,r=ie.BILINEAR_SAMPLINGMODE,o,h,l=0,c="",u=!1,f=5){const d=typeof s=="number"?u:!!s.blockCompilation,_={uniforms:si.Uniforms,samplers:si.Samplers,size:typeof s=="number"?s:void 0,camera:n,samplingMode:r,engine:o,reusable:h,textureType:l,vertexUrl:si.VertexUrl,indexParameters:{varyingCount:0,depCount:0},textureFormat:f,defines:c,...s,blockCompilation:!0};super(e,si.FragmentUrl,{effectWrapper:typeof s=="number"||!s.effectWrapper?new si(e,o,void 0,void 0,_):void 0,..._}),this._effectWrapper.options.blockCompilation=d,this.direction=t,this.onApplyObservable.add(()=>{this._effectWrapper.textureWidth=this._outputTexture?this._outputTexture.width:this.width,this._effectWrapper.textureHeight=this._outputTexture?this._outputTexture.height:this.height}),this.kernel=i}updateEffect(e=null,t=null,i=null,s,n,r){this._effectWrapper._updateParameters(n,r)}static _Parse(e,t,i,s){return Ae.Parse(()=>new As(e.name,e.direction,e.kernel,e.options,t,e.renderTargetSamplingMode,i.getEngine(),e.reusable,e.textureType,void 0,!1),e,i,s)}}D([tc()],As.prototype,"direction",null);D([B()],As.prototype,"kernel",null);D([B()],As.prototype,"packedFloat",null);vt("BABYLON.BlurPostProcess",As);class xi{get camera(){return this._effectLayerOptions.camera}get renderingGroupId(){return this._effectLayerOptions.renderingGroupId}set renderingGroupId(e){this._effectLayerOptions.renderingGroupId=e}get mainTexture(){return this._mainTexture}get shaderLanguage(){return this._shaderLanguage}setMaterialForRendering(e,t){if(this._mainTexture.setMaterialForRendering(e,t),Array.isArray(e))for(let i=0;i<e.length;++i){const s=e[i];t?this._materialForRendering[s.uniqueId]=[s,t]:delete this._materialForRendering[s.uniqueId]}else t?this._materialForRendering[e.uniqueId]=[e,t]:delete this._materialForRendering[e.uniqueId]}getEffectIntensity(e){var t;return(t=this._effectIntensity[e.uniqueId])!=null?t:1}setEffectIntensity(e,t){this._effectIntensity[e.uniqueId]=t}constructor(e,t,i=!1){this._vertexBuffers={},this._maxSize=0,this._mainTextureDesiredSize={width:0,height:0},this._shouldRender=!0,this._postProcesses=[],this._textures=[],this._emissiveTextureAndColor={texture:null,color:new H},this._effectIntensity={},this.neutralColor=new H,this.isEnabled=!0,this.disableBoundingBoxesFromEffectLayer=!1,this.onDisposeObservable=new Z,this.onBeforeRenderMainTextureObservable=new Z,this.onBeforeComposeObservable=new Z,this.onBeforeRenderMeshToEffect=new Z,this.onAfterRenderMeshToEffect=new Z,this.onAfterComposeObservable=new Z,this.onSizeChangedObservable=new Z,this._shaderLanguage=0,this._materialForRendering={},this._shadersLoaded=!1,this.name=e,this._scene=t||Ee.LastCreatedScene,xi._SceneComponentInitialization(this._scene),this._scene.getEngine().isWebGPU&&!i&&!xi.ForceGLSL&&(this._shaderLanguage=1),this._engine=this._scene.getEngine(),this._maxSize=this._engine.getCaps().maxTextureSize,this._scene.effectLayers.push(this),this._mergeDrawWrapper=[],this._generateIndexBuffer(),this._generateVertexBuffer()}_numInternalDraws(){return 1}_init(e){this._effectLayerOptions={mainTextureRatio:.5,alphaBlendingMode:2,camera:null,renderingGroupId:-1,mainTextureType:0,generateStencilBuffer:!1,...e},this._setMainTextureSize(),this._createMainTexture(),this._createTextureAndPostProcesses()}_generateIndexBuffer(){const e=[];e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),this._indexBuffer=this._engine.createIndexBuffer(e)}_generateVertexBuffer(){const e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1);const t=new A(this._engine,e,A.PositionKind,!1,!1,2);this._vertexBuffers[A.PositionKind]=t}_setMainTextureSize(){this._effectLayerOptions.mainTextureFixedSize?(this._mainTextureDesiredSize.width=this._effectLayerOptions.mainTextureFixedSize,this._mainTextureDesiredSize.height=this._effectLayerOptions.mainTextureFixedSize):(this._mainTextureDesiredSize.width=this._engine.getRenderWidth()*this._effectLayerOptions.mainTextureRatio,this._mainTextureDesiredSize.height=this._engine.getRenderHeight()*this._effectLayerOptions.mainTextureRatio,this._mainTextureDesiredSize.width=this._engine.needPOTTextures?fi(this._mainTextureDesiredSize.width,this._maxSize):this._mainTextureDesiredSize.width,this._mainTextureDesiredSize.height=this._engine.needPOTTextures?fi(this._mainTextureDesiredSize.height,this._maxSize):this._mainTextureDesiredSize.height),this._mainTextureDesiredSize.width=Math.floor(this._mainTextureDesiredSize.width),this._mainTextureDesiredSize.height=Math.floor(this._mainTextureDesiredSize.height)}_createMainTexture(){this._mainTexture=new us("EffectLayerMainRTT",{width:this._mainTextureDesiredSize.width,height:this._mainTextureDesiredSize.height},this._scene,!1,!0,this._effectLayerOptions.mainTextureType,!1,ie.TRILINEAR_SAMPLINGMODE,!0,this._effectLayerOptions.generateStencilBuffer),this._mainTexture.activeCamera=this._effectLayerOptions.camera,this._mainTexture.wrapU=ie.CLAMP_ADDRESSMODE,this._mainTexture.wrapV=ie.CLAMP_ADDRESSMODE,this._mainTexture.anisotropicFilteringLevel=1,this._mainTexture.updateSamplingMode(ie.BILINEAR_SAMPLINGMODE),this._mainTexture.renderParticles=!1,this._mainTexture.renderList=null,this._mainTexture.ignoreCameraViewport=!0;for(const e in this._materialForRendering){const[t,i]=this._materialForRendering[e];this._mainTexture.setMaterialForRendering(t,i)}if(this._mainTexture.customIsReadyFunction=(e,t,i)=>{if((i||t===0)&&e.subMeshes)for(let s=0;s<e.subMeshes.length;++s){const n=e.subMeshes[s],r=n.getMaterial(),o=n.getRenderingMesh();if(!r)continue;const l=o._getInstancesRenderList(n._id,!!n.getReplacementMesh()).hardwareInstancedRendering[n._id]||o.hasThinInstances;if(this._setEmissiveTextureAndColor(o,n,r),!this._isReady(n,l,this._emissiveTextureAndColor.texture))return!1}return!0},this._mainTexture.customRenderFunction=(e,t,i,s)=>{this.onBeforeRenderMainTextureObservable.notifyObservers(this);let n;const r=this._scene.getEngine();if(s.length){for(r.setColorWrite(!1),n=0;n<s.length;n++)this._renderSubMesh(s.data[n]);r.setColorWrite(!0)}for(n=0;n<e.length;n++)this._renderSubMesh(e.data[n]);for(n=0;n<t.length;n++)this._renderSubMesh(t.data[n]);const o=r.getAlphaMode();for(n=0;n<i.length;n++){const h=i.data[n],l=h.getMaterial();if(l&&l.needDepthPrePass){const c=l.getScene().getEngine();c.setColorWrite(!1),this._renderSubMesh(h),c.setColorWrite(!0)}this._renderSubMesh(h,!0)}r.setAlphaMode(o)},this._mainTexture.onClearObservable.add(e=>{e.clear(this.neutralColor,!0,!0,!0)}),this._scene.getBoundingBoxRenderer){const e=this._scene.getBoundingBoxRenderer().enabled;this._mainTexture.onBeforeBindObservable.add(()=>{this._scene.getBoundingBoxRenderer().enabled=!this.disableBoundingBoxesFromEffectLayer&&e}),this._mainTexture.onAfterUnbindObservable.add(()=>{this._scene.getBoundingBoxRenderer().enabled=e})}}_addCustomEffectDefines(e){}_isReady(e,t,i){var I;const s=this._scene.getEngine(),n=e.getMesh(),r=(I=n._internalAbstractMeshDataInfo._materialForRenderPass)==null?void 0:I[s.currentRenderPassId];if(r)return r.isReadyForSubMesh(n,e,t);const o=e.getMaterial();if(!o)return!1;if(this._useMeshMaterial(e.getRenderingMesh()))return o.isReadyForSubMesh(e.getMesh(),e,t);const h=[],l=[A.PositionKind];let c=!1,u=!1;if(o){const T=o.needAlphaTesting(),x=o.getAlphaTestTexture(),y=x&&x.hasAlpha&&(o.useAlphaFromDiffuseTexture||o._useAlphaFromAlbedoTexture);x&&(T||y)&&(h.push("#define DIFFUSE"),n.isVerticesDataPresent(A.UV2Kind)&&x.coordinatesIndex===1?(h.push("#define DIFFUSEUV2"),u=!0):n.isVerticesDataPresent(A.UVKind)&&(h.push("#define DIFFUSEUV1"),c=!0),T&&(h.push("#define ALPHATEST"),h.push("#define ALPHATESTVALUE 0.4")),x.gammaSpace||h.push("#define DIFFUSE_ISLINEAR"));const R=o.opacityTexture;R&&(h.push("#define OPACITY"),n.isVerticesDataPresent(A.UV2Kind)&&R.coordinatesIndex===1?(h.push("#define OPACITYUV2"),u=!0):n.isVerticesDataPresent(A.UVKind)&&(h.push("#define OPACITYUV1"),c=!0))}i&&(h.push("#define EMISSIVE"),n.isVerticesDataPresent(A.UV2Kind)&&i.coordinatesIndex===1?(h.push("#define EMISSIVEUV2"),u=!0):n.isVerticesDataPresent(A.UVKind)&&(h.push("#define EMISSIVEUV1"),c=!0),i.gammaSpace||h.push("#define EMISSIVE_ISLINEAR")),n.useVertexColors&&n.isVerticesDataPresent(A.ColorKind)&&n.hasVertexAlpha&&o.transparencyMode!==X.MATERIAL_OPAQUE&&(l.push(A.ColorKind),h.push("#define VERTEXALPHA")),c&&(l.push(A.UVKind),h.push("#define UV1")),u&&(l.push(A.UV2Kind),h.push("#define UV2"));const f=new G0;if(n.useBones&&n.computeBonesUsingShaders){l.push(A.MatricesIndicesKind),l.push(A.MatricesWeightsKind),n.numBoneInfluencers>4&&(l.push(A.MatricesIndicesExtraKind),l.push(A.MatricesWeightsExtraKind)),h.push("#define NUM_BONE_INFLUENCERS "+n.numBoneInfluencers);const T=n.skeleton;T&&T.isUsingTextureForMatrices?h.push("#define BONETEXTURE"):h.push("#define BonesPerMesh "+(T?T.bones.length+1:0)),n.numBoneInfluencers>0&&f.addCPUSkinningFallback(0,n)}else h.push("#define NUM_BONE_INFLUENCERS 0");const d=n.morphTargetManager;let _=0;d&&(_=d.numMaxInfluencers||d.numInfluencers,_>0&&(h.push("#define MORPHTARGETS"),h.push("#define NUM_MORPH_INFLUENCERS "+_),d.isUsingTextureForTargets&&h.push("#define MORPHTARGETS_TEXTURE"),qp(l,n,_))),t&&(h.push("#define INSTANCES"),N0(l),e.getRenderingMesh().hasThinInstances&&h.push("#define THIN_INSTANCES")),Mc(o,this._scene,h),this._addCustomEffectDefines(h);const p=e._getDrawWrapper(void 0,!0),g=p.defines,m=h.join("\n");if(g!==m){const T=["world","mBones","viewProjection","glowColor","morphTargetInfluences","morphTargetCount","boneTextureWidth","diffuseMatrix","emissiveMatrix","opacityMatrix","opacityIntensity","morphTargetTextureInfo","morphTargetTextureIndices","glowIntensity"];Xr(T),p.setEffect(this._engine.createEffect("glowMapGeneration",l,T,["diffuseSampler","emissiveSampler","opacitySampler","boneSampler","morphTargets"],m,f,void 0,void 0,{maxSimultaneousMorphTargets:_},this._shaderLanguage,this._shadersLoaded?void 0:async()=>{await this._importShadersAsync(),this._shadersLoaded=!0}),m)}const b=p.effect.isReady();return this._arePostProcessAndMergeReady()&&b}async _importShadersAsync(){this._shaderLanguage===1?await Promise.all([Oe(()=>import("./glowMapGeneration.vertex-O7p-xSBA.js"),__vite__mapDeps([58,22,25,23,3,4,5,6,7,8,9,10])),Oe(()=>import("./glowMapGeneration.fragment-CfLBq-Y2.js"),__vite__mapDeps([59,29,3,4,5,6,7,8,9,10]))]):await Promise.all([Oe(()=>import("./glowMapGeneration.vertex-BcKlBU7O.js"),__vite__mapDeps([60,36,37,3,4,5,6,7,8,9,10])),Oe(()=>import("./glowMapGeneration.fragment-C2VnGqtj.js"),__vite__mapDeps([61,35,3,4,5,6,7,8,9,10]))])}_arePostProcessAndMergeReady(){let e=!0;for(let i=0;i<this._postProcesses.length;i++)e=this._postProcesses[i].isReady()&&e;const t=this._numInternalDraws();for(let i=0;i<t;++i){let s=this._mergeDrawWrapper[i];s||(s=this._mergeDrawWrapper[i]=new Xn(this._engine),s.setEffect(this._createMergeEffect())),e=s.effect.isReady()&&e}return e}render(){if(!this._arePostProcessAndMergeReady())return;const e=this._scene.getEngine(),t=this._numInternalDraws();this.onBeforeComposeObservable.notifyObservers(this);const i=e.getAlphaMode();for(let n=0;n<t;++n){const r=this._mergeDrawWrapper[n];e.enableEffect(r),e.setState(!1),e.bindBuffers(this._vertexBuffers,this._indexBuffer,r.effect),e.setAlphaMode(this._effectLayerOptions.alphaBlendingMode),this._internalRender(r.effect,n)}e.setAlphaMode(i),this.onAfterComposeObservable.notifyObservers(this);const s=this._mainTexture.getSize();this._setMainTextureSize(),(s.width!==this._mainTextureDesiredSize.width||s.height!==this._mainTextureDesiredSize.height)&&this._mainTextureDesiredSize.width!==0&&this._mainTextureDesiredSize.height!==0&&(this.onSizeChangedObservable.notifyObservers(this),this._disposeTextureAndPostProcesses(),this._createMainTexture(),this._createTextureAndPostProcesses())}hasMesh(e){return this.renderingGroupId===-1||e.renderingGroupId===this.renderingGroupId}shouldRender(){return this.isEnabled&&this._shouldRender}_shouldRenderMesh(e){return!0}_canRenderMesh(e,t){return!t.needAlphaBlendingForMesh(e)}_shouldRenderEmissiveTextureForMesh(){return!0}_renderSubMesh(e,t=!1){var p;if(!this.shouldRender())return;const i=e.getMaterial(),s=e.getMesh(),n=e.getReplacementMesh(),r=e.getRenderingMesh(),o=e.getEffectiveMesh(),h=this._scene,l=h.getEngine();if(o._internalAbstractMeshDataInfo._isActiveIntermediate=!1,!i||!this._canRenderMesh(r,i))return;let c=i._getEffectiveOrientation(r);o._getWorldMatrixDeterminant()<0&&(c=c===X.ClockWiseSideOrientation?X.CounterClockWiseSideOrientation:X.ClockWiseSideOrientation);const f=c===X.ClockWiseSideOrientation;l.setState(i.backFaceCulling,i.zOffset,void 0,f,i.cullBackFaces,void 0,i.zOffsetUnits);const d=r._getInstancesRenderList(e._id,!!n);if(d.mustReturn||!this._shouldRenderMesh(r))return;const _=d.hardwareInstancedRendering[e._id]||r.hasThinInstances;if(this._setEmissiveTextureAndColor(r,e,i),this.onBeforeRenderMeshToEffect.notifyObservers(s),this._useMeshMaterial(r))r.render(e,t,n||void 0);else if(this._isReady(e,_,this._emissiveTextureAndColor.texture)){const g=(p=o._internalAbstractMeshDataInfo._materialForRenderPass)==null?void 0:p[l.currentRenderPassId];let m=e._getDrawWrapper();if(!m&&g&&(m=g._getDrawWrapper()),!m)return;const b=m.effect;if(l.enableEffect(m),_||r._bind(e,b,i.fillMode),g?g.bindForSubMesh(o.getWorldMatrix(),o,e):(b.setMatrix("viewProjection",h.getTransformMatrix()),b.setMatrix("world",o.getWorldMatrix()),b.setFloat4("glowColor",this._emissiveTextureAndColor.color.r,this._emissiveTextureAndColor.color.g,this._emissiveTextureAndColor.color.b,this._emissiveTextureAndColor.color.a)),!g){const I=i.needAlphaTesting(),T=i.getAlphaTestTexture(),x=T&&T.hasAlpha&&(i.useAlphaFromDiffuseTexture||i._useAlphaFromAlbedoTexture);if(T&&(I||x)){b.setTexture("diffuseSampler",T);const R=T.getTextureMatrix();R&&b.setMatrix("diffuseMatrix",R)}const y=i.opacityTexture;if(y){b.setTexture("opacitySampler",y),b.setFloat("opacityIntensity",y.level);const R=y.getTextureMatrix();R&&b.setMatrix("opacityMatrix",R)}if(this._emissiveTextureAndColor.texture&&(b.setTexture("emissiveSampler",this._emissiveTextureAndColor.texture),b.setMatrix("emissiveMatrix",this._emissiveTextureAndColor.texture.getTextureMatrix())),r.useBones&&r.computeBonesUsingShaders&&r.skeleton){const R=r.skeleton;if(R.isUsingTextureForMatrices){const E=R.getTransformMatrixTexture(r);if(!E)return;b.setTexture("boneSampler",E),b.setFloat("boneTextureWidth",4*(R.bones.length+1))}else b.setMatrices("mBones",R.getTransformMatrices(r))}U0(r,b),r.morphTargetManager&&r.morphTargetManager.isUsingTextureForTargets&&r.morphTargetManager._bind(b),t&&l.setAlphaMode(i.alphaMode),b.setFloat("glowIntensity",this.getEffectIntensity(r)),Yr(b,i,h)}r._processRendering(o,e,b,i.fillMode,d,_,(I,T)=>b.setMatrix("world",T))}else this._mainTexture.resetRefreshCounter();this.onAfterRenderMeshToEffect.notifyObservers(s)}_useMeshMaterial(e){return!1}_rebuild(){const e=this._vertexBuffers[A.PositionKind];e&&e._rebuild(),this._generateIndexBuffer()}_disposeTextureAndPostProcesses(){this._mainTexture.dispose();for(let e=0;e<this._postProcesses.length;e++)this._postProcesses[e]&&this._postProcesses[e].dispose();this._postProcesses=[];for(let e=0;e<this._textures.length;e++)this._textures[e]&&this._textures[e].dispose();this._textures=[]}dispose(){const e=this._vertexBuffers[A.PositionKind];e&&(e.dispose(),this._vertexBuffers[A.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null);for(const i of this._mergeDrawWrapper)i.dispose();this._mergeDrawWrapper=[],this._disposeTextureAndPostProcesses();const t=this._scene.effectLayers.indexOf(this,0);t>-1&&this._scene.effectLayers.splice(t,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeComposeObservable.clear(),this.onBeforeRenderMeshToEffect.clear(),this.onAfterRenderMeshToEffect.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()}getClassName(){return"EffectLayer"}static Parse(e,t,i){return J.Instantiate(e.customType).Parse(e,t,i)}}xi.ForceGLSL=!1;xi._SceneComponentInitialization=a=>{throw ye("EffectLayerSceneComponent")};D([B()],xi.prototype,"name",void 0);D([p0()],xi.prototype,"neutralColor",void 0);D([B()],xi.prototype,"isEnabled",void 0);D([e_()],xi.prototype,"camera",null);D([B()],xi.prototype,"renderingGroupId",null);D([B()],xi.prototype,"disableBoundingBoxesFromEffectLayer",void 0);it.prototype.getHighlightLayerByName=function(a){var e;for(let t=0;t<((e=this.effectLayers)==null?void 0:e.length);t++)if(this.effectLayers[t].name===a&&this.effectLayers[t].getEffectName()===kt.EffectName)return this.effectLayers[t];return null};class ml extends mt{constructor(e,t,i,s,n,r=ie.BILINEAR_SAMPLINGMODE,o,h){super(e,"glowBlurPostProcess",["screenSize","direction","blurWidth"],null,s,n,r,o,h),this.direction=t,this.kernel=i,this.onApplyObservable.add(l=>{l.setFloat2("screenSize",this.width,this.height),l.setVector2("direction",this.direction),l.setFloat("blurWidth",this.kernel)})}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Oe(()=>import("./glowBlurPostProcess.fragment-D0h3Yhq8.js"),__vite__mapDeps([62,3,4,5,6,7,8,9,10])))):t.push(Oe(()=>import("./glowBlurPostProcess.fragment-BmYiq-YF.js"),__vite__mapDeps([63,3,4,5,6,7,8,9,10]))),super._gatherImports(e,t)}}class kt extends xi{set blurHorizontalSize(e){this._horizontalBlurPostprocess.kernel=e,this._options.blurHorizontalSize=e}set blurVerticalSize(e){this._verticalBlurPostprocess.kernel=e,this._options.blurVerticalSize=e}get blurHorizontalSize(){return this._horizontalBlurPostprocess.kernel}get blurVerticalSize(){return this._verticalBlurPostprocess.kernel}constructor(e,t,i){super(e,t,i!==void 0?!!i.forceGLSL:!1),this.name=e,this.innerGlow=!0,this.outerGlow=!0,this.onBeforeBlurObservable=new Z,this.onAfterBlurObservable=new Z,this._instanceGlowingMeshStencilReference=kt.GlowingMeshStencilReference++,this._meshes={},this._excludedMeshes={},this.neutralColor=kt.NeutralColor,this._engine.isStencilEnable||U.Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new Engine(canvas, antialias, { stencil: true }"),this._options={mainTextureRatio:.5,blurTextureSizeRatio:.5,blurHorizontalSize:1,blurVerticalSize:1,alphaBlendingMode:2,camera:null,renderingGroupId:-1,mainTextureType:0,forceGLSL:!1,...i},this._init({alphaBlendingMode:this._options.alphaBlendingMode,camera:this._options.camera,mainTextureFixedSize:this._options.mainTextureFixedSize,mainTextureRatio:this._options.mainTextureRatio,renderingGroupId:this._options.renderingGroupId,mainTextureType:this._options.mainTextureType}),this._shouldRender=!1}async _importShadersAsync(){this._shaderLanguage===1?await Promise.all([Oe(()=>import("./glowMapMerge.fragment-z1wsxOL6.js"),__vite__mapDeps([64,3,4,5,6,7,8,9,10])),Oe(()=>import("./glowMapMerge.vertex-BOpN3rPY.js"),__vite__mapDeps([65,3,4,5,6,7,8,9,10])),Oe(()=>import("./glowBlurPostProcess.fragment-D0h3Yhq8.js"),__vite__mapDeps([62,3,4,5,6,7,8,9,10]))]):await Promise.all([Oe(()=>import("./glowMapMerge.fragment-C9pBmOul.js"),__vite__mapDeps([66,3,4,5,6,7,8,9,10])),Oe(()=>import("./glowMapMerge.vertex-CYvG5BDv.js"),__vite__mapDeps([67,3,4,5,6,7,8,9,10])),Oe(()=>import("./glowBlurPostProcess.fragment-BmYiq-YF.js"),__vite__mapDeps([63,3,4,5,6,7,8,9,10]))]),await super._importShadersAsync()}getEffectName(){return kt.EffectName}_numInternalDraws(){return 2}_createMergeEffect(){return this._engine.createEffect("glowMapMerge",[A.PositionKind],["offset"],["textureSampler"],this._options.isStroke?"#define STROKE \n":void 0,void 0,void 0,void 0,void 0,this._shaderLanguage,this._shadersLoaded?void 0:async()=>{await this._importShadersAsync(),this._shadersLoaded=!0})}_createTextureAndPostProcesses(){let e=this._mainTextureDesiredSize.width*this._options.blurTextureSizeRatio,t=this._mainTextureDesiredSize.height*this._options.blurTextureSizeRatio;e=this._engine.needPOTTextures?fi(e,this._maxSize):e,t=this._engine.needPOTTextures?fi(t,this._maxSize):t;let i=0;if(this._engine.getCaps().textureHalfFloatRender?i=2:i=0,this._blurTexture=new us("HighlightLayerBlurRTT",{width:e,height:t},this._scene,!1,!0,i),this._blurTexture.wrapU=ie.CLAMP_ADDRESSMODE,this._blurTexture.wrapV=ie.CLAMP_ADDRESSMODE,this._blurTexture.anisotropicFilteringLevel=16,this._blurTexture.updateSamplingMode(ie.TRILINEAR_SAMPLINGMODE),this._blurTexture.renderParticles=!1,this._blurTexture.ignoreCameraViewport=!0,this._textures=[this._blurTexture],this._options.alphaBlendingMode===2)this._downSamplePostprocess=new Yn("HighlightLayerPPP",this._options.blurTextureSizeRatio,null,ie.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._downSamplePostprocess.externalTextureSamplerBinding=!0,this._downSamplePostprocess.onApplyObservable.add(s=>{s.setTexture("textureSampler",this._mainTexture)}),this._horizontalBlurPostprocess=new ml("HighlightLayerHBP",new oe(1,0),this._options.blurHorizontalSize,1,null,ie.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._horizontalBlurPostprocess.onApplyObservable.add(s=>{s.setFloat2("screenSize",e,t)}),this._verticalBlurPostprocess=new ml("HighlightLayerVBP",new oe(0,1),this._options.blurVerticalSize,1,null,ie.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._verticalBlurPostprocess.onApplyObservable.add(s=>{s.setFloat2("screenSize",e,t)}),this._postProcesses=[this._downSamplePostprocess,this._horizontalBlurPostprocess,this._verticalBlurPostprocess];else{this._horizontalBlurPostprocess=new As("HighlightLayerHBP",new oe(1,0),this._options.blurHorizontalSize/2,{width:e,height:t},null,ie.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,i);const s=this._horizontalBlurPostprocess;s.width=e,s.height=t,s.externalTextureSamplerBinding=!0,s.onApplyObservable.add(n=>{n.setTexture("textureSampler",this._mainTexture)}),this._verticalBlurPostprocess=new As("HighlightLayerVBP",new oe(0,1),this._options.blurVerticalSize/2,{width:e,height:t},null,ie.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,i),this._postProcesses=[this._horizontalBlurPostprocess,this._verticalBlurPostprocess]}this._mainTexture.onAfterUnbindObservable.add(()=>{this.onBeforeBlurObservable.notifyObservers(this);const s=this._blurTexture.renderTarget;s&&(this._scene.postProcessManager.directRender(this._postProcesses,s,!0),this._engine.unBindFramebuffer(s,!0)),this.onAfterBlurObservable.notifyObservers(this)}),this._postProcesses.map(s=>{s.autoClear=!1})}needStencil(){return!0}isReady(e,t){const i=e.getMaterial(),s=e.getRenderingMesh();if(!i||!s||!this._meshes)return!1;let n=null;const r=this._meshes[s.uniqueId];return r&&r.glowEmissiveOnly&&i&&(n=i.emissiveTexture),super._isReady(e,t,n)}_internalRender(e,t){e.setTexture("textureSampler",this._blurTexture);const i=this._engine;i.cacheStencilState(),i.setStencilOperationPass(7681),i.setStencilOperationFail(7680),i.setStencilOperationDepthFail(7680),i.setStencilMask(0),i.setStencilBuffer(!0),i.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),this.outerGlow&&t===0&&(e.setFloat("offset",0),i.setStencilFunction(517),i.drawElementsType(X.TriangleFillMode,0,6)),this.innerGlow&&t===1&&(e.setFloat("offset",1),i.setStencilFunction(514),i.drawElementsType(X.TriangleFillMode,0,6)),i.restoreStencilState()}shouldRender(){return super.shouldRender()?!!this._meshes:!1}_shouldRenderMesh(e){return!(this._excludedMeshes&&this._excludedMeshes[e.uniqueId]||!super.hasMesh(e))}_canRenderMesh(e,t){return!0}_addCustomEffectDefines(e){e.push("#define HIGHLIGHT")}_setEmissiveTextureAndColor(e,t,i){const s=this._meshes[e.uniqueId];s?this._emissiveTextureAndColor.color.set(s.color.r,s.color.g,s.color.b,1):this._emissiveTextureAndColor.color.set(this.neutralColor.r,this.neutralColor.g,this.neutralColor.b,this.neutralColor.a),s&&s.glowEmissiveOnly&&i?(this._emissiveTextureAndColor.texture=i.emissiveTexture,this._emissiveTextureAndColor.color.set(1,1,1,1)):this._emissiveTextureAndColor.texture=null}addExcludedMesh(e){if(!this._excludedMeshes)return;if(!this._excludedMeshes[e.uniqueId]){const i={mesh:e,beforeBind:null,afterRender:null,stencilState:!1};i.beforeBind=e.onBeforeBindObservable.add(s=>{i.stencilState=s.getEngine().getStencilBuffer(),s.getEngine().setStencilBuffer(!1)}),i.afterRender=e.onAfterRenderObservable.add(s=>{s.getEngine().setStencilBuffer(i.stencilState)}),this._excludedMeshes[e.uniqueId]=i}}removeExcludedMesh(e){if(!this._excludedMeshes)return;const t=this._excludedMeshes[e.uniqueId];t&&(t.beforeBind&&e.onBeforeBindObservable.remove(t.beforeBind),t.afterRender&&e.onAfterRenderObservable.remove(t.afterRender)),this._excludedMeshes[e.uniqueId]=null}hasMesh(e){return!this._meshes||!super.hasMesh(e)?!1:this._meshes[e.uniqueId]!==void 0&&this._meshes[e.uniqueId]!==null}addMesh(e,t,i=!1){if(!this._meshes)return;const s=this._meshes[e.uniqueId];s?s.color=t:(this._meshes[e.uniqueId]={mesh:e,color:t,observerHighlight:e.onBeforeBindObservable.add(n=>{this.isEnabled&&(this._excludedMeshes&&this._excludedMeshes[n.uniqueId]?this._defaultStencilReference(n):n.getScene().getEngine().setStencilFunctionReference(this._instanceGlowingMeshStencilReference))}),observerDefault:e.onAfterRenderObservable.add(n=>{this.isEnabled&&this._defaultStencilReference(n)}),glowEmissiveOnly:i},e.onDisposeObservable.add(()=>{this._disposeMesh(e)})),this._shouldRender=!0}removeMesh(e){if(!this._meshes)return;const t=this._meshes[e.uniqueId];t&&(t.observerHighlight&&e.onBeforeBindObservable.remove(t.observerHighlight),t.observerDefault&&e.onAfterRenderObservable.remove(t.observerDefault),delete this._meshes[e.uniqueId]),this._shouldRender=!1;for(const i in this._meshes)if(this._meshes[i]){this._shouldRender=!0;break}}removeAllMeshes(){if(this._meshes){for(const e in this._meshes)if(Object.prototype.hasOwnProperty.call(this._meshes,e)){const t=this._meshes[e];t&&this.removeMesh(t.mesh)}}}_defaultStencilReference(e){e.getScene().getEngine().setStencilFunctionReference(kt.NormalMeshStencilReference)}_disposeMesh(e){this.removeMesh(e),this.removeExcludedMesh(e)}dispose(){if(this._meshes){for(const e in this._meshes){const t=this._meshes[e];t&&t.mesh&&(t.observerHighlight&&t.mesh.onBeforeBindObservable.remove(t.observerHighlight),t.observerDefault&&t.mesh.onAfterRenderObservable.remove(t.observerDefault))}this._meshes=null}if(this._excludedMeshes){for(const e in this._excludedMeshes){const t=this._excludedMeshes[e];t&&(t.beforeBind&&t.mesh.onBeforeBindObservable.remove(t.beforeBind),t.afterRender&&t.mesh.onAfterRenderObservable.remove(t.afterRender))}this._excludedMeshes=null}super.dispose()}getClassName(){return"HighlightLayer"}serialize(){const e=Ae.Serialize(this);if(e.customType="BABYLON.HighlightLayer",e.meshes=[],this._meshes)for(const t in this._meshes){const i=this._meshes[t];i&&e.meshes.push({glowEmissiveOnly:i.glowEmissiveOnly,color:i.color.asArray(),meshId:i.mesh.id})}if(e.excludedMeshes=[],this._excludedMeshes)for(const t in this._excludedMeshes){const i=this._excludedMeshes[t];i&&e.excludedMeshes.push(i.mesh.id)}return e}static Parse(e,t,i){const s=Ae.Parse(()=>new kt(e.name,t,e.options),e,t,i);let n;for(n=0;n<e.excludedMeshes.length;n++){const r=t.getMeshById(e.excludedMeshes[n]);r&&s.addExcludedMesh(r)}for(n=0;n<e.meshes.length;n++){const r=e.meshes[n],o=t.getMeshById(r.meshId);o&&s.addMesh(o,de.FromArray(r.color),r.glowEmissiveOnly)}return s}}kt.EffectName="HighlightLayer";kt.NeutralColor=new H(0,0,0,0);kt.GlowingMeshStencilReference=2;kt.NormalMeshStencilReference=1;D([B()],kt.prototype,"innerGlow",void 0);D([B()],kt.prototype,"outerGlow",void 0);D([B()],kt.prototype,"blurHorizontalSize",null);D([B()],kt.prototype,"blurVerticalSize",null);D([B("options")],kt.prototype,"_options",void 0);vt("BABYLON.HighlightLayer",kt);const Kv="clipPlaneFragmentDeclaration",Xv="#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nvarying float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nvarying float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nvarying float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nvarying float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nvarying float fClipDistance6;\n#endif\n";Me.IncludesShadersStore[Kv]=Xv;const Yv="logDepthDeclaration",qv="#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;varying float vFragmentDepth;\n#endif\n";Me.IncludesShadersStore[Yv]=qv;const jv="fogFragmentDeclaration",$v="#ifdef FOG\n#define FOGMODE_NONE 0.\n#define FOGMODE_EXP 1.\n#define FOGMODE_EXP2 2.\n#define FOGMODE_LINEAR 3.\n#define E 2.71828\nuniform vec4 vFogInfos;uniform vec3 vFogColor;varying vec3 vFogDistance;float CalcFogFactor()\n{float fogCoeff=1.0;float fogStart=vFogInfos.y;float fogEnd=vFogInfos.z;float fogDensity=vFogInfos.w;float fogDistance=length(vFogDistance);if (FOGMODE_LINEAR==vFogInfos.x)\n{fogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);}\nelse if (FOGMODE_EXP==vFogInfos.x)\n{fogCoeff=1.0/pow(E,fogDistance*fogDensity);}\nelse if (FOGMODE_EXP2==vFogInfos.x)\n{fogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);}\nreturn clamp(fogCoeff,0.0,1.0);}\n#endif\n";Me.IncludesShadersStore[jv]=$v;const Zv="clipPlaneFragment",Qv="#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nif (false) {}\n#endif\n#ifdef CLIPPLANE\nelse if (fClipDistance>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE2\nelse if (fClipDistance2>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE3\nelse if (fClipDistance3>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE4\nelse if (fClipDistance4>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE5\nelse if (fClipDistance5>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE6\nelse if (fClipDistance6>0.0)\n{discard;}\n#endif\n";Me.IncludesShadersStore[Zv]=Qv;const Jv="fogFragment",eb="#ifdef FOG\nfloat fog=CalcFogFactor();\n#ifdef PBR\nfog=toLinearSpace(fog);\n#endif\ncolor.rgb=mix(vFogColor,color.rgb,fog);\n#endif\n";Me.IncludesShadersStore[Jv]=eb;const tb="logDepthFragment",ib="#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif\n";Me.IncludesShadersStore[tb]=ib;const sb="imageProcessingCompatibility",nb="#ifdef IMAGEPROCESSINGPOSTPROCESS\ngl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(2.2));\n#endif\n";Me.IncludesShadersStore[sb]=nb;const rb="gridPixelShader",ab="#extension GL_OES_standard_derivatives : enable\n#define SQRT2 1.41421356\n#define PI 3.14159\nprecision highp float;uniform float visibility;uniform vec3 mainColor;uniform vec3 lineColor;uniform vec4 gridControl;uniform vec3 gridOffset;varying vec3 vPosition;varying vec3 vNormal;\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#ifdef OPACITY\nvarying vec2 vOpacityUV;uniform sampler2D opacitySampler;uniform vec2 vOpacityInfos;\n#endif\nfloat getDynamicVisibility(float position) {float majorGridFrequency=gridControl.y;if (floor(position+0.5)==floor(position/majorGridFrequency+0.5)*majorGridFrequency)\n{return 1.0;}\nreturn gridControl.z;}\nfloat getAnisotropicAttenuation(float differentialLength) {const float maxNumberOfLines=10.0;return clamp(1.0/(differentialLength+1.0)-1.0/maxNumberOfLines,0.0,1.0);}\nfloat isPointOnLine(float position,float differentialLength) {float fractionPartOfPosition=position-floor(position+0.5); \nfractionPartOfPosition/=differentialLength; \n#ifdef ANTIALIAS\nfractionPartOfPosition=clamp(fractionPartOfPosition,-1.,1.);float result=0.5+0.5*cos(fractionPartOfPosition*PI); \nreturn result;\n#else\nreturn abs(fractionPartOfPosition)<SQRT2/4. ? 1. : 0.;\n#endif\n}\nfloat contributionOnAxis(float position) {float differentialLength=length(vec2(dFdx(position),dFdy(position)));differentialLength*=SQRT2; \nfloat result=isPointOnLine(position,differentialLength);float dynamicVisibility=getDynamicVisibility(position);result*=dynamicVisibility;float anisotropicAttenuation=getAnisotropicAttenuation(differentialLength);result*=anisotropicAttenuation;return result;}\nfloat normalImpactOnAxis(float x) {float normalImpact=clamp(1.0-3.0*abs(x*x*x),0.0,1.0);return normalImpact;}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nfloat gridRatio=gridControl.x;vec3 gridPos=(vPosition+gridOffset.xyz)/gridRatio;float x=contributionOnAxis(gridPos.x);float y=contributionOnAxis(gridPos.y);float z=contributionOnAxis(gridPos.z);vec3 normal=normalize(vNormal);x*=normalImpactOnAxis(normal.x);y*=normalImpactOnAxis(normal.y);z*=normalImpactOnAxis(normal.z);\n#ifdef MAX_LINE\nfloat grid=clamp(max(max(x,y),z),0.,1.);\n#else\nfloat grid=clamp(x+y+z,0.,1.);\n#endif\nvec3 color=mix(mainColor,lineColor,grid);\n#ifdef FOG\n#include<fogFragment>\n#endif\nfloat opacity=1.0;\n#ifdef TRANSPARENT\nopacity=clamp(grid,0.08,gridControl.w*grid);\n#endif\n#ifdef OPACITY\nopacity*=texture2D(opacitySampler,vOpacityUV).a;\n#endif\ngl_FragColor=vec4(color.rgb,opacity*visibility);\n#ifdef TRANSPARENT\n#ifdef PREMULTIPLYALPHA\ngl_FragColor.rgb*=opacity;\n#endif\n#else\n#endif\n#include<logDepthFragment>\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";Me.ShadersStore[rb]=ab;const ob="instancesDeclaration",hb="#ifdef INSTANCES\nattribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;\n#ifdef INSTANCESCOLOR\nattribute vec4 instanceColor;\n#endif\n#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)\nuniform mat4 world;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nattribute vec4 previousWorld0;attribute vec4 previousWorld1;attribute vec4 previousWorld2;attribute vec4 previousWorld3;\n#ifdef THIN_INSTANCES\nuniform mat4 previousWorld;\n#endif\n#endif\n#else\n#if !defined(WORLD_UBO)\nuniform mat4 world;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nuniform mat4 previousWorld;\n#endif\n#endif\n";Me.IncludesShadersStore[ob]=hb;const lb="fogVertexDeclaration",cb="#ifdef FOG\nvarying vec3 vFogDistance;\n#endif\n";Me.IncludesShadersStore[lb]=cb;const ub="clipPlaneVertexDeclaration",fb="#ifdef CLIPPLANE\nuniform vec4 vClipPlane;varying float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nuniform vec4 vClipPlane2;varying float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nuniform vec4 vClipPlane3;varying float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nuniform vec4 vClipPlane4;varying float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nuniform vec4 vClipPlane5;varying float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nuniform vec4 vClipPlane6;varying float fClipDistance6;\n#endif\n";Me.IncludesShadersStore[ub]=fb;const db="instancesVertex",_b="#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nmat4 finalPreviousWorld=mat4(previousWorld0,previousWorld1,\npreviousWorld2,previousWorld3);\n#endif\n#ifdef THIN_INSTANCES\nfinalWorld=world*finalWorld;\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nfinalPreviousWorld=previousWorld*finalPreviousWorld;\n#endif\n#endif\n#else\nmat4 finalWorld=world;\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nmat4 finalPreviousWorld=previousWorld;\n#endif\n#endif\n";Me.IncludesShadersStore[db]=_b;const pb="fogVertex",gb="#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif\n";Me.IncludesShadersStore[pb]=gb;const mb="clipPlaneVertex",vb="#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif\n#ifdef CLIPPLANE2\nfClipDistance2=dot(worldPos,vClipPlane2);\n#endif\n#ifdef CLIPPLANE3\nfClipDistance3=dot(worldPos,vClipPlane3);\n#endif\n#ifdef CLIPPLANE4\nfClipDistance4=dot(worldPos,vClipPlane4);\n#endif\n#ifdef CLIPPLANE5\nfClipDistance5=dot(worldPos,vClipPlane5);\n#endif\n#ifdef CLIPPLANE6\nfClipDistance6=dot(worldPos,vClipPlane6);\n#endif\n";Me.IncludesShadersStore[mb]=vb;const bb="logDepthVertex",xb="#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;gl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif\n";Me.IncludesShadersStore[bb]=xb;const yb="gridVertexShader",Tb="precision highp float;attribute vec3 position;attribute vec3 normal;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#include<instancesDeclaration>\nuniform mat4 projection;uniform mat4 view;varying vec3 vPosition;varying vec3 vNormal;\n#include<logDepthDeclaration>\n#include<fogVertexDeclaration>\n#ifdef OPACITY\nvarying vec2 vOpacityUV;uniform mat4 opacityMatrix;uniform vec2 vOpacityInfos;\n#endif\n#include<clipPlaneVertexDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\n#include<fogVertex>\nvec4 cameraSpacePosition=view*worldPos;gl_Position=projection*cameraSpacePosition;\n#ifdef OPACITY\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\nif (vOpacityInfos.x==0.)\n{vOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));}\nelse\n{vOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));}\n#endif \n#include<clipPlaneVertex>\n#include<logDepthVertex>\nvPosition=position;vNormal=normal;\n#define CUSTOM_VERTEX_MAIN_END\n}";Me.ShadersStore[yb]=Tb;class Ab extends k0{constructor(){super(),this.CLIPPLANE=!1,this.CLIPPLANE2=!1,this.CLIPPLANE3=!1,this.CLIPPLANE4=!1,this.CLIPPLANE5=!1,this.CLIPPLANE6=!1,this.OPACITY=!1,this.ANTIALIAS=!1,this.TRANSPARENT=!1,this.FOG=!1,this.PREMULTIPLYALPHA=!1,this.MAX_LINE=!1,this.UV1=!1,this.UV2=!1,this.INSTANCES=!1,this.THIN_INSTANCES=!1,this.IMAGEPROCESSINGPOSTPROCESS=!1,this.SKIPFINALCOLORCLAMP=!1,this.LOGARITHMICDEPTH=!1,this.rebuild()}}class zt extends V0{constructor(e,t){super(e,t),this.mainColor=de.Black(),this.lineColor=de.Teal(),this.gridRatio=1,this.gridOffset=v.Zero(),this.majorUnitFrequency=10,this.minorUnitVisibility=.33,this.opacity=1,this.antialias=!0,this.preMultiplyAlpha=!1,this.useMaxLine=!1,this._gridControl=new Pe(this.gridRatio,this.majorUnitFrequency,this.minorUnitVisibility,this.opacity)}needAlphaBlending(){return this.opacity<1||this._opacityTexture&&this._opacityTexture.isReady()}needAlphaBlendingForMesh(e){return e.visibility<1||this.needAlphaBlending()}isReadyForSubMesh(e,t,i){const s=t._drawWrapper;if(this.isFrozen&&s.effect&&s._wasPreviouslyReady&&s._wasPreviouslyUsingInstances===i)return!0;t.materialDefines||(t.materialDefines=new Ab);const n=t.materialDefines,r=this.getScene();if(this._isReadyForSubMesh(t))return!0;if(n.TRANSPARENT!==this.opacity<1&&(n.TRANSPARENT=!n.TRANSPARENT,n.markAsUnprocessed()),n.PREMULTIPLYALPHA!=this.preMultiplyAlpha&&(n.PREMULTIPLYALPHA=!n.PREMULTIPLYALPHA,n.markAsUnprocessed()),n.MAX_LINE!==this.useMaxLine&&(n.MAX_LINE=!n.MAX_LINE,n.markAsUnprocessed()),n.ANTIALIAS!==this.antialias&&(n.ANTIALIAS=!n.ANTIALIAS,n.markAsUnprocessed()),n._areTexturesDirty&&(n._needUVs=!1,r.texturesEnabled&&this._opacityTexture&&De.OpacityTextureEnabled))if(this._opacityTexture.isReady())n._needUVs=!0,n.OPACITY=!0;else return!1;if(Bc(e,r,this._useLogarithmicDepth,!1,this.fogEnabled,!1,n),Lc(r,r.getEngine(),this,n,!!i),n.isDirty){n.markAsProcessed(),r.resetCachedMaterial(),Nc(e,n,!1,!1);const o=[A.PositionKind,A.NormalKind];n.UV1&&o.push(A.UVKind),n.UV2&&o.push(A.UV2Kind),n.IMAGEPROCESSINGPOSTPROCESS=r.imageProcessingConfiguration.applyByPostProcess,Oc(o,n);const h=["projection","mainColor","lineColor","gridControl","gridOffset","vFogInfos","vFogColor","world","view","opacityMatrix","vOpacityInfos","visibility","logarithmicDepthConstant"],l=n.toString();Xr(h),t.setEffect(r.getEngine().createEffect("grid",o,h,["opacitySampler"],l,void 0,this.onCompiled,this.onError),n,this._materialContext)}return!t.effect||!t.effect.isReady()?!1:(n._renderId=r.getRenderId(),s._wasPreviouslyReady=!0,s._wasPreviouslyUsingInstances=!!i,!0)}bindForSubMesh(e,t,i){const s=this.getScene(),n=i.materialDefines;if(!n)return;const r=i.effect;r&&(this._activeEffect=r,this._activeEffect.setFloat("visibility",t.visibility),(!n.INSTANCES||n.THIN_INSTANCE)&&this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("view",s.getViewMatrix()),this._activeEffect.setMatrix("projection",s.getProjectionMatrix()),this._mustRebind(s,r,i)&&(this._activeEffect.setColor3("mainColor",this.mainColor),this._activeEffect.setColor3("lineColor",this.lineColor),this._activeEffect.setVector3("gridOffset",this.gridOffset),this._gridControl.x=this.gridRatio,this._gridControl.y=Math.round(this.majorUnitFrequency),this._gridControl.z=this.minorUnitVisibility,this._gridControl.w=this.opacity,this._activeEffect.setVector4("gridControl",this._gridControl),this._opacityTexture&&De.OpacityTextureEnabled&&(this._activeEffect.setTexture("opacitySampler",this._opacityTexture),this._activeEffect.setFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),this._activeEffect.setMatrix("opacityMatrix",this._opacityTexture.getTextureMatrix())),Yr(r,this,s),this._useLogarithmicDepth&&B0(n,r,s)),L0(s,t,this._activeEffect),this._afterBind(t,this._activeEffect,i))}dispose(e){super.dispose(e)}clone(e){return Ae.Clone(()=>new zt(e,this.getScene()),this)}serialize(){const e=super.serialize();return e.customType="BABYLON.GridMaterial",e}getClassName(){return"GridMaterial"}static Parse(e,t,i){return Ae.Parse(()=>new zt(e.name,t),e,t,i)}}D([ls()],zt.prototype,"mainColor",void 0);D([ls()],zt.prototype,"lineColor",void 0);D([B()],zt.prototype,"gridRatio",void 0);D([yi()],zt.prototype,"gridOffset",void 0);D([B()],zt.prototype,"majorUnitFrequency",void 0);D([B()],zt.prototype,"minorUnitVisibility",void 0);D([B()],zt.prototype,"opacity",void 0);D([B()],zt.prototype,"antialias",void 0);D([B()],zt.prototype,"preMultiplyAlpha",void 0);D([B()],zt.prototype,"useMaxLine",void 0);D([_i("opacityTexture")],zt.prototype,"_opacityTexture",void 0);D([je("_markAllSubMeshesAsTexturesDirty")],zt.prototype,"opacityTexture",void 0);vt("BABYLON.GridMaterial",zt);we.prototype.createDynamicTexture=function(a,e,t,i){const s=new ft(this,4);return s.baseWidth=a,s.baseHeight=e,t&&(a=this.needPOTTextures?fi(a,this._caps.maxTextureSize):a,e=this.needPOTTextures?fi(e,this._caps.maxTextureSize):e),s.width=a,s.height=e,s.isReady=!1,s.generateMipMaps=t,s.samplingMode=i,this.updateTextureSamplingMode(i,s),this._internalTexturesCache.push(s),s};we.prototype.updateDynamicTexture=function(a,e,t,i=!1,s,n=!1,r=!1){if(!a)return;const o=this._gl,h=o.TEXTURE_2D,l=this._bindTextureDirectly(h,a,!0,n);this._unpackFlipY(t===void 0?a.invertY:t),i&&o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);const c=this._getWebGLTextureType(a.type),u=this._getInternalFormat(s||a.format),f=this._getRGBABufferInternalSizedFormat(a.type,u);o.texImage2D(h,0,f,u,c,e),a.generateMipMaps&&o.generateMipmap(h),l||this._bindTextureDirectly(h,null),i&&o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),s&&(a.format=s),a._dynamicTextureSource=e,a._premulAlpha=i,a.invertY=t||!1,a.isReady=!0};class Wn extends ie{constructor(e,t,i,s=!1,n=3,r=5,o){const h=!i||i._isScene,l=h?i:i==null?void 0:i.scene,c=h?!s:i;super(null,l,c,o,n,void 0,void 0,void 0,void 0,r),this.name=e,this.wrapU=ie.CLAMP_ADDRESSMODE,this.wrapV=ie.CLAMP_ADDRESSMODE,this._generateMipMaps=s;const u=this._getEngine();if(!u)return;if(t.getContext)this._canvas=t,this._ownCanvas=!1,this._texture=u.createDynamicTexture(this._canvas.width,this._canvas.height,s,n);else{this._canvas=u.createCanvas(1,1),this._ownCanvas=!0;const d=t;d.width||d.width===0?this._texture=u.createDynamicTexture(d.width,d.height,s,n):this._texture=u.createDynamicTexture(t,t,s,n)}const f=this.getSize();this._canvas.width!==f.width&&(this._canvas.width=f.width),this._canvas.height!==f.height&&(this._canvas.height=f.height),this._context=this._canvas.getContext("2d")}getClassName(){return"DynamicTexture"}get canRescale(){return!0}_recreate(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this._getEngine().createDynamicTexture(e.width,e.height,this._generateMipMaps,this.samplingMode)}scale(e){const t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)}scaleTo(e,t){const i=this.getSize();i.width=e,i.height=t,this._recreate(i)}getContext(){return this._context}clear(e){const t=this.getSize();e&&(this._context.fillStyle=e),this._context.clearRect(0,0,t.width,t.height)}update(e,t=!1,i=!1){this._getEngine().updateDynamicTexture(this._texture,this._canvas,e===void 0?!0:e,t,this._format||void 0,void 0,i)}drawText(e,t,i,s,n,r,o,h=!0){const l=this.getSize();if(r&&(this._context.fillStyle=r,this._context.fillRect(0,0,l.width,l.height)),this._context.font=s,t==null){const c=this._context.measureText(e);t=(l.width-c.width)/2}if(i==null){const c=parseInt(s.replace(/\D/g,""));i=l.height/2+c/3.65}this._context.fillStyle=n||"",this._context.fillText(e,t,i),h&&this.update(o)}dispose(){var e,t;super.dispose(),this._ownCanvas&&((t=(e=this._canvas)==null?void 0:e.remove)==null||t.call(e)),this._canvas=null,this._context=null}clone(){const e=this.getScene();if(!e)return this;const t=this.getSize(),i=new Wn(this.name,t,e,this._generateMipMaps);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.wrapU=this.wrapU,i.wrapV=this.wrapV,i}serialize(){const e=this.getScene();e&&!e.isReady()&&U.Warn("The scene must be ready before serializing the dynamic texture");const t=super.serialize();return Wn._IsCanvasElement(this._canvas)&&(t.base64String=this._canvas.toDataURL()),t.invertY=this._invertY,t.samplingMode=this.samplingMode,t}static _IsCanvasElement(e){return e.toDataURL!==void 0}_rebuild(){this.update()}}bt.AddNodeConstructor("Light_Type_3",(a,e)=>()=>new _n(a,v.Zero(),e));class _n extends Fe{constructor(e,t,i){super(e,i),this.groundColor=new de(0,0,0),this.direction=t||v.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=v.Normalize(e.subtract(v.Zero())),this.direction}getShadowGenerator(){return null}transferToEffect(e,t){const i=v.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=v.Normalize(this.direction);return e.setFloat3(t,i.x,i.y,i.z),this}computeWorldMatrix(){return this._worldMatrix||(this._worldMatrix=O.Identity()),this._worldMatrix}getTypeID(){return Fe.LIGHTTYPEID_HEMISPHERICLIGHT}prepareLightSpecificDefines(e,t){e["HEMILIGHT"+t]=!0}}D([ls()],_n.prototype,"groundColor",void 0);D([yi()],_n.prototype,"direction",void 0);vt("BABYLON.HemisphericLight",_n);function It(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */It=()=>a;var a={},e=Object.prototype,t=e.hasOwnProperty,i=typeof Symbol=="function"?Symbol:{},s=i.iterator||"@@iterator",n=i.asyncIterator||"@@asyncIterator",r=i.toStringTag||"@@toStringTag";function o(S,w,P){return Object.defineProperty(S,w,{value:P,enumerable:!0,configurable:!0,writable:!0}),S[w]}try{o({},"")}catch{o=(w,P,G)=>w[P]=G}function h(S,w,P,G){var L=w&&w.prototype instanceof u?w:u,W=Object.create(L.prototype),K=new R(G||[]);return W._invoke=((ce,$,z)=>{var k="suspendedStart";return(M,V)=>{if(k==="executing")throw new Error("Generator is already running");if(k==="completed"){if(M==="throw")throw V;return C()}for(z.method=M,z.arg=V;;){var q=z.delegate;if(q){var he=T(q,z);if(he){if(he===c)continue;return he}}if(z.method==="next")z.sent=z._sent=z.arg;else if(z.method==="throw"){if(k==="suspendedStart")throw k="completed",z.arg;z.dispatchException(z.arg)}else z.method==="return"&&z.abrupt("return",z.arg);k="executing";var pe=l(ce,$,z);if(pe.type==="normal"){if(k=z.done?"completed":"suspendedYield",pe.arg===c)continue;return{value:pe.arg,done:z.done}}pe.type==="throw"&&(k="completed",z.method="throw",z.arg=pe.arg)}}})(S,P,K),W}function l(S,w,P){try{return{type:"normal",arg:S.call(w,P)}}catch(G){return{type:"throw",arg:G}}}a.wrap=h;var c={};function u(){}function f(){}function d(){}var _={};o(_,s,function(){return this});var p=Object.getPrototypeOf,g=p&&p(p(E([])));g&&g!==e&&t.call(g,s)&&(_=g);var m=d.prototype=u.prototype=Object.create(_);function b(S){["next","throw","return"].forEach(function(w){o(S,w,function(P){return this._invoke(w,P)})})}function I(S,w){function P(L,W,K,ce){var $=l(S[L],S,W);if($.type!=="throw"){var z=$.arg,k=z.value;return k&&typeof k=="object"&&t.call(k,"__await")?w.resolve(k.__await).then(M=>{P("next",M,K,ce)},M=>{P("throw",M,K,ce)}):w.resolve(k).then(M=>{z.value=M,K(z)},M=>P("throw",M,K,ce))}ce($.arg)}var G;this._invoke=(L,W)=>{function K(){return new w((ce,$)=>{P(L,W,ce,$)})}return G=G?G.then(K,K):K()}}function T(S,w){var P=S.iterator[w.method];if(P===void 0){if(w.delegate=null,w.method==="throw"){if(S.iterator.return&&(w.method="return",w.arg=void 0,T(S,w),w.method==="throw"))return c;w.method="throw",w.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var G=l(P,S.iterator,w.arg);if(G.type==="throw")return w.method="throw",w.arg=G.arg,w.delegate=null,c;var L=G.arg;return L?L.done?(w[S.resultName]=L.value,w.next=S.nextLoc,w.method!=="return"&&(w.method="next",w.arg=void 0),w.delegate=null,c):L:(w.method="throw",w.arg=new TypeError("iterator result is not an object"),w.delegate=null,c)}function x(S){var w={tryLoc:S[0]};1 in S&&(w.catchLoc=S[1]),2 in S&&(w.finallyLoc=S[2],w.afterLoc=S[3]),this.tryEntries.push(w)}function y(S){var w=S.completion||{};w.type="normal",delete w.arg,S.completion=w}function R(S){this.tryEntries=[{tryLoc:"root"}],S.forEach(x,this),this.reset(!0)}function E(S){if(S){var w=S[s];if(w)return w.call(S);if(typeof S.next=="function")return S;if(!isNaN(S.length)){var P=-1,G=function L(){for(;++P<S.length;)if(t.call(S,P))return L.value=S[P],L.done=!1,L;return L.value=void 0,L.done=!0,L};return G.next=G}}return{next:C}}function C(){return{value:void 0,done:!0}}return f.prototype=d,o(m,"constructor",d),o(d,"constructor",f),f.displayName=o(d,r,"GeneratorFunction"),a.isGeneratorFunction=S=>{var w=typeof S=="function"&&S.constructor;return!!w&&(w===f||(w.displayName||w.name)==="GeneratorFunction")},a.mark=S=>(Object.setPrototypeOf?Object.setPrototypeOf(S,d):(S.__proto__=d,o(S,r,"GeneratorFunction")),S.prototype=Object.create(m),S),a.awrap=S=>({__await:S}),b(I.prototype),o(I.prototype,n,function(){return this}),a.AsyncIterator=I,a.async=(S,w,P,G,L)=>{L===void 0&&(L=Promise);var W=new I(h(S,w,P,G),L);return a.isGeneratorFunction(w)?W:W.next().then(K=>K.done?K.value:W.next())},b(m),o(m,r,"Generator"),o(m,s,function(){return this}),o(m,"toString",()=>"[object Generator]"),a.keys=S=>{var w=[];for(var P in S)w.push(P);return w.reverse(),function G(){for(;w.length;){var L=w.pop();if(L in S)return G.value=L,G.done=!1,G}return G.done=!0,G}},a.values=E,R.prototype={constructor:R,reset:function(S){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(y),!S)for(var w in this)w.charAt(0)==="t"&&t.call(this,w)&&!isNaN(+w.slice(1))&&(this[w]=void 0)},stop:function(){this.done=!0;var S=this.tryEntries[0].completion;if(S.type==="throw")throw S.arg;return this.rval},dispatchException:function(S){if(this.done)throw S;var w=this;function P($,z){return W.type="throw",W.arg=S,w.next=$,z&&(w.method="next",w.arg=void 0),!!z}for(var G=this.tryEntries.length-1;G>=0;--G){var L=this.tryEntries[G],W=L.completion;if(L.tryLoc==="root")return P("end");if(L.tryLoc<=this.prev){var K=t.call(L,"catchLoc"),ce=t.call(L,"finallyLoc");if(K&&ce){if(this.prev<L.catchLoc)return P(L.catchLoc,!0);if(this.prev<L.finallyLoc)return P(L.finallyLoc)}else if(K){if(this.prev<L.catchLoc)return P(L.catchLoc,!0)}else{if(!ce)throw new Error("try statement without catch or finally");if(this.prev<L.finallyLoc)return P(L.finallyLoc)}}}},abrupt:function(S,w){for(var P=this.tryEntries.length-1;P>=0;--P){var G=this.tryEntries[P];if(G.tryLoc<=this.prev&&t.call(G,"finallyLoc")&&this.prev<G.finallyLoc){var L=G;break}}L&&(S==="break"||S==="continue")&&L.tryLoc<=w&&w<=L.finallyLoc&&(L=null);var W=L?L.completion:{};return W.type=S,W.arg=w,L?(this.method="next",this.next=L.finallyLoc,c):this.complete(W)},complete:function(S,w){if(S.type==="throw")throw S.arg;return S.type==="break"||S.type==="continue"?this.next=S.arg:S.type==="return"?(this.rval=this.arg=S.arg,this.method="return",this.next="end"):S.type==="normal"&&w&&(this.next=w),c},finish:function(S){for(var w=this.tryEntries.length-1;w>=0;--w){var P=this.tryEntries[w];if(P.finallyLoc===S)return this.complete(P.completion,P.afterLoc),y(P),c}},catch:function(S){for(var w=this.tryEntries.length-1;w>=0;--w){var P=this.tryEntries[w];if(P.tryLoc===S){var G=P.completion;if(G.type==="throw"){var L=G.arg;y(P)}return L}}throw new Error("illegal catch attempt")},delegateYield:function(S,w,P){return this.delegate={iterator:E(S),resultName:w,nextLoc:P},this.method==="next"&&(this.arg=void 0),c}},a}function e0(a){return e0=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?e=>typeof e:e=>e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e,e0(a)}function vl(a,e,t,i,s,n,r){try{var o=a[n](r),h=o.value}catch(l){return void t(l)}o.done?e(h):Promise.resolve(h).then(i,s)}function Gi(a){return function(){var e=this,t=arguments;return new Promise((i,s)=>{var n=a.apply(e,t);function r(h){vl(n,i,s,r,o,"next",h)}function o(h){vl(n,i,s,r,o,"throw",h)}r(void 0)})}}function Mt(a,e){if(!(a instanceof e))throw new TypeError("Cannot call a class as a function")}function bl(a,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(a,i.key,i)}}function Pt(a,e,t){return e&&bl(a.prototype,e),t&&bl(a,t),Object.defineProperty(a,"prototype",{writable:!1}),a}function ff(a,e,t){return e in a?Object.defineProperty(a,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):a[e]=t,a}function Yi(a,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(e&&e.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),e&&t0(a,e)}function Ur(a){return Ur=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Ur(a)}function t0(a,e){return t0=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},t0(a,e)}function Rb(a,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(a)}function qi(a){var e=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],()=>{})),!0}catch{return!1}}();return function(){var t,i=Ur(a);if(e){var s=Ur(this).constructor;t=Reflect.construct(i,arguments,s)}else t=i.apply(this,arguments);return Rb(this,t)}}function xl(a,e){return function(t){if(Array.isArray(t))return t}(a)||function(t,i){var s=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(s!=null){var n,r,o=[],h=!0,l=!1;try{for(s=s.call(t);!(h=(n=s.next()).done)&&(o.push(n.value),!i||o.length!==i);h=!0);}catch(c){l=!0,r=c}finally{try{h||s.return==null||s.return()}finally{if(l)throw r}}return o}}(a,e)||oo(a,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function yl(a){return function(e){if(Array.isArray(e))return i0(e)}(a)||function(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}(a)||oo(a)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function oo(a,e){if(a){if(typeof a=="string")return i0(a,e);var t=Object.prototype.toString.call(a).slice(8,-1);return t==="Object"&&a.constructor&&(t=a.constructor.name),t==="Map"||t==="Set"?Array.from(a):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i0(a,e):void 0}}function i0(a,e){(e==null||e>a.length)&&(e=a.length);for(var t=0,i=new Array(e);t<e;t++)i[t]=a[t];return i}function js(a,e,t,i){var s=Number(a.substring(1));return s=s||0,t?s+e:s+i}function kr(){return new Promise(a=>setTimeout(a)).then(()=>Date.now())}var Ib=Math.PI/2,Eb=new v(2,2,2),Tl=function(){function a(){Mt(this,a),this.tool=0,this.start=v.Zero(),this.end=v.Zero(),this.extruding=!1,this.gcodeLineNumber=0,this.gcodeFilePosition=0,this.color=null,this.feedRate=0,this.layerHeight=0,this.isPerimeter=!1}return Pt(a,[{key:"length",value:function(){return v.Distance(this.start,this.end)}},{key:"renderLine",value:function(e){var t=[this.start,this.end],i=Zt.CreateLines("lines",t,e);i.enableEdgesRendering(),i.edgesWidth=10,i.edgesColor=new H(1,1,0,1)}},{key:"renderLinev4",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:.4,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.layerHeight===0&&(this.layerHeight=this.start.y);var i={},s=this.length()+t,n=this.start.add(this.end).divide(Eb),r=this.end.subtract(this.start),o=Math.sqrt(Math.pow(r.x,2)+Math.pow(r.y,2)+Math.pow(r.z,2)),h=Math.atan2(r.z,r.x),l=Math.acos(r.y/o);return i.matrix=O.Compose(new v(s,this.layerHeight,e),re.FromEulerVector(new v(0,-h,Ib-l)),n),i.color=this.color,i.props={gcodeLineNumber:this.gcodeLineNumber,gcodeFilePosition:this.gcodeFilePosition,originalColor:this.color},i}},{key:"renderParticle",value:function(e){e.position.x=this.start.x,e.position.y=this.start.y,e.position.z=this.start.z,e.color=this.color}},{key:"getPoints",value:function(){return{points:[this.start,this.end],colors:[this.color,this.color]}}},{key:"getColor",value:function(){return this.extruding?new H(1,1,1,1):new H(1,0,0,1)}},{key:"getVoxelSegments",value:function(e,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,s=arguments.length>3?arguments[3]:void 0,n=new Array,r=v.Distance(this.start,this.end);if(!(r<.1)){var o=Math.round(100*(r/(e/2)-1))/100,h=Math.atan2(this.end.z-this.start.z,this.end.x-this.start.x);s&&(this.start.y-=e/2,this.end.y-=e/2);var l=this.start.clone(),c=0;n.push(l.clone());var u=e/2*Math.cos(h),f=e/2*Math.sin(h),d=0;for(o!==0&&(d=(this.end.y-this.start.y)/o);c<o;){if(l.x+=u,l.y+=d,l.z+=f,n.push(l.clone()),i>e)for(var _=l.x-i;_<=l.x+i;_+=e)for(var p=l.z-i;p<l.z+i;p+=e)n.push(new v(_,l.y,p));c++}if(n.push(this.end.clone()),this.layerHeight>t&&s){for(var g=[],m=0;m<n.length;m++)for(var b=n[m],I=1;I<Math.ceil(this.layerHeight/t);I++)g.push(new v(b.x,b.y-I*t,b.z));n.push.apply(n,g)}return n}}}]),a}(),s0={Extruder:"Extruder"},$s=.3,fr=function(){function a(){Mt(this,a),this.name="",this.color=new H(0,0,1,1),this.updateDarkerValue(),this.diameter=.4,this.toolType=s0.Extruder}return Pt(a,[{key:"colorString",get:function(){return this.color.toHexString()},set:function(e){this.color=H.FromHexString(e+"FF"),this.updateDarkerValue()}},{key:"updateDarkerValue",value:function(){this.color.r<.3&&this.color.g<.3&&this.color.b<.3?this.colorDarker=this.color.add(new H($s,$s,$s,0)):this.colorDarker=this.color.subtract(new H($s,$s,$s,0))}},{key:"isAdditive",value:function(){return this.toolType===s0.Extruder}},{key:"getDiameter",value:function(){return this.diameter}},{key:"toJson",value:function(){return JSON.stringify(this)}}],[{key:"fromJson",value:function(e){var t;t=e0(e)==="object"?e:JSON.parse(e);var i=new a;return i.name=t.name,i.color=new H(t.color.r,t.color.g,t.color.b,t.color.a),i.diameter=parseFloat(t.diameter),i.toolType=t.toolType,i}}]),a}();new Array;var Ss={Block:1,Line:2,Point:3,Voxel:5},ts={Color:0,Feed:1,Feature:2},ca=function(){function a(e,t,i,s,n){Mt(this,a),this.scene=e,this.specularColor=t,this.loadingProgressCallback=i,this.renderFuncs=s,this.solidMat,this.transparentMat,this.previousFilePosition=0,this.currentFilePosition=0,this.tools=n,this.scrubDistance=10,this.progressColor=new H(0,1,0,1),this.isLoading=!0,this.vertexAlpha=!1,this.forceRedraw=!1,this.material=null,this.fadeRate=.2,this.transparentValue=.25,this.renderRange=0,this.g1AsExtrusion=!1,this.progressMode=!1,this.hasMixing=!1,this.colorMode=ts.Color,this.renderAnimation=!0,this.timeStamp=0,this.persistTravels=!1}return Pt(a,[{key:"updateFilePosition",value:function(e){this.previousFilePosition=this.currentFilePosition-5,this.currentFilePosition=e+5}},{key:"updateLiveTrackingShowSolid",value:function(e){this.liveTrackingShowSolid=e}},{key:"lerp",value:function(e,t,i){return e+(t-e)*i}},{key:"doScrub",value:function(e,t,i){return Math.abs(e-this.currentFilePosition)>5e4||this.currentFilePosition<e&&Math.abs(e-this.currentFilePosition)>this.scrubDistance&&e>=t-1e3&&e<=i+1e3}},{key:"getTransparentValue",value:function(){return this.vertexAlpha?this.transparentValue:0}},{key:"canUpdateColor",value:function(){return this.colorMode==ts.Color&&!this.hasMixing}},{key:"forceDraw",value:function(){this.timeStamp=0}}]),a}(),Cb=function(a){Yi(t,ca);var e=qi(t);function t(i,s,n,r,o,h){var l;return Mt(this,t),(l=e.call(this,i,s,n,r,o)).meshIndex=h!=null?h:0,l.lostInSpace=O.Identity().setTranslation(new v(1e4,1e4,1e4)),l.additiveColor=new H(0,1,0,.8),l}return Pt(t,[{key:"buildBox",value:function(){if(this.solidMat)try{this.solidMat.dispose(),this.solidMat=null}catch{console.warn("nothing to dispose")}if(this.transparentMat)try{this.transparentMat.dispose(),this.transparentMat=null}catch{console.warn("nothing to dispose")}var i=Zt.CreateBox("box",{width:1,height:1,depth:1,sideOrientation:F.FRONTSIDE},this.scene);return this.material=new ee("mat",this.scene),this.material.specularColor=this.specularColor,i.material=this.material,this.vertexAlpha&&(i.hasVertexAlpha=!0,i.material.forceDepthWrite=!0,i.material.alpha=.99),i}},{key:"render",value:function(i){for(var s=this,n=new Array(i.length),r=0,o=new Array(i.length),h=0;h<i.length;h++){var l=i[h];if(l==null)break;var c=this.tools[l.tool];if(l.extruding){var u=l.renderLinev4(this.g1AsExtrusion?1:c.getDiameter(),.1),f={};f.matrix=u.matrix,f.color=u.color,f.tool=l.tool,n[r++]=f,o[h]=u.props.gcodeFilePosition}}for(var d=new Float32Array(16*r),_=new Float32Array(4*r),p=new Array(r),g=0;g<r;g++){var m=n[g];m.matrix.copyToArray(d,16*g),m.color.toArray(_,4*g),_[4*g+3]=this.getTransparentValue(),p[h]=!1}var b=this.buildBox();b.alphaIndex=this.meshIndex,b.renderingGroupId=2,b.thinInstanceSetBuffer("matrix",d,16,!1),b.thinInstanceSetBuffer("color",_,4,!1),b.thinInstanceRefreshBoundingInfo();var I=function(){for(var S=R,w=R,P=0;P<r;P++){var G=16*P,L=4*P;if(s.canUpdateColor()&&(n[P].color=s.hasMixing?n[P].color:s.tools[n[P].tool].color),!R||s.progressMode){if(!p[P])if(s.progressMode){if(o[P]<=s.currentFilePosition){_[L]=s.progressColor.r,_[L+1]=s.progressColor.g,_[L+2]=s.progressColor.b,_[L+3]=1,S=!0;continue}n[P].color.toArray(_,L),_[L+3]=s.getTransparentValue(),S=!0,n[P].matrix.copyToArray(d,G),w=!0}else{if(o[P]<=s.currentFilePosition&&_[L+3]<.5&&(s.renderAnimation&&s.progressColor.toArray(_,L),_[L+3]=s.renderAnimation?.9:2,S=!0,n[P].matrix.copyToArray(d,G),w=!0,s.renderAnimation))continue;if(_[L+3]>.5&&_[L+3]<1){_[L+3]+=.02;var W=10*(_[L+3]-.9);_[L]=s.lerp(s.progressColor.r,n[P].color.r,W),_[L+1]=s.lerp(s.progressColor.g,n[P].color.g,W),_[L+2]=s.lerp(s.progressColor.b,n[P].color.b,W),S=!0}_[L+3]>=1&&!p[P]&&(n[P].color.toArray(_,L),_[L+3]=1,p[P]=!0,S=!0)}}else o[P]<=s.currentFilePosition?(n[P].color.toArray(_,L),n[P].matrix.copyToArray(d,16*P),_[L+3]=1,p[P]=!0):(s.getTransparentValue()===0?s.lostInSpace.copyToArray(d,16*P):n[P].matrix.copyToArray(d,16*P),_[L+3]=s.getTransparentValue(),p[P]=!1)}S&&b.thinInstanceBufferUpdated("color"),w&&(b.thinInstanceBufferUpdated("matrix"),b.thinInstanceRefreshBoundingInfo())};if(i.length!==0){var T=i[0].gcodeFilePosition,x=i.slice(-1)[0].gcodeFilePosition,y=0,R=!1,E=!1;this.timeStamp=Date.now();var C=function(){if(!(s.isLoading||Date.now()-s.timeStamp<200)){if(s.timeStamp=Date.now(),s.doScrub(y,T,x)||s.forceRedraw){R=!0,s.forceRedraw=!1,y=0;for(var S=0;S<p.length;S++)p[S]=!1;E&&b.unfreezeWorldMatrix(),I()}else s.currentFilePosition>=T-3e4&&s.currentFilePosition<=x+3e4?(R=!1,E&&b.unfreezeWorldMatrix(),I()):E||(b.freezeWorldMatrix(),E=!0);y=s.currentFilePosition}};this.renderFuncs.push(C),this.scene.registerBeforeRender(C)}}}]),t}(),Sb=function(a){Yi(t,ca);var e=qi(t);function t(i,s,n,r,o,h){var l;return Mt(this,t),(l=e.call(this,i,s,n,r,o)).meshIndex=h!=null?h:0,l.lostInSpace=O.Identity().setTranslation(new v(1e4,1e4,1e4)),l.additiveColor=new H(0,1,0,.8),l}return Pt(t,[{key:"buildCylinder",value:function(){if(this.solidMat)try{this.solidMat.dispose(),this.solidMat=null}catch{console.warn("nothing to dispose")}if(this.transparentMat)try{this.transparentMat.dispose(),this.transparentMat=null}catch{console.warn("nothing to dispose")}var i=Zt.CreateCylinder("box",{height:1,diameter:1},this.scene);return i.locallyTranslate(new v(0,0,0)),i.rotate(new v(0,0,1),Math.PI/2,ci.WORLD),i.bakeCurrentTransformIntoVertices(),this.material=new ee("mat",this.scene),this.material.specularColor=this.specularColor,i.material=this.material,this.vertexAlpha&&(i.hasVertexAlpha=!0,i.material.forceDepthWrite=!0,i.material.alpha=.99),i}},{key:"render",value:function(i){for(var s=this,n=new Array(i.length),r=0,o=new Array(i.length),h=0;h<i.length;h++){var l=i[h];if(l==null)break;var c=this.tools[l.tool];if(l.extruding){var u=l.renderLinev4(this.g1AsExtrusion?1:c.getDiameter(),.1),f={};f.matrix=u.matrix,f.color=u.color,f.tool=l.tool,n[r++]=f,o[h]=u.props.gcodeFilePosition}}for(var d=new Float32Array(16*r),_=new Float32Array(4*r),p=new Array(r),g=0;g<r;g++){var m=n[g];m.matrix.copyToArray(d,16*g),m.color.toArray(_,4*g),_[4*g+3]=this.getTransparentValue(),p[g]=!1}var b=this.buildCylinder();b.thinInstanceSetBuffer("matrix",d,16,!1),b.thinInstanceSetBuffer("color",_,4,!1),b.thinInstanceRefreshBoundingInfo(),b.alphaIndex=this.meshIndex,b.renderingGroupId=2;var I=function(){for(var S=R,w=R,P=0;P<r;P++){var G=16*P,L=4*P;if(s.canUpdateColor()&&(n[P].color=s.hasMixing?n[P].color:s.tools[n[P].tool].color),!R||s.progressMode){if(!p[P])if(s.progressMode){if(o[P]<=s.currentFilePosition){_[L]=s.progressColor.r,_[L+1]=s.progressColor.g,_[L+2]=s.progressColor.b,_[L+3]=1,S=!0;continue}n[P].color.toArray(_,L),_[L+3]=s.getTransparentValue(),S=!0,n[P].matrix.copyToArray(d,G),w=!0}else{if(o[P]<=s.currentFilePosition&&_[L+3]<.5&&(s.renderAnimation&&s.progressColor.toArray(_,L),_[L+3]=s.renderAnimation?.9:2,S=!0,n[P].matrix.copyToArray(d,G),w=!0,s.renderAnimation))continue;if(_[L+3]>.5&&_[L+3]<1){_[L+3]+=.02;var W=10*(_[L+3]-.9);_[L]=s.lerp(s.progressColor.r,n[P].color.r,W),_[L+1]=s.lerp(s.progressColor.g,n[P].color.g,W),_[L+2]=s.lerp(s.progressColor.b,n[P].color.b,W)}_[L+3]>=1&&!p[P]&&(n[P].color.toArray(_,L),_[L+3]=1,p[P]=!0,S=!0)}}else o[P]<=s.currentFilePosition?(n[P].color.toArray(_,L),n[P].matrix.copyToArray(d,G),_[L+3]=1,p[P]=!0):(s.getTransparentValue()===0?s.lostInSpace.copyToArray(d,G):n[P].matrix.copyToArray(d,G),_[L+3]=s.getTransparentValue(),p[P]=!1)}S&&b.thinInstanceBufferUpdated("color"),w&&(b.thinInstanceBufferUpdated("matrix"),b.thinInstanceRefreshBoundingInfo())};if(i.length!==0){var T=i[0].gcodeFilePosition,x=i.slice(-1)[0].gcodeFilePosition,y=0,R=!1,E=!1;this.timeStamp=Date.now();var C=function(){if(!(s.isLoading||Date.now()-s.timeStamp<200)){if(s.timeStamp=Date.now(),s.doScrub(y,T,x)||s.forceRedraw){R=!0,s.forceRedraw=!1,y=0;for(var S=0;S<p.length;S++)p[S]=!1;E&&b.unfreezeWorldMatrix(),I()}else s.currentFilePosition>=T-3e4&&s.currentFilePosition<=x+3e4?(R=!1,E&&b.unfreezeWorldMatrix(),I()):E||(E=!0,b.freezeWorldMatrix());y=s.currentFilePosition}};this.renderFuncs.push(C),this.scene.registerBeforeRender(C)}}}]),t}(),Mb=Pt(function a(e,t){Mt(this,a),this.filePosition=e,this.add=t,this.complete=!1}),df=function(a){Yi(i,ca);var e,t=qi(i);function i(s,n,r,o,h,l,c){var u;return Mt(this,i),(u=t.call(this,s,n,r,o,h)).voxelWidth=parseFloat(l),u.voxelHeight=parseFloat(c),u.solidMat,u.transparentMat,u.hasSubtractive=!1,u.lostInSpace=O.Identity().setTranslation(new v(1e4,1e4,1e4)),u.clearColor=new H(1,0,0,0),u.additiveColor=new H(0,1,0,.8),u.subtractiveColor=new H(1,0,0,.8),u}return Pt(i,[{key:"buildBox",value:function(){if(this.solidMat)try{this.solidMat.dispose(),this.solidMat=null}catch{}if(this.transparentMat)try{this.transparentMat.dispose(),this.transparentMat=null}catch{}var s=Zt.CreateBox("box",{width:this.voxelWidth,height:this.voxelHeight,depth:this.voxelWidth},this.scene);return s.hasVertexAlpha=!0,s.updateFacetData=!0,this.material=new ee("mat",this.scene),this.material.needDepthPrePass=!0,this.material.forceDepthWrite=!0,this.material.backFaceCulling=!1,s.material=this.material,s}},{key:"render",value:(e=Gi(It().mark(function s(n){var r,o,h,l,c,u,f,d,_,p,g,m,b,I,T,x,y,R,E,C,S,w=this;return It().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:for(this.isLoading=!0,r=parseInt(300/this.voxelWidth)+1,o=r,h=parseInt(300/this.voxelHeight)+1,l=new Array(o),c=0;c<=h;c++)l[c]=new Object;u=0,f=new Date,d=0;case 10:if(!(d<n.length)){P.next=63;break}if((_=n[d])!=null){P.next=14;break}return P.abrupt("break",63);case 14:if(p=this.tools[_.tool],_.extruding){P.next=17;break}return P.abrupt("continue",60);case 17:if((g=_.getVoxelSegments(this.voxelWidth,this.voxelHeight,p.getDiameter()/2,p.isAdditive()))!==void 0&&g.length!==0){P.next=20;break}return P.abrupt("continue",60);case 20:m=new Mb(_.gcodeFilePosition,p.isAdditive()),b=0;case 22:if(!(b<g.length)){P.next=60;break}if(I=g[b],T=Math.floor(I.x/this.voxelWidth),x=Math.floor(I.y/this.voxelHeight),y=Math.floor(I.z/this.voxelWidth),x<0&&(x=0),x!==u&&p.isAdditive()&&(u=x),p.toolType!=="Extruder"){P.next=35;break}R=null;try{R=l[x][T][y]}catch{R=null}if(R)R.voxelEvents.push(m);else try{Object.prototype.hasOwnProperty.call(l[x],T)||(l[x][T]={}),l[x][T][y]={color:_.color,voxelEvents:[m]}}catch(G){console.log(G),console.log("".concat(T," ").concat(x," ").concat(y))}P.next=51;break;case 35:this.hasSubtractive=!0,E=x;case 37:if(!(E<=u+1)){P.next=51;break}P.prev=38,l[E][T][y]?l[E][T][y].voxelEvents.push(m):(Object.prototype.hasOwnProperty.call(l[E],T)||(l[E][T]={}),l[E][T][y]={color:_.color,voxelEvents:[m]}),P.next=48;break;case 42:if(P.prev=42,P.t0=P.catch(38),!(E<0)){P.next=46;break}return P.abrupt("continue",48);case 46:Object.prototype.hasOwnProperty.call(l[E],T)||(l[E][T]={}),l[E][T][y]={color:_.color,voxelEvents:[m]};case 48:E++,P.next=37;break;case 51:if(n[d]=null,!(d%1e4==0||new Date-f>5e3)){P.next=57;break}return f=new Date,this.loadingProgressCallback(d/n.length,"Generating Voxel Map..."),P.next=57,kr();case 57:b++,P.next=22;break;case 60:d++,P.next=10;break;case 63:this.loadingProgressCallback(d/n.length,"Rendering Voxel..."),C=It().mark(function G(L){var W,K,ce,$,z,k,M,V,q,he,pe,se,ue,me,ne,Ie,Se,Q,be,Be,ze,Ke,Rt,Ct,Ge,Jt,Wt,ji,Is;return It().wrap(Ti=>{for(;;)switch(Ti.prev=Ti.next){case 0:if(W=[],l[L]!==void 0){Ti.next=3;break}return Ti.abrupt("return","continue");case 3:for(K=999999999999,ce=-999999999999,$=[],z=0,k=Object.entries(l[L]);z<k.length;z++)for(M=xl(k[z],2),V=M[0],q=M[1],he=0,pe=Object.entries(q);he<pe.length;he++)ue=xl(pe[he],2),me=ue[0],(ne=ue[1]).voxelEvents[0].filePosition<K&&(K=ne.voxelEvents[0].filePosition),ne.voxelEvents.slice()[0].filePosition>ce&&(ce=ne.voxelEvents[0].filePosition),(se=$).push.apply(se,yl(ne.voxelEvents.map(Ht=>Ht.filePosition))),ne.color.a=1,(Ie={matrix:O.Identity(),color:ne.color.clone(),voxelEvents:ne.voxelEvents,lastDrawnCount:0}).matrix.setTranslation(new v(V*w.voxelWidth,L*w.voxelHeight,me*w.voxelWidth)),W.push(Ie);for(Se=0,$=$.sort((Ht,oi)=>Ht-oi),$=yl(new Set($)),W.length,l[L]=null,(Q=w.buildBox()).alphaIndex=L,Q.renderingGroupId=1,be=new Float32Array(16*W.length),Be=new Float32Array(4*W.length),ze=0;ze<W.length;ze++){Ke=W[ze];try{Ke&&(Ke.matrix.copyToArray(be,16*ze),Ke.color.toArray(Be,4*ze),w.hasSubtractive||delete Ke.matrix)}catch(Ht){console.log(Ht)}}if(Q.thinInstanceSetBuffer("matrix",be,16,!1),Q.thinInstanceSetBuffer("color",Be,4,!1),Q.thinInstanceRefreshBoundingInfo(),Rt=()=>{for(var Ht=!1,oi=!1,Vt=0;Vt<W.length;Vt++){var Yt=W[Vt];Jt&&(w.clearColor.toArray(Be,4*Vt),w.hasSubtractive&&w.lostInSpace.copyToArray(be,16*Vt));var $i=Yt.voxelEvents.filter(tr=>tr.filePosition<w.currentFilePosition).slice(-1)[0];$i!=null&&($i.add?($i.filePosition>Ct&&$i.filePosition<=w.currentFilePosition&&(Yt.lastDrawnCount=0,w.hasSubtractive&&Yt.matrix.copyToArray(be,16*Vt)),Jt&&(Yt.lastDrawnCount=i.drawDelay),Yt.lastDrawnCount<i.drawDelay?(w.additiveColor.toArray(Be,4*Vt),Yt.lastDrawnCount++):(Yt.color.toArray(Be,4*Vt),w.hasSubtractive&&Yt.matrix.copyToArray(be,16*Vt))):($i.filePosition>=Ct&&$i.filePosition<=w.currentFilePosition&&(Yt.lastDrawnCount=0),Jt&&(Yt.lastDrawnCount=i.drawDelay),Yt.lastDrawnCount<i.drawDelay?(w.subtractiveColor.toArray(Be,4*Vt),Yt.lastDrawnCount++):(Ht=!0,w.clearColor.toArray(Be,4*Vt),w.hasSubtractive&&w.lostInSpace.copyToArray(be,16*Vt),oi=!0)))}Q.thinInstanceBufferUpdated("color"),Ht&&Q.thinInstanceRefreshBoundingInfo(),oi&&(Q.thinInstanceRefreshBoundingInfo(),Q.thinInstanceBufferUpdated("matrix"))},Ct=0,Ge=!0,Jt=!1,Wt=Number.MAX_VALUE,ji=Date.now(),Is=()=>{if(!(w.isLoading||Date.now()-ji<200)){if(ji=Date.now(),w.doScrub(Ct,K,ce)||Ge||w.forceRedraw){Se=0,Jt=!0,w.forceRedraw=!1;for(var Ht=0;Ht<W.length;Ht++)W[Ht].voxelEvents.forEach(Vt=>Vt.complete=!1);Rt(),Ge=!1}else if(Se<$.length-1&&$[Se]<w.currentFilePosition){Jt=!1,Wt=0,Rt();for(var oi=Se;oi<$.length&&(Se=oi,!($[oi]>w.currentFilePosition));oi++);}else Wt<10&&(Wt++,Rt());Ct=w.currentFilePosition}},w.loadingProgressCallback&&w.loadingProgressCallback(L/u,"Rendering Voxels..."),w.renderFuncs.push(Is),w.scene.registerBeforeRender(Is),!(new Date-f>1e3)){Ti.next=36;break}return f=new Date,Ti.next=36,kr();case 36:case"end":return Ti.stop()}},G,this)}),S=0;case 67:if(!(S<u)){P.next=75;break}return P.delegateYield(C(S),"t1",69);case 69:if(P.t1!=="continue"){P.next=72;break}return P.abrupt("continue",72);case 72:S++,P.next=67;break;case 75:this.isLoading=!1,this.loadingProgressCallback(1),l=null;case 78:case"end":return P.stop()}},s,this,[[38,42]])})),function(s){return e.apply(this,arguments)})}]),i}();ff(df,"drawDelay",5);var Al=function(a){Yi(t,ca);var e=qi(t);function t(i,s,n,r,o,h){var l;return Mt(this,t),(l=e.call(this,i,s,n,r,o)).meshIndex=h!=null?h:0,l.additiveColor=new H(0,1,0,.8),l.travels=!1,l.travelColorArray=[new H(1,0,0,1),new H(1,0,0,1)],l}return Pt(t,[{key:"render",value:function(i){var s=this,n=new Array(i.length);this.renderMode="Line Rendering";for(var r=new Array(i.length),o=new Array(i.length),h=new Array(i.length),l=new Array(i.length),c=new Array(i.length),u=new Array(i.length),f=0;f<i.length;f++){var d=i[f];if(d==null)break;var _=this.tools[d.tool];n[f]=d.gcodeFilePosition;var p=d.getPoints(this.scene);r[f]=p.points,o[f]=this.travels?this.travelColorArray:p.colors,c[f]=d.tool,u[f]=d.isPerimeter,h[f]=_.isAdditive()&&!this.travels,l[f]=!1}var g=Zt.CreateLineSystem(this.travels?"travels":"lineMesh",{lines:r,colors:o,updatable:!0},this.scene);r=null,g.isVisible=!0,g.isPickable=!1,g.markVerticesDataAsUpdatable(A.ColorKind),g.material.backFaceCulling=!1,g.material.forceDepthWrite=!0,g.material.specularColor=this.specularColor,g.alphaIndex=this.meshIndex,g.renderingGroupId=2;var m=n[0],b=n.slice(-1)[0],I=0,T=!1,x=0,y=function(){var C=g.getVerticesData(A.ColorKind);if(C){var S=-1,w=-1;if(T){for(var P=0;P<n.length;P++){var G=8*P;s.canUpdateColor()&&!s.travels&&(u[P]?o[P]=[s.tools[c[P]].color,s.tools[c[P]].color]:o[P]=[s.tools[c[P]].colorDarker,s.tools[c[P]].colorDarker]),s.travels&&!s.persistTravels?(C[G+3]=0,C[G+7]=0,l[P]=n[P]<=s.currentFilePosition):s.travels&&s.persistTravels?(o[P][0].toArray(C,G),o[P][1].toArray(C,G+4),C[G+3]=n[P]<=s.currentFilePosition?1:0,C[G+7]=n[P]<=s.currentFilePosition?1:0,l[P]=n[P]<=s.currentFilePosition):n[P]<=s.currentFilePosition&&!s.progressMode?(o[P][0].toArray(C,G),o[P][1].toArray(C,G+4),C[G+3]=h[P]?1:0,C[G+7]=h[P]?1:0,l[P]=!0):(s.progressMode&&(o[P][0].toArray(C,G),o[P][1].toArray(C,G+4),C[G+3]=s.getTransparentValue(),C[G+7]=s.getTransparentValue()),C[G+3]=h[P]?s.getTransparentValue():0,C[G+7]=h[P]?s.getTransparentValue():0,l[P]=!1)}x=0,g.updateVerticesData(A.ColorKind,C,!0)}for(var L=x;L<n.length;L++)n[L]<=s.currentFilePosition&&(S=L),n[L]<=s.currentFilePosition&&(w=L);for(var W=l.findIndex(z=>z===!1);W<=S;W++){var K=8*W;if(h[W]||s.travels&&s.persistTravels){if(l[W])continue;s.progressMode||C[K+3]<=.5?(C[K]=s.progressColor.r,C[K+1]=s.progressColor.g,C[K+2]=s.progressColor.b,C[K+3]=.9,C[K+4]=s.progressColor.r,C[K+5]=s.progressColor.g,C[K+6]=s.progressColor.b,C[K+7]=.9):C[K+3]<1?(C[K+3]+=.02,C[K+7]+=.02):C[K+3]>=1&&(C[K]=o[W][0].r,C[K+1]=o[W][0].g,C[K+2]=o[W][0].b,C[K+3]=1,C[K+4]=o[W][1].r,C[K+5]=o[W][1].g,C[K+6]=o[W][1].b,C[K+7]=1,l[W]=!0)}else{if(l[W])continue;C[K+3]===0?(C[K]=1,C[K+1]=0,C[K+2]=0,C[K+3]=.9,C[K+4]=1,C[K+5]=0,C[K+6]=0,C[K+7]=.9):C[K+3]<1?(C[K+3]+=.02,C[K+7]+=.02):(C[K+3]=1e-4,C[K+7]=1e-4,l[W]=!0)}x=W}for(var ce=S;ce<w;ce++){var $=8*ce;C[$+3]=1,C[$+7]=1}g.updateVerticesData(A.ColorKind,C,!0)}else console.log("Error")},R=Date.now(),E=function(){if(!(s.isLoading||Date.now()-R<200)){if(R=Date.now(),s.doScrub(I,m,b)||s.forceRedraw){s.forceRedraw=!1,T=!0;for(var C=0;C<l.length;C++)l[C]=!1;x=0,I=0,y()}else s.currentFilePosition>=m-3e4&&s.currentFilePosition<=b+3e4&&(T=!1,y());I=s.currentFilePosition}};this.renderFuncs.push(E),this.scene.registerBeforeRender(E)}}]),t}(),Xs=function(){function a(){Mt(this,a),ff(this,"unknownFeatureColor",new H(.5,.5,.5,1)),this.feature=null,this.perimeter=!0,this.support=!1,this.missingFeatures=[]}return Pt(a,[{key:"isTypeComment",value:function(e){return!1}},{key:"getFeatureColor",value:function(e){return new H(1,1,1,1)}},{key:"isPerimeter",value:function(){return this.perimeter}},{key:"isSupport",value:function(){return this.support}},{key:"processComments",value:function(e,t){}},{key:"reportMissingFeature",value:function(e){this.missingFeatures.includes(e)||(console.error("Missing feature ".concat(e)),this.missingFeatures.push(e))}}]),a}(),Pb=function(a){Yi(t,Xs);var e=qi(t);function t(){var i;return Mt(this,t),(i=e.call(this)).featureList={Perimeter:{color:new H(1,.9,.3,1),perimeter:!1,support:!1},"External perimeter":{color:new H(1,.5,.2,1),perimeter:!0,support:!1},"Internal infill":{color:new H(.59,.19,.16,1),perimeter:!1,support:!1},"Solid infill":{color:new H(.59,.19,.8,1),perimeter:!1,support:!1},"Top solid infill":{color:new H(.95,.25,.25,1),perimeter:!0,support:!1},"Bridge infill":{color:new H(.3,.5,.73,1),perimeter:!1,support:!1},"Gap fill":{color:new H(1,1,1,1),perimeter:!1,support:!1},Skirt:{color:new H(0,.53,.43,1),perimeter:!1,support:!1},"Skirt/Brim":{color:new H(0,.53,.43,1),perimeter:!1,support:!1},"Supported material":{color:new H(0,1,0,1),perimeter:!1,support:!0},"Supported material interface":{color:new H(0,.5,0,1),perimeter:!1,support:!0},Custom:{color:new H(.5,.5,.5,1),perimeter:!1,support:!1},Unknown:{color:new H(.5,.5,.5,1),perimeter:!1,support:!1},"Support material":{color:new H(.5,.5,.5,1),perimeter:!1,support:!0},"Support material interface":{color:new H(.5,.5,.5,1),perimeter:!1,support:!0},"Overhang perimeter":{color:new H(.5,.5,.5,1),perimeter:!0,support:!1},"Wipe tower":{color:new H(.5,.5,.5,1),perimeter:!0,support:!1}},i}return Pt(t,[{key:"isTypeComment",value:function(i){return!!i.trim().startsWith(";TYPE:")&&(this.feature=i.substring(6).trim(),!0)}},{key:"getFeatureColor",value:function(){if(Object.prototype.hasOwnProperty.call(this.featureList,this.feature))try{return this.featureList[this.feature].color}catch{this.reportMissingFeature(this.feature)}return this.unknownFeatureColor}},{key:"isPerimeter",value:function(){try{return this.featureList[this.feature].perimeter}catch{return this.reportMissingFeature(this.feature),!0}}},{key:"isSupport",value:function(){try{return this.featureList[this.feature].support}catch{return this.reportMissingFeature(this.feature),!1}}},{key:"processComments",value:function(i,s){try{for(var n=i.length-350;n<i.length-1;n++){var r=i[n];if(r.includes("nozzle_diameter"))for(var o=r.indexOf("=")+1,h=r.substring(o).split(","),l=0;l<h.length;l++)s.tools.length<l&&(s.tools[l].diameter=h[l])}}catch(c){console.error(c)}}}]),t}(),wb=function(a){Yi(t,Xs);var e=qi(t);function t(){var i;return Mt(this,t),(i=e.call(this)).featureList={SKIN:{color:new H(1,.9,.3,1),perimeter:!0,support:!1},"WALL-OUTER":{color:new H(1,.5,.2,1),perimeter:!0,support:!1},"WALL-INNER":{color:new H(.59,.19,.16,1),perimeter:!1,support:!1},FILL:{color:new H(.95,.25,.25,1),perimeter:!1,support:!1},SKIRT:{color:new H(0,.53,.43,1),perimeter:!1,support:!1},SUPPORT:{color:new H(0,.53,.43,1),perimeter:!1,support:!0},CUSTOM:{color:new H(.5,.5,.5,1),perimeter:!1,support:!1},UNKNOWN:{color:new H(.5,.5,.5,1),perimeter:!1,support:!1}},i}return Pt(t,[{key:"isTypeComment",value:function(i){return!!i.trim().startsWith(";TYPE:")&&(this.feature=i.substring(6).trim(),!0)}},{key:"getFeatureColor",value:function(){if(Object.prototype.hasOwnProperty.call(this.featureList,this.feature))try{return this.featureList[this.feature].color}catch{this.reportMissingFeature(this.feature)}return this.unknownFeatureColor}},{key:"isPerimeter",value:function(){try{return this.featureList[this.feature].perimeter}catch{return this.reportMissingFeature(this.feature),!0}}},{key:"isSupport",value:function(){try{return this.featureList[this.feature].support}catch{return this.reportMissingFeature(this.feature),!1}}}]),t}(),Db=function(a){Yi(t,Xs);var e=qi(t);function t(){var i;return Mt(this,t),(i=e.call(this)).featureList={Perimeter:{color:new H(1,.9,.3,1),perimeter:!1,support:!1},"External perimeter":{color:new H(1,.5,.2,1),perimeter:!0,support:!1},"Internal infill":{color:new H(.59,.19,.16,1),perimeter:!1,support:!1},"Solid infill":{color:new H(.59,.19,.8,1),perimeter:!1,support:!1},"Top solid infill":{color:new H(.95,.25,.25,1),perimeter:!0,support:!1},"Bridge infill":{color:new H(.3,.5,.73,1),perimeter:!1,support:!1},"Gap fill":{color:new H(1,1,1,1),perimeter:!1,support:!1},Skirt:{color:new H(0,.53,.43,1),perimeter:!1,support:!1},"Skirt/Brim":{color:new H(0,.53,.43,1),perimeter:!1,support:!1},"Supported material":{color:new H(0,1,0,1),perimeter:!1,support:!0},"Supported material interface":{color:new H(0,.5,0,1),perimeter:!1,support:!0},Custom:{color:new H(.5,.5,.5,1),perimeter:!1,support:!1},Unknown:{color:new H(.5,.5,.5,1),perimeter:!1,support:!1},"Support material":{color:new H(.5,.5,.5,1),perimeter:!1,support:!1},"Support material interface":{color:new H(.5,.5,.5,1),perimeter:!1,support:!1},"Overhang perimeter":{color:new H(.5,.5,.5,1),perimeter:!0,support:!1},"Wipe tower":{color:new H(.5,.5,.5,1),perimeter:!1,support:!1}},i}return Pt(t,[{key:"isTypeComment",value:function(i){return!!i.trim().startsWith(";TYPE:")&&(this.feature=i.substring(6).trim(),!0)}},{key:"getFeatureColor",value:function(){if(Object.prototype.hasOwnProperty.call(this.featureList,this.feature))try{return this.featureList[this.feature].color}catch{this.reportMissingFeature(this.feature)}return this.unknownFeatureColor}},{key:"isPerimeter",value:function(){try{return this.featureList[this.feature].perimeter}catch{return this.reportMissingFeature(this.feature),!0}}},{key:"isSupport",value:function(){try{return this.featureList[this.feature].support}catch{return this.reportMissingFeature(this.feature),!1}}}]),t}(),Fb=function(a){Yi(t,Xs);var e=qi(t);function t(){var i;return Mt(this,t),(i=e.call(this)).featureList={"WALL-OUTER":{color:new H(.47,.18,.18,1),perimeter:!0,support:!1},"WALL-INNER":{color:new H(0,.55,0,1),perimeter:!1,support:!1},FILL:{color:new H(.9,.2,.2,1),perimeter:!1,support:!1},"SOLID-FILL":{color:new H(.95,.25,.25,1),perimeter:!1,support:!1},BRIDGE:{color:new H(.9,.15,.195,1),perimeter:!1,support:!1},SKIRT:{color:new H(.31,.12,.33,1),perimeter:!1,support:!1},SUPPORT:{color:new H(0,.53,.43,1),perimeter:!1,support:!0},"DENSE-SUPPORT":{color:new H(0,.28,.55,1),perimeter:!1,support:!0},RAFT:{color:new H(.59,.49,.2,1),perimeter:!1,support:!1},CUSTOM:{color:new H(.5,.5,.5,1),perimeter:!1,support:!1},UNKNOWN:{color:new H(.5,.5,.5,1),perimeter:!1,support:!1}},i}return Pt(t,[{key:"isTypeComment",value:function(i){return!!i.trim().startsWith(";TYPE:")&&(this.feature=i.substring(6).trim(),!0)}},{key:"getFeatureColor",value:function(){if(Object.prototype.hasOwnProperty.call(this.featureList,this.feature))try{return this.featureList[this.feature].color}catch{this.reportMissingFeature(this.feature)}return this.unknownFeatureColor}},{key:"isPerimeter",value:function(){try{return this.featureList[this.feature].perimeter}catch{return this.reportMissingFeature(this.feature),!0}}},{key:"isSupport",value:function(){try{return this.featureList[this.feature].support}catch{return this.reportMissingFeature(this.feature),!1}}}]),t}(),Ob=function(a){Yi(t,Xs);var e=qi(t);function t(){var i;return Mt(this,t),(i=e.call(this)).featureList={shells:{color:new H(1,.9,.3,1),perimeter:!0,support:!1},"sparse infill":{color:new H(.59,.19,.16,1),perimeter:!1,support:!1},"solid fill":{color:new H(.59,.19,.8,1),perimeter:!0,support:!1},Unknown:{color:new H(.5,.5,.5,1),perimeter:!1,support:!1},"Support material":{color:new H(.5,.5,.5,1),perimeter:!1,support:!0},"Support material interface":{color:new H(.5,.5,.5,1),perimeter:!1,support:!0},"Overhang perimeter":{color:new H(.5,.5,.5,1),perimeter:!0,support:!1},"Wipe tower":{color:new H(.5,.5,.5,1),perimeter:!0,support:!1}},i}return Pt(t,[{key:"isTypeComment",value:function(i){return!!i.trim().startsWith("; feature")&&(this.feature=i.substring(9).trim(),!0)}},{key:"getFeatureColor",value:function(){if(Object.prototype.hasOwnProperty.call(this.featureList,this.feature))try{return this.featureList[this.feature].color}catch{this.reportMissingFeature(this.feature)}return this.unknownFeatureColor}},{key:"isPerimeter",value:function(){try{return this.featureList[this.feature].perimeter}catch{return this.reportMissingFeature(this.feature),!0}}},{key:"isSupport",value:function(){try{return this.featureList[this.feature].support}catch{return this.reportMissingFeature(this.feature),!1}}},{key:"processComments",value:function(i,s){try{for(var n=i.length-350;n<i.length-1;n++){var r=i[n];if(r.includes("nozzle_diameter"))for(var o=r.indexOf("=")+1,h=r.substring(o).split(","),l=0;l<h.length;l++)s.tools.length<l&&(s.tools[l].diameter=h[l])}}catch(c){console.error(c)}}}]),t}(),Bb=function(a){Yi(t,Xs);var e=qi(t);function t(){var i;return Mt(this,t),(i=e.call(this)).featureList={"Outer wall":{color:new H(1,.9,.3,1),perimeter:!0,support:!1},"Inner wall":{color:new H(1,.49,.22,1),perimeter:!1,support:!1},"Overhang wall":{color:new H(.15,.16,.75,1),perimeter:!1,support:!1},"Sparse infill":{color:new H(.69,.19,.16,1),perimeter:!1,support:!1},"Internal solid infill":{color:new H(.59,.33,.8,1),perimeter:!1,support:!1},"Top surface":{color:new H(.7,.22,.22,1),perimeter:!0,support:!1},"Bottom surface":{color:new H(.4,.36,.78,1),perimeter:!0,support:!1},Bridge:{color:new H(.3,.5,.73,1),perimeter:!1,support:!1},Custom:{color:new H(.37,.82,.58,1),perimeter:!1,support:!1},Support:{color:new H(0,1,0,1),perimeter:!1,support:!0},"Support interface":{color:new H(.12,.38,.13,1),perimeter:!1,support:!0},"Prime tower":{color:new H(.7,.89,.67,1),perimeter:!1,support:!1},"Internal Bridge":{color:new H(.3,.5,.73,1),perimeter:!1,support:!1},Skirt:{color:new H(0,.53,.43,1),perimeter:!1,support:!1}},i}return Pt(t,[{key:"isTypeComment",value:function(i){return!!i.trim().startsWith(";TYPE:")&&(this.feature=i.substring(6).trim(),!0)}},{key:"getFeatureColor",value:function(){if(Object.prototype.hasOwnProperty.call(this.featureList,this.feature))try{return this.featureList[this.feature].color}catch{this.reportMissingFeature(this.feature)}return this.unknownFeatureColor}},{key:"isPerimeter",value:function(){try{return this.featureList[this.feature].perimeter}catch{return this.reportMissingFeature(this.feature),!0}}},{key:"isSupport",value:function(){try{return this.featureList[this.feature].support}catch{return this.reportMissingFeature(this.feature),!1}}},{key:"processComments",value:function(i,s){try{for(var n=i.length-350;n<i.length-1;n++){var r=i[n];if(r.includes("nozzle_diameter"))for(var o=r.indexOf("=")+1,h=Number(r.substring(o)),l=0;l<s.tools.length;l++)s.tools.length<l&&(s.tools[l].diameter=h)}}catch(c){console.error(c)}}}]),t}(),Lb=function(){function a(){Mt(this,a)}return Pt(a,null,[{key:"getSlicer",value:function(e){if(!e)return null;var t=e.substring(0,1e4);return t.includes("; generated by PrusaSlicer")?new Pb:t.includes(";Generated with Cura_SteamEngine")?new wb:t.includes("; generated by SuperSlicer")?new Db:t.includes("Sliced by ideaMaker")?new Fb:t.includes("; Generated by Kiri:Moto")?new Ob:t.includes("generated by OrcaSlicer ")?new Bb:new Xs}}]),a}(),Rl=1e6,Nb=function(){function a(){Mt(this,a),this.currentPosition=new v(0,0,0),this.currentColor=new H(.25,.25,.25,1),this.currentTool=0,this.renderVersion=Ss.Line,this.absolute=!0,this.linesIndex=0,this.lines=[],this.renderedLines=[],this.currentLineNumber=0,this.lastFilePositionIndex=0,this.travels=[],this.sps,this.maxHeight=0,this.minHeight=0,this.lineCount=0,this.renderMode="",this.extruderCount=10,this.layerDictionary=[],this.previousLayerHeight=0,this.currentLayerHeight=0,this.liveTracking=!1,this.liveTrackingShowSolid=localStorage.getItem("showSolid")==="true",this.gcodeLineIndex=[],this.gcodeFilePosition=0,this.refreshTime=200,this.timeStamp=0,this.lineLengthTolerance=.05,this.tools=new Array;for(var r=["#00FFFF","#FF00FF","#FFFF00","#000000","#FFFFFF"],o=0;o<5;o++){var h=new fr;h.color=H.FromHexString(r[o]),h.diameter=.4,this.tools.push(h)}this.progressColor=new H(0,1,0,1),this.keepProgressColor=!1,this.lineMeshIndex=0,this.scene=null,this.renderFuncs=new Array,this.meshBreakPoint=1e5,this.feedRateTrimming=!1,this.currentFeedRate=0,this.feedValues=0,this.numChanges=0,this.avgFeed=0,this.maxFeedRate=0,this.minFeedRate=Number.MAX_VALUE,this.underspeedPercent=1,this.colorMode=Number.parseInt(localStorage.getItem("processorColorMode"),10),this.colorMode||this.setColorMode(ts.Color),this.minColorRate=Number.parseInt(localStorage.getItem("minColorRate"),10),this.minColorRate||(this.minColorRate=1200,localStorage.setItem("minColorRate",this.minColorRate)),this.maxColorRate=Number.parseInt(localStorage.getItem("maxColorRate"),10),this.maxColorRate||(this.maxColorRate=3600,localStorage.setItem("maxColorRate",this.maxColorRate)),this.minFeedColorString=localStorage.getItem("minFeedColor"),this.minFeedColorString||(this.minFeedColorString="#0000FF"),this.minFeedColor=H.FromHexString(this.minFeedColorString.padEnd(9,"F")),this.maxFeedColorString=localStorage.getItem("maxFeedColor"),this.maxFeedColorString||(this.maxFeedColorString="#FF0000"),this.maxFeedColor=H.FromHexString(this.maxFeedColorString.padEnd(9,"F")),this.everyNthRow=0,this.currentRowIdx=-1,this.currentZ=0,this.renderTravels=!0,this.persistTravels=!1,this.vertexAlpha=!1,this.forceWireMode=localStorage.getItem("forceWireMode")==="true",this.spreadLines=!1,this.spreadLineAmount=10,this.debug=!1,this.specularColor=new de(0,0,0),this.cancelLoad=!1,this.loadingProgressCallback=()=>{},this.hasSpindle=!1,this.voxelWidth=1,this.voxelHeight=1,this.forceVoxels=!1,this.renderInstances=new Array,this.meshIndex=0,this.highQualityExtrusion=!1,this.perimeterOnly=!1,this.lastUpdate=Date.now(),this.g1AsExtrusion=!1,this.firstGCodeByte=0,this.lastGCodeByte=0,this.zBelt=!1,this.gantryAngle=45*Math.PI/180,this.hyp=Math.cos(this.gantryAngle),this.adj=Math.tan(this.gantryAngle),this.currentZ=0,this.beltLength=100,this.nozzleStartPosition=new v(0,0,0),this.nozzlePosition=new v(0,0,0),this.nozzleFeedRate=0,this.firmwareRetraction=!1,this.inches=!1,this.fixRadius=!1,this.csysContainers=new Array,this.lastCommand="G0",this.arcPlane="XY",this.workplaceOffsets=[new v(0,0,0),new v(0,0,0)],this.currentWorkplace=0,this.progressMode=!1,this.transparentValue=.25,this.hasMixing=!1,this.renderAnimation=!0}var e,t,i,s,n;return Pt(a,[{key:"doUpdate",value:function(){this.lastUpdate=Date.now()}},{key:"setProgressColor",value:function(r){var o=this;this.progressColor=H.FromHexString(r.padEnd(9,"F")),this.renderInstances.forEach(h=>h.progressColor=o.progressColor)}},{key:"getMaxHeight",value:function(){return this.maxHeight+1}},{key:"getMinHeight",value:function(){return this.minHeight}},{key:"setRenderQualitySettings",value:function(r,o){if(this.forceVoxels)return this.renderVersion=Ss.Voxel,this.meshBreakPoint=Rl,void(this.lines=new Array(Rl));this.lines=new Array(1.5*this.meshBreakPoint),o===void 0&&(o=1);var h=0,l=this.forceWireMode?2:1,c=2;switch(this.refreshTime=5e3,this.everyNthRow=1,this.renderTravels=!0,o){case 1:l=2,this.refreshTime=3e4,h=25e3,c=50,this.renderTravels=!1;break;case 2:l=2,this.refreshTime=3e4,h=5e5,c=10,this.renderTravels=!1;break;case 3:h=1e6,c=3;break;case 4:h=15e6,c=2;break;case 5:h=25e6;break;default:return this.renderVersion=Ss.Block,void(this.everyNthRow=1)}for(var u=l;u<4;u++){var f=void 0;switch(u){case 1:f=24;break;case 2:f=2;break;case 3:f=1}for(var d=this.everyNthRow;d<=c;d++)if(this.debug&&console.log("Mode: "+u+" NRow: "+d+" vertexcount: "+r*f/d),r*f/d<h)return this.renderVersion=u,void(this.everyNthRow=d)}}},{key:"initVariables",value:function(){this.currentPosition=new v(this.workplaceOffsets[this.currentWorkplace].x,this.workplaceOffsets[this.currentWorkplace].z,this.workplaceOffsets[this.currentWorkplace].y),this.cancelLoad=!1,this.absolute=!0,this.currentZ=0,this.currentRowIdx=-1,this.gcodeLineIndex=[],this.lineMeshIndex=0,this.previousLayerHeight=this.currentPosition.y,this.currentLayerHeight=this.currentPosition.y,this.minFeedRate=Number.MAX_VALUE,this.maxFeedRate=0,this.hasSpindle=!1,this.currentColor=new H(1,1,1,1),this.slicer=null,this.skip=!1,this.isSupport=!1,this.currentTool=0,this.firstGCodeByte=0,this.lastGCodeByte=0,this.layerDictionary=[],this.lastZExtrusion=0,this.renderedLines=[],this.beltLength=0,this.lastCommand="G0",this.lines=new Array(1.5*this.meshBreakPoint),this.linesIndex=0,this.hasMixing=!1,this.workplaceOffsets.length===0&&(this.workplaceOffsets=[new v(0,0,0)],this.currentWorkplace=0)}},{key:"g0g1",value:function(r,o,h,l,c){var u,f,d=r.split(/(?=[GXYZEFUVAB])/),_=new Tl,p=!1;_.tool=this.currentTool,_.gcodeLineNumber=o,_.gcodeFilePosition=h,_.start=this.currentPosition.clone(),_.feedRate=this.currentFeedRate,_.isPerimeter=this.slicer.isPerimeter(),c[0]!=="G1"&&c[0]!=="G01"||!this.g1AsExtrusion||(_.extruding=!0,_.color=(u=(f=this.tools[this.currentTool])===null||f===void 0?void 0:f.color.clone())!==null&&u!==void 0?u:this.tools[0].color.clone(),this.maxHeight=this.zBelt?this.currentPosition.z:this.currentPosition.y),this.zBelt&&(d=d.sort().reverse());for(var g=0;g<d.length;g++){var m=d[g];switch(m[0]){case"X":this.zBelt?this.currentPosition.x=Number(m.substring(1)):this.currentPosition.x=this.absolute?Number(m.substring(1))+this.workplaceOffsets[this.currentWorkplace].x:this.currentPosition.x+Number(m.substring(1)),p=!0;break;case"Y":this.zBelt?(this.currentPosition.y=Number(m.substring(1))*this.hyp,this.currentPosition.z=this.currentZ+this.currentPosition.y*this.adj):this.currentPosition.z=this.absolute?Number(m.substring(1))+this.workplaceOffsets[this.currentWorkplace].y:this.currentPosition.z+Number(m.substring(1)),p=!0;break;case"Z":this.zBelt?(this.currentZ=-Number(m.substring(1)),this.currentPosition.z=this.currentZ+this.currentPosition.y*this.adj,p=!0):(this.currentPosition.y=this.absolute?Number(m.substring(1))+this.workplaceOffsets[this.currentWorkplace].z:this.currentPosition.y+Number(m.substring(1)),this.lastY&&this.lastY===this.currentPosition.y||(this.lastY=this.currentPosition.y,this.lastY===void 0&&(this.lastY=0)),this.currentPosition.y<this.minHeight&&(this.minHeight=this.currentPosition.y),this.spreadLines&&(this.currentPosition.y*=this.spreadLineAmount));break;case"E":Number(m.substring(1))>0&&(_.extruding=!0,this.maxHeight=this.currentPosition.y);break;case"F":if(this.currentFeedRate=Number(m.substring(1)),_.feedRate=this.currentFeedRate,this.currentFeedRate>this.maxFeedRate&&(this.maxFeedRate=this.currentFeedRate),this.currentFeedRate<this.minFeedRate&&(this.minFeedRate=this.currentFeedRate),this.colorMode===ts.Feed){var b=(this.currentFeedRate-this.minColorRate)/(this.maxColorRate-this.minColorRate);this.currentColor=b>=1?this.maxFeedColor:b<=0?this.minFeedColor:H.Lerp(this.minFeedColor,this.maxFeedColor,b)}}}if(this.zBelt&&(this.beltLength=this.currentPosition.z<this.beltLength?this.currentPosition.z:this.beltLength),!(_.extruding&&this.skip||(_.end=this.currentPosition.clone(),this.debug,this.feedRateTrimming&&(this.feedValues+=this.currentFeedRate,this.numChanges++,this.avgFeed=this.feedValues/this.numChanges*this.underspeedPercent),this.everyNthRow>1&&_.extruding&&(this.currentPosition.y>this.currentZ&&(this.currentRowIdx++,this.currentRowIdx%3==0&&this.currentRowIdx++,this.currentZ=this.currentPosition.y),this.currentRowIdx%this.everyNthRow==0&&this.currentRowIdx>2)))){var I=this.hasSpindle&&c[0]==="G1",T=this.g1AsExtrusion||_.length()>=this.lineLengthTolerance;l&&(this.renderedLines.push(_),_.extruding&&this.lastZExtrusion<this.currentPosition.y&&(this.layerDictionary.push(h),this.lastZExtrusion=this.currentPosition.y),I||T&&_.extruding?(this.currentColor===null&&(this.currentColor=new H(1,1,1,1)),_.color=this.currentColor.clone(),this.lines[this.linesIndex++]=_,this.zBelt&&this.currentZ<this.currentLayerHeight&&!this.isSupport?(this.previousLayerHeight=this.currentLayerHeight,this.currentLayerHeight=this.currentZ):!this.zBelt&&this.currentPosition.y>this.currentLayerHeight&&!this.isSupport&&p&&(this.previousLayerHeight=this.currentLayerHeight,this.currentLayerHeight=this.currentPosition.y)):this.renderTravels&&!_.extruding&&(_.color=new H(1,0,0,1),this.travels.push(_)),this.zBelt?_.layerHeight=Math.abs(this.currentLayerHeight-this.previousLayerHeight):this.g1AsExtrusion?_.layerHeight=1:_.layerHeight=this.currentLayerHeight-this.previousLayerHeight)}}},{key:"g2g3",value:function(r,o,h,l){var c=this,u=r.split(/(?=[GXYZIJKFREUVAB])/),f=r.indexOf("E")>0||this.g1AsExtrusion,d=u.filter(g=>g==="G2"||g==="G02"),_={position:this.currentPosition.clone(),points:[]};try{_=function(g,m,b,I,T,x,y){for(var R=new v(m.x,m.z,m.y),E=R.clone(),C=0,S=0,w=0,P=g.some(ji=>ji.includes("G2")),G=0;G<g.length;G++){var L=g[G];switch(L[0]){case"X":E.x=js(L,E.x,b,y.x);break;case"Y":E.y=js(L,E.y,b,y.y);break;case"Z":E.z=js(L,E.z,b,y.z);break;case"I":C=js(L,C,!1,0);break;case"J":case"K":S=js(L,S,!1,0);break;case"R":w=js(L,w,!1,0)}}var W="x",K="y",ce="z";switch(x){case"XY":W="x",K="y",ce="z";break;case"XZ":W="z",K="x",ce="y";var $=S;S=C,C=$;break;case"YZ":W="y",K="z",ce="x"}if(w){var z=E[W]-R[W],k=E[K]-R[K],M=Math.pow(z,2)+Math.pow(k,2);if(M===0)return{position:R.clone(),points:[]};var V=Math.pow(w,2)-M/4,q=0;if(V>=0)q=Math.sqrt(V/M);else if(V<-.02*Math.pow(w,2)){if(!T)return console.error("G2/G3: Radius too small"),{position:{x:E.x,y:E.z,z:E.y},points:[]};var he=Math.sqrt(Math.pow(z/2,2)+Math.pow(k/2,2));V=Math.pow(he,2)-M/4,q=Math.sqrt(V/M)}(P&&w<0||!P&&w>0)&&(q=-q),C=z/2+k*q,S=k/2-z*q}else if(C===0&&S===0)return{position:R.clone(),points:[]};var pe,se=R[W]===E[W]&&R[K]===E[K],ue=R[W]+C,me=R[K]+S,ne=Math.sqrt(C*C+S*S),Ie=Math.atan2(-S,-C),Se=Math.atan2(E[K]-me,E[W]-ue);se?pe=2*Math.PI:(pe=P?Ie-Se:Se-Ie)<0&&(pe+=2*Math.PI);var Q=ne*pe/I;Q<1&&(Q=1);var be=pe/Q;be*=P?-1:1;for(var Be=new Array,ze=(E[ce]-R[ce])/Q,Ke=R[W],Rt=R[K],Ct=R[ce],Ge=Ie,Jt=0;Jt<Q-1;Jt++){Ge+=be,Ke=ue+ne*Math.cos(Ge),Rt=me+ne*Math.sin(Ge),Ct+=ze;var Wt={};Wt[W]=Ke,Wt[K]=Rt,Wt[ce]=Ct,Be.push({x:Wt.x,y:Wt.z,z:Wt.y})}return Be.push({x:E.x,y:E.z,z:E.y}),{position:{x:E.x,y:E.z,z:E.y},points:Be}}(u,this.currentPosition,!this.absolute,.1,this.fixRadius,this.arcPlane,this.workplaceOffsets[this.currentWorkplace])}catch(g){console.error("Arc Error",g)}var p=this.currentPosition.clone();_.points.forEach((g,m)=>{var b=new Tl;b.tool=c.currentTool,b.gcodeLineNumber=o,b.gcodeFilePosition=h,b.feedRate=c.currentFeedRate,b.isPerimeter=c.slicer.isPerimeter(),c.g1AsExtrusion?b.layerHeight=1:b.layerHeight=c.currentLayerHeight-c.previousLayerHeight,b.start=p.clone(),b.end=new v(g.x,g.y,g.z),b.extruding=f,b.color=f?c.currentColor.clone():new H(1,0,0,1),c.debug&&(b.color=d?new H(0,1,1,1):new H(1,1,0,1),m===0&&(b.color=new H(0,1,0,1))),p=b.end.clone(),c.debug&&console.log(b),l&&(c.renderedLines.push(b),b.extruding?c.lines[c.linesIndex++]=b:c.travels.push(b))}),this.currentPosition=new v(p.x,p.y,p.z),this.currentPosition.y>this.currentLayerHeight&&!this.isSupport&&(this.previousLayerHeight=this.currentLayerHeight,this.currentLayerHeight=this.currentPosition.y)}},{key:"m567",value:function(r){var o=r.split(/(?=[PE])/),h=[1,1,1];if(this.colorMode!==ts.Feed){for(var l=1;l<o.length;l++){var c=o[l];c[0]==="E"&&(this.extruderPercentage=c.substring(1).split(":"))}for(var u=0;u<this.extruderPercentage.length;u++)h[0]-=(1-this.tools[u].color.r)*this.extruderPercentage[u],h[1]-=(1-this.tools[u].color.g)*this.extruderPercentage[u],h[2]-=(1-this.tools[u].color.b)*this.extruderPercentage[u];this.currentColor=new H(h[0],h[1],h[2],.1)}}},{key:"processGcodeFile",value:(n=Gi(It().mark(function r(o,h,l){var c,u,f,d,_,p;return It().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(this.initVariables(),this.slicer=Lb.getSlicer(o),this.meshIndex=0,this.currentTool=0,h==null&&(h=4),o&&o.length!==0){g.next=7;break}return g.abrupt("return");case 7:u=o.split("\n"),this.slicer.processComments(u,this),typeof l=="function"&&l(),this.lineCount=u.length,this.debug&&console.info("Line Count : ".concat(this.lineCount)),this.setRenderQualitySettings(this.lineCount,h),this.tools.length===0&&this.tools.push(new fr),this.currentColor=(c=this.tools[0].color)!==null&&c!==void 0?c:new fr().color,u.reverse(),f=0,d=0,this.timeStamp=Date.now();case 19:if(!u.length){g.next=36;break}if(!this.cancelLoad){g.next=23;break}return this.cancelLoad=!1,g.abrupt("return");case 23:if(_=u.pop(),f+=_.length+1,d++,_.trim(),_.startsWith(";")?this.slicer&&this.slicer.isTypeComment(_)&&(this.isSupport=this.slicer.isSupport(),this.colorMode===ts.Feature&&(this.currentColor=this.slicer.getFeatureColor())):(this.slicer&&this.slicer.isTypeComment(_),p=!this.perimeterOnly||this.slicer&&this.slicer.isPerimeter()||this.g1AsExtrusion,this.firstGCodeByte===0&&_.length>0&&(this.firstGCodeByte=f),this.lastGCodeByte=f,this.processLine(_,d,f,p)),!(Date.now()-this.timeStamp>10)){g.next=33;break}return this.loadingProgressCallback&&this.loadingProgressCallback(f/o.length,"Loading File..."),g.next=32,kr();case 32:this.timeStamp=g.sent;case 33:this.doUpdate(),g.next=19;break;case 36:if(this.layerDictionary.push(o.length),!this.renderTravels){g.next=40;break}return g.next=40,this.createTravelLines(this.scene);case 40:this.loadingProgressCallback&&this.loadingProgressCallback(1),o={};case 42:case"end":return g.stop()}},r,this)})),function(r,o,h){return n.apply(this,arguments)})},{key:"loadingComplete",value:function(){this.renderInstances.forEach(r=>r.isLoading=!1),this.updateFilePosition(Number.MAX_VALUE-1),this.updateFilePosition(Number.MAX_VALUE)}},{key:"processLine",value:(s=Gi(It().mark(function r(o,h,l){var c,u,f,d,_,p,g,m,b,I,T,x,y,R=arguments;return It().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(c=!(R.length>3&&R[3]!==void 0)||R[3],(u=o.indexOf(";"))>-1&&(o=o.substring(0,u-1).trim()),o=o.toUpperCase(),(d=o.match(/[GM]+[0-9.]+/g))===null&&o.match(/[XYZ]+[+-]?[0-9.]+/g)!==null&&(d=this.lastCommand),_=o.trim().split(/[GM]+[0-9.]+/g),!d){E.next=62;break}p=0;case 9:if(!(p<d.length)){E.next=60;break}E.t0=d[p],E.next=E.t0==="G0"||E.t0==="G1"||E.t0==="G00"||E.t0==="G01"?13:E.t0==="G2"||E.t0==="G3"||E.t0==="G02"||E.t0==="G03"?15:E.t0==="G10"?17:E.t0==="G11"?19:E.t0==="G17"?21:E.t0==="G18"?23:E.t0==="G19"?25:E.t0==="G20"?27:E.t0==="G28"?29:E.t0==="G53"?32:E.t0==="G54"||E.t0==="G55"||E.t0==="G56"||E.t0==="G57"||E.t0==="G58"||E.t0==="G59"?33:E.t0==="G59.1"||E.t0==="G59.2"||E.t0==="G59.2"?36:E.t0==="G90"?39:E.t0==="G91"?41:E.t0==="G92"?43:E.t0==="S"?44:E.t0==="M3"||E.t0==="M4"?46:E.t0==="M567"?51:E.t0==="M600"?54:56;break;case 13:return this.g0g1(_[1+p],h,l,c,d),E.abrupt("break",56);case 15:return this.g2g3(d[p]+" "+_[1+p],h,l,c),E.abrupt("break",56);case 17:return this.firmwareRetraction=!0,E.abrupt("break",56);case 19:return this.firmwareRetraction=!1,E.abrupt("break",56);case 21:return this.arcPlane="XY",E.abrupt("break",56);case 23:return this.arcPlane="XZ",E.abrupt("break",56);case 25:return this.arcPlane="YZ",E.abrupt("break",56);case 27:return this.inches=!0,E.abrupt("break",56);case 29:return(f=o.split(/(?=[GXYZ])/)).length===1||o==="G28 W"?this.currentPosition=new v(this.workplaceOffsets[this.currentWorkplace].x,this.workplaceOffsets[this.currentWorkplace].z,this.workplaceOffsets[this.currentWorkplace].y):(f.some(C=>C.trim()==="X")&&(this.currentPosition.x=this.workplaceOffsets[this.currentWorkplace].x),f.some(C=>C.trim()==="Y")&&(this.currentPosition.z=this.workplaceOffsets[this.currentWorkplace].y),f.some(C=>C.trim()==="Z")&&(this.currentPosition.y=this.workplaceOffsets[this.currentWorkplace].z)),E.abrupt("break",56);case 32:return E.abrupt("break",56);case 33:return this.currentWorkplace=54-Number(d[p].substring(1)),this.currentPosition=this.workplaceOffsets[this.currentWorkplace].clone(),E.abrupt("break",56);case 36:return this.currentWorkplace=10*(58.6-Number(d[p].substring(1))),this.currentPosition=this.workplaceOffsets[this.currentWorkplace].clone(),E.abrupt("break",56);case 39:return this.absolute=!0,E.abrupt("break",56);case 41:return this.absolute=!1,E.abrupt("break",56);case 43:return E.abrupt("break",56);case 44:return this.hasSpindle=!0,E.abrupt("break",56);case 46:return g=o.split(/(?=[SM])/),(m=(m=g.filter(C=>C.startsWith("S")))[0]?Number(m[0].substring(1)):0)>0&&(this.hasSpindle=!0),E.abrupt("break",56);case 51:return this.hasMixing=!0,this.m567(o),E.abrupt("break",56);case 54:try{this.currentTool++,this.currentTool>=this.tools.length&&(this.currentTool=0),this.colorMode!==ts.Feed&&(this.currentColor=this.tools[this.currentTool].color.clone())}catch(C){console.log(C)}return E.abrupt("break",56);case 56:this.lastCommand=d;case 57:p++,E.next=9;break;case 60:E.next=64;break;case 62:o.startsWith("T")&&(b=Number.parseInt(o.substring(1),10),isNaN(b)||(this.currentPosition.z+=10,this.currentTool=b,this.currentTool>=this.tools.length?this.currentTool=this.currentTool%this.tools.length:b<0&&(this.currentTool=0),this.colorMode!==ts.Feed&&((y=Number(o.substring(1))%this.extruderCount)<0&&(y=0),this.currentColor=(I=(T=this.tools[y])===null||T===void 0||(x=T.color)===null||x===void 0?void 0:x.clone())!==null&&I!==void 0?I:new de(1,0,0)))),this.debug;case 64:if(!(this.linesIndex>=this.meshBreakPoint)){E.next=71;break}return E.next=67,this.createMesh(this.scene);case 67:return E.next=69,kr();case 69:this.doUpdate(),this.meshIndex++;case 71:case"end":return E.stop()}},r,this)})),function(r,o,h){return s.apply(this,arguments)})},{key:"createMesh",value:(i=Gi(It().mark(function r(o){var h,l,c;return It().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.zBelt&&(h=this.lines[this.linesIndex-1].layerHeight,this.lines.forEach(f=>{f.layerHeight=h})),this.renderVersion===Ss.Line||this.renderVersion===Ss.Point?l=new Al(o,this.specularColor,this.loadingProgressCallback,this.renderFuncs,this.tools,this.meshIndex):this.renderVersion===Ss.Block?l=this.highQualityExtrusion?new Sb(o,this.specularColor,this.loadingProgressCallback,this.renderFuncs,this.tools,this.meshIndex):new Cb(o,this.specularColor,this.loadingProgressCallback,this.renderFuncs,this.tools,this.meshIndex):this.renderVersion===Ss.Voxel&&(l=new df(o,this.specularColor,this.loadingProgressCallback,this.renderFuncs,this.tools,this.voxelWidth,this.voxelHeight)),l.progressColor=this.progressColor,l.vertexAlpha=this.vertexAlpha,l.g1AsExtrusion=this.g1AsExtrusion,l.progressMode=this.progressMode,l.transparentValue=this.transparentValue,l.hasMixing=this.hasMixing,l.colorMode=this.colorMode,l.renderAnimation=this.renderAnimation,l.persistTravels=this.persistTravels,this.renderInstances.push(l),!((c=this.lines.slice(0,this.linesIndex-1))!=null&&c.length>0)){u.next=16;break}return u.next=16,l.render(c);case 16:this.linesIndex=0;case 17:case"end":return u.stop()}},r,this)})),function(r){return i.apply(this,arguments)})},{key:"chunk",value:function(r,o){for(var h=[],l=0,c=r.length;l<c;l+=o)h.push(r.slice(l,l+o));return h}},{key:"createTravelLines",value:(t=Gi(It().mark(function r(o){var h,l,c;return It().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:h=this.chunk(this.travels,2e4),l=0;case 2:if(!(l<h.length)){u.next=13;break}return(c=new Al(o,this.specularColor,this.loadingProgressCallback,this.renderFuncs,this.tools,this.meshIndex)).travels=!0,c.meshIndex=this.meshIndex+1e3,c.persistTravels=this.persistTravels,u.next=9,c.render(h[l]);case 9:this.renderInstances.push(c);case 10:l++,u.next=2;break;case 13:this.travels=[];case 14:case"end":return u.stop()}},r,this)})),function(r){return t.apply(this,arguments)})},{key:"updateFilePosition",value:function(r){this.renderInstances.forEach(h=>h.updateFilePosition(r));try{r<this.renderedLines[this.lastFilePositionIndex].gcodeFilePosition&&(this.lastFilePositionIndex=0,this.currentLineNumber=0)}catch{this.lastFilePositionIndex=0,this.currentLineNumber=0}for(var o=this.lastFilePositionIndex;o<this.renderedLines.length&&!(this.renderedLines[o].gcodeFilePosition>r+5);o++)this.currentLineNumber=this.renderedLines[o].gcodeLineNumber,this.nozzleStartPosition=this.renderedLines[o].start,this.nozzlePosition=this.renderedLines[o].end,this.nozzleFeedRate=this.renderedLines[o].feedRate,this.lastFilePositionIndex=o;this.doUpdate()}},{key:"updateFilePositionIndex",value:function(r){var o=this;r>=this.renderedLines.length||(this.currentLineNumber=this.renderedLines[r].gcodeLineNumber,this.nozzleStartPosition=this.renderedLines[r].start,this.nozzlePosition=this.renderedLines[r].end,this.nozzleFeedRate=this.renderedLines[r].feedRate,this.lastFilePositionIndex=r,this.renderInstances.forEach(h=>h.updateFilePosition(o.renderedLines[r].gcodeFilePosition)),this.doUpdate())}},{key:"doFinalPass",value:function(){var r=this;this.liveTracking=!0,this.gcodeFilePosition=Number.MAX_VALUE,setTimeout(()=>{r.liveTracking=!1},this.refreshTime+200)}},{key:"updateMesh",value:function(){this.renderVersion===1?console.log("Version 1"):this.renderVersion===2&&console.log("Version 2")}},{key:"unregisterEvents",value:function(){for(var r=0;r<this.renderFuncs.length;r++)this.scene.unregisterBeforeRender(this.renderFuncs[r]),delete this.renderFuncs[r];this.renderFuncs=[];for(var o=0;o<this.renderInstances.length;o++)delete this.renderInstances[o];this.renderInstances=[]}},{key:"setLiveTracking",value:function(r){this.liveTracking=r}},{key:"setColorMode",value:function(r){r||(this.colorMode=ts.Color),localStorage.setItem("processorColorMode",r),this.colorMode=r}},{key:"updateMinFeedColor",value:function(r){localStorage.setItem("minFeedColor",r),this.minFeedColorString=r,this.minFeedColor=H.FromHexString(r.padEnd(9,"F"))}},{key:"updateMaxFeedColor",value:function(r){localStorage.setItem("maxFeedColor",r),this.maxFeedColorString=r,this.maxFeedColor=H.FromHexString(r.padEnd(9,"F"))}},{key:"updateColorRate",value:function(r,o){localStorage.setItem("minColorRate",r),localStorage.setItem("maxColorRate",o),this.minColorRate=r,this.maxColorRate=o}},{key:"updateForceWireMode",value:function(r){this.forceWireMode=r,localStorage.setItem("forceWireMode",r)}},{key:"setLiveTrackingShowSolid",value:function(r){this.liveTrackingShowSolid=r,localStorage.setItem("showSolid",r)}},{key:"setAlpha",value:function(r){this.vertexAlpha=r}},{key:"resetTools",value:function(){this.tools.length=0}},{key:"addTool",value:function(r,o){var h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:s0.Extruder,l=new fr;l.color=H.FromHexString(r.padEnd(9,"F")),l.updateDarkerValue(),l.diameter=o,l.toolType=h,this.tools.push(l)}},{key:"updateTool",value:function(r,o,h){h<this.tools.length&&(this.tools[h].color=H.FromHexString(r.padEnd(9,"F")),this.tools[h].updateDarkerValue(),this.tools[h].diameter=o)}},{key:"forceRedraw",value:function(){for(var r=0;r<this.renderInstances.length;r++)this.renderInstances[r].forceRedraw=!0;this.doUpdate()}},{key:"forceRender",value:function(){for(var r=0;r<this.renderInstances.length;r++)this.renderInstances[r].timeStamp=0}},{key:"useHighQualityExtrusion",value:function(r){this.highQualityExtrusion=r}},{key:"setVoxelMode",value:function(r){this.forceVoxels=r}},{key:"useSpecularColor",value:function(r){var o=r?new de(.4,.4,.4):new de(0,0,0);this.specularColor=o,this.renderInstances.forEach(h=>{if(h.material!==null&&Object.prototype.hasOwnProperty.call(h.material,"specularColor"))try{h.material.specularColor=o}catch(l){console.error(l)}}),this.scene&&this.scene.render(!0,!0)}},{key:"g1AsExtrusion",value:function(r){this.g1AsExtrusion=r}},{key:"cancel",value:(e=Gi(It().mark(function r(){return It().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.cancelLoad=!0,o.next=3,this.pauseProcessing();case 3:case"end":return o.stop()}},r,this)})),function(){return e.apply(this,arguments)})},{key:"setZBeltAngle",value:function(r){this.gantryAngle=(90-r)*Math.PI/180,this.hyp=Math.cos(this.gantryAngle),this.adj=Math.tan(this.gantryAngle)}},{key:"setTransparencyValue",value:function(r){this.transparentValue=r,this.renderInstances.forEach(o=>{o.transparentValue=r})}},{key:"setRenderAnimation",value:function(r){var o=this;this.renderAnimation=r,this.renderInstances.forEach(h=>h.renderAnimation=o.renderAnimation)}},{key:"setTravelPersistence",value:function(r){var o=this;this.persistTravels=r,this.renderInstances.forEach(h=>{h.persistTravels=o.persistTravels})}}]),a}(),Il=0,Ub=1,kb=function(){function a(e){Mt(this,a),this.buildVolume={x:{min:0,max:100},y:{min:0,max:100},z:{min:0,max:100}};var t=localStorage.getItem("buildVolume");t!==null&&(this.buildVolume=JSON.parse(t)),this.renderMode=Number.parseInt(localStorage.getItem("renderBedMode"),10),this.renderMode||(this.renderMode=Il),this.bedMesh,this.isDelta=!1,this.scene=e,this.registerClipIgnore=()=>{},this.bedLineColor="#0000FF",this.getBedColor()||this.setBedColor("#0000FF"),this.planeMaterial=this.buildGridMaterial(),this.boxMaterial=new ee("bedBoxMaterial",this.scene),this.boxMaterial.alpha=0,this.debug=!1}return Pt(a,[{key:"setRenderMode",value:function(e){this.renderMode=e,localStorage.setItem("renderBedMode",this.renderMode),this.bedMesh&&(this.scene.removeMesh(this.bedMesh),this.bedMesh.dispose(!1,!0)),this.buildBed(),this.scene.render()}},{key:"buildBed",value:function(){if(!(this.renderMode>1||this.debug)){if(this.bedMesh&&this.bedMesh.isDisposed()&&(this.bedMesh=null),this.bedMesh)return this.bedMesh;switch(this.renderMode){case Il:this.buildFlatBed();break;case Ub:this.buildBox()}return this.bedMesh}}},{key:"setDelta",value:function(e){this.isDelta=e,this.setRenderMode(this.renderMode)}},{key:"buildFlatBed",value:function(){var e=this.getCenter(),t=this.getSize();if(this.isDelta){var i=Math.abs(this.buildVolume.x.max-this.buildVolume.x.min)/2;this.bedMesh=Zt.CreateDisc("BuildPlate",{radius:i},this.scene),this.bedMesh.rotationQuaternion=re.RotationAxis(new v(1,0,0),Math.PI/2),this.bedMesh.material=this.planeMaterial}else{var s=t.x,n=t.y;this.bedMesh=Zt.CreatePlane("BuildPlate",{width:s,height:n},this.scene),this.bedMesh.material=this.planeMaterial,this.bedMesh.rotationQuaternion=re.RotationAxis(new v(1,0,0),Math.PI/2),this.bedMesh.translate(new v(e.x,0,e.y),1,ci.WORLD)}this.registerClipIgnore(this.bedMesh)}},{key:"getCenter",value:function(){return{x:(this.buildVolume.x.max+this.buildVolume.x.min)/2,y:(this.buildVolume.y.max+this.buildVolume.y.min)/2,z:(this.buildVolume.z.max+this.buildVolume.z.min)/2}}},{key:"getSize",value:function(){return{x:Math.abs(this.buildVolume.x.max-this.buildVolume.x.min),y:Math.abs(this.buildVolume.y.max-this.buildVolume.y.min),z:Math.abs(this.buildVolume.z.max-this.buildVolume.z.min)}}},{key:"buildBox",value:function(){var e=this,t=this.getSize(),i=this.getCenter();if(this.isDelta)this.bedMesh=Zt.CreateCylinder("bed",{diameterTop:t.x,diameterBottom:t.x,height:t.z},this.scene),this.bedMesh.position.x=i.x,this.bedMesh.position.y=i.z,this.bedMesh.position.z=i.x,this.bedMesh.alpha=0,this.bedMesh.diffuseColor=new H(0,0,0,0),this.bedMesh.isPickable=!1,this.bedMesh.enableEdgesRendering(void 0,!0),this.bedMesh.renderingGroupId=2,this.scene.setRenderingAutoClearDepthStencil(2,!1,!1,!1),new kt("hl",this.scene,{isStroke:!0,blurTextureSizeRatio:3}).addMesh(this.bedMesh,this.getBedColor4()),this.bedMesh.onBeforeRenderObservable.add(()=>{e.scene.getEngine().setColorWrite(!1)}),this.bedMesh.onAfterRenderObservable.add(()=>{e.scene.getEngine().setColorWrite(!0)}),this.registerClipIgnore(this.bedMesh);else{this.bedMesh=Zt.CreateBox("bed",{width:t.x,depth:t.y,height:t.z},this.scene);var s=this.getCenter();this.bedMesh.position.x=s.x-this.buildVolume.x.min,this.bedMesh.position.y=s.z-this.buildVolume.z.min,this.bedMesh.position.z=s.y-this.buildVolume.y.min,this.bedMesh.diffuseColor=new H(0,0,0,0),this.bedMesh.enableEdgesRendering(),this.bedMesh.edgesWidth=100,this.bedMesh.material=this.boxMaterial,this.bedMesh.isPickable=!1,this.bedMesh.edgesColor=this.getBedColor4(),this.registerClipIgnore(this.bedMesh)}}},{key:"setVisibility",value:function(e){this.bedMesh&&this.bedMesh.setEnabled(e)}},{key:"commitBedSize",value:function(){localStorage.setItem("buildVolume",JSON.stringify(this.buildVolume)),this.setRenderMode(this.renderMode)}},{key:"buildGridMaterial",value:function(){var e=new zt("bedMaterial",this.scene);return e.mainColor=new H(0,0,0,0),e.lineColor=de.FromHexString(this.getBedColor()),e.gridRatio=5,e.opacity=.8,e.majorUnitFrequency=10,e.minorUnitVisibility=.6,e.gridOffset=new v(0,0,0),e}},{key:"getBedColor",value:function(){return localStorage.getItem("bedLineColor")}},{key:"setBedColor",value:function(e){localStorage.setItem("bedLineColor",e),this.renderMode>1||this.planeMaterial&&(this.planeMaterial=this.buildGridMaterial(),this.dispose(),this.buildBed(),this.scene.render())}},{key:"getBedColor4",value:function(){return H.FromHexString(this.getBedColor().padEnd(9,"F"))}},{key:"dispose",value:function(){this.bedMesh&&!this.bedMesh.isDisposed&&this.bedMesh.dispose(!1,!0)}}]),a}(),Vb=function(){function a(e){Mt(this,a),this.scene=e,this.checkerBoard="iVBORw0KGgoAAAANSUhEUgAAAQEAAAEBCAIAAAD3joeqAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALnSURBVHhe7dZBEYQwFAVBWBtogAv+IhIEsZd4yGG6L/lPwFRl31jqPM/neeZghd98oUoD1GmAOg1QpwHqNECdBqjTAHUaoE4D1GmAOg1QpwHqNECdBqjTAHUaoE4D1GmAOg1QpwHqNECdBqjTAHUaoE4D1GmAOg1QpwHqNECdBqjTAHUaoE4D1GmAOg1QpwHqNECdBqjTAHUaoE4D1GmAOg1QpwHqNECdBqjTAHUaoE4D1GmAOg1QpwHqNECdBqjTAHUaoE4D1GmAOg1QpwHqNECdBqjTAHUaoE4D1GmAOg1QpwHqNECdBqjTAHUaoE4D1GmAOg1QpwHqNECdBqjTAHUaoE4D1GmAOg1QpwHqNECdBqjTAHUaoE4D1GmAOg1QpwHqNECdBqjTAHUaoE4D1GmAOg1QpwHqNECdBqjTAHUaoE4D1GmAOg1QpwHqNECdBqjTAHUaoE4D1GmAOg1QpwHqNECdBqjTAHUaoE4D1GmAOg1QpwHqNECdBqjb7/ueJyscxzHGmIMV9u/75skK7/te1zUHK/gLUacB6jRAnQao0wB1GqBOA9RpgDoNUKcB6jRAnQao0wB1GqBOA9RpgDoNUKcB6jRAnQao0wB1GqBOA9RpgDoNUKcB6jRAnQao0wB1GqBOA9RpgDoNUKcB6jRAnQao0wB1GqBOA9RpgDoNUKcB6jRAnQao0wB1GqBOA9RpgDoNUKcB6jRAnQao0wB1GqBOA9RpgDoNUKcB6jRAnQao0wB1GqBOA9RpgDoNUKcB6jRAnQao0wB1GqBOA9RpgDoNUKcB6jRAnQao0wB1GqBOA9RpgDoNUKcB6jRAnQao0wB1GqBOA9RpgDoNUKcB6jRAnQao0wB1GqBOA9RpgDoNUKcB6jRAnQao0wB1GqBOA9RpgDoNUKcB6jRAnQao0wB1GqBOA9RpgDoNUKcB6jRAnQao0wB1GqBOA9RpgDoNUKcB6jRAnQao0wB1GqBOA7Rt2x+drw1hSNi5LQAAAABJRU5ErkJggg==",this.xmark="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPQAAADPCAMAAAD1TAyiAAAAkFBMVEX39/eZAAD8//+TAACWAACRAAD4+vr5/PyaAAD39fX18vLy6enr29v18PDm0dG1Y2PewMDYtbWuUFDkzc2jLy+iKSnLlpbRpKS/enrIjo6hJCTbu7u8dHSxWFi4a2vEh4eoOzudEhKdEBDPn5+pQUHq2dmsSUmnODjUqqqhJye0YGCeGRnIk5OrTEy6b2+fHh7/wUBWAAAIiElEQVR4nO2d2ULbOhRF4yNFijNAQiCBMoShhBTo7f//3bUc2kLIIOnsI6ut90v7hLS8ZCVWZJ1Op02bNm3atGnTps0fGGOsizGm6Z4kiiHqDMeT+Wo1vxwPS6IGwI2lqt3qqlf/WPH2DZnpYqnVz3SL5cXUpuWumnucL66Xp1WW14v5UUlWsDlDw0VPaV28i9aqWAyTYRsqJ8fVRdfrXlT/VP9/nvTFOkDDY/UB+Be4uhmSUKMbXRgsis990EqfD0Q6YMvz7cjrZs9Ledm2v7MLVQdG+EFO07udyC7q5UhaNk2KPV3QxSW6A/TQ3Yfs0n0QpTblsTrQgRvsRyhdHWiwln0lSG0Hp3tHWi37dASkpkMX+Y36WIzaDvVBZjeZD2HUXp5r6nMhajPw64C+R7mmC09mMeqK2cNzTX2HoaaJN7MQtRn0PJkr6q+ITy4zCGAWmc2st2dYB2gZ0GIhMJvZR3/PdQcu2a7tKkg0nrqatwM70Otz2yx7gU2Cqe1jcPuaO6/QLFQ0ljrcs2t/wJvBTXiTSGr7GMHMVW0uI0TjqKM8u+ZHnFbpOK5VDHWcZ9f6ijWBxzVaU7MXr2I9V+N7ybjk5ihudNfUJ8wHPZrGMlfUjPFt5/HQheZRc5gLNY5vmv5jNMyjpinjehf6Nf6mpu8c6Io6+r5mea5afo6/qc0Lp2WGa57nKreMmYzXcrRrpucqvXjmzsHVwMPUEa7Znqt2m4SOoeZ7Lopuo9CFvg38GYDGbM88aP4ld9SdEGoIc6HimeOesTYT5JrGgNFVJR6aviJUF/rJ2zXGc1F8Y3w5iX3I2oi3a5RnfR3/OW0fMNC+rlGeC71gfCPjf2D+7IXPbAZjLtSE8UBdgkx7ucYx81bJ6BpHfdrf3xGKXJraljPOuk3sGtm26LO9s1nQr0eHmprx1vvDl713d+V0DzVdYubtOsw1YHrFXf/K9c4RThMgM+dpuk4fdlMXe1wj7+dK9BFzTZI4y2SfssM11DPrm8lb7OG9HiEd2uYa67lQ/D0YZgjt0RbXWM+FmiF+oF5B+6RfNqZWCv4xeP/f5yyPvevVObZXdx+oaQ69pkXB/MnyV7+usdTvXWMnSjdzo3ZLWjD1b9doz2qM2xBgT2So0Z670P2hMq7hnsF7YiVc5+25pvbbH+qbajbL3bML3YBd++++9IqaSmzRBFOHbAP0iAwznhoZKeacqeWY86WWZM6VWpY5T2ppZrf5JjdqeWb4kyY7WvyFsJra9z2WJNGwZ8kD1Bm5TsWck2vcmoEHdSau03muqbNwndJzTZ2B67Se86BO7bmmvgCv3YZmmJ456B3Mv4a5YdcNMTfpWjfG3KDrBpkbc90oc0OuG2ZuwLVuntnrNBAo8/2geWZHndB1xZzHeWAJXWfDnNB1RszJXGfFnMj1xm6V5pPAtdaZMeN3Unxmzs2zC3gP3CfmL8gjqGARpd6zg7jZCFLrL5kyC1Jn69kF+U7Ce+Z8PbuIuM7as4uA68w9u9AEu2uoKJ6yZ+4Yc4Zl1qs0p88yYvpPaNMqd2pTQl/5WEf4GFZuTAn37AJ5LUMqIp5dMnYt5NlF5Upt+kKeXbp5jnCxsb1Olq7N6Ickc5auTf+LLHOGrsU9u2TmOoFnF/WaEXUSzzX1RTbUiTzX1Lm4Tua5ps7DdVLmTKjNwKeEwN9F7X+cPo666fvaDO5TMzfuOqSEAJKacQgVgLkBzzW1VMEPH+ZGPDdK3ZjnBqltc54bo7bD5J9VjVPHH7P+51JXnptPYuoMPLskpc7Cs4u6SUadiWcXwWJsm8xNo75LItfRJUFkksQ1HWXFnMR1dswJXGfILO46S2Zh15ky1+WL/jlmV75IiJoYNZXEo05E9l0hymN86Cb2cVzENU3BR6bNRi9garhrQOmXD+nOCL3cpNGu8Z4Jv0kF/Mkl4Nn9WTP6hqVG/gpgJTyvqbGuu2PYCDfg5+d32yjQrgvU2y2mDzy4v9jY9Ai+rzXqtgbWpXDZ2C5jRmfIP9/lHl3/xow9f/vTRmasa1Ydz9+BlioouvNPncK6ZlcpcKFz6OjbtmHdjDAlquog7urAkvIHssVz3UgJpOaVJK5Dr0DRWz3X1B0cNauC0jr2HtWZnZ5rapxr/vjGVcza47luCOeaU8izDi1ww27/Szc46i63+AjdYjriccw6jJpTh7lOH1ag7fAx6yhq9cCbyWC3tNdx+qZzC6keytxwZUGvi3oep286iK/5mvmrtcV8SnuXTTB0wm+QC42ZvEPKJli+azY04ot3WHkMvuscoEPLY7Af37kTGQC6G1zih+tazXkfWfx7OqasEbNUFffLiZ0xoeNKOfEK+XSZx/1YZkm+2PJVLNcvzG+hzG9k8SW76Dm6Yf6jZcmB5pQpi6fmLyJwCqzzSrNFU6s+k5kzfWtmOTqKK9AFWBiMv6k1uyRIHDViCZheIpkBJUFiRjigUG3V8CxukEHKoES4hqz1d0YxN7UClX4Jdq2vMEVbIw44xpW7CS3adM+eutcpg5lRnl3CCn50p6Af5W1otXdsWaOQ0hfAoyLoJui2Rpdy8neNfaUj6K1w+JHjvq6xm4HNwB9aomwCLXxuMPSrO/bRc4QJHS3vc+Qu/vVi67f/V/eEjtOn8YEzCLREoVo79Dj5QP8QO6LY9vcuK6jlQGKbux08HRpiail47KOhy7tdHVB6RTItG7P/o0OrC6GW32JpdaY+Dzet7mcduXoNNL7fja1u5SstWju90kr/vtG0Vur6siPasDUPxVZsrV6kBtjHGLJHDzdf77RL7/Z6Ni7l26Vy/qQ2prTqai8nJllBEGOJyr5LSWTTnB1r6XH2vVBK1RdbqW7veT6gHGqgiKa61J3H8fzi9fX1YjIedFJd7sZjjF3H/CPAbdq0adOmTZs2bbD5H8lJpKRvNiuNAAAAAElFTkSuQmCC",this.buildObjectMeshes=new Array,this.labels=new Array,this.labelSVGS=new Array,this.baseMaterial=null,this.highlightMaterial=null,this.cancelledMaterial=null,this.cancelledHighlightMaterial=null,this.showCancelObjects=!1,this.objectCallback=null,this.renderFailedCallback=null,this.labelCallback=null,this.registerClipIgnore=null,this.getMaxHeight=null,this.alphaLevel=.5,this.observableControls=null,this.showLabel=localStorage.getItem("showObjectLabels"),this.showLabel===null?this.showLabel=!0:this.showLabel=JSON.parse(this.showLabel),this.rebuildMaterials()}return Pt(a,[{key:"setBuildMaterial",value:function(e,t,i){i||(i=this.alphaLevel);var s=new ee(e,this.scene);return s.diffuseColor=t,s.specularColor=new de(0,0,0),s.alpha=i,s.needAlphaTesting=()=>!0,s.separateCullingPass=!0,s.backFaceCulling=!0,s}},{key:"rebuildMaterials",value:function(){this.baseMaterial=this.setBuildMaterial("BuildObjectBaseMaterial",new H(.1,.5,.1),.25),this.highlightMaterial=this.setBuildMaterial("BuildObjectHighlightMateria",new de(.8,.8,.8)),this.cancelledMaterial=this.setBuildMaterial("BuildObjectHighlightMateria",new de(1,0,0),.4),this.cancelledHighlightMaterial=this.setBuildMaterial("BuildObjectHighlightMateria",new de(1,1,0),.6);var e=ie.CreateFromBase64String(this.xmark,"checkerboard",this.scene);this.cancelledMaterial.diffuseTexture=e,this.cancelledHighlightMaterial.diffuseTexture=e}},{key:"loadObjectBoundaries",value:function(e){if(this.rebuildMaterials(),this.buildObjectMeshes.length>0){for(var t=0;t<this.buildObjectMeshes.length;t++)this.buildObjectMeshes[t].dispose();this.labelSVGS.forEach(o=>window.URL.revokeObjectURL(o)),this.buildObjectMeshes=new Array,this.labels=new Array}if(e)for(var i=0;i<e.length;i++){var s=e[i],n=Zt.CreateTiledBox("OBJECTMESH:"+s.name,{pattern:F.CAP_ALL,alignVertical:F.TOP,alignHorizontal:F.LEFT,tileHeight:4,tileWidth:4,width:Math.abs(s.x[1]-s.x[0]),height:this.getMaxHeight()+10,depth:Math.abs(s.y[1]-s.y[0]),sideOrientation:F.FRONTSIDE},this.scene);n.position.x=(s.x[1]+s.x[0])/2,n.position.y=this.getMaxHeight()/2-4,n.position.z=(s.y[1]+s.y[0])/2,n.alphaIndex=5e6,n.isPickable=!0,s.index=i,n.metadata=s,n.enablePointerMoveEvents=!0,n.renderingGroupId=3,this.setObjectTexture(n),n.setEnabled(this.showCancelObjects),this.registerClipIgnore(n),this.buildObjectMeshes.push(n);var r=this.makeTextPlane(s.name,s.cancelled?"yellow":"white",20);r.position=new v(0,this.getMaxHeight()/2+10,0),r.isPickable=!1,r.metadata=s,r.parent=n,r.setEnabled(this.showLabel),this.labels.push(r)}}},{key:"makeTextPlane",value:function(e,t,i){var s=uu("svg").attr("width",800).attr("height",200).attr("fill","none");s.append("text").attr("x",400).attr("y",100).attr("font-family","Verdana").attr("font-size","50px").attr("text-anchor","middle").attr("alignment-baseline","middle").attr("fill","black").attr("stroke",t).attr("stroke-width",2).attr("text-rendering","optimizeLegibility").text(e);var n=s.attr("title","test2").attr("version",1.1).attr("xmlns","http://www.w3.org/2000/svg").node(),r=new XMLSerializer().serializeToString(n),o=new Blob(['<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'+r],{type:"image/svg+xml"}),h=window.URL.createObjectURL(o);this.labelSVGS.push(h);var l=Zt.CreatePlane("TextPlane",{width:i,height:8},this.scene);return l.material=new ee("TextPlaneMaterial",this.scene),l.material.backFaceCulling=!1,l.material.specularColor=new de(0,0,0),l.material.diffuseTexture=new ie(h,this.scene),l.material.diffuseTexture.hasAlpha=!0,l.billboardMode=7,this.registerClipIgnore(l),l}},{key:"buildObservables",value:function(){var e=this;if(!this.observableControls){var t=0,i=!1,s=0;this.observableControls=this.scene.onPointerObservable.add(n=>{var r=n.pickInfo;switch(n.type){case Ce.POINTERDOWN:i=!0,s=Date.now();break;case Ce.POINTERUP:if(i=!1,Date.now()-s>200)return;e.handleClick(r);break;case Ce.POINTERMOVE:if(i||Date.now()-t<100)return;t=Date.now(),e.handlePointerMove(r)}})}}},{key:"clearObservables",value:function(){this.observableControls&&(this.scene.onPointerObservable.remove(this.observableControls),this.observableControls=null)}},{key:"showObjectSelection",value:function(e){this.showCancelObjects=e,this.buildObjectMeshes.forEach(t=>t.setEnabled(e)),e?this.buildObservables():this.clearObservables()}},{key:"setObjectTexture",value:function(e){e.metadata&&(e.metadata.cancelled?(e.material=this.cancelledMaterial,e.enableEdgesRendering(),e.edgesWidth=15,e.edgesColor=new H(1,0,0,1)):(e.material=this.baseMaterial,e.enableEdgesRendering(),e.edgesWidth=15,e.edgesColor=new H(0,1,0,1)))}},{key:"handleClick",value:function(e){this.showCancelObjects&&e.hit&&e.pickedMesh&&e.pickedMesh.name.includes("OBJECTMESH")&&this.objectCallback&&this.objectCallback(e.pickedMesh.metadata)}},{key:"handlePointerMove",value:function(e){var t=this;this.showCancelObjects&&(this.buildObjectMeshes.forEach(i=>t.setObjectTexture(i)),e.hit&&e.pickedMesh&&e.pickedMesh.name.includes("OBJECTMESH")?(e.pickedMesh.material=e.pickedMesh.metadata.cancelled?this.cancelledHighlightMaterial:this.highlightMaterial,this.labelCallback&&this.labelCallback(e.pickedMesh.metadata.name)):this.labelCallback&&this.labelCallback(""))}},{key:"showLabels",value:function(e){localStorage.setItem("showObjectLabels",e),this.showLabel=e,this.labels.forEach(t=>t.setEnabled(e))}}]),a}(),Gb=function(){function a(e){Mt(this,a),this.visible=localStorage.getItem("axesVisible"),this.visible===null?this.visible=!0:this.visible=JSON.parse(this.visible),this.scene=e,this.registerClipIgnore=()=>{},this.axesMesh=null,this.axesMeshPosition=null,this.size=50,this.debug=!1}return Pt(a,[{key:"show",value:function(e){localStorage.setItem("axesVisible",e),this.axesMesh&&this.axesMesh.setEnabled(e),this.scene.render()}},{key:"makeTextPlane",value:function(e,t,i){var s=new Wn("DynamicTexture",50,this.scene,!0);s.hasAlpha=!0,s.drawText(e,5,40,"bold 36px Arial",t,"transparent",!0);var n=F.CreatePlane("TextPlane",i,this.scene,!0);return n.material=new ee("TextPlaneMaterial",this.scene),n.material.backFaceCulling=!1,n.material.specularColor=new de(0,0,0),n.material.diffuseTexture=s,n}},{key:"resize",value:function(e){this.size=e,this.axesMesh.dispose(!1,!0),this.render()}},{key:"render",value:function(e){var t=this;if(!this.debug)if(!this.axesMesh||this.axesMesh.isDisposed()){this.axesMesh=new F("axis",this.scene),this.registerClipIgnore(this.axesMesh);var i=F.CreateLines("axisX",[v.Zero(),new v(this.size,0,0),new v(.95*this.size,.05*this.size,0),new v(this.size,0,0),new v(.95*this.size,-.05*this.size,0)],this.scene);i.color=new de(1,0,0),i.parent=this.axesMesh;var s=this.makeTextPlane("X","red",this.size/10);s.billboardMode=7,s.position=new v(.9*this.size,.05*this.size,0),s.parent=this.axesMesh;var n=F.CreateLines("axisZ",[v.Zero(),new v(0,0,this.size),new v(0,-.05*this.size,.95*this.size),new v(0,0,this.size),new v(0,.05*this.size,.95*this.size)],this.scene);n.color=new de(0,1,0),n.parent=this.axesMesh;var r=this.makeTextPlane("Y","green",this.size/10);r.billboardMode=7,r.position=new v(0,.05*this.size,.9*this.size),r.parent=this.axesMesh;var o=F.CreateLines("axisY",[v.Zero(),new v(0,this.size,0),new v(-.05*this.size,.95*this.size,0),new v(0,this.size,0),new v(.05*this.size,.95*this.size,0)],this.scene);o.color=new de(0,0,1),o.parent=this.axesMesh;var h=this.makeTextPlane("Z","blue",this.size/10);h.billboardMode=7,h.position=new v(0,.9*this.size,-.05*this.size),h.parent=this.axesMesh,this.axesMesh.setEnabled(this.visible),this.axesMesh.getChildren().forEach(l=>t.registerClipIgnore(l)),e&&(this.axesMesh.position=e)}else e&&(this.axesMesh.position=e)}},{key:"dispose",value:function(){this.axesMesh&&this.axesMesh.dispose(!1,!0)}}]),a}(),Ze=null;function Zs(a,e,t){var i=function(s,n,r,o,h,l){var c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:75,u=uu("svg").attr("width",400).attr("height",300);u.append("rect").attr("x",0).attr("y",0).attr("width",400).attr("height",300).attr("fill","#333333"),u.append("text").attr("x",200).attr("y",150).attr("font-family","Roboto").attr("font-size",c+"px").attr("text-anchor","middle").attr("alignment-baseline","middle").attr("fill",o).attr("stroke",r).attr("stroke-width",2).attr("text-rendering","optimizeLegibility").text(n);var f=u.attr("title","test2").attr("version",1.1).attr("xmlns","http://www.w3.org/2000/svg").node(),d='<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">',_=new XMLSerializer().serializeToString(f),p=new Blob([d+_],{type:"image/svg+xml"}),g=window.URL.createObjectURL(p),m=Zt.CreatePlane("TextPlane",{width:h,height:l},s);return m.material=new ee("TextPlaneMaterial",s),m.material.backFaceCulling=!1,m.material.specularColor=new de(0,0,0),m.material.diffuseTexture=new ie(g,s),m.material.diffuseTexture.hasAlpha=!1,m}(a,e,"white","white",6,6,90);i.name=e,i.lookAt(t),i.position=t.scale(-3),e==="Top"&&i.rotate(Gt.Z,Math.PI/2,ci.LOCAL),e==="Bottom"&&i.rotate(Gt.Z,-Math.PI/2,ci.LOCAL),i.metadata={x:Math.sign(t.x),y:Math.sign(t.y),z:Math.sign(t.z)},i.isPickable=!0}function gs(a,e,t){var i=Zt.CreateSphere(e,{diameter:1.1},a),s=v.Zero();s.x=t.x-.25*Math.sign(t.x),s.y=t.y-.1*Math.sign(t.y),s.z=t.z-.25*Math.sign(t.z),i.metadata={x:-1*Math.sign(t.x),y:-1*Math.sign(t.y),z:-1*Math.sign(t.z)},i.position=s,i.isPickable=!0}var n0,Ma=null;function pi(a,e,t){Ma||((Ma=new ee("edgematerial",a)).diffuseColor=new de(.5,.5,.5));var i=Zt.CreateBox(e,{width:.35,height:5.8,depth:.35},a),s=v.Zero();t.y!==0&&(i.rotate(Gt.Z,Math.PI/2,ci.WORLD),t.x!==0&&i.rotate(Gt.Y,Math.PI/2,ci.WORLD),i.bakeCurrentTransformIntoVertices()),s.x=t.x-Math.sign(t.x),s.y=t.y-Math.sign(t.y),s.z=t.z-Math.sign(t.z),i.metadata={x:-1*Math.sign(t.x),y:-1*Math.sign(t.y),z:-1*Math.sign(t.z)},i.position=s,i.material=Ma}function zb(a,e,t){(Ze=new it(a)).autoClear=!1;var i=new tt("camera1",5*Math.PI/8,5*Math.PI/8,13,new v(0,0,0),Ze);i.viewport=new on(.85,.85,.15,.15),i.viewport.toGlobal(200,200),e.afterRender=()=>{Ze.render(),i.alpha=t.alpha,i.beta=t.beta,i.radius=15},new _n("light1",new v(0,1,0),Ze).intensity=.8,new _n("light2",new v(-1,-.5,0),Ze).intensity=.8;var s=3.9;pi(Ze,"FrontLeft",new v(-3.9,0,-3.9)),pi(Ze,"BackLeft",new v(-3.9,0,s)),pi(Ze,"BackRight",new v(s,0,s)),pi(Ze,"FrontRight",new v(s,0,-3.9)),pi(Ze,"TopFront",new v(0,s,-3.9)),pi(Ze,"TopBack",new v(0,s,s)),pi(Ze,"TopLeft",new v(-3.9,s,0)),pi(Ze,"TopRight",new v(s,s,0)),pi(Ze,"BottomFront",new v(0,-3.9,-3.9)),pi(Ze,"BottomBack",new v(0,-3.9,s)),pi(Ze,"BottomLeft",new v(-3.9,-3.9,0)),pi(Ze,"BottomRight",new v(s,-3.9,0)),gs(Ze,"FrontTopLeft",new v(-3,3,-3)),gs(Ze,"FrontTopRight",new v(3,3,-3)),gs(Ze,"BackTopLeft",new v(-3,3,3)),gs(Ze,"BackTopRight",new v(3,3,3)),gs(Ze,"FrontBottomLeft",new v(-3,-3,-3)),gs(Ze,"FrontBottomRight",new v(3,-3,-3)),gs(Ze,"BackBottomLeft",new v(-3,-3,3)),gs(Ze,"BackBottomRight",new v(3,-3,3)),Zs(Ze,"Front",new v(0,0,1)),Zs(Ze,"Right",new v(-1,0,0)),Zs(Ze,"Back",new v(0,0,-1)),Zs(Ze,"Left",new v(1,0,0)),Zs(Ze,"Top",new v(0,-1,0)),Zs(Ze,"Bottom",new v(0,1,0)),Ze.onPointerDown=(n,r)=>{r.distance>0&&n0&&(n0(r.pickedMesh.metadata),Ze.render(!0))}}var Wb=function(){function a(e){Mt(this,a),this.visible=!0,this.scene=e,this.workplacePoints=[],this.workplaceMeshes=[],this.registerClipIgnore=()=>{}}return Pt(a,[{key:"setOffsets",value:function(e){this.workplacePoints=e,this.render()}},{key:"makeTextPlane",value:function(e,t,i){var s=new Wn("DynamicTexture",50,this.scene,!0);s.hasAlpha=!0,s.drawText(e,5,40,"bold 36px Arial",t,"transparent",!0);var n=F.CreatePlane("TextPlane",i,this.scene,!0);return n.material=new ee("TextPlaneMaterial",this.scene),n.material.backFaceCulling=!1,n.material.specularColor=new de(0,0,0),n.material.diffuseTexture=s,n}},{key:"render",value:function(){if(this.workplaceMeshes.length>0){for(var e=0;e<this.workplaceMeshes.length;e++)this.workplaceMeshes[e].dispose(!1,!0);this.workplaceMeshes=[]}if(this.visible)for(var t=0;t<this.workplacePoints.length;t++){var i=this.workplacePoints[t];if(!v.ZeroReadOnly.equals(i)){var s=this.makeTextPlane(t+1,"white",5);s.position=new v(i.x+1,i.z+2,i.y),s.billboardMode=7,s.isVisible=!0,s.renderingGroupId=2,this.registerClipIgnore(s),this.workplaceMeshes.push(s);var n=Zt.CreateBox("box",{size:1},this.scene);n.renderingGroupId=2,n.position=new v(i.x,i.z,i.y),n.isVisible=!0,this.registerClipIgnore(n),this.workplaceMeshes.push(n)}}}}]),a}(),Hb=function(){function a(n){Mt(this,a),this.lastLoadKey="lastLoadFailed",this.fileData=null,this.fileDataArray=null,this.fileSize=0,this.gcodeProcessor=new Nb,this.maxHeight=0,this.minHeight=0,this.sceneBackgroundColor="#000000",this.canvas=n,this.scene={},this.loading=!1,this.toolVisible=!1,this.travelVisible=!1,this.debug=!1,this.zTopClipValue=1e6,this.zBottomClipValue=-1e6,this.cancelHitTimer=0,this.pause=!1,this.hqNozzle=!0,this.cameraInertia=localStorage.getItem("cameraInertia")==="true",this.bed=null,this.buildObjects=null,this.axes=null,this.workplace=null,this.renderQuality=Number(localStorage.getItem("renderQuality")),this.renderQuality!==void 0&&this.renderQuality!==null||(this.renderQuality=1),this.renderTimeout=1e3,this.simulation=!1,this.simulationLastUpdate=0,this.simulationTimeToMove=0,this.simulationCurrentLine=null,this.simulationMultiplier=1,this.simulationUpdatePosition=()=>{},this.simulationStopped=()=>{},this.simLine=v.Zero(),this.isMMS=!1}var e,t,i,s;return Pt(a,[{key:"getMaxHeight",value:function(){return this.maxHeight}},{key:"getMinHeight",value:function(){return this.minHeight}},{key:"setCameraType",value:function(n){this.scene.activeCamera=n?this.orbitCamera:this.flyCamera}},{key:"setZClipPlane",value:function(n,r){this.zTopClipValue=-n,this.zBottomClipValue=r,r>n&&(this.zTopClipValue=r+1),this.scene.clipPlane=new Xt(0,1,0,this.zTopClipValue),this.scene.clipPlane2=new Xt(0,-1,0,this.zBottomClipValue),this.scene.render()}},{key:"isArcRotateCameraStopped",value:function(n){return n.inertialAlphaOffset===0&&n.inertialBetaOffset===0&&n.inertialRadiusOffset===0&&n.inertialPanningX===0&&n.inertialPanningY===0}},{key:"init",value:(s=Gi(It().mark(function n(r){var o,h,l=this;return It().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return r===void 0&&(r=!1),console.info("GCode Viewer - Sindarius - ".concat("3.7.16"," ")),c.next=4,Ye.IsSupportedAsync;case 4:if(!c.sent||!r){c.next=13;break}return console.log("WebGPU Supported"),this.engine=new Ye(this.canvas,{doNotHandleContextLost:!0}),c.next=10,this.engine.initAsync();case 10:console.log(this.engine),c.next=15;break;case 13:console.log("WebGPU Not Supported"),this.engine=new le(this.canvas,!0,{doNotHandleContextLost:!0});case 15:this.engine.enableOfflineSupport=!1,this.engine.setHardwareScalingLevel(1/window.devicePixelRatio),this.scene=new it(this.engine),this.scene.performancePriority=Ha.BackwardCompatible,this.debug,this.scene.clearColor=de.FromHexString(this.getBackgroundColor()),this.bed=new kb(this.scene),this.bed.registerClipIgnore=u=>{l.registerClipIgnore(u)},o=this.bed.getCenter(),this.orbitCamera=new tt("Camera",Math.PI/2,2.356194,250,new v(o.x,-2,o.y),this.scene),this.orbitCamera.attachControl(!1),this.orbitCamera.invertRotation=!1,this.orbitCamera.attachControl(this.canvas,!1),this.orbitCamera.maxZ=1e5,this.orbitCamera.lowerRadiusLimit=5,this.updateCameraInertiaProperties(),(h=new jr("light2",new v(0,1,-1),this.scene)).diffuse=new de(1,1,1),h.specular=new de(1,1,1),this.engine.runRenderLoop(()=>{if(!document.hidden){if(l.simulation){if(l.pause)return}else if(l.pause||Date.now()-l.gcodeProcessor.lastUpdate>l.renderTimeout&&l.isArcRotateCameraStopped(l.orbitCamera))return;if(l.simulation)try{l.runSimulation(),l.gcodeProcessor.doUpdate()}catch{l.simulation=!1,l.simulationStopped()}l.scene.render(!0),h.position=l.scene.cameras[0].position}}),this.buildObjects=new Vb(this.scene),this.buildObjects.getMaxHeight=()=>l.gcodeProcessor.getMaxHeight(),this.buildObjects.registerClipIgnore=u=>{l.registerClipIgnore(u)},this.bed.buildBed(),this.axes=new Gb(this.scene),this.axes.registerClipIgnore=u=>{l.registerClipIgnore(u)},this.axes.render(),this.workplace=new Wb(this.scene),this.workplace.registerClipIgnore=u=>{l.registerClipIgnore(u)},this.workplace.setOffsets(this.gcodeProcessor.workplaceOffsets),this.workplace.render(),this.resetCamera(),zb(this.engine,this.scene,this.orbitCamera),n0=u=>{console.log("viewbox callback",u),l.setViewboxCameraPosition(u)},setTimeout(()=>{l.forceRender()},1e3);case 50:case"end":return c.stop()}},n,this)})),function(n){return s.apply(this,arguments)})},{key:"setViewboxCameraPosition",value:function(n){var r=this.bed.getCenter(),o=this.bed.getSize();this.scene.activeCamera.radius=1.5*o.x,this.scene.activeCamera.target=new v(r.x,r.z,r.y);var h=v.Zero(),l=(n.x===0?1:0)+(n.y===0?1:0)+(n.z===0?1:0)==2?1.75:1.35;switch(n.x){case 1:h.x=r.x-o.x*l;break;case 0:h.x=r.x;break;case-1:h.x=r.x+o.x*l}switch(n.y){case 1:h.y=r.z-o.z*l;break;case 0:h.y=r.z;break;case-1:h.y=r.z+o.z*l}switch(n.z){case 1:h.z=r.y-o.y*l;break;case 0:h.z=r.y;break;case-1:h.z=r.y+o.y*l}n.x===0&&n.z===0?(this.scene.activeCamera.target=new v(r.x,0,r.y),this.scene.activeCamera.position=h,this.scene.activeCamera.alpha=3*Math.PI/2):this.scene.activeCamera.position=h,this.scene.render(!0),this.scene.render(!0)}},{key:"resize",value:function(){this.engine.resize(),this.scene.render(!0)}},{key:"refreshUI",value:function(){setTimeout(()=>{},0)}},{key:"resetCamera",value:function(){var n=this.bed.getCenter(),r=this.bed.getSize();this.bed.isDelta?(this.scene.activeCamera.radius=n.x,this.scene.activeCamera.target=new v(n.x,-2,n.y),this.scene.activeCamera.position=new v(-r.x,r.z,-r.x)):(this.scene.activeCamera.radius=3*n.x,this.scene.activeCamera.target=new v(n.x,-2,n.y),this.scene.activeCamera.position=new v(-r.x/2,r.z,-r.y/2)),this.scene.render(!0),this.scene.render(!0)}},{key:"lastLoadFailed",value:function(){return!!localStorage&&localStorage.getItem(this.lastLoadKey)==="true"}},{key:"setLoadFlag",value:function(){localStorage&&localStorage.setItem(this.lastLoadKey,"true")}},{key:"clearLoadFlag",value:function(){localStorage&&(localStorage.setItem(this.lastLoadKey,""),localStorage.removeItem(this.lastLoadKey))}},{key:"processFile",value:(i=Gi(It().mark(function n(r){return It().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:this.clearScene(),this.refreshUI(),r?(this.fileData=r,this.fileSize=r.length):(this.fileData=0,this.fileSize=0),this.fileDataArray=[];try{this.fileData===null&&this.fileData===""||(this.fileDataArray=this.fileData.split("\n"))}catch{this.fileDataArray=[]}return this.gcodeProcessor.setProgressColor(this.getProgressColor()),this.gcodeProcessor.scene=this.scene,this.lastLoadFailed()&&(console.error("Last rendering failed dropping to SBC quality"),this.updateRenderQuality(1),this.clearLoadFlag()),this.setLoadFlag(),o.next=11,this.gcodeProcessor.processGcodeFile(r,this.renderQuality);case 11:return this.clearLoadFlag(),o.next=14,this.gcodeProcessor.createMesh(this.scene);case 14:this.gcodeProcessor.loadingComplete(),this.maxHeight=this.gcodeProcessor.getMaxHeight(),this.minHeight=this.gcodeProcessor.getMinHeight(),this.toggleTravels(this.travelVisible),this.setCursorVisiblity(this.toolCursorVisible),this.gcodeProcessor.zBelt&&(this.bed.buildVolume.y.min=this.gcodeProcessor.beltLength,this.bed.buildVolume.y.max=0,this.bed.dispose(),this.bed.buildBed());case 20:case"end":return o.stop()}},n,this)})),function(n){return i.apply(this,arguments)})},{key:"toggleTravels",value:function(n){var r,o=function(l,c){var u=typeof Symbol<"u"&&l[Symbol.iterator]||l["@@iterator"];if(!u){if(Array.isArray(l)||(u=oo(l))||c){u&&(l=u);var f=0,d=()=>{};return{s:d,n:()=>f>=l.length?{done:!0}:{done:!1,value:l[f++]},e:m=>{throw m},f:d}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var _,p=!0,g=!1;return{s:()=>{u=u.call(l)},n:()=>{var m=u.next();return p=m.done,m},e:m=>{g=!0,_=m},f:()=>{try{p||u.return==null||u.return()}finally{if(g)throw _}}}}(this.scene.meshes);try{for(o.s();!(r=o.n()).done;){var h=r.value;h.name==="travels"&&(h.isVisible=n)}}catch(l){o.e(l)}finally{o.f()}this.travelVisible=n,this.scene.render(!0)}},{key:"getProgressColor",value:function(){var n=localStorage.getItem("progressColor");return n===null&&(n="#FFFFFF"),n}},{key:"setProgressColor",value:function(n){localStorage.setItem("progressColor",n),this.gcodeProcessor.setProgressColor(n)}},{key:"getBackgroundColor",value:function(){var n=localStorage.getItem("sceneBackgroundColor");return n===null&&(n="#000000"),n}},{key:"setBackgroundColor",value:function(n){this.scene!==null&&this.scene!==void 0&&(n.length>7&&(n=n.substring(0,7)),this.scene.clearColor=de.FromHexString(n),this.scene.render()),localStorage.setItem("sceneBackgroundColor",n)}},{key:"clearScene",value:function(n){this.fileData&&n&&(this.fileData=""),this.gcodeProcessor.unregisterEvents();for(var r=this.scene.meshes.length-1;r>=0;r--){var o=this.scene.meshes[r];o&&this.debug&&console.log("Disposing ".concat(o.name)),this.scene.removeMesh(o),o&&typeof o.dispose=="function"&&o.dispose(!1,!0)}for(var h=this.scene.materials.length-1;h>=0;h--){var l=this.scene.materials[h];l.name==="solidMaterial"&&(l&&this.debug&&console.log("Disposing ".concat(l.name)),this.scene.removeMaterial(l),l&&typeof l.dispose=="function"&&l.dispose(!1,!0))}this.toolCursor&&(this.toolCursor.dispose(!1,!0),this.toolCursor=void 0),this.buildtoolCursor(),this.bed.buildBed(),this.axes.render(),this.workplace.render()}},{key:"reload",value:(t=Gi(It().mark(function n(){return It().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return this.clearScene(),r.next=3,this.processFile(this.fileData);case 3:case"end":return r.stop()}},n,this)})),function(){return t.apply(this,arguments)})},{key:"getRenderMode",value:function(){return this.gcodeProcessor.renderMode}},{key:"setCursorVisiblity",value:function(n){this.scene!==void 0&&(this.toolCursor===void 0&&this.buildtoolCursor(),this.toolCursorMesh.isVisible=n,this.toolCursorVisible=n,this.scene.render())}},{key:"updateToolPosition",value:function(n){var r=0,o=0,h=0;if(this.buildtoolCursor(),n instanceof v)r=n.x,o=n.z,h=n.y;else for(var l=0;l<n.length;l++)switch(n[l].axes){case"X":r=n[l].position;break;case"Y":o=n[l].position;break;case"Z":h=n[l].position*(this.gcodeProcessor.spreadLines?this.gcodeProcessor.spreadLineAmount:1)}this.toolCursor.setAbsolutePosition(new v(r,h,o)),this.toolCursorMesh.isVisible&&this.scene.render()}},{key:"buildtoolCursor",value:function(){if(this.toolCursor===void 0){this.toolCursor=new Te("toolCursorContainer"),ks.ShowLoadingScreen=!1,ks.Append("","data:# WaveFront *.obj file (generated by Autodesk ATF)\n\ng JRNozzle\n\nv 0.429187 -3.010668 2.826259\nv 0.421210 -3.010485 2.813202\nv 0.412190 -3.010277 2.801026\nv 0.401522 -3.010032 2.790242\nv 0.389909 -3.009764 2.780255\nv 0.392210 -2.909791 2.780255\nv 0.403822 -2.910058 2.790242\nv 0.414490 -2.910303 2.801026\nv 0.423510 -2.910511 2.813202\nv 0.431487 -2.910695 2.826259\nv 0.373704 -3.009392 2.770250\nv 0.356792 -3.009002 2.762005\nv 0.338760 -3.008588 2.756557\nv 0.320082 -3.008158 2.752720\nv 0.322382 -2.908184 2.752720\nv 0.341060 -2.908614 2.756557\nv 0.359093 -2.909029 2.762005\nv 0.376004 -2.909418 2.770250\nv 0.294312 -3.007565 2.749930\nv 0.268495 -3.006971 2.747890\nv 0.242609 -3.006376 2.746972\nv 0.216685 -3.005779 2.746676\nv 0.218985 -2.905806 2.746676\nv 0.244909 -2.906402 2.746972\nv 0.270795 -2.906998 2.747890\nv 0.296612 -2.907591 2.749930\nv 0.137458 -3.003956 2.746676\nv 0.139758 -2.903983 2.746676\nv 0.137458 -3.003956 3.015984\nv 0.139758 -2.903983 3.015984\nv 0.230784 -3.006103 3.015984\nv 0.233084 -2.906130 3.015984\nv 0.251108 -3.006571 3.015850\nv 0.271425 -3.007038 3.015480\nv 0.291729 -3.007506 3.014692\nv 0.312025 -3.007973 3.013633\nv 0.314326 -2.907999 3.013633\nv 0.294029 -2.907532 3.014692\nv 0.273725 -2.907065 3.015480\nv 0.253408 -2.906598 3.015850\nv 0.327664 -3.008332 3.012024\nv 0.343112 -3.008688 3.009541\nv 0.358225 -3.009035 3.005526\nv 0.373124 -3.009378 3.000537\nv 0.375424 -2.909405 3.000537\nv 0.360525 -2.909062 3.005526\nv 0.345412 -2.908714 3.009541\nv 0.329964 -2.908359 3.012024\nv 0.388822 -3.009739 2.992940\nv 0.403254 -3.010071 2.983797\nv 0.415441 -3.010352 2.971906\nv 0.426166 -3.010599 2.958227\nv 0.428466 -2.910625 2.958227\nv 0.417742 -2.910378 2.971906\nv 0.405555 -2.910098 2.983797\nv 0.391122 -2.909766 2.992940\nv 0.432998 -3.010756 2.942842\nv 0.438146 -3.010874 2.927042\nv 0.440638 -3.010932 2.910586\nv 0.441608 -3.010954 2.893754\nv 0.443908 -2.910980 2.893754\nv 0.442938 -2.910958 2.910586\nv 0.440446 -2.910901 2.927042\nv 0.435298 -2.910782 2.942842\nv 0.441038 -3.010941 2.876383\nv 0.439178 -3.010898 2.859264\nv 0.434976 -3.010801 2.842606\nv 0.437276 -2.910828 2.842606\nv 0.441478 -2.910924 2.859264\nv 0.443338 -2.910967 2.876383\nv 0.510093 -3.012529 2.628475\nv 0.551628 -3.013485 2.651463\nv 0.590608 -3.014382 2.677637\nv 0.625121 -3.015176 2.709380\nv 0.656797 -3.015905 2.744661\nv 0.659097 -2.915931 2.744661\nv 0.627421 -2.915202 2.709380\nv 0.592908 -2.914408 2.677637\nv 0.553928 -2.913511 2.651463\nv 0.512393 -2.912556 2.628475\nv 0.679846 -3.016435 2.786804\nv 0.697041 -3.016831 2.830679\nv 0.705168 -3.017017 2.877239\nv 0.708160 -3.017086 2.925319\nv 0.710460 -2.917113 2.925319\nv 0.707468 -2.917044 2.877239\nv 0.699341 -2.916857 2.830679\nv 0.682146 -2.916461 2.786804\nv 0.706219 -3.017042 2.960458\nv 0.700958 -3.016921 2.994740\nv 0.689832 -3.016665 3.027509\nv 0.674925 -3.016322 3.059302\nv 0.677225 -2.916348 3.059302\nv 0.692133 -2.916691 3.027509\nv 0.703258 -2.916947 2.994740\nv 0.708519 -2.917068 2.960458\nv 0.656164 -3.015890 3.084796\nv 0.635398 -3.015412 3.108227\nv 0.611325 -3.014858 3.128259\nv 0.585291 -3.014260 3.146273\nv 0.587591 -2.914286 3.146273\nv 0.613625 -2.914885 3.128259\nv 0.637698 -2.915439 3.108227\nv 0.658464 -2.915917 3.084796\nv 0.556876 -3.013606 3.161195\nv 0.527664 -3.012934 3.173934\nv 0.497122 -3.012231 3.183026\nv 0.465779 -3.011510 3.189926\nv 0.468079 -2.911536 3.189926\nv 0.499422 -2.912257 3.183026\nv 0.529964 -2.912960 3.173934\nv 0.559176 -2.913632 3.161195\nv 0.427819 -3.010637 3.194504\nv 0.389776 -3.009761 3.197889\nv 0.351607 -3.008883 3.199454\nv 0.313368 -3.008003 3.200000\nv 0.315668 -2.908030 3.200000\nv 0.353907 -2.908910 3.199454\nv 0.392076 -2.909788 3.197889\nv 0.430119 -2.910663 3.194504\nv -0.119022 -2.998056 3.200000\nv -0.116722 -2.898082 3.200000\nv -0.119022 -2.998056 2.200000\nv -0.116722 -2.898082 2.200000\nv 0.137458 -3.003956 2.200000\nv 0.139758 -2.903983 2.200000\nv 0.137458 -3.003956 2.566689\nv 0.139758 -2.903983 2.566689\nv 0.256907 -3.006704 2.566689\nv 0.259207 -2.906731 2.566689\nv 0.528882 -3.012962 2.200000\nv 0.531182 -2.912988 2.200000\nv 0.843786 -3.020207 2.200000\nv 0.846086 -2.920233 2.200000\nv -0.361403 -2.992479 3.200000\nv -0.848178 -2.981280 3.200000\nv -0.845878 -2.881306 3.200000\nv -0.359103 -2.892506 3.200000\nv -0.848178 -2.981280 3.015984\nv -0.845878 -2.881306 3.015984\nv -0.619226 -2.986547 3.015984\nv -0.616926 -2.886574 3.015984\nv -0.619226 -2.986547 2.617310\nv -0.616926 -2.886574 2.617310\nv -0.619316 -2.986545 2.592175\nv -0.619616 -2.986539 2.567043\nv -0.620298 -2.986523 2.541920\nv -0.621240 -2.986501 2.516802\nv -0.618940 -2.886528 2.516802\nv -0.617998 -2.886549 2.541920\nv -0.617316 -2.886565 2.567043\nv -0.617016 -2.886572 2.592175\nv -0.623187 -2.986456 2.498146\nv -0.626433 -2.986382 2.479806\nv -0.631888 -2.986256 2.462004\nv -0.638697 -2.986100 2.444533\nv -0.636397 -2.886126 2.444533\nv -0.629588 -2.886283 2.462004\nv -0.624133 -2.886408 2.479806\nv -0.620887 -2.886483 2.498146\nv -0.649070 -2.985861 2.428224\nv -0.661200 -2.985582 2.413707\nv -0.676153 -2.985238 2.402066\nv -0.692746 -2.984856 2.392096\nv -0.690446 -2.884882 2.392096\nv -0.673853 -2.885264 2.402066\nv -0.658900 -2.885608 2.413707\nv -0.646770 -2.885887 2.428224\nv -0.719047 -2.984251 2.383107\nv -0.745835 -2.983635 2.376701\nv -0.773318 -2.983002 2.373986\nv -0.801179 -2.982361 2.373271\nv -0.798879 -2.882388 2.373271\nv -0.771018 -2.883029 2.373986\nv -0.743535 -2.883661 2.376701\nv -0.716747 -2.884277 2.383107\nv -0.823764 -2.981842 2.373764\nv -0.846217 -2.981325 2.375333\nv -0.868428 -2.980814 2.378851\nv -0.890477 -2.980307 2.383680\nv -0.888177 -2.880333 2.383680\nv -0.866128 -2.880841 2.378851\nv -0.843917 -2.881352 2.375333\nv -0.821464 -2.881868 2.373764\nv -0.907395 -2.979918 2.388908\nv -0.924242 -2.979530 2.394350\nv -0.940967 -2.979145 2.400154\nv -0.957618 -2.978762 2.406179\nv -0.955318 -2.878789 2.406179\nv -0.938667 -2.879172 2.400154\nv -0.921942 -2.879557 2.394350\nv -0.905095 -2.879944 2.388908\nv -0.981789 -2.978206 2.406179\nv -0.979489 -2.878233 2.406179\nv -0.981789 -2.978206 2.203967\nv -0.979489 -2.878233 2.203967\nv -0.955081 -2.978821 2.199277\nv -0.928288 -2.979437 2.195213\nv -0.901363 -2.980056 2.192119\nv -0.874363 -2.980678 2.189575\nv -0.872063 -2.880704 2.189575\nv -0.899063 -2.880083 2.192119\nv -0.925988 -2.879463 2.195213\nv -0.952781 -2.878847 2.199277\nv -0.841836 -2.981426 2.187396\nv -0.809288 -2.982175 2.185732\nv -0.776708 -2.982924 2.184901\nv -0.744109 -2.983674 2.184553\nv -0.741809 -2.883701 2.184553\nv -0.774408 -2.882951 2.184901\nv -0.806988 -2.882201 2.185732\nv -0.839536 -2.881452 2.187396\nv -0.700655 -2.984674 2.185766\nv -0.657537 -2.985666 2.189337\nv -0.615019 -2.986644 2.197134\nv -0.572898 -2.987613 2.207723\nv -0.570598 -2.887640 2.207723\nv -0.612719 -2.886671 2.197134\nv -0.655237 -2.885693 2.189337\nv -0.698355 -2.884701 2.185766\nv -0.541154 -2.988344 2.220145\nv -0.510585 -2.989047 2.234674\nv -0.482032 -2.989704 2.252818\nv -0.454729 -2.990332 2.273203\nv -0.452429 -2.890358 2.273203\nv -0.479732 -2.889730 2.252818\nv -0.508284 -2.889073 2.234674\nv -0.538854 -2.888370 2.220145\nv -0.433234 -2.990827 2.294554\nv -0.413950 -2.991270 2.317498\nv -0.398331 -2.991630 2.343084\nv -0.384902 -2.991939 2.370248\nv -0.382602 -2.891965 2.370248\nv -0.396031 -2.891656 2.343084\nv -0.411649 -2.891297 2.317498\nv -0.430934 -2.890853 2.294554\nv -0.374848 -2.992170 2.400254\nv -0.367099 -2.992348 2.430703\nv -0.363132 -2.992439 2.461879\nv -0.361403 -2.992479 2.493486\nv -0.359103 -2.892506 2.493486\nv -0.360832 -2.892466 2.461879\nv -0.364799 -2.892375 2.430703\nv -0.372548 -2.892196 2.400254\nv -1.800595 -2.959368 1.700000\nv 1.662591 -3.039045 1.700000\nv 1.662591 -3.039045 3.700000\nv -1.800595 -2.959368 3.700000\nv 0.500000 0.000000 7.700000\nv 0.492808 0.084500 7.700000\nv 0.471439 0.166570 7.700000\nv 0.436507 0.243847 7.700000\nv 0.389018 0.314110 7.700000\nv 0.330337 0.375336 7.700000\nv 0.262154 0.425765 7.700000\nv 0.186428 0.463945 7.700000\nv 0.105340 0.488778 7.700000\nv 0.021221 0.499549 7.700000\nv -0.063509 0.495950 7.700000\nv -0.146411 0.478083 7.700000\nv -0.225102 0.446463 7.700000\nv -0.297317 0.401999 7.700000\nv -0.360978 0.345969 7.700000\nv -0.414255 0.279987 7.700000\nv -0.455614 0.205951 7.700000\nv -0.483866 0.125989 7.700000\nv -0.498199 0.042403 7.700000\nv -0.498199 -0.042403 7.700000\nv -0.483866 -0.125989 7.700000\nv -0.455614 -0.205951 7.700000\nv -0.414255 -0.279987 7.700000\nv -0.360978 -0.345969 7.700000\nv -0.297317 -0.401999 7.700000\nv -0.225102 -0.446463 7.700000\nv -0.146411 -0.478083 7.700000\nv -0.063509 -0.495950 7.700000\nv 0.021221 -0.499549 7.700000\nv 0.105340 -0.488778 7.700000\nv 0.186428 -0.463945 7.700000\nv 0.262154 -0.425765 7.700000\nv 0.330337 -0.375336 7.700000\nv 0.389018 -0.314110 7.700000\nv 0.436507 -0.243847 7.700000\nv 0.471439 -0.166570 7.700000\nv 0.492808 -0.084500 7.700000\nv 0.500000 0.000000 3.700000\nv 0.492808 -0.084500 3.700000\nv 0.471439 -0.166570 3.700000\nv 0.436507 -0.243847 3.700000\nv 0.389018 -0.314110 3.700000\nv 0.330337 -0.375336 3.700000\nv 0.262154 -0.425765 3.700000\nv 0.186428 -0.463945 3.700000\nv 0.105340 -0.488778 3.700000\nv 0.021221 -0.499549 3.700000\nv -0.063509 -0.495950 3.700000\nv -0.146411 -0.478083 3.700000\nv -0.225102 -0.446463 3.700000\nv -0.297317 -0.401999 3.700000\nv -0.360978 -0.345969 3.700000\nv -0.414255 -0.279987 3.700000\nv -0.455614 -0.205951 3.700000\nv -0.483866 -0.125989 3.700000\nv -0.498199 -0.042403 3.700000\nv -0.498199 0.042403 3.700000\nv -0.483866 0.125989 3.700000\nv -0.455614 0.205951 3.700000\nv -0.414255 0.279987 3.700000\nv -0.360978 0.345969 3.700000\nv -0.297317 0.401999 3.700000\nv -0.225102 0.446463 3.700000\nv -0.146411 0.478083 3.700000\nv -0.063509 0.495950 3.700000\nv 0.021221 0.499549 3.700000\nv 0.105340 0.488778 3.700000\nv 0.186428 0.463945 3.700000\nv 0.262154 0.425765 3.700000\nv 0.330337 0.375336 3.700000\nv 0.389018 0.314110 3.700000\nv 0.436507 0.243847 3.700000\nv 0.471439 0.166570 3.700000\nv 0.492808 0.084500 3.700000\nv 0.500000 -0.000000 6.366667\nv 0.500000 -0.000000 5.033333\nv 0.492404 0.086824 6.366667\nv 0.492404 0.086824 5.033333\nv 0.469846 0.171010 6.366667\nv 0.469846 0.171010 5.033333\nv 0.433013 0.250000 6.366667\nv 0.433013 0.250000 5.033333\nv 0.383022 0.321394 6.366667\nv 0.383022 0.321394 5.033333\nv 0.321394 0.383022 6.366667\nv 0.321394 0.383022 5.033333\nv 0.250000 0.433013 6.366667\nv 0.250000 0.433013 5.033333\nv 0.171010 0.469846 6.366667\nv 0.171010 0.469846 5.033333\nv 0.086824 0.492404 6.366667\nv 0.086824 0.492404 5.033333\nv -0.000000 0.500000 6.366667\nv -0.000000 0.500000 5.033333\nv -0.086824 0.492404 6.366667\nv -0.086824 0.492404 5.033333\nv -0.171010 0.469846 6.366667\nv -0.171010 0.469846 5.033333\nv -0.250000 0.433013 6.366667\nv -0.250000 0.433013 5.033333\nv -0.321394 0.383022 6.366667\nv -0.321394 0.383022 5.033333\nv -0.383022 0.321394 6.366667\nv -0.383022 0.321394 5.033333\nv -0.433013 0.250000 6.366667\nv -0.433013 0.250000 5.033333\nv -0.469846 0.171010 6.366667\nv -0.469846 0.171010 5.033333\nv -0.492404 0.086824 6.366667\nv -0.492404 0.086824 5.033333\nv -0.500000 0.000000 6.366667\nv -0.500000 0.000000 5.033333\nv -0.492404 -0.086824 6.366667\nv -0.492404 -0.086824 5.033333\nv -0.469846 -0.171010 6.366667\nv -0.469846 -0.171010 5.033333\nv -0.433013 -0.250000 6.366667\nv -0.433013 -0.250000 5.033333\nv -0.383022 -0.321394 6.366667\nv -0.383022 -0.321394 5.033333\nv -0.321394 -0.383022 6.366667\nv -0.321394 -0.383022 5.033333\nv -0.250000 -0.433013 6.366667\nv -0.250000 -0.433013 5.033333\nv -0.171010 -0.469846 6.366667\nv -0.171010 -0.469846 5.033333\nv -0.086824 -0.492404 6.366667\nv -0.086824 -0.492404 5.033333\nv -0.000000 -0.500000 6.366667\nv -0.000000 -0.500000 5.033333\nv 0.086824 -0.492404 6.366667\nv 0.086824 -0.492404 5.033333\nv 0.171010 -0.469846 6.366667\nv 0.171010 -0.469846 5.033333\nv 0.250000 -0.433013 6.366667\nv 0.250000 -0.433013 5.033333\nv 0.321394 -0.383022 6.366667\nv 0.321394 -0.383022 5.033333\nv 0.383022 -0.321394 6.366667\nv 0.383022 -0.321394 5.033333\nv 0.433013 -0.250000 6.366667\nv 0.433013 -0.250000 5.033333\nv 0.469846 -0.171010 6.366667\nv 0.469846 -0.171010 5.033333\nv 0.492404 -0.086824 6.366667\nv 0.492404 -0.086824 5.033333\nv 1.292723 0.000000 7.700000\nv 1.285145 -0.139768 7.700000\nv 1.262500 -0.277897 7.700000\nv 1.225053 -0.412768 7.700000\nv 1.173244 -0.542800 7.700000\nv 1.107679 -0.666468 7.700000\nv 1.029128 -0.782323 7.700000\nv 0.938511 -0.889005 7.700000\nv 0.836891 -0.985264 7.700000\nv 0.725459 -1.069973 7.700000\nv 0.605522 -1.142136 7.700000\nv 0.478486 -1.200910 7.700000\nv 0.345840 -1.245603 7.700000\nv 0.209139 -1.275693 7.700000\nv 0.069987 -1.290827 7.700000\nv -0.069987 -1.290827 7.700000\nv -0.209139 -1.275693 7.700000\nv -0.345840 -1.245603 7.700000\nv -0.478486 -1.200910 7.700000\nv -0.605522 -1.142136 7.700000\nv -0.725459 -1.069973 7.700000\nv -0.836891 -0.985264 7.700000\nv -0.938511 -0.889005 7.700000\nv -1.029128 -0.782323 7.700000\nv -1.107679 -0.666468 7.700000\nv -1.173244 -0.542800 7.700000\nv -1.225053 -0.412768 7.700000\nv -1.262500 -0.277897 7.700000\nv -1.285145 -0.139768 7.700000\nv -1.292723 0.000000 7.700000\nv -1.285145 0.139768 7.700000\nv -1.262500 0.277897 7.700000\nv -1.225053 0.412768 7.700000\nv -1.173244 0.542800 7.700000\nv -1.107679 0.666468 7.700000\nv -1.029128 0.782323 7.700000\nv -0.938511 0.889005 7.700000\nv -0.836891 0.985264 7.700000\nv -0.725459 1.069973 7.700000\nv -0.605522 1.142136 7.700000\nv -0.478486 1.200910 7.700000\nv -0.345840 1.245603 7.700000\nv -0.209139 1.275693 7.700000\nv -0.069987 1.290827 7.700000\nv 0.069987 1.290827 7.700000\nv 0.209139 1.275693 7.700000\nv 0.345840 1.245603 7.700000\nv 0.478486 1.200910 7.700000\nv 0.605522 1.142136 7.700000\nv 0.725459 1.069973 7.700000\nv 0.836891 0.985264 7.700000\nv 0.938511 0.889005 7.700000\nv 1.029128 0.782323 7.700000\nv 1.107679 0.666468 7.700000\nv 1.173244 0.542800 7.700000\nv 1.225053 0.412768 7.700000\nv 1.262500 0.277897 7.700000\nv 1.285145 0.139768 7.700000\nv 1.292723 0.000000 3.700000\nv 1.285145 0.139768 3.700000\nv 1.262500 0.277897 3.700000\nv 1.225053 0.412768 3.700000\nv 1.173244 0.542800 3.700000\nv 1.107679 0.666468 3.700000\nv 1.029128 0.782323 3.700000\nv 0.938511 0.889005 3.700000\nv 0.836891 0.985264 3.700000\nv 0.725459 1.069973 3.700000\nv 0.605522 1.142136 3.700000\nv 0.478486 1.200910 3.700000\nv 0.345840 1.245603 3.700000\nv 0.209139 1.275693 3.700000\nv 0.069987 1.290827 3.700000\nv -0.069987 1.290827 3.700000\nv -0.209139 1.275693 3.700000\nv -0.345840 1.245603 3.700000\nv -0.478486 1.200910 3.700000\nv -0.605522 1.142136 3.700000\nv -0.725459 1.069973 3.700000\nv -0.836891 0.985264 3.700000\nv -0.938511 0.889005 3.700000\nv -1.029128 0.782323 3.700000\nv -1.107679 0.666468 3.700000\nv -1.173244 0.542800 3.700000\nv -1.225053 0.412768 3.700000\nv -1.262500 0.277897 3.700000\nv -1.285145 0.139768 3.700000\nv -1.292723 0.000000 3.700000\nv -1.285145 -0.139768 3.700000\nv -1.262500 -0.277897 3.700000\nv -1.225053 -0.412768 3.700000\nv -1.173244 -0.542800 3.700000\nv -1.107679 -0.666468 3.700000\nv -1.029128 -0.782323 3.700000\nv -0.938511 -0.889005 3.700000\nv -0.836891 -0.985264 3.700000\nv -0.725459 -1.069973 3.700000\nv -0.605522 -1.142136 3.700000\nv -0.478486 -1.200910 3.700000\nv -0.345840 -1.245603 3.700000\nv -0.209139 -1.275693 3.700000\nv -0.069987 -1.290827 3.700000\nv 0.069987 -1.290827 3.700000\nv 0.209139 -1.275693 3.700000\nv 0.345840 -1.245603 3.700000\nv 0.478486 -1.200910 3.700000\nv 0.605522 -1.142136 3.700000\nv 0.725459 -1.069973 3.700000\nv 0.836891 -0.985264 3.700000\nv 0.938511 -0.889005 3.700000\nv 1.029128 -0.782323 3.700000\nv 1.107679 -0.666468 3.700000\nv 1.173244 -0.542800 3.700000\nv 1.225053 -0.412768 3.700000\nv 1.262500 -0.277897 3.700000\nv 1.285145 -0.139768 3.700000\nv 1.292723 0.000000 5.700000\nv 1.285145 -0.139768 5.700000\nv 1.262500 -0.277897 5.700000\nv 1.225053 -0.412768 5.700000\nv 1.173244 -0.542800 5.700000\nv 1.107679 -0.666468 5.700000\nv 1.029128 -0.782323 5.700000\nv 0.938511 -0.889005 5.700000\nv 0.836891 -0.985264 5.700000\nv 0.725459 -1.069973 5.700000\nv 0.605522 -1.142136 5.700000\nv 0.478486 -1.200910 5.700000\nv 0.345840 -1.245603 5.700000\nv 0.209139 -1.275693 5.700000\nv 0.069987 -1.290827 5.700000\nv -0.069987 -1.290827 5.700000\nv -0.209139 -1.275693 5.700000\nv -0.345840 -1.245603 5.700000\nv -0.478486 -1.200910 5.700000\nv -0.605522 -1.142136 5.700000\nv -0.725459 -1.069973 5.700000\nv -0.836891 -0.985264 5.700000\nv -0.938511 -0.889005 5.700000\nv -1.029128 -0.782323 5.700000\nv -1.107679 -0.666468 5.700000\nv -1.173244 -0.542800 5.700000\nv -1.225053 -0.412768 5.700000\nv -1.262500 -0.277897 5.700000\nv -1.285145 -0.139768 5.700000\nv -1.292723 0.000000 5.700000\nv -1.285145 0.139768 5.700000\nv -1.262500 0.277897 5.700000\nv -1.225053 0.412768 5.700000\nv -1.173244 0.542800 5.700000\nv -1.107679 0.666468 5.700000\nv -1.029128 0.782323 5.700000\nv -0.938511 0.889005 5.700000\nv -0.836891 0.985264 5.700000\nv -0.725459 1.069973 5.700000\nv -0.605522 1.142136 5.700000\nv -0.478486 1.200910 5.700000\nv -0.345840 1.245603 5.700000\nv -0.209139 1.275693 5.700000\nv -0.069987 1.290827 5.700000\nv 0.069987 1.290827 5.700000\nv 0.209139 1.275693 5.700000\nv 0.345840 1.245603 5.700000\nv 0.478486 1.200910 5.700000\nv 0.605522 1.142136 5.700000\nv 0.725459 1.069973 5.700000\nv 0.836891 0.985264 5.700000\nv 0.938511 0.889005 5.700000\nv 1.029128 0.782323 5.700000\nv 1.107679 0.666468 5.700000\nv 1.173244 0.542800 5.700000\nv 1.225053 0.412768 5.700000\nv 1.262500 0.277897 5.700000\nv 1.285145 0.139768 5.700000\nv 3.463185 -0.079677 3.700000\nv 1.800595 2.959368 3.700000\nv -1.662591 3.039045 3.700000\nv -3.463185 0.079677 3.700000\nv 1.800595 2.959368 1.700000\nv 3.463185 -0.079677 1.700000\nv -3.463185 0.079677 1.700000\nv -1.662591 3.039045 1.700000\nv -1.292723 -0.000000 1.700000\nv -1.285145 -0.139768 1.700000\nv -1.262500 -0.277897 1.700000\nv -1.225053 -0.412768 1.700000\nv -1.173244 -0.542800 1.700000\nv -1.107679 -0.666468 1.700000\nv -1.029128 -0.782323 1.700000\nv -0.938511 -0.889005 1.700000\nv -0.836891 -0.985264 1.700000\nv -0.725459 -1.069973 1.700000\nv -0.605522 -1.142136 1.700000\nv -0.478486 -1.200910 1.700000\nv -0.345840 -1.245603 1.700000\nv -0.209139 -1.275693 1.700000\nv -0.069987 -1.290827 1.700000\nv 0.069987 -1.290827 1.700000\nv 0.209139 -1.275693 1.700000\nv 0.345840 -1.245603 1.700000\nv 0.478486 -1.200910 1.700000\nv 0.605522 -1.142136 1.700000\nv 0.725459 -1.069973 1.700000\nv 0.836891 -0.985264 1.700000\nv 0.938511 -0.889005 1.700000\nv 1.029128 -0.782323 1.700000\nv 1.107679 -0.666468 1.700000\nv 1.173244 -0.542800 1.700000\nv 1.225053 -0.412768 1.700000\nv 1.262500 -0.277897 1.700000\nv 1.285145 -0.139768 1.700000\nv 1.292723 0.000000 1.700000\nv 1.285145 0.139768 1.700000\nv 1.262500 0.277897 1.700000\nv 1.225053 0.412768 1.700000\nv 1.173244 0.542800 1.700000\nv 1.107679 0.666468 1.700000\nv 1.029128 0.782323 1.700000\nv 0.938511 0.889005 1.700000\nv 0.836891 0.985264 1.700000\nv 0.725459 1.069973 1.700000\nv 0.605522 1.142136 1.700000\nv 0.478486 1.200910 1.700000\nv 0.345840 1.245603 1.700000\nv 0.209139 1.275693 1.700000\nv 0.069987 1.290827 1.700000\nv -0.069987 1.290827 1.700000\nv -0.209139 1.275693 1.700000\nv -0.345840 1.245603 1.700000\nv -0.478486 1.200910 1.700000\nv -0.605522 1.142136 1.700000\nv -0.725459 1.069973 1.700000\nv -0.836891 0.985264 1.700000\nv -0.938511 0.889005 1.700000\nv -1.029128 0.782323 1.700000\nv -1.107679 0.666468 1.700000\nv -1.173244 0.542800 1.700000\nv -1.225053 0.412768 1.700000\nv -1.262500 0.277897 1.700000\nv -1.285145 0.139768 1.700000\nv -0.200000 -0.000000 0.000000\nv -0.193185 0.051764 0.000000\nv -0.173205 0.100000 0.000000\nv -0.141421 0.141421 0.000000\nv -0.100000 0.173205 0.000000\nv -0.051764 0.193185 0.000000\nv 0.000000 0.200000 0.000000\nv 0.051764 0.193185 0.000000\nv 0.100000 0.173205 0.000000\nv 0.141421 0.141421 0.000000\nv 0.173205 0.100000 0.000000\nv 0.193185 0.051764 0.000000\nv 0.200000 0.000000 0.000000\nv 0.193185 -0.051764 0.000000\nv 0.173205 -0.100000 0.000000\nv 0.141421 -0.141421 0.000000\nv 0.100000 -0.173205 0.000000\nv 0.051764 -0.193185 0.000000\nv 0.000000 -0.200000 0.000000\nv -0.051764 -0.193185 0.000000\nv -0.100000 -0.173205 0.000000\nv -0.141421 -0.141421 0.000000\nv -0.173205 -0.100000 0.000000\nv -0.193185 -0.051764 0.000000\nv 0.000000 0.000000 0.428901\nv -0.500000 -0.000000 0.000000\nv -0.492808 -0.084500 0.000000\nv -0.471439 -0.166570 0.000000\nv -0.436507 -0.243847 0.000000\nv -0.389018 -0.314110 0.000000\nv -0.330337 -0.375336 0.000000\nv -0.262154 -0.425765 0.000000\nv -0.186428 -0.463945 0.000000\nv -0.105340 -0.488778 0.000000\nv -0.021221 -0.499549 0.000000\nv 0.063509 -0.495950 0.000000\nv 0.146411 -0.478083 0.000000\nv 0.225102 -0.446463 0.000000\nv 0.297317 -0.401999 0.000000\nv 0.360978 -0.345969 0.000000\nv 0.414255 -0.279987 0.000000\nv 0.455614 -0.205951 0.000000\nv 0.483866 -0.125989 0.000000\nv 0.498199 -0.042403 0.000000\nv 0.498199 0.042403 0.000000\nv 0.483866 0.125989 0.000000\nv 0.455614 0.205951 0.000000\nv 0.414255 0.279987 0.000000\nv 0.360978 0.345969 0.000000\nv 0.297317 0.401999 0.000000\nv 0.225102 0.446463 0.000000\nv 0.146411 0.478083 0.000000\nv 0.063509 0.495950 0.000000\nv -0.021221 0.499549 0.000000\nv -0.105340 0.488778 0.000000\nv -0.186428 0.463945 0.000000\nv -0.262154 0.425765 0.000000\nv -0.330337 0.375336 0.000000\nv -0.389018 0.314110 0.000000\nv -0.436507 0.243847 0.000000\nv -0.471439 0.166570 0.000000\nv -0.492808 0.084500 0.000000\nvt -0.006050 0.000000 0.000000\nvt -0.004537 0.000000 0.000000\nvt -0.006050 0.010000 0.000000\nvt -0.004537 0.010000 0.000000\nvt -0.003025 0.000000 0.000000\nvt -0.003025 0.010000 0.000000\nvt -0.001512 0.000000 0.000000\nvt -0.001512 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.007508 0.000000 0.000000\nvt -0.005631 0.000000 0.000000\nvt -0.007508 0.010000 0.000000\nvt -0.005631 0.010000 0.000000\nvt -0.003754 0.000000 0.000000\nvt -0.003754 0.010000 0.000000\nvt -0.001877 0.000000 0.000000\nvt -0.001877 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.010360 0.000000 0.000000\nvt -0.007770 0.000000 0.000000\nvt -0.010360 0.010000 0.000000\nvt -0.007770 0.010000 0.000000\nvt -0.005180 0.000000 0.000000\nvt -0.005180 0.010000 0.000000\nvt -0.002590 0.000000 0.000000\nvt -0.002590 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.007925 -0.000000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.007925 0.010000 0.000000\nvt 0.000000 0.010000 0.000000\nvt -0.026931 0.000000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.026931 0.010000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.009335 -0.000000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.009335 0.010000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.008130 0.000000 0.000000\nvt -0.006097 0.000000 0.000000\nvt -0.008130 0.010000 0.000000\nvt -0.006097 0.010000 0.000000\nvt -0.004065 0.000000 0.000000\nvt -0.004065 0.010000 0.000000\nvt -0.002032 0.000000 0.000000\nvt -0.002032 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.006251 0.000000 0.000000\nvt -0.004688 0.000000 0.000000\nvt -0.006251 0.010000 0.000000\nvt -0.004688 0.010000 0.000000\nvt -0.003125 0.000000 0.000000\nvt -0.003125 0.010000 0.000000\nvt -0.001563 0.000000 0.000000\nvt -0.001563 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.006789 0.000000 0.000000\nvt -0.005091 0.000000 0.000000\nvt -0.006789 0.010000 0.000000\nvt -0.005091 0.010000 0.000000\nvt -0.003394 0.000000 0.000000\nvt -0.003394 0.010000 0.000000\nvt -0.001697 0.000000 0.000000\nvt -0.001697 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.006630 0.000000 0.000000\nvt -0.004972 0.000000 0.000000\nvt -0.006630 0.010000 0.000000\nvt -0.004972 0.010000 0.000000\nvt -0.003315 0.000000 0.000000\nvt -0.003315 0.010000 0.000000\nvt -0.001657 0.000000 0.000000\nvt -0.001657 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.006865 0.000000 0.000000\nvt -0.005149 0.000000 0.000000\nvt -0.006865 0.010000 0.000000\nvt -0.005149 0.010000 0.000000\nvt -0.003432 0.000000 0.000000\nvt -0.003432 0.010000 0.000000\nvt -0.001716 0.000000 0.000000\nvt -0.001716 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.018718 0.000000 0.000000\nvt -0.014039 0.000000 0.000000\nvt -0.018718 0.010000 0.000000\nvt -0.014039 0.010000 0.000000\nvt -0.009359 0.000000 0.000000\nvt -0.009359 0.010000 0.000000\nvt -0.004680 0.000000 0.000000\nvt -0.004680 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.018784 0.000000 0.000000\nvt -0.014088 0.000000 0.000000\nvt -0.018784 0.010000 0.000000\nvt -0.014088 0.010000 0.000000\nvt -0.009392 0.000000 0.000000\nvt -0.009392 0.010000 0.000000\nvt -0.004696 0.000000 0.000000\nvt -0.004696 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.013807 0.000000 0.000000\nvt -0.010355 0.000000 0.000000\nvt -0.013807 0.010000 0.000000\nvt -0.010355 0.010000 0.000000\nvt -0.006903 0.000000 0.000000\nvt -0.006903 0.010000 0.000000\nvt -0.003452 0.000000 0.000000\nvt -0.003452 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.012491 0.000000 0.000000\nvt -0.009368 0.000000 0.000000\nvt -0.012491 0.010000 0.000000\nvt -0.009368 0.010000 0.000000\nvt -0.006245 0.000000 0.000000\nvt -0.006245 0.010000 0.000000\nvt -0.003123 0.000000 0.000000\nvt -0.003123 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.012726 0.000000 0.000000\nvt -0.009545 0.000000 0.000000\nvt -0.012726 0.010000 0.000000\nvt -0.009545 0.010000 0.000000\nvt -0.006363 0.000000 0.000000\nvt -0.006363 0.010000 0.000000\nvt -0.003182 0.000000 0.000000\nvt -0.003182 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.015278 0.000000 0.000000\nvt -0.011459 0.000000 0.000000\nvt -0.015278 0.010000 0.000000\nvt -0.011459 0.010000 0.000000\nvt -0.007639 0.000000 0.000000\nvt -0.007639 0.010000 0.000000\nvt -0.003820 0.000000 0.000000\nvt -0.003820 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.043251 0.000000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.043251 0.010000 0.000000\nvt 0.000000 0.010000 0.000000\nvt -0.100000 0.000000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.100000 0.010000 0.000000\nvt 0.000000 0.010000 0.000000\nvt -0.025655 -0.000000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.025655 0.010000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.036669 0.000000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.036669 0.010000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.011948 -0.000000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.011948 0.010000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.045659 0.000000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.045659 0.010000 0.000000\nvt 0.000000 0.010000 0.000000\nvt -0.031499 -0.000000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.031499 0.010000 0.000000\nvt 0.000000 0.010000 0.000000\nvt -0.054314 0.000000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.054314 0.010000 0.000000\nvt 0.000000 0.010000 0.000000\nvt 0.091303 -0.049228 0.000000\nvt 0.057925 -0.006380 0.000000\nvt 0.059804 -0.049228 0.000000\nvt 0.032599 -0.012559 0.000000\nvt 0.033759 0.005561 0.000000\nvt 0.031169 0.005470 0.000000\nvt 0.062079 -0.004081 0.000000\nvt 0.036341 0.005765 0.000000\nvt 0.038919 0.006044 0.000000\nvt 0.040787 0.006428 0.000000\nvt 0.042591 0.006973 0.000000\nvt 0.044282 0.007797 0.000000\nvt 0.045903 0.008798 0.000000\nvt 0.047065 0.009796 0.000000\nvt 0.048132 0.010875 0.000000\nvt 0.049034 0.012093 0.000000\nvt 0.065978 -0.001464 0.000000\nvt 0.049832 0.013398 0.000000\nvt 0.069431 0.001710 0.000000\nvt 0.050411 0.015033 0.000000\nvt 0.072599 0.005238 0.000000\nvt 0.050831 0.016699 0.000000\nvt 0.074905 0.009453 0.000000\nvt 0.051017 0.018411 0.000000\nvt 0.076625 0.013840 0.000000\nvt 0.077437 0.018496 0.000000\nvt 0.051075 0.020148 0.000000\nvt 0.077737 0.023304 0.000000\nvt 0.050977 0.021831 0.000000\nvt 0.077543 0.026818 0.000000\nvt 0.050728 0.023476 0.000000\nvt 0.077016 0.030246 0.000000\nvt 0.075904 0.033523 0.000000\nvt 0.050213 0.025057 0.000000\nvt 0.074412 0.036702 0.000000\nvt 0.072536 0.039252 0.000000\nvt 0.070459 0.041595 0.000000\nvt 0.049530 0.026595 0.000000\nvt 0.068051 0.043598 0.000000\nvt 0.065447 0.045400 0.000000\nvt 0.062604 0.046892 0.000000\nvt 0.048457 0.027963 0.000000\nvt 0.059682 0.048166 0.000000\nvt 0.047238 0.029152 0.000000\nvt 0.056627 0.049075 0.000000\nvt 0.053492 0.049765 0.000000\nvt 0.045794 0.030066 0.000000\nvt 0.049695 0.050223 0.000000\nvt 0.044224 0.030826 0.000000\nvt 0.045890 0.050561 0.000000\nvt 0.042734 0.031325 0.000000\nvt 0.041222 0.031726 0.000000\nvt 0.042072 0.050718 0.000000\nvt 0.039677 0.031975 0.000000\nvt 0.038247 0.050772 0.000000\nvt 0.038113 0.032136 0.000000\nvt 0.036083 0.032242 0.000000\nvt 0.034052 0.032320 0.000000\nvt 0.032019 0.032357 0.000000\nvt 0.029987 0.032371 0.000000\nvt 0.020651 0.032371 0.000000\nvt -0.005003 0.050772 0.000000\nvt 0.020651 0.005440 0.000000\nvt -0.005003 -0.049228 0.000000\nvt 0.020651 -0.012559 0.000000\nvt 0.020651 -0.049228 0.000000\nvt 0.028576 0.005440 0.000000\nvt -0.048690 0.000000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.048690 0.010000 0.000000\nvt 0.000000 0.010000 0.000000\nvt -0.018402 0.000000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.018402 0.010000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.022901 0.000000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.022901 0.010000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.039867 0.000000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.039867 0.010000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.010053 0.000000 0.000000\nvt -0.007540 0.000000 0.000000\nvt -0.010053 0.010000 0.000000\nvt -0.007540 0.010000 0.000000\nvt -0.005026 0.000000 0.000000\nvt -0.005026 0.010000 0.000000\nvt -0.002513 0.000000 0.000000\nvt -0.002513 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.007435 0.000000 0.000000\nvt -0.005576 0.000000 0.000000\nvt -0.007435 0.010000 0.000000\nvt -0.005576 0.010000 0.000000\nvt -0.003718 0.000000 0.000000\nvt -0.003718 0.010000 0.000000\nvt -0.001859 0.000000 0.000000\nvt -0.001859 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.007532 0.000000 0.000000\nvt -0.005649 0.000000 0.000000\nvt -0.007532 0.010000 0.000000\nvt -0.005649 0.010000 0.000000\nvt -0.003766 0.000000 0.000000\nvt -0.003766 0.010000 0.000000\nvt -0.001883 0.000000 0.000000\nvt -0.001883 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.011010 0.000000 0.000000\nvt -0.008258 0.000000 0.000000\nvt -0.011010 0.010000 0.000000\nvt -0.008258 0.010000 0.000000\nvt -0.005505 0.000000 0.000000\nvt -0.005505 0.010000 0.000000\nvt -0.002753 0.000000 0.000000\nvt -0.002753 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.008993 0.000000 0.000000\nvt -0.006745 0.000000 0.000000\nvt -0.008993 0.010000 0.000000\nvt -0.006745 0.010000 0.000000\nvt -0.004497 0.000000 0.000000\nvt -0.004497 0.010000 0.000000\nvt -0.002248 0.000000 0.000000\nvt -0.002248 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.007083 0.000000 0.000000\nvt -0.005312 0.000000 0.000000\nvt -0.007083 0.010000 0.000000\nvt -0.005312 0.010000 0.000000\nvt -0.003541 0.000000 0.000000\nvt -0.003541 0.010000 0.000000\nvt -0.001771 0.000000 0.000000\nvt -0.001771 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.002418 -0.000000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.002418 0.010000 0.000000\nvt 0.000000 0.010000 0.000000\nvt -0.020221 0.000000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.020221 0.010000 0.000000\nvt 0.000000 0.010000 0.000000\nvt -0.010841 0.000000 0.000000\nvt -0.008131 0.000000 0.000000\nvt -0.010841 0.010000 0.000000\nvt -0.008131 0.010000 0.000000\nvt -0.005421 0.000000 0.000000\nvt -0.005421 0.010000 0.000000\nvt -0.002710 0.000000 0.000000\nvt -0.002710 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.013039 0.000000 0.000000\nvt -0.009779 0.000000 0.000000\nvt -0.013039 0.010000 0.000000\nvt -0.009779 0.010000 0.000000\nvt -0.006519 0.000000 0.000000\nvt -0.006519 0.010000 0.000000\nvt -0.003260 0.000000 0.000000\nvt -0.003260 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.017283 0.000000 0.000000\nvt -0.012962 0.000000 0.000000\nvt -0.017283 0.010000 0.000000\nvt -0.012962 0.010000 0.000000\nvt -0.008641 0.000000 0.000000\nvt -0.008641 0.010000 0.000000\nvt -0.004321 0.000000 0.000000\nvt -0.004321 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.013513 0.000000 0.000000\nvt -0.010135 0.000000 0.000000\nvt -0.013513 0.010000 0.000000\nvt -0.010135 0.010000 0.000000\nvt -0.006756 0.000000 0.000000\nvt -0.006756 0.010000 0.000000\nvt -0.003378 0.000000 0.000000\nvt -0.003378 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.011957 0.000000 0.000000\nvt -0.008967 0.000000 0.000000\nvt -0.011957 0.010000 0.000000\nvt -0.008967 0.010000 0.000000\nvt -0.005978 0.000000 0.000000\nvt -0.005978 0.010000 0.000000\nvt -0.002989 0.000000 0.000000\nvt -0.002989 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.012546 0.000000 0.000000\nvt -0.009409 0.000000 0.000000\nvt -0.012546 0.010000 0.000000\nvt -0.009409 0.010000 0.000000\nvt -0.006273 0.000000 0.000000\nvt -0.006273 0.010000 0.000000\nvt -0.003136 0.000000 0.000000\nvt -0.003136 0.010000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.070651 0.000000 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.070651 0.010000 0.000000\nvt -0.000000 0.010000 0.000000\nvt -0.029248 0.050772 0.000000\nvt -0.055037 0.032371 0.000000\nvt -0.029248 -0.019879 0.000000\nvt -0.055037 -0.007497 0.000000\nvt -0.055046 -0.010010 0.000000\nvt -0.077938 0.050772 0.000000\nvt -0.077938 0.032371 0.000000\nvt -0.055076 -0.012523 0.000000\nvt -0.055144 -0.015036 0.000000\nvt -0.055238 -0.017547 0.000000\nvt -0.055433 -0.019413 0.000000\nvt -0.034504 -0.037478 0.000000\nvt -0.032942 -0.034919 0.000000\nvt -0.031598 -0.032203 0.000000\nvt -0.055758 -0.021247 0.000000\nvt -0.038583 -0.041907 0.000000\nvt -0.036433 -0.039772 0.000000\nvt -0.056304 -0.023027 0.000000\nvt -0.044170 -0.045760 0.000000\nvt -0.041314 -0.043946 0.000000\nvt -0.047228 -0.047213 0.000000\nvt -0.056985 -0.024774 0.000000\nvt -0.050403 -0.048455 0.000000\nvt -0.058022 -0.026405 0.000000\nvt -0.054616 -0.049514 0.000000\nvt -0.059235 -0.027857 0.000000\nvt -0.060731 -0.029021 0.000000\nvt -0.058869 -0.050294 0.000000\nvt -0.062391 -0.030018 0.000000\nvt -0.063182 -0.050651 0.000000\nvt -0.065022 -0.030917 0.000000\nvt -0.067701 -0.031558 0.000000\nvt -0.067529 -0.050772 0.000000\nvt -0.070450 -0.031829 0.000000\nvt -0.070789 -0.050738 0.000000\nvt -0.073237 -0.031901 0.000000\nvt -0.074048 -0.050654 0.000000\nvt -0.075496 -0.031851 0.000000\nvt -0.077304 -0.050488 0.000000\nvt -0.077742 -0.031694 0.000000\nvt -0.080557 -0.050270 0.000000\nvt -0.079964 -0.031343 0.000000\nvt -0.083258 -0.050016 0.000000\nvt -0.082169 -0.030860 0.000000\nvt -0.083862 -0.030337 0.000000\nvt -0.085951 -0.049706 0.000000\nvt -0.085547 -0.029793 0.000000\nvt -0.088631 -0.049300 0.000000\nvt -0.087220 -0.029212 0.000000\nvt -0.091303 -0.048831 0.000000\nvt -0.088885 -0.028610 0.000000\nvt -0.091303 -0.028610 0.000000\nvt -0.030593 -0.029202 0.000000\nvt -0.029818 -0.026157 0.000000\nvt -0.029421 -0.023040 0.000000\nvt 0.346410 0.000000 0.000000\nvt 0.168202 0.050000 0.000000\nvt 0.000000 0.000000 0.000000\nvt 0.114336 0.048934 0.000000\nvt 0.110023 0.048577 0.000000\nvt 0.346410 0.200000 0.000000\nvt 0.264508 0.050000 0.000000\nvt 0.233009 0.050000 0.000000\nvt 0.193857 0.050000 0.000000\nvt 0.205805 0.086669 0.000000\nvt 0.193857 0.086669 0.000000\nvt 0.000000 0.200000 0.000000\nvt 0.168202 0.150000 0.000000\nvt 0.211452 0.150000 0.000000\nvt 0.215277 0.149945 0.000000\nvt 0.081902 0.070618 0.000000\nvt 0.095267 0.131598 0.000000\nvt 0.095267 0.150000 0.000000\nvt 0.143957 0.150000 0.000000\nvt 0.143957 0.079349 0.000000\nvt 0.143784 0.076188 0.000000\nvt 0.143388 0.073070 0.000000\nvt 0.142612 0.070025 0.000000\nvt 0.141607 0.067025 0.000000\nvt 0.140263 0.064308 0.000000\nvt 0.138701 0.061750 0.000000\nvt 0.136772 0.059455 0.000000\nvt 0.134622 0.057320 0.000000\nvt 0.131891 0.055282 0.000000\nvt 0.129035 0.053467 0.000000\nvt 0.125977 0.052014 0.000000\nvt 0.122802 0.050772 0.000000\nvt 0.118589 0.049713 0.000000\nvt 0.105677 0.048455 0.000000\nvt 0.102416 0.048490 0.000000\nvt 0.099157 0.048573 0.000000\nvt 0.095901 0.048740 0.000000\nvt 0.092648 0.048957 0.000000\nvt 0.089947 0.049212 0.000000\nvt 0.087254 0.049521 0.000000\nvt 0.084574 0.049928 0.000000\nvt 0.081902 0.050397 0.000000\nvt 0.118168 0.091731 0.000000\nvt 0.084320 0.070618 0.000000\nvt 0.118159 0.089217 0.000000\nvt 0.118129 0.086704 0.000000\nvt 0.118061 0.084192 0.000000\nvt 0.117967 0.081680 0.000000\nvt 0.117772 0.079815 0.000000\nvt 0.085985 0.070015 0.000000\nvt 0.117447 0.077981 0.000000\nvt 0.087658 0.069435 0.000000\nvt 0.116902 0.076200 0.000000\nvt 0.089344 0.068891 0.000000\nvt 0.091036 0.068368 0.000000\nvt 0.093241 0.067885 0.000000\nvt 0.095463 0.067533 0.000000\nvt 0.097709 0.067376 0.000000\nvt 0.116221 0.074453 0.000000\nvt 0.099968 0.067327 0.000000\nvt 0.115183 0.072822 0.000000\nvt 0.102755 0.067399 0.000000\nvt 0.113970 0.071371 0.000000\nvt 0.105504 0.067670 0.000000\nvt 0.108183 0.068311 0.000000\nvt 0.110814 0.069210 0.000000\nvt 0.112474 0.070207 0.000000\nvt 0.118168 0.131598 0.000000\nvt 0.248110 0.108680 0.000000\nvt 0.245804 0.104466 0.000000\nvt 0.242636 0.100938 0.000000\nvt 0.239184 0.097764 0.000000\nvt 0.235285 0.095146 0.000000\nvt 0.231130 0.092848 0.000000\nvt 0.219095 0.149789 0.000000\nvt 0.222900 0.149450 0.000000\nvt 0.226697 0.148993 0.000000\nvt 0.229832 0.148303 0.000000\nvt 0.232887 0.147393 0.000000\nvt 0.235809 0.146120 0.000000\nvt 0.238652 0.144627 0.000000\nvt 0.241256 0.142826 0.000000\nvt 0.243664 0.140823 0.000000\nvt 0.245741 0.138480 0.000000\nvt 0.247617 0.135930 0.000000\nvt 0.249109 0.132751 0.000000\nvt 0.250221 0.129474 0.000000\nvt 0.250748 0.126046 0.000000\nvt 0.250942 0.122532 0.000000\nvt 0.250643 0.117724 0.000000\nvt 0.249830 0.113068 0.000000\nvt 0.400000 0.148589 0.000000\nvt 0.400000 0.157080 0.000000\nvt 0.266667 0.157080 0.000000\nvt 0.266667 -0.157080 0.000000\nvt 0.400000 -0.157080 0.000000\nvt 0.400000 -0.148589 0.000000\nvt 0.266667 -0.148353 0.000000\nvt 0.400000 -0.140098 0.000000\nvt 0.266667 -0.139626 0.000000\nvt 0.400000 -0.131607 0.000000\nvt 0.266667 -0.130900 0.000000\nvt 0.400000 -0.123116 0.000000\nvt 0.266667 -0.122173 0.000000\nvt 0.400000 -0.114626 0.000000\nvt 0.266667 -0.113446 0.000000\nvt 0.400000 -0.106135 0.000000\nvt 0.266667 -0.104720 0.000000\nvt 0.400000 -0.097644 0.000000\nvt 0.266667 -0.095993 0.000000\nvt 0.400000 -0.089153 0.000000\nvt 0.266667 -0.087266 0.000000\nvt 0.400000 -0.080663 0.000000\nvt 0.266667 -0.078540 0.000000\nvt 0.400000 -0.072172 0.000000\nvt 0.266667 -0.069813 0.000000\nvt 0.400000 -0.063681 0.000000\nvt 0.266667 -0.061087 0.000000\nvt 0.400000 -0.055190 0.000000\nvt 0.266667 -0.052360 0.000000\nvt 0.400000 -0.046699 0.000000\nvt 0.266667 -0.043633 0.000000\nvt 0.400000 -0.038209 0.000000\nvt 0.266667 -0.034907 0.000000\nvt 0.400000 -0.029718 0.000000\nvt 0.266667 -0.026180 0.000000\nvt 0.400000 -0.021227 0.000000\nvt 0.266667 -0.017453 0.000000\nvt 0.400000 -0.012736 0.000000\nvt 0.266667 -0.008727 0.000000\nvt 0.400000 -0.004245 0.000000\nvt 0.266667 0.000000 0.000000\nvt 0.400000 0.004245 0.000000\nvt 0.266667 0.008727 0.000000\nvt 0.400000 0.012736 0.000000\nvt 0.266667 0.017453 0.000000\nvt 0.400000 0.021227 0.000000\nvt 0.266667 0.026180 0.000000\nvt 0.400000 0.029718 0.000000\nvt 0.266667 0.034907 0.000000\nvt 0.400000 0.038209 0.000000\nvt 0.266667 0.043633 0.000000\nvt 0.400000 0.046699 0.000000\nvt 0.266667 0.052360 0.000000\nvt 0.400000 0.055190 0.000000\nvt 0.266667 0.061087 0.000000\nvt 0.400000 0.063681 0.000000\nvt 0.266667 0.069813 0.000000\nvt 0.400000 0.072172 0.000000\nvt 0.266667 0.078540 0.000000\nvt 0.400000 0.080663 0.000000\nvt 0.266667 0.087266 0.000000\nvt 0.400000 0.089153 0.000000\nvt 0.266667 0.095993 0.000000\nvt 0.400000 0.097644 0.000000\nvt 0.266667 0.104720 0.000000\nvt 0.400000 0.106135 0.000000\nvt 0.266667 0.113446 0.000000\nvt 0.400000 0.114626 0.000000\nvt 0.266667 0.122173 0.000000\nvt 0.400000 0.123116 0.000000\nvt 0.266667 0.130900 0.000000\nvt 0.400000 0.131607 0.000000\nvt 0.266667 0.139626 0.000000\nvt 0.400000 0.140098 0.000000\nvt 0.266667 0.148353 0.000000\nvt 0.000000 -0.148589 0.000000\nvt 0.000000 -0.157080 0.000000\nvt 0.133333 -0.157080 0.000000\nvt 0.133333 0.157080 0.000000\nvt 0.000000 0.157080 0.000000\nvt 0.000000 0.148589 0.000000\nvt 0.133333 0.148353 0.000000\nvt 0.000000 0.140098 0.000000\nvt 0.133333 0.139626 0.000000\nvt 0.000000 0.131607 0.000000\nvt 0.133333 0.130900 0.000000\nvt 0.000000 0.123116 0.000000\nvt 0.133333 0.122173 0.000000\nvt 0.000000 0.114626 0.000000\nvt 0.133333 0.113446 0.000000\nvt 0.000000 0.106135 0.000000\nvt 0.133333 0.104720 0.000000\nvt 0.000000 0.097644 0.000000\nvt 0.133333 0.095993 0.000000\nvt 0.000000 0.089153 0.000000\nvt 0.133333 0.087266 0.000000\nvt 0.000000 0.080663 0.000000\nvt 0.133333 0.078540 0.000000\nvt 0.000000 0.072172 0.000000\nvt 0.133333 0.069813 0.000000\nvt 0.000000 0.063681 0.000000\nvt 0.133333 0.061087 0.000000\nvt 0.000000 0.055190 0.000000\nvt 0.133333 0.052360 0.000000\nvt 0.000000 0.046699 0.000000\nvt 0.133333 0.043633 0.000000\nvt 0.000000 0.038209 0.000000\nvt 0.133333 0.034907 0.000000\nvt 0.000000 0.029718 0.000000\nvt 0.133333 0.026180 0.000000\nvt 0.000000 0.021227 0.000000\nvt 0.133333 0.017453 0.000000\nvt 0.000000 0.012736 0.000000\nvt 0.133333 0.008727 0.000000\nvt 0.000000 0.004245 0.000000\nvt 0.133333 0.000000 0.000000\nvt 0.000000 -0.004245 0.000000\nvt 0.133333 -0.008727 0.000000\nvt 0.000000 -0.012736 0.000000\nvt 0.133333 -0.017453 0.000000\nvt 0.000000 -0.021227 0.000000\nvt 0.133333 -0.026180 0.000000\nvt 0.000000 -0.029718 0.000000\nvt 0.133333 -0.034907 0.000000\nvt 0.000000 -0.038209 0.000000\nvt 0.133333 -0.043633 0.000000\nvt 0.000000 -0.046699 0.000000\nvt 0.133333 -0.052360 0.000000\nvt 0.000000 -0.055190 0.000000\nvt 0.133333 -0.061087 0.000000\nvt -0.000000 -0.063681 0.000000\nvt 0.133333 -0.069813 0.000000\nvt 0.000000 -0.072172 0.000000\nvt 0.133333 -0.078540 0.000000\nvt 0.000000 -0.080663 0.000000\nvt 0.133333 -0.087266 0.000000\nvt 0.000000 -0.089153 0.000000\nvt 0.133333 -0.095993 0.000000\nvt 0.000000 -0.097644 0.000000\nvt 0.133333 -0.104720 0.000000\nvt 0.000000 -0.106135 0.000000\nvt 0.133333 -0.113446 0.000000\nvt 0.000000 -0.114626 0.000000\nvt 0.133333 -0.122173 0.000000\nvt 0.000000 -0.123116 0.000000\nvt 0.133333 -0.130900 0.000000\nvt 0.000000 -0.131607 0.000000\nvt 0.133333 -0.139626 0.000000\nvt 0.000000 -0.140098 0.000000\nvt 0.133333 -0.148353 0.000000\nvt -0.400000 0.392117 0.000000\nvt -0.200000 0.392117 0.000000\nvt -0.400000 0.406121 0.000000\nvt -0.200000 0.406121 0.000000\nvt -0.400000 -0.406121 0.000000\nvt -0.200000 -0.406121 0.000000\nvt -0.400000 -0.392117 0.000000\nvt -0.200000 -0.392117 0.000000\nvt -0.400000 -0.378113 0.000000\nvt -0.200000 -0.378113 0.000000\nvt -0.400000 -0.364108 0.000000\nvt -0.200000 -0.364108 0.000000\nvt -0.400000 -0.350104 0.000000\nvt -0.200000 -0.350104 0.000000\nvt -0.400000 -0.336100 0.000000\nvt -0.200000 -0.336100 0.000000\nvt -0.400000 -0.322096 0.000000\nvt -0.200000 -0.322096 0.000000\nvt -0.400000 -0.308092 0.000000\nvt -0.200000 -0.308092 0.000000\nvt -0.400000 -0.294088 0.000000\nvt -0.200000 -0.294088 0.000000\nvt -0.400000 -0.280083 0.000000\nvt -0.200000 -0.280083 0.000000\nvt -0.400000 -0.266079 0.000000\nvt -0.200000 -0.266079 0.000000\nvt -0.400000 -0.252075 0.000000\nvt -0.200000 -0.252075 0.000000\nvt -0.400000 -0.238071 0.000000\nvt -0.200000 -0.238071 0.000000\nvt -0.400000 -0.224067 0.000000\nvt -0.200000 -0.224067 0.000000\nvt -0.400000 -0.210063 0.000000\nvt -0.200000 -0.210063 0.000000\nvt -0.400000 -0.196058 0.000000\nvt -0.200000 -0.196058 0.000000\nvt -0.400000 -0.182054 0.000000\nvt -0.200000 -0.182054 0.000000\nvt -0.400000 -0.168050 0.000000\nvt -0.200000 -0.168050 0.000000\nvt -0.400000 -0.154046 0.000000\nvt -0.200000 -0.154046 0.000000\nvt -0.400000 -0.140042 0.000000\nvt -0.200000 -0.140042 0.000000\nvt -0.400000 -0.126038 0.000000\nvt -0.200000 -0.126038 0.000000\nvt -0.400000 -0.112033 0.000000\nvt -0.200000 -0.112033 0.000000\nvt -0.400000 -0.098029 0.000000\nvt -0.200000 -0.098029 0.000000\nvt -0.400000 -0.084025 0.000000\nvt -0.200000 -0.084025 0.000000\nvt -0.400000 -0.070021 0.000000\nvt -0.200000 -0.070021 0.000000\nvt -0.400000 -0.056017 0.000000\nvt -0.200000 -0.056017 0.000000\nvt -0.400000 -0.042013 0.000000\nvt -0.200000 -0.042013 0.000000\nvt -0.400000 -0.028008 0.000000\nvt -0.200000 -0.028008 0.000000\nvt -0.400000 -0.014004 0.000000\nvt -0.200000 -0.014004 0.000000\nvt -0.400000 0.000000 0.000000\nvt -0.200000 0.000000 0.000000\nvt -0.400000 0.014004 0.000000\nvt -0.200000 0.014004 0.000000\nvt -0.400000 0.028008 0.000000\nvt -0.200000 0.028008 0.000000\nvt -0.400000 0.042013 0.000000\nvt -0.200000 0.042013 0.000000\nvt -0.400000 0.056017 0.000000\nvt -0.200000 0.056017 0.000000\nvt -0.400000 0.070021 0.000000\nvt -0.200000 0.070021 0.000000\nvt -0.400000 0.084025 0.000000\nvt -0.200000 0.084025 0.000000\nvt -0.400000 0.098029 0.000000\nvt -0.200000 0.098029 0.000000\nvt -0.400000 0.112033 0.000000\nvt -0.200000 0.112033 0.000000\nvt -0.400000 0.126038 0.000000\nvt -0.200000 0.126038 0.000000\nvt -0.400000 0.140042 0.000000\nvt -0.200000 0.140042 0.000000\nvt -0.400000 0.154046 0.000000\nvt -0.200000 0.154046 0.000000\nvt -0.400000 0.168050 0.000000\nvt -0.200000 0.168050 0.000000\nvt -0.400000 0.182054 0.000000\nvt -0.200000 0.182054 0.000000\nvt -0.400000 0.196058 0.000000\nvt -0.200000 0.196058 0.000000\nvt -0.400000 0.210063 0.000000\nvt -0.200000 0.210063 0.000000\nvt -0.400000 0.224067 0.000000\nvt -0.200000 0.224067 0.000000\nvt -0.400000 0.238071 0.000000\nvt -0.200000 0.238071 0.000000\nvt -0.400000 0.252075 0.000000\nvt -0.200000 0.252075 0.000000\nvt -0.400000 0.266079 0.000000\nvt -0.200000 0.266079 0.000000\nvt -0.400000 0.280083 0.000000\nvt -0.200000 0.280083 0.000000\nvt -0.400000 0.294088 0.000000\nvt -0.200000 0.294088 0.000000\nvt -0.400000 0.308092 0.000000\nvt -0.200000 0.308092 0.000000\nvt -0.400000 0.322096 0.000000\nvt -0.200000 0.322096 0.000000\nvt -0.400000 0.336100 0.000000\nvt -0.200000 0.336100 0.000000\nvt -0.400000 0.350104 0.000000\nvt -0.200000 0.350104 0.000000\nvt -0.400000 0.364108 0.000000\nvt -0.200000 0.364108 0.000000\nvt -0.400000 0.378113 0.000000\nvt -0.200000 0.378113 0.000000\nvt -0.000000 -0.392117 0.000000\nvt -0.000000 -0.406121 0.000000\nvt -0.000000 0.406121 0.000000\nvt -0.000000 0.392117 0.000000\nvt -0.000000 0.378113 0.000000\nvt -0.000000 0.364108 0.000000\nvt -0.000000 0.350104 0.000000\nvt -0.000000 0.336100 0.000000\nvt -0.000000 0.322096 0.000000\nvt -0.000000 0.308092 0.000000\nvt -0.000000 0.294088 0.000000\nvt -0.000000 0.280083 0.000000\nvt -0.000000 0.266079 0.000000\nvt -0.000000 0.252075 0.000000\nvt -0.000000 0.238071 0.000000\nvt -0.000000 0.224067 0.000000\nvt -0.000000 0.210063 0.000000\nvt -0.000000 0.196058 0.000000\nvt -0.000000 0.182054 0.000000\nvt -0.000000 0.168050 0.000000\nvt -0.000000 0.154046 0.000000\nvt -0.000000 0.140042 0.000000\nvt -0.000000 0.126038 0.000000\nvt -0.000000 0.112033 0.000000\nvt -0.000000 0.098029 0.000000\nvt -0.000000 0.084025 0.000000\nvt -0.000000 0.070021 0.000000\nvt -0.000000 0.056017 0.000000\nvt -0.000000 0.042013 0.000000\nvt -0.000000 0.028008 0.000000\nvt -0.000000 0.014004 0.000000\nvt -0.000000 0.000000 0.000000\nvt -0.000000 -0.014004 0.000000\nvt -0.000000 -0.028008 0.000000\nvt -0.000000 -0.042013 0.000000\nvt -0.000000 -0.056017 0.000000\nvt -0.000000 -0.070021 0.000000\nvt -0.000000 -0.084025 0.000000\nvt -0.000000 -0.098029 0.000000\nvt -0.000000 -0.112033 0.000000\nvt -0.000000 -0.126038 0.000000\nvt -0.000000 -0.140042 0.000000\nvt -0.000000 -0.154046 0.000000\nvt -0.000000 -0.168050 0.000000\nvt -0.000000 -0.182054 0.000000\nvt -0.000000 -0.196058 0.000000\nvt -0.000000 -0.210063 0.000000\nvt -0.000000 -0.224067 0.000000\nvt -0.000000 -0.238071 0.000000\nvt -0.000000 -0.252075 0.000000\nvt -0.000000 -0.266079 0.000000\nvt -0.000000 -0.280083 0.000000\nvt -0.000000 -0.294088 0.000000\nvt -0.000000 -0.308092 0.000000\nvt -0.000000 -0.322096 0.000000\nvt -0.000000 -0.336100 0.000000\nvt -0.000000 -0.350104 0.000000\nvt -0.000000 -0.364108 0.000000\nvt -0.000000 -0.378113 0.000000\nvt -0.049281 0.008450 0.000000\nvt -0.128515 0.013977 0.000000\nvt -0.050000 -0.000000 0.000000\nvt -0.129272 -0.000000 0.000000\nvt -0.128515 -0.013977 0.000000\nvt -0.126250 0.027790 0.000000\nvt -0.047144 0.016657 0.000000\nvt -0.122505 0.041277 0.000000\nvt -0.117324 0.054280 0.000000\nvt -0.043651 0.024385 0.000000\nvt -0.110768 0.066647 0.000000\nvt -0.038902 0.031411 0.000000\nvt -0.102913 0.078232 0.000000\nvt -0.093851 0.088900 0.000000\nvt -0.033034 0.037534 0.000000\nvt -0.083689 0.098526 0.000000\nvt -0.072546 0.106997 0.000000\nvt -0.026215 0.042576 0.000000\nvt -0.060552 0.114214 0.000000\nvt -0.018643 0.046394 0.000000\nvt -0.047849 0.120091 0.000000\nvt -0.034584 0.124560 0.000000\nvt -0.010534 0.048878 0.000000\nvt -0.020914 0.127569 0.000000\nvt -0.002122 0.049955 0.000000\nvt -0.006999 0.129083 0.000000\nvt 0.006999 0.129083 0.000000\nvt 0.006351 0.049595 0.000000\nvt 0.020914 0.127569 0.000000\nvt 0.014641 0.047808 0.000000\nvt 0.034584 0.124560 0.000000\nvt 0.047849 0.120091 0.000000\nvt 0.022510 0.044646 0.000000\nvt 0.060552 0.114214 0.000000\nvt 0.072546 0.106997 0.000000\nvt 0.029732 0.040200 0.000000\nvt 0.083689 0.098526 0.000000\nvt 0.036098 0.034597 0.000000\nvt 0.093851 0.088900 0.000000\nvt 0.102913 0.078232 0.000000\nvt 0.041425 0.027999 0.000000\nvt 0.110768 0.066647 0.000000\nvt 0.045561 0.020595 0.000000\nvt 0.117324 0.054280 0.000000\nvt 0.122505 0.041277 0.000000\nvt 0.048387 0.012599 0.000000\nvt 0.126250 0.027790 0.000000\nvt 0.049820 0.004240 0.000000\nvt 0.128515 0.013977 0.000000\nvt 0.129272 0.000000 0.000000\nvt 0.049820 -0.004240 0.000000\nvt 0.128515 -0.013977 0.000000\nvt 0.126250 -0.027790 0.000000\nvt 0.048387 -0.012599 0.000000\nvt 0.122505 -0.041277 0.000000\nvt 0.045561 -0.020595 0.000000\nvt 0.117324 -0.054280 0.000000\nvt 0.110768 -0.066647 0.000000\nvt 0.041425 -0.027999 0.000000\nvt 0.102913 -0.078232 0.000000\nvt 0.036098 -0.034597 0.000000\nvt 0.093851 -0.088900 0.000000\nvt 0.083689 -0.098526 0.000000\nvt 0.029732 -0.040200 0.000000\nvt 0.072546 -0.106997 0.000000\nvt 0.022510 -0.044646 0.000000\nvt 0.060552 -0.114214 0.000000\nvt 0.047849 -0.120091 0.000000\nvt 0.014641 -0.047808 0.000000\nvt 0.034584 -0.124560 0.000000\nvt 0.020914 -0.127569 0.000000\nvt 0.006351 -0.049595 0.000000\nvt 0.006999 -0.129083 0.000000\nvt -0.002122 -0.049955 0.000000\nvt -0.006999 -0.129083 0.000000\nvt -0.020914 -0.127569 0.000000\nvt -0.010534 -0.048878 0.000000\nvt -0.034584 -0.124560 0.000000\nvt -0.018643 -0.046394 0.000000\nvt -0.047849 -0.120091 0.000000\nvt -0.060552 -0.114214 0.000000\nvt -0.026215 -0.042576 0.000000\nvt -0.072546 -0.106997 0.000000\nvt -0.033034 -0.037534 0.000000\nvt -0.083689 -0.098526 0.000000\nvt -0.093851 -0.088900 0.000000\nvt -0.038902 -0.031411 0.000000\nvt -0.102913 -0.078232 0.000000\nvt -0.110768 -0.066647 0.000000\nvt -0.043651 -0.024385 0.000000\nvt -0.117324 -0.054280 0.000000\nvt -0.047144 -0.016657 0.000000\nvt -0.122505 -0.041277 0.000000\nvt -0.126250 -0.027790 0.000000\nvt -0.049281 -0.008450 0.000000\nvt 0.180059 0.295937 0.000000\nvt 0.110768 0.066647 0.000000\nvt 0.346319 -0.007968 0.000000\nvt 0.117324 0.054280 0.000000\nvt 0.122505 0.041277 0.000000\nvt -0.166259 0.303904 0.000000\nvt 0.006999 0.129083 0.000000\nvt 0.020914 0.127569 0.000000\nvt 0.034584 0.124560 0.000000\nvt -0.346319 0.007968 0.000000\nvt -0.102913 0.078232 0.000000\nvt -0.093851 0.088900 0.000000\nvt -0.083689 0.098526 0.000000\nvt -0.180059 -0.295937 0.000000\nvt -0.110768 -0.066647 0.000000\nvt -0.117324 -0.054280 0.000000\nvt -0.122505 -0.041277 0.000000\nvt 0.166259 -0.303904 0.000000\nvt -0.006999 -0.129083 0.000000\nvt -0.020914 -0.127569 0.000000\nvt -0.034584 -0.124560 0.000000\nvt 0.102913 -0.078232 0.000000\nvt 0.093851 -0.088900 0.000000\nvt 0.083689 -0.098526 0.000000\nvt 0.128515 0.013977 0.000000\nvt 0.129272 0.000000 0.000000\nvt 0.128515 -0.013977 0.000000\nvt 0.126250 -0.027790 0.000000\nvt 0.122505 -0.041277 0.000000\nvt 0.117324 -0.054280 0.000000\nvt 0.110768 -0.066647 0.000000\nvt 0.072546 -0.106997 0.000000\nvt 0.060552 -0.114214 0.000000\nvt 0.047849 -0.120091 0.000000\nvt 0.034584 -0.124560 0.000000\nvt 0.020914 -0.127569 0.000000\nvt 0.006999 -0.129083 0.000000\nvt -0.047849 -0.120091 0.000000\nvt -0.060552 -0.114214 0.000000\nvt -0.072546 -0.106997 0.000000\nvt -0.083689 -0.098526 0.000000\nvt -0.093851 -0.088900 0.000000\nvt -0.102913 -0.078232 0.000000\nvt -0.126250 -0.027790 0.000000\nvt -0.128515 -0.013977 0.000000\nvt -0.129272 0.000000 0.000000\nvt -0.128515 0.013977 0.000000\nvt -0.126250 0.027790 0.000000\nvt -0.122505 0.041277 0.000000\nvt -0.117324 0.054280 0.000000\nvt -0.110768 0.066647 0.000000\nvt -0.072546 0.106997 0.000000\nvt -0.060552 0.114214 0.000000\nvt -0.047849 0.120091 0.000000\nvt -0.034584 0.124560 0.000000\nvt -0.020914 0.127569 0.000000\nvt -0.006999 0.129083 0.000000\nvt 0.047849 0.120091 0.000000\nvt 0.060552 0.114214 0.000000\nvt 0.072546 0.106997 0.000000\nvt 0.083689 0.098526 0.000000\nvt 0.093851 0.088900 0.000000\nvt 0.102913 0.078232 0.000000\nvt 0.126250 0.027790 0.000000\nvt 0.346319 0.007968 0.000000\nvt 0.110768 -0.066647 0.000000\nvt 0.180059 -0.295937 0.000000\nvt 0.102913 -0.078232 0.000000\nvt 0.093851 -0.088900 0.000000\nvt 0.166259 0.303904 0.000000\nvt 0.102913 0.078232 0.000000\nvt 0.110768 0.066647 0.000000\nvt 0.117324 0.054280 0.000000\nvt -0.180059 0.295937 0.000000\nvt -0.006999 0.129083 0.000000\nvt 0.006999 0.129083 0.000000\nvt 0.020914 0.127569 0.000000\nvt -0.346319 -0.007968 0.000000\nvt -0.110768 0.066647 0.000000\nvt -0.102913 0.078232 0.000000\nvt -0.093851 0.088900 0.000000\nvt -0.166259 -0.303904 0.000000\nvt -0.102913 -0.078232 0.000000\nvt -0.110768 -0.066647 0.000000\nvt -0.117324 -0.054280 0.000000\nvt 0.006999 -0.129083 0.000000\nvt -0.006999 -0.129083 0.000000\nvt -0.020914 -0.127569 0.000000\nvt -0.128515 -0.013977 0.000000\nvt -0.129272 -0.000000 0.000000\nvt -0.128515 0.013977 0.000000\nvt -0.126250 0.027790 0.000000\nvt -0.122505 0.041277 0.000000\nvt -0.117324 0.054280 0.000000\nvt -0.083689 0.098526 0.000000\nvt -0.072546 0.106997 0.000000\nvt -0.060552 0.114214 0.000000\nvt -0.047849 0.120091 0.000000\nvt -0.034584 0.124560 0.000000\nvt -0.020914 0.127569 0.000000\nvt 0.034584 0.124560 0.000000\nvt 0.047849 0.120091 0.000000\nvt 0.060552 0.114214 0.000000\nvt 0.072546 0.106997 0.000000\nvt 0.083689 0.098526 0.000000\nvt 0.093851 0.088900 0.000000\nvt 0.122505 0.041277 0.000000\nvt 0.126250 0.027790 0.000000\nvt 0.128515 0.013977 0.000000\nvt 0.129272 -0.000000 0.000000\nvt 0.128515 -0.013977 0.000000\nvt 0.126250 -0.027790 0.000000\nvt 0.122505 -0.041277 0.000000\nvt 0.117324 -0.054280 0.000000\nvt 0.083689 -0.098526 0.000000\nvt 0.072546 -0.106997 0.000000\nvt 0.060552 -0.114214 0.000000\nvt 0.047849 -0.120091 0.000000\nvt 0.034584 -0.124560 0.000000\nvt 0.020914 -0.127569 0.000000\nvt -0.034584 -0.124560 0.000000\nvt -0.047849 -0.120091 0.000000\nvt -0.060552 -0.114214 0.000000\nvt -0.072546 -0.106997 0.000000\nvt -0.083689 -0.098526 0.000000\nvt -0.093851 -0.088900 0.000000\nvt -0.122505 -0.041277 0.000000\nvt -0.126250 -0.027790 0.000000\nvt 0.000000 0.000000 0.000000\nvt 0.346410 0.000000 0.000000\nvt 0.000000 0.200000 0.000000\nvt 0.346410 0.200000 0.000000\nvt 0.217487 0.107025 0.000000\nvt 0.219108 0.108026 0.000000\nvt 0.209288 0.131469 0.000000\nvt 0.220270 0.109024 0.000000\nvt 0.221337 0.110103 0.000000\nvt 0.222239 0.111320 0.000000\nvt 0.223616 0.114261 0.000000\nvt 0.224037 0.115926 0.000000\nvt 0.223037 0.112626 0.000000\nvt 0.224223 0.117638 0.000000\nvt 0.211318 0.131363 0.000000\nvt 0.224280 0.119375 0.000000\nvt 0.212882 0.131202 0.000000\nvt 0.224183 0.121059 0.000000\nvt 0.214427 0.130954 0.000000\nvt 0.215939 0.130553 0.000000\nvt 0.223933 0.122704 0.000000\nvt 0.217429 0.130054 0.000000\nvt 0.223418 0.124284 0.000000\nvt 0.219000 0.129294 0.000000\nvt 0.221662 0.127191 0.000000\nvt 0.220443 0.128380 0.000000\nvt 0.222735 0.125823 0.000000\nvt 0.207257 0.131548 0.000000\nvt 0.209546 0.104993 0.000000\nvt 0.212124 0.105272 0.000000\nvt 0.213992 0.105656 0.000000\nvt 0.206964 0.104789 0.000000\nvt 0.205225 0.131585 0.000000\nvt 0.204374 0.104697 0.000000\nvt 0.203192 0.131598 0.000000\nvt 0.201781 0.104668 0.000000\nvt 0.193857 0.131598 0.000000\nvt 0.193857 0.104668 0.000000\nvt 0.215796 0.106201 0.000000\nvt 0.000000 0.000000 0.000000\nvt 0.346410 0.000000 0.000000\nvt 0.000000 0.200000 0.000000\nvt 0.346410 0.200000 0.000000\nvt 0.000000 0.000000 0.000000\nvt 0.346410 0.000000 0.000000\nvt 0.000000 0.200000 0.000000\nvt 0.346410 0.200000 0.000000\nvt 0.000000 0.000000 0.000000\nvt 0.346410 0.000000 0.000000\nvt 0.000000 0.200000 0.000000\nvt 0.346410 0.200000 0.000000\nvt 0.000000 0.000000 0.000000\nvt 0.346410 0.000000 0.000000\nvt 0.000000 0.200000 0.000000\nvt 0.346410 0.200000 0.000000\nvt 0.049281 -0.008450 0.000000\nvt 0.050000 0.000000 0.000000\nvt -0.041425 -0.027999 0.000000\nvt 0.049281 0.008450 0.000000\nvt 0.047144 0.016657 0.000000\nvt 0.043651 0.024385 0.000000\nvt 0.038902 0.031411 0.000000\nvt 0.033034 0.037534 0.000000\nvt 0.026215 0.042576 0.000000\nvt 0.018643 0.046394 0.000000\nvt 0.010534 0.048878 0.000000\nvt 0.002122 0.049955 0.000000\nvt -0.006351 0.049595 0.000000\nvt -0.014641 0.047808 0.000000\nvt -0.022510 0.044646 0.000000\nvt -0.029732 0.040200 0.000000\nvt -0.036098 0.034597 0.000000\nvt -0.041425 0.027999 0.000000\nvt -0.045561 -0.020595 0.000000\nvt -0.045561 0.020595 0.000000\nvt -0.048387 -0.012599 0.000000\nvt -0.048387 0.012599 0.000000\nvt -0.049820 -0.004240 0.000000\nvt -0.049820 0.004240 0.000000\nvt -0.036098 -0.034597 0.000000\nvt 0.038902 -0.031411 0.000000\nvt 0.043651 -0.024385 0.000000\nvt 0.047144 -0.016657 0.000000\nvt 0.033034 -0.037534 0.000000\nvt -0.029732 -0.040200 0.000000\nvt 0.026215 -0.042576 0.000000\nvt -0.022510 -0.044646 0.000000\nvt 0.018643 -0.046394 0.000000\nvt -0.014641 -0.047808 0.000000\nvt 0.010534 -0.048878 0.000000\nvt -0.006351 -0.049595 0.000000\nvt 0.002122 -0.049955 0.000000\nvt 0.000000 0.028798 0.000000\nvt 0.047324 0.028798 0.000000\nvt 0.000000 0.031416 0.000000\nvt 0.000000 0.023562 0.000000\nvt 0.047324 0.023562 0.000000\nvt 0.000000 0.026180 0.000000\nvt 0.000000 0.018326 0.000000\nvt 0.047324 0.018326 0.000000\nvt 0.000000 0.020944 0.000000\nvt 0.000000 0.013090 0.000000\nvt 0.047324 0.013090 0.000000\nvt 0.000000 0.015708 0.000000\nvt 0.000000 0.007854 0.000000\nvt 0.047324 0.007854 0.000000\nvt 0.000000 0.010472 0.000000\nvt 0.000000 0.002618 0.000000\nvt 0.047324 0.002618 0.000000\nvt 0.000000 0.005236 0.000000\nvt 0.000000 -0.002618 0.000000\nvt 0.047324 -0.002618 0.000000\nvt 0.000000 0.000000 0.000000\nvt 0.000000 -0.007854 0.000000\nvt 0.047324 -0.007854 0.000000\nvt 0.000000 -0.005236 0.000000\nvt 0.000000 -0.013090 0.000000\nvt 0.047324 -0.013090 0.000000\nvt 0.000000 -0.010472 0.000000\nvt -0.000000 -0.018326 0.000000\nvt 0.047324 -0.018326 0.000000\nvt 0.000000 -0.015708 0.000000\nvt 0.000000 -0.023562 0.000000\nvt 0.047324 -0.023562 0.000000\nvt -0.000000 -0.020944 0.000000\nvt 0.000000 -0.028798 0.000000\nvt 0.047324 -0.028798 0.000000\nvt 0.000000 -0.026180 0.000000\nvt 0.000000 -0.031416 0.000000\nvt 0.047324 -0.031416 0.000000\nvt 0.047324 -0.010472 0.000000\nvt 0.047324 0.010472 0.000000\nvt 0.047324 -0.026180 0.000000\nvt 0.047324 -0.020944 0.000000\nvt 0.047324 -0.015708 0.000000\nvt 0.047324 -0.005236 0.000000\nvt 0.047324 0.000000 0.000000\nvt 0.047324 0.005236 0.000000\nvt 0.047324 0.015708 0.000000\nvt 0.047324 0.020944 0.000000\nvt 0.047324 0.026180 0.000000\nvt -0.187574 -0.271890 0.000000\nvt -0.187574 -0.281600 0.000000\nvt -0.000000 -0.281600 0.000000\nvt -0.000000 0.281600 0.000000\nvt -0.187574 0.281600 0.000000\nvt -0.187574 0.271890 0.000000\nvt -0.000000 0.266379 0.000000\nvt -0.187574 0.262180 0.000000\nvt -0.000000 0.251157 0.000000\nvt -0.187574 0.252469 0.000000\nvt -0.187574 0.242759 0.000000\nvt -0.000000 0.235935 0.000000\nvt -0.187574 0.233049 0.000000\nvt -0.000000 0.220714 0.000000\nvt -0.187574 0.223338 0.000000\nvt -0.187574 0.213628 0.000000\nvt -0.000000 0.205492 0.000000\nvt -0.187574 0.203917 0.000000\nvt -0.187574 0.194207 0.000000\nvt -0.000000 0.190270 0.000000\nvt -0.187574 0.184497 0.000000\nvt -0.000000 0.175049 0.000000\nvt -0.187574 0.174786 0.000000\nvt -0.187574 0.165076 0.000000\nvt -0.000000 0.159827 0.000000\nvt -0.187574 0.155366 0.000000\nvt 0.000000 0.144606 0.000000\nvt -0.187574 0.145655 0.000000\nvt -0.187574 0.135945 0.000000\nvt -0.000000 0.129384 0.000000\nvt -0.187574 0.126235 0.000000\nvt -0.000000 0.114162 0.000000\nvt -0.187574 0.116524 0.000000\nvt -0.187574 0.106814 0.000000\nvt -0.000000 0.098941 0.000000\nvt -0.187574 0.097104 0.000000\nvt -0.187574 0.087393 0.000000\nvt -0.000000 0.083719 0.000000\nvt -0.187574 0.077683 0.000000\nvt -0.000000 0.068497 0.000000\nvt -0.187574 0.067972 0.000000\nvt -0.187574 0.058262 0.000000\nvt -0.000000 0.053276 0.000000\nvt -0.187574 0.048552 0.000000\nvt -0.000000 0.038054 0.000000\nvt -0.187574 0.038841 0.000000\nvt -0.187574 0.029131 0.000000\nvt -0.000000 0.022832 0.000000\nvt -0.187574 0.019421 0.000000\nvt -0.000000 0.007611 0.000000\nvt -0.187574 0.009710 0.000000\nvt -0.187574 0.000000 0.000000\nvt -0.000000 -0.007611 0.000000\nvt -0.187574 -0.009710 0.000000\nvt -0.187574 -0.019421 0.000000\nvt -0.000000 -0.022832 0.000000\nvt -0.187574 -0.029131 0.000000\nvt -0.000000 -0.038054 0.000000\nvt -0.187574 -0.038841 0.000000\nvt -0.187574 -0.048552 0.000000\nvt -0.000000 -0.053276 0.000000\nvt -0.187574 -0.058262 0.000000\nvt -0.000000 -0.068497 0.000000\nvt -0.187574 -0.067972 0.000000\nvt -0.187574 -0.077683 0.000000\nvt -0.000000 -0.083719 0.000000\nvt -0.187574 -0.087393 0.000000\nvt -0.000000 -0.098941 0.000000\nvt -0.187574 -0.097104 0.000000\nvt -0.187574 -0.106814 0.000000\nvt -0.000000 -0.114162 0.000000\nvt -0.187574 -0.116524 0.000000\nvt -0.187574 -0.126235 0.000000\nvt -0.000000 -0.129384 0.000000\nvt -0.187574 -0.135945 0.000000\nvt 0.000000 -0.144606 0.000000\nvt -0.187574 -0.145655 0.000000\nvt -0.187574 -0.155366 0.000000\nvt -0.000000 -0.159827 0.000000\nvt -0.187574 -0.165076 0.000000\nvt -0.000000 -0.175049 0.000000\nvt -0.187574 -0.174786 0.000000\nvt -0.187574 -0.184497 0.000000\nvt -0.000000 -0.190270 0.000000\nvt -0.187574 -0.194207 0.000000\nvt -0.000000 -0.205492 0.000000\nvt -0.187574 -0.203917 0.000000\nvt -0.187574 -0.213628 0.000000\nvt -0.000000 -0.220714 0.000000\nvt -0.187574 -0.223338 0.000000\nvt -0.187574 -0.233049 0.000000\nvt -0.000000 -0.235935 0.000000\nvt -0.187574 -0.242759 0.000000\nvt -0.000000 -0.251157 0.000000\nvt -0.187574 -0.252469 0.000000\nvt -0.187574 -0.262180 0.000000\nvt -0.000000 -0.266379 0.000000\nvt 0.019319 -0.005176 0.000000\nvt 0.049281 -0.008450 0.000000\nvt 0.020000 -0.000000 0.000000\nvt 0.050000 -0.000000 0.000000\nvt 0.049281 0.008450 0.000000\nvt 0.047144 -0.016657 0.000000\nvt 0.017321 -0.010000 0.000000\nvt 0.043651 -0.024385 0.000000\nvt 0.038902 -0.031411 0.000000\nvt 0.014142 -0.014142 0.000000\nvt 0.033034 -0.037534 0.000000\nvt 0.010000 -0.017321 0.000000\nvt 0.026215 -0.042576 0.000000\nvt 0.018643 -0.046394 0.000000\nvt 0.005176 -0.019319 0.000000\nvt 0.010534 -0.048878 0.000000\nvt -0.000000 -0.020000 0.000000\nvt 0.002122 -0.049955 0.000000\nvt -0.006351 -0.049595 0.000000\nvt -0.005176 -0.019319 0.000000\nvt -0.014641 -0.047808 0.000000\nvt -0.022510 -0.044646 0.000000\nvt -0.010000 -0.017321 0.000000\nvt -0.029732 -0.040200 0.000000\nvt -0.014142 -0.014142 0.000000\nvt -0.036098 -0.034597 0.000000\nvt -0.041425 -0.027999 0.000000\nvt -0.017321 -0.010000 0.000000\nvt -0.045561 -0.020595 0.000000\nvt -0.019319 -0.005176 0.000000\nvt -0.048387 -0.012599 0.000000\nvt -0.049820 -0.004240 0.000000\nvt -0.020000 0.000000 0.000000\nvt -0.049820 0.004240 0.000000\nvt -0.019319 0.005176 0.000000\nvt -0.048387 0.012599 0.000000\nvt -0.045561 0.020595 0.000000\nvt -0.017321 0.010000 0.000000\nvt -0.041425 0.027999 0.000000\nvt -0.014142 0.014142 0.000000\nvt -0.036098 0.034597 0.000000\nvt -0.029732 0.040200 0.000000\nvt -0.010000 0.017321 0.000000\nvt -0.022510 0.044646 0.000000\nvt -0.005176 0.019319 0.000000\nvt -0.014641 0.047808 0.000000\nvt -0.006351 0.049595 0.000000\nvt -0.000000 0.020000 0.000000\nvt 0.002122 0.049955 0.000000\nvt 0.010534 0.048878 0.000000\nvt 0.005176 0.019319 0.000000\nvt 0.018643 0.046394 0.000000\nvt 0.010000 0.017321 0.000000\nvt 0.026215 0.042576 0.000000\nvt 0.033034 0.037534 0.000000\nvt 0.014142 0.014142 0.000000\nvt 0.038902 0.031411 0.000000\nvt 0.017321 0.010000 0.000000\nvt 0.043651 0.024385 0.000000\nvt 0.047144 0.016657 0.000000\nvt 0.019319 0.005176 0.000000\nvn 0.086061 -0.001980 -0.050888\nvn 0.083729 -0.001926 -0.054642\nvn 0.086061 -0.001980 -0.050888\nvn 0.083729 -0.001926 -0.054642\nvn 0.075681 -0.001741 -0.065341\nvn 0.075681 -0.001741 -0.065341\nvn 0.067174 -0.001545 -0.074062\nvn 0.067174 -0.001545 -0.074062\nvn 0.064164 -0.001476 -0.076687\nvn 0.064164 -0.001476 -0.076687\nvn 0.053891 -0.001240 -0.084227\nvn 0.049685 -0.001143 -0.086776\nvn 0.053891 -0.001240 -0.084227\nvn 0.049685 -0.001143 -0.086776\nvn 0.036164 -0.000832 -0.093228\nvn 0.036164 -0.000832 -0.093228\nvn 0.023042 -0.000530 -0.097308\nvn 0.023042 -0.000530 -0.097308\nvn 0.018655 -0.000429 -0.098244\nvn 0.018655 -0.000429 -0.098244\nvn 0.011240 -0.000259 -0.099366\nvn 0.009796 -0.000225 -0.099519\nvn 0.011240 -0.000259 -0.099366\nvn 0.009796 -0.000225 -0.099519\nvn 0.005542 -0.000128 -0.099846\nvn 0.005542 -0.000128 -0.099846\nvn 0.001942 -0.000045 -0.099981\nvn 0.001942 -0.000045 -0.099981\nvn 0.000743 -0.000017 -0.099997\nvn 0.000743 -0.000017 -0.099997\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn -0.099974 0.002300 -0.000000\nvn -0.099974 0.002300 -0.000000\nvn -0.099974 0.002300 -0.000000\nvn -0.099974 0.002300 -0.000000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000466 -0.000011 0.099999\nvn 0.001046 -0.000024 0.099995\nvn 0.000466 -0.000011 0.099999\nvn 0.001046 -0.000024 0.099995\nvn 0.002786 -0.000064 0.099961\nvn 0.002786 -0.000064 0.099961\nvn 0.004763 -0.000110 0.099886\nvn 0.004763 -0.000110 0.099886\nvn 0.005429 -0.000125 0.099852\nvn 0.005429 -0.000125 0.099852\nvn 0.009292 -0.000214 0.099567\nvn 0.012107 -0.000279 0.099264\nvn 0.009292 -0.000214 0.099567\nvn 0.012107 -0.000279 0.099264\nvn 0.020556 -0.000473 0.097863\nvn 0.020556 -0.000473 0.097863\nvn 0.029728 -0.000684 0.095476\nvn 0.029728 -0.000684 0.095476\nvn 0.032728 -0.000753 0.094490\nvn 0.032728 -0.000753 0.094490\nvn 0.041872 -0.000963 0.090806\nvn 0.046881 -0.001079 0.088323\nvn 0.041872 -0.000963 0.090806\nvn 0.046881 -0.001079 0.088323\nvn 0.061464 -0.001414 0.078868\nvn 0.061464 -0.001414 0.078868\nvn 0.075900 -0.001746 0.065086\nvn 0.075900 -0.001746 0.065086\nvn 0.079979 -0.001840 0.060000\nvn 0.079979 -0.001840 0.060000\nvn 0.090669 -0.002086 0.042128\nvn 0.092694 -0.002133 0.037461\nvn 0.090669 -0.002086 0.042128\nvn 0.092694 -0.002133 0.037461\nvn 0.097366 -0.002240 0.022692\nvn 0.097366 -0.002240 0.022692\nvn 0.099584 -0.002291 0.008814\nvn 0.099584 -0.002291 0.008814\nvn 0.099884 -0.002298 0.004241\nvn 0.099884 -0.002298 0.004241\nvn 0.099953 -0.002300 -0.002042\nvn 0.099807 -0.002296 -0.005778\nvn 0.099953 -0.002300 -0.002042\nvn 0.099807 -0.002296 -0.005778\nvn 0.098500 -0.002266 -0.017104\nvn 0.098500 -0.002266 -0.017104\nvn 0.095225 -0.002191 -0.030455\nvn 0.095225 -0.002191 -0.030455\nvn 0.093711 -0.002156 -0.034838\nvn 0.093711 -0.002156 -0.034838\nvn -0.047162 0.001085 0.088174\nvn -0.050864 0.001170 0.086090\nvn -0.047162 0.001085 0.088174\nvn -0.050864 0.001170 0.086090\nvn -0.061592 0.001417 0.078768\nvn -0.061592 0.001417 0.078768\nvn -0.072233 0.001662 0.069135\nvn -0.072233 0.001662 0.069135\nvn -0.075421 0.001735 0.065640\nvn -0.075421 0.001735 0.065640\nvn -0.086698 0.001995 0.049794\nvn -0.089635 0.002062 0.044287\nvn -0.086698 0.001995 0.049794\nvn -0.089635 0.002062 0.044287\nvn -0.096421 0.002218 0.026422\nvn -0.096421 0.002218 0.026422\nvn -0.099488 0.002289 0.009841\nvn -0.099488 0.002289 0.009841\nvn -0.099876 0.002298 0.004416\nvn -0.099876 0.002298 0.004416\nvn -0.099896 0.002298 -0.003929\nvn -0.099593 0.002291 -0.008713\nvn -0.099896 0.002298 -0.003929\nvn -0.099593 0.002291 -0.008713\nvn -0.097230 0.002237 -0.023268\nvn -0.097230 0.002237 -0.023268\nvn -0.092010 0.002117 -0.039112\nvn -0.092010 0.002117 -0.039112\nvn -0.089726 0.002064 -0.044102\nvn -0.089726 0.002064 -0.044102\nvn -0.081389 0.001872 -0.058072\nvn -0.078698 0.001811 -0.061671\nvn -0.081389 0.001872 -0.058072\nvn -0.078698 0.001811 -0.061671\nvn -0.069513 0.001599 -0.071871\nvn -0.069513 0.001599 -0.071871\nvn -0.059264 0.001363 -0.080535\nvn -0.059264 0.001363 -0.080535\nvn -0.055671 0.001281 -0.083061\nvn -0.055671 0.001281 -0.083061\nvn -0.047526 0.001093 -0.087977\nvn -0.044336 0.001020 -0.089629\nvn -0.047526 0.001093 -0.087977\nvn -0.044336 0.001020 -0.089629\nvn -0.034310 0.000789 -0.093927\nvn -0.034310 0.000789 -0.093927\nvn -0.023835 0.000548 -0.097116\nvn -0.023835 0.000548 -0.097116\nvn -0.020317 0.000467 -0.097913\nvn -0.020317 0.000467 -0.097913\nvn -0.012483 0.000287 -0.099217\nvn -0.010931 0.000251 -0.099401\nvn -0.012483 0.000287 -0.099217\nvn -0.010931 0.000251 -0.099401\nvn -0.006322 0.000145 -0.099800\nvn -0.006322 0.000145 -0.099800\nvn -0.002316 0.000053 -0.099973\nvn -0.002316 0.000053 -0.099973\nvn -0.000982 0.000023 -0.099995\nvn -0.000982 0.000023 -0.099995\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.099974 -0.002300 0.000000\nvn 0.099974 -0.002300 0.000000\nvn 0.099974 -0.002300 0.000000\nvn 0.099974 -0.002300 0.000000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn -0.099974 0.002300 -0.000000\nvn -0.099974 0.002300 -0.000000\nvn -0.099974 0.002300 -0.000000\nvn -0.099974 0.002300 -0.000000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.080290 -0.001847 0.059583\nvn 0.080290 -0.001847 0.059583\nvn 0.080290 -0.001847 0.059583\nvn 0.080290 -0.001847 0.059583\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn -0.078868 0.001814 -0.061454\nvn -0.078868 0.001814 -0.061454\nvn -0.078868 0.001814 -0.061454\nvn -0.078868 0.001814 -0.061454\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.099974 -0.002300 0.000000\nvn 0.099974 -0.002300 0.000000\nvn 0.099974 -0.002300 0.000000\nvn 0.099974 -0.002300 0.000000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.099974 -0.002300 0.000000\nvn 0.099974 -0.002300 0.000000\nvn 0.099974 -0.002300 0.000000\nvn 0.099974 -0.002300 0.000000\nvn 0.099973 -0.002300 -0.000220\nvn 0.099972 -0.002300 -0.000638\nvn 0.099973 -0.002300 -0.000220\nvn 0.099972 -0.002300 -0.000638\nvn 0.099956 -0.002300 -0.001890\nvn 0.099956 -0.002300 -0.001890\nvn 0.099916 -0.002299 -0.003403\nvn 0.099916 -0.002299 -0.003403\nvn 0.099897 -0.002298 -0.003921\nvn 0.099897 -0.002298 -0.003921\nvn 0.099549 -0.002290 -0.009210\nvn 0.099161 -0.002281 -0.012727\nvn 0.099549 -0.002290 -0.009210\nvn 0.099161 -0.002281 -0.012727\nvn 0.097223 -0.002237 -0.023298\nvn 0.097223 -0.002237 -0.023298\nvn 0.094013 -0.002163 -0.034014\nvn 0.094013 -0.002163 -0.034014\nvn 0.092695 -0.002133 -0.037459\nvn 0.092695 -0.002133 -0.037459\nvn 0.085457 -0.001966 -0.051897\nvn 0.081991 -0.001886 -0.057218\nvn 0.085457 -0.001966 -0.051897\nvn 0.081991 -0.001886 -0.057218\nvn 0.069198 -0.001592 -0.072174\nvn 0.069198 -0.001592 -0.072174\nvn 0.054828 -0.001261 -0.083620\nvn 0.054828 -0.001261 -0.083620\nvn 0.049798 -0.001146 -0.086711\nvn 0.049798 -0.001146 -0.086711\nvn 0.033800 -0.000778 -0.094111\nvn 0.029330 -0.000675 -0.095600\nvn 0.033800 -0.000778 -0.094111\nvn 0.029330 -0.000675 -0.095600\nvn 0.015918 -0.000366 -0.098724\nvn 0.015918 -0.000366 -0.098724\nvn 0.004973 -0.000114 -0.099876\nvn 0.004973 -0.000114 -0.099876\nvn 0.001365 -0.000031 -0.099991\nvn 0.001365 -0.000031 -0.099991\nvn -0.001389 0.000032 -0.099990\nvn -0.003775 0.000087 -0.099929\nvn -0.001389 0.000032 -0.099990\nvn -0.003775 0.000087 -0.099929\nvn -0.010964 0.000252 -0.099397\nvn -0.010964 0.000252 -0.099397\nvn -0.019476 0.000448 -0.098084\nvn -0.019476 0.000448 -0.098084\nvn -0.022336 0.000514 -0.097472\nvn -0.022336 0.000514 -0.097472\nvn -0.029303 0.000674 -0.095608\nvn -0.029913 0.000688 -0.095419\nvn -0.029303 0.000674 -0.095608\nvn -0.029913 0.000688 -0.095419\nvn -0.031734 0.000730 -0.094828\nvn -0.031734 0.000730 -0.094828\nvn -0.033594 0.000773 -0.094185\nvn -0.033594 0.000773 -0.094185\nvn -0.034212 0.000787 -0.093962\nvn -0.034212 0.000787 -0.093962\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.099974 -0.002300 0.000000\nvn 0.099974 -0.002300 0.000000\nvn 0.099974 -0.002300 0.000000\nvn 0.099974 -0.002300 0.000000\nvn 0.017666 -0.000406 0.098426\nvn 0.016520 -0.000380 0.098625\nvn 0.017666 -0.000406 0.098426\nvn 0.016520 -0.000380 0.098625\nvn 0.013102 -0.000301 0.099138\nvn 0.013102 -0.000301 0.099138\nvn 0.010056 -0.000231 0.099493\nvn 0.010056 -0.000231 0.099493\nvn 0.009039 -0.000208 0.099590\nvn 0.009039 -0.000208 0.099590\nvn 0.006942 -0.000160 0.099759\nvn 0.006154 -0.000142 0.099810\nvn 0.006942 -0.000160 0.099759\nvn 0.006154 -0.000142 0.099810\nvn 0.003791 -0.000087 0.099928\nvn 0.003791 -0.000087 0.099928\nvn 0.001560 -0.000036 0.099988\nvn 0.001560 -0.000036 0.099988\nvn 0.000816 -0.000019 0.099997\nvn 0.000816 -0.000019 0.099997\nvn -0.001881 0.000043 0.099982\nvn -0.004603 0.000106 0.099894\nvn -0.001881 0.000043 0.099982\nvn -0.004603 0.000106 0.099894\nvn -0.012812 0.000295 0.099175\nvn -0.012812 0.000295 0.099175\nvn -0.022270 0.000512 0.097487\nvn -0.022270 0.000512 0.097487\nvn -0.025412 0.000585 0.096716\nvn -0.025412 0.000585 0.096716\nvn -0.035332 0.000813 0.093547\nvn -0.038594 0.000888 0.092248\nvn -0.035332 0.000813 0.093547\nvn -0.038594 0.000888 0.092248\nvn -0.048195 0.001109 0.087613\nvn -0.048195 0.001109 0.087613\nvn -0.057783 0.001329 0.081605\nvn -0.057783 0.001329 0.081605\nvn -0.060791 0.001399 0.079388\nvn -0.060791 0.001399 0.079388\nvn -0.069391 0.001596 0.071989\nvn -0.072520 0.001668 0.068833\nvn -0.069391 0.001596 0.071989\nvn -0.072520 0.001668 0.068833\nvn -0.081175 0.001868 0.058371\nvn -0.081175 0.001868 0.058371\nvn -0.088273 0.002031 0.046943\nvn -0.088273 0.002031 0.046943\nvn -0.090254 0.002076 0.043010\nvn -0.090254 0.002076 0.043010\nvn -0.094395 0.002172 0.032938\nvn -0.095543 0.002198 0.029439\nvn -0.094395 0.002172 0.032938\nvn -0.095543 0.002198 0.029439\nvn -0.098230 0.002260 0.018593\nvn -0.098230 0.002260 0.018593\nvn -0.099665 0.002293 0.007845\nvn -0.099665 0.002293 0.007845\nvn -0.099882 0.002298 0.004281\nvn -0.099882 0.002298 0.004281\nvn -0.099974 0.002300 -0.000000\nvn -0.099974 0.002300 -0.000000\nvn -0.099974 0.002300 -0.000000\nvn -0.099974 0.002300 -0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.098562 0.016900 0.000000\nvn -0.100000 0.000000 0.000000\nvn -0.100000 0.000000 0.000000\nvn -0.098562 -0.016900 0.000000\nvn -0.098481 -0.017365 0.000000\nvn -0.094288 -0.033314 0.000000\nvn -0.093969 -0.034202 0.000000\nvn -0.087301 -0.048769 0.000000\nvn -0.086603 -0.050000 0.000000\nvn -0.077804 -0.062822 0.000000\nvn -0.076604 -0.064279 0.000000\nvn -0.066067 -0.075067 0.000000\nvn -0.064279 -0.076604 0.000000\nvn -0.052431 -0.085153 0.000000\nvn -0.050000 -0.086603 0.000000\nvn -0.037286 -0.092789 0.000000\nvn -0.034202 -0.093969 0.000000\nvn -0.021068 -0.097756 0.000000\nvn -0.017365 -0.098481 0.000000\nvn -0.004244 -0.099910 0.000000\nvn 0.000000 -0.100000 0.000000\nvn 0.012702 -0.099190 0.000000\nvn 0.017365 -0.098481 0.000000\nvn 0.029282 -0.095617 0.000000\nvn 0.034202 -0.093969 0.000000\nvn 0.045020 -0.089293 0.000000\nvn 0.050000 -0.086603 0.000000\nvn 0.059463 -0.080400 0.000000\nvn 0.064279 -0.076604 0.000000\nvn 0.072196 -0.069194 0.000000\nvn 0.076604 -0.064279 0.000000\nvn 0.082851 -0.055997 0.000000\nvn 0.086603 -0.050000 0.000000\nvn 0.091123 -0.041190 0.000000\nvn 0.093969 -0.034202 0.000000\nvn 0.096773 -0.025198 0.000000\nvn 0.098481 -0.017365 0.000000\nvn 0.099640 -0.008481 0.000000\nvn 0.100000 0.000000 0.000000\nvn 0.099640 0.008481 0.000000\nvn 0.098481 0.017365 0.000000\nvn 0.096773 0.025198 0.000000\nvn 0.093969 0.034202 0.000000\nvn 0.091123 0.041190 0.000000\nvn 0.086603 0.050000 0.000000\nvn 0.082851 0.055997 0.000000\nvn 0.076604 0.064279 0.000000\nvn 0.072196 0.069194 0.000000\nvn 0.064279 0.076604 0.000000\nvn 0.059463 0.080400 0.000000\nvn 0.050000 0.086603 0.000000\nvn 0.045020 0.089293 0.000000\nvn 0.034202 0.093969 0.000000\nvn 0.029282 0.095617 0.000000\nvn 0.017365 0.098481 0.000000\nvn 0.012702 0.099190 0.000000\nvn 0.000000 0.100000 0.000000\nvn -0.004244 0.099910 0.000000\nvn -0.017365 0.098481 0.000000\nvn -0.021068 0.097756 0.000000\nvn -0.034202 0.093969 0.000000\nvn -0.037286 0.092789 0.000000\nvn -0.050000 0.086603 0.000000\nvn -0.052431 0.085153 0.000000\nvn -0.064279 0.076604 0.000000\nvn -0.066067 0.075067 0.000000\nvn -0.076604 0.064279 0.000000\nvn -0.077804 0.062822 0.000000\nvn -0.086603 0.050000 0.000000\nvn -0.087301 0.048769 0.000000\nvn -0.093969 0.034202 0.000000\nvn -0.094288 0.033314 0.000000\nvn -0.098481 0.017365 0.000000\nvn -0.098562 -0.016900 0.000000\nvn -0.100000 -0.000000 0.000000\nvn -0.100000 -0.000000 0.000000\nvn -0.098562 0.016900 0.000000\nvn -0.098481 0.017365 0.000000\nvn -0.094288 0.033314 0.000000\nvn -0.093969 0.034202 0.000000\nvn -0.087301 0.048769 0.000000\nvn -0.086603 0.050000 0.000000\nvn -0.077804 0.062822 0.000000\nvn -0.076604 0.064279 0.000000\nvn -0.066067 0.075067 0.000000\nvn -0.064279 0.076604 0.000000\nvn -0.052431 0.085153 0.000000\nvn -0.050000 0.086603 0.000000\nvn -0.037286 0.092789 0.000000\nvn -0.034202 0.093969 0.000000\nvn -0.021068 0.097756 0.000000\nvn -0.017365 0.098481 0.000000\nvn -0.004244 0.099910 0.000000\nvn 0.000000 0.100000 0.000000\nvn 0.012702 0.099190 0.000000\nvn 0.017365 0.098481 0.000000\nvn 0.029282 0.095617 0.000000\nvn 0.034202 0.093969 0.000000\nvn 0.045020 0.089293 0.000000\nvn 0.050000 0.086603 0.000000\nvn 0.059463 0.080400 0.000000\nvn 0.064279 0.076604 0.000000\nvn 0.072196 0.069194 0.000000\nvn 0.076604 0.064279 0.000000\nvn 0.082851 0.055997 0.000000\nvn 0.086603 0.050000 0.000000\nvn 0.091123 0.041190 0.000000\nvn 0.093969 0.034202 0.000000\nvn 0.096773 0.025198 0.000000\nvn 0.098481 0.017365 0.000000\nvn 0.099640 0.008481 0.000000\nvn 0.100000 0.000000 0.000000\nvn 0.099640 -0.008481 0.000000\nvn 0.098481 -0.017365 0.000000\nvn 0.096773 -0.025198 0.000000\nvn 0.093969 -0.034202 0.000000\nvn 0.091123 -0.041190 0.000000\nvn 0.086603 -0.050000 0.000000\nvn 0.082851 -0.055997 0.000000\nvn 0.076604 -0.064279 0.000000\nvn 0.072196 -0.069194 0.000000\nvn 0.064279 -0.076604 0.000000\nvn 0.059463 -0.080400 0.000000\nvn 0.050000 -0.086603 0.000000\nvn 0.045020 -0.089293 0.000000\nvn 0.034202 -0.093969 0.000000\nvn 0.029282 -0.095617 0.000000\nvn 0.017365 -0.098481 0.000000\nvn 0.012702 -0.099190 0.000000\nvn 0.000000 -0.100000 0.000000\nvn -0.004244 -0.099910 0.000000\nvn -0.017365 -0.098481 0.000000\nvn -0.021068 -0.097756 0.000000\nvn -0.034202 -0.093969 0.000000\nvn -0.037286 -0.092789 0.000000\nvn -0.050000 -0.086603 0.000000\nvn -0.052431 -0.085153 0.000000\nvn -0.064279 -0.076604 0.000000\nvn -0.066067 -0.075067 0.000000\nvn -0.076604 -0.064279 0.000000\nvn -0.077804 -0.062822 0.000000\nvn -0.086603 -0.050000 0.000000\nvn -0.087301 -0.048769 0.000000\nvn -0.093969 -0.034202 0.000000\nvn -0.094288 -0.033314 0.000000\nvn -0.098481 -0.017365 0.000000\nvn 0.099414 -0.010812 0.000000\nvn 0.099414 -0.010812 0.000000\nvn 0.100000 -0.000000 0.000000\nvn 0.100000 -0.000000 0.000000\nvn 0.099414 0.010812 0.000000\nvn 0.099414 0.010812 0.000000\nvn 0.097662 0.021497 0.000000\nvn 0.097662 0.021497 0.000000\nvn 0.094765 0.031930 0.000000\nvn 0.094765 0.031930 0.000000\nvn 0.090758 0.041989 0.000000\nvn 0.090758 0.041989 0.000000\nvn 0.085686 0.051555 0.000000\nvn 0.085686 0.051555 0.000000\nvn 0.079609 0.060517 0.000000\nvn 0.079609 0.060517 0.000000\nvn 0.072600 0.068770 0.000000\nvn 0.072600 0.068770 0.000000\nvn 0.064739 0.076216 0.000000\nvn 0.064739 0.076216 0.000000\nvn 0.056119 0.082769 0.000000\nvn 0.056119 0.082769 0.000000\nvn 0.046841 0.088351 0.000000\nvn 0.046841 0.088351 0.000000\nvn 0.037014 0.092898 0.000000\nvn 0.037014 0.092898 0.000000\nvn 0.026753 0.096355 0.000000\nvn 0.026753 0.096355 0.000000\nvn 0.016178 0.098683 0.000000\nvn 0.016178 0.098683 0.000000\nvn 0.005414 0.099853 0.000000\nvn 0.005414 0.099853 0.000000\nvn -0.005414 0.099853 -0.000000\nvn -0.005414 0.099853 -0.000000\nvn -0.016178 0.098683 -0.000000\nvn -0.016178 0.098683 -0.000000\nvn -0.026753 0.096355 -0.000000\nvn -0.026753 0.096355 -0.000000\nvn -0.037014 0.092898 -0.000000\nvn -0.037014 0.092898 -0.000000\nvn -0.046841 0.088351 -0.000000\nvn -0.046841 0.088351 -0.000000\nvn -0.056119 0.082769 -0.000000\nvn -0.056119 0.082769 -0.000000\nvn -0.064739 0.076216 -0.000000\nvn -0.064739 0.076216 -0.000000\nvn -0.072600 0.068770 -0.000000\nvn -0.072600 0.068770 -0.000000\nvn -0.079609 0.060517 -0.000000\nvn -0.079609 0.060517 -0.000000\nvn -0.085686 0.051555 -0.000000\nvn -0.085686 0.051555 -0.000000\nvn -0.090758 0.041989 -0.000000\nvn -0.090758 0.041989 -0.000000\nvn -0.094765 0.031930 -0.000000\nvn -0.094765 0.031930 -0.000000\nvn -0.097662 0.021497 -0.000000\nvn -0.097662 0.021497 -0.000000\nvn -0.099414 0.010812 -0.000000\nvn -0.099414 0.010812 -0.000000\nvn -0.100000 0.000000 0.000000\nvn -0.100000 0.000000 0.000000\nvn -0.099414 -0.010812 0.000000\nvn -0.099414 -0.010812 0.000000\nvn -0.097662 -0.021497 0.000000\nvn -0.097662 -0.021497 0.000000\nvn -0.094765 -0.031930 0.000000\nvn -0.094765 -0.031930 0.000000\nvn -0.090758 -0.041989 0.000000\nvn -0.090758 -0.041989 0.000000\nvn -0.085686 -0.051555 0.000000\nvn -0.085686 -0.051555 0.000000\nvn -0.079609 -0.060517 0.000000\nvn -0.079609 -0.060517 0.000000\nvn -0.072600 -0.068770 0.000000\nvn -0.072600 -0.068770 0.000000\nvn -0.064739 -0.076216 0.000000\nvn -0.064739 -0.076216 0.000000\nvn -0.056119 -0.082769 0.000000\nvn -0.056119 -0.082769 0.000000\nvn -0.046841 -0.088351 0.000000\nvn -0.046841 -0.088351 0.000000\nvn -0.037014 -0.092898 0.000000\nvn -0.037014 -0.092898 0.000000\nvn -0.026753 -0.096355 0.000000\nvn -0.026753 -0.096355 0.000000\nvn -0.016178 -0.098683 0.000000\nvn -0.016178 -0.098683 0.000000\nvn -0.005414 -0.099853 0.000000\nvn -0.005414 -0.099853 0.000000\nvn 0.005414 -0.099853 0.000000\nvn 0.005414 -0.099853 0.000000\nvn 0.016178 -0.098683 0.000000\nvn 0.016178 -0.098683 0.000000\nvn 0.026753 -0.096355 0.000000\nvn 0.026753 -0.096355 0.000000\nvn 0.037014 -0.092898 0.000000\nvn 0.037014 -0.092898 0.000000\nvn 0.046841 -0.088351 0.000000\nvn 0.046841 -0.088351 0.000000\nvn 0.056119 -0.082769 0.000000\nvn 0.056119 -0.082769 0.000000\nvn 0.064739 -0.076216 0.000000\nvn 0.064739 -0.076216 0.000000\nvn 0.072600 -0.068770 0.000000\nvn 0.072600 -0.068770 0.000000\nvn 0.079609 -0.060517 0.000000\nvn 0.079609 -0.060517 0.000000\nvn 0.085686 -0.051555 0.000000\nvn 0.085686 -0.051555 0.000000\nvn 0.090758 -0.041989 0.000000\nvn 0.090758 -0.041989 0.000000\nvn 0.094765 -0.031930 0.000000\nvn 0.094765 -0.031930 0.000000\nvn 0.097662 -0.021497 0.000000\nvn 0.097662 -0.021497 0.000000\nvn 0.099414 0.010812 0.000000\nvn 0.100000 0.000000 0.000000\nvn 0.099414 -0.010812 0.000000\nvn 0.097662 -0.021497 0.000000\nvn 0.094765 -0.031930 0.000000\nvn 0.090758 -0.041989 0.000000\nvn 0.085686 -0.051555 0.000000\nvn 0.079609 -0.060517 0.000000\nvn 0.072600 -0.068770 0.000000\nvn 0.064739 -0.076216 0.000000\nvn 0.056119 -0.082769 0.000000\nvn 0.046841 -0.088351 0.000000\nvn 0.037014 -0.092898 0.000000\nvn 0.026753 -0.096355 0.000000\nvn 0.016178 -0.098683 0.000000\nvn 0.005414 -0.099853 0.000000\nvn -0.005414 -0.099853 0.000000\nvn -0.016178 -0.098683 0.000000\nvn -0.026753 -0.096355 0.000000\nvn -0.037014 -0.092898 0.000000\nvn -0.046841 -0.088351 0.000000\nvn -0.056119 -0.082769 0.000000\nvn -0.064739 -0.076216 0.000000\nvn -0.072600 -0.068770 0.000000\nvn -0.079609 -0.060517 0.000000\nvn -0.085686 -0.051555 0.000000\nvn -0.090758 -0.041989 0.000000\nvn -0.094765 -0.031930 0.000000\nvn -0.097662 -0.021497 0.000000\nvn -0.099414 -0.010812 0.000000\nvn -0.100000 0.000000 0.000000\nvn -0.099414 0.010812 -0.000000\nvn -0.097662 0.021497 -0.000000\nvn -0.094765 0.031930 -0.000000\nvn -0.090758 0.041989 -0.000000\nvn -0.085686 0.051555 -0.000000\nvn -0.079609 0.060517 -0.000000\nvn -0.072600 0.068770 -0.000000\nvn -0.064739 0.076216 -0.000000\nvn -0.056119 0.082769 -0.000000\nvn -0.046841 0.088351 -0.000000\nvn -0.037014 0.092898 -0.000000\nvn -0.026753 0.096355 -0.000000\nvn -0.016178 0.098683 -0.000000\nvn -0.005414 0.099853 -0.000000\nvn 0.005414 0.099853 0.000000\nvn 0.016178 0.098683 0.000000\nvn 0.026753 0.096355 0.000000\nvn 0.037014 0.092898 0.000000\nvn 0.046841 0.088351 0.000000\nvn 0.056119 0.082769 0.000000\nvn 0.064739 0.076216 0.000000\nvn 0.072600 0.068770 0.000000\nvn 0.079609 0.060517 0.000000\nvn 0.085686 0.051555 0.000000\nvn 0.090758 0.041989 0.000000\nvn 0.094765 0.031930 0.000000\nvn 0.097662 0.021497 0.000000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.085430 -0.051979 0.000000\nvn 0.085430 -0.051979 0.000000\nvn 0.085430 -0.051979 0.000000\nvn 0.085430 -0.051979 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.002300 -0.099974 0.000000\nvn -0.087730 -0.047995 0.000000\nvn -0.087730 -0.047995 0.000000\nvn -0.087730 -0.047995 0.000000\nvn -0.087730 -0.047995 0.000000\nvn -0.085430 0.051979 0.000000\nvn -0.085430 0.051979 0.000000\nvn -0.085430 0.051979 0.000000\nvn -0.085430 0.051979 0.000000\nvn 0.002300 0.099974 0.000000\nvn 0.002300 0.099974 0.000000\nvn 0.002300 0.099974 0.000000\nvn 0.002300 0.099974 0.000000\nvn 0.087730 0.047995 0.000000\nvn 0.087730 0.047995 0.000000\nvn 0.087730 0.047995 0.000000\nvn 0.087730 0.047995 0.000000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.000000 0.000000 0.100000\nvn 0.087543 -0.023457 -0.042262\nvn 0.087543 -0.023457 -0.042262\nvn 0.090631 -0.000000 -0.042262\nvn 0.064086 -0.064086 -0.042262\nvn 0.064086 -0.064086 -0.042262\nvn 0.078489 -0.045315 -0.042262\nvn 0.023457 -0.087543 -0.042262\nvn 0.023457 -0.087543 -0.042262\nvn 0.045315 -0.078489 -0.042262\nvn -0.023457 -0.087543 -0.042262\nvn -0.023457 -0.087543 -0.042262\nvn -0.000000 -0.090631 -0.042262\nvn -0.064086 -0.064086 -0.042262\nvn -0.064086 -0.064086 -0.042262\nvn -0.045315 -0.078489 -0.042262\nvn -0.087543 -0.023457 -0.042262\nvn -0.087543 -0.023457 -0.042262\nvn -0.078489 -0.045315 -0.042262\nvn -0.087543 0.023457 -0.042262\nvn -0.087543 0.023457 -0.042262\nvn -0.090631 0.000000 -0.042262\nvn -0.064086 0.064086 -0.042262\nvn -0.064086 0.064086 -0.042262\nvn -0.078489 0.045315 -0.042262\nvn -0.023457 0.087543 -0.042262\nvn -0.023457 0.087543 -0.042262\nvn -0.045315 0.078489 -0.042262\nvn 0.023457 0.087543 -0.042262\nvn 0.023457 0.087543 -0.042262\nvn -0.000000 0.090631 -0.042262\nvn 0.064086 0.064086 -0.042262\nvn 0.064086 0.064086 -0.042262\nvn 0.045315 0.078489 -0.042262\nvn 0.087543 0.023457 -0.042262\nvn 0.087543 0.023457 -0.042262\nvn 0.078489 0.045315 -0.042262\nvn 0.090631 0.000000 -0.042262\nvn -0.045315 0.078489 -0.042262\nvn -0.045315 -0.078489 -0.042262\nvn 0.078489 0.045315 -0.042262\nvn 0.045315 0.078489 -0.042262\nvn -0.000000 0.090631 -0.042262\nvn -0.078489 0.045315 -0.042262\nvn -0.090631 0.000000 -0.042262\nvn -0.078489 -0.045315 -0.042262\nvn -0.000000 -0.090631 -0.042262\nvn 0.045315 -0.078489 -0.042262\nvn 0.078489 -0.045315 -0.042262\nvn -0.090099 -0.009799 -0.042262\nvn -0.090631 -0.000000 -0.042262\nvn -0.090631 -0.000000 -0.042262\nvn -0.090099 0.009799 -0.042262\nvn -0.089327 0.015317 -0.042262\nvn -0.088512 0.019483 -0.042262\nvn -0.085454 0.030193 -0.042262\nvn -0.085887 0.028939 -0.042262\nvn -0.082254 0.038055 -0.042262\nvn -0.079122 0.044200 -0.042262\nvn -0.077658 0.046725 -0.042262\nvn -0.070514 0.056936 -0.042262\nvn -0.072151 0.054847 -0.042262\nvn -0.065798 0.062327 -0.042262\nvn -0.059877 0.068034 -0.042262\nvn -0.058673 0.069075 -0.042262\nvn -0.050861 0.075014 -0.042262\nvn -0.047518 0.077175 -0.042262\nvn -0.042452 0.080073 -0.042262\nvn -0.033792 0.084095 -0.042262\nvn -0.033546 0.084194 -0.042262\nvn -0.024246 0.087327 -0.042262\nvn -0.019094 0.088597 -0.042262\nvn -0.014662 0.089437 -0.042262\nvn -0.003846 0.090549 -0.042262\nvn -0.004907 0.090498 -0.042262\nvn 0.004907 0.090498 -0.042262\nvn 0.011512 0.089897 -0.042262\nvn 0.014662 0.089437 -0.042262\nvn 0.026539 0.086658 -0.042262\nvn 0.024246 0.087327 -0.042262\nvn 0.033546 0.084194 -0.042262\nvn 0.040802 0.080927 -0.042262\nvn 0.042452 0.080073 -0.042262\nvn 0.050861 0.075014 -0.042262\nvn 0.053892 0.072867 -0.042262\nvn 0.058673 0.069075 -0.042262\nvn 0.065431 0.062711 -0.042262\nvn 0.065798 0.062327 -0.042262\nvn 0.072151 0.054847 -0.042262\nvn 0.075088 0.050751 -0.042262\nvn 0.077658 0.046725 -0.042262\nvn 0.082585 0.037331 -0.042262\nvn 0.082254 0.038055 -0.042262\nvn 0.085887 0.028939 -0.042262\nvn 0.087706 0.022837 -0.042262\nvn 0.088512 0.019483 -0.042262\nvn 0.090304 0.007686 -0.042262\nvn 0.090099 0.009799 -0.042262\nvn 0.090631 0.000000 -0.042262\nvn 0.090304 -0.007686 -0.042262\nvn 0.090099 -0.009799 -0.042262\nvn 0.088512 -0.019483 -0.042262\nvn 0.087706 -0.022837 -0.042262\nvn 0.085887 -0.028939 -0.042262\nvn 0.082585 -0.037331 -0.042262\nvn 0.082254 -0.038055 -0.042262\nvn 0.077658 -0.046725 -0.042262\nvn 0.075088 -0.050751 -0.042262\nvn 0.072151 -0.054847 -0.042262\nvn 0.065431 -0.062711 -0.042262\nvn 0.065798 -0.062327 -0.042262\nvn 0.058673 -0.069075 -0.042262\nvn 0.053892 -0.072867 -0.042262\nvn 0.050861 -0.075014 -0.042262\nvn 0.040802 -0.080927 -0.042262\nvn 0.042452 -0.080073 -0.042262\nvn 0.033546 -0.084194 -0.042262\nvn 0.026539 -0.086658 -0.042262\nvn 0.024246 -0.087327 -0.042262\nvn 0.014662 -0.089437 -0.042262\nvn 0.011512 -0.089897 -0.042262\nvn 0.004907 -0.090498 -0.042262\nvn -0.003846 -0.090549 -0.042262\nvn -0.004907 -0.090498 -0.042262\nvn -0.014662 -0.089437 -0.042262\nvn -0.019094 -0.088597 -0.042262\nvn -0.024246 -0.087327 -0.042262\nvn -0.033792 -0.084095 -0.042262\nvn -0.033546 -0.084194 -0.042262\nvn -0.042452 -0.080073 -0.042262\nvn -0.047518 -0.077175 -0.042262\nvn -0.050861 -0.075014 -0.042262\nvn -0.059877 -0.068034 -0.042262\nvn -0.058673 -0.069075 -0.042262\nvn -0.065798 -0.062327 -0.042262\nvn -0.070514 -0.056936 -0.042262\nvn -0.072151 -0.054847 -0.042262\nvn -0.077658 -0.046725 -0.042262\nvn -0.079122 -0.044200 -0.042262\nvn -0.082254 -0.038055 -0.042262\nvn -0.085454 -0.030193 -0.042262\nvn -0.085887 -0.028939 -0.042262\nvn -0.088512 -0.019483 -0.042262\nvn -0.089327 -0.015317 -0.042262\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nvn 0.000000 0.000000 -0.100000\nusemtl Brass_-_Polished\nf 1/1/1 2/2/2 10/3/3\nf 10/3/3 2/2/2 9/4/4\nf 9/4/4 2/2/2 3/5/5\nf 9/4/4 3/5/5 8/6/6\nf 8/6/6 3/5/5 4/7/7\nf 8/6/6 4/7/7 7/8/8\nf 7/8/8 4/7/7 5/9/9\nf 7/8/8 5/9/9 6/10/10\nf 5/11/11 11/12/12 6/13/13\nf 6/13/13 11/12/12 18/14/14\nf 18/14/14 11/12/12 12/15/15\nf 18/14/14 12/15/15 17/16/16\nf 17/16/16 12/15/15 13/17/17\nf 17/16/16 13/17/17 16/18/18\nf 16/18/18 13/17/17 14/19/19\nf 16/18/18 14/19/19 15/20/20\nf 14/21/21 19/22/22 15/23/23\nf 15/23/23 19/22/22 26/24/24\nf 26/24/24 19/22/22 20/25/25\nf 26/24/24 20/25/25 25/26/26\nf 25/26/26 20/25/25 21/27/27\nf 25/26/26 21/27/27 24/28/28\nf 24/28/28 21/27/27 22/29/29\nf 24/28/28 22/29/29 23/30/30\nf 22/31/31 27/32/32 23/33/33\nf 23/33/33 27/32/32 28/34/34\nf 27/35/35 29/36/36 28/37/37\nf 28/37/37 29/36/36 30/38/38\nf 29/39/39 31/40/40 30/41/41\nf 30/41/41 31/40/40 32/42/42\nf 31/43/43 33/44/44 32/45/45\nf 32/45/45 33/44/44 40/46/46\nf 40/46/46 33/44/44 34/47/47\nf 40/46/46 34/47/47 39/48/48\nf 39/48/48 34/47/47 35/49/49\nf 39/48/48 35/49/49 38/50/50\nf 38/50/50 35/49/49 36/51/51\nf 38/50/50 36/51/51 37/52/52\nf 36/53/53 41/54/54 37/55/55\nf 37/55/55 41/54/54 48/56/56\nf 48/56/56 41/54/54 42/57/57\nf 48/56/56 42/57/57 47/58/58\nf 47/58/58 42/57/57 43/59/59\nf 47/58/58 43/59/59 46/60/60\nf 46/60/60 43/59/59 44/61/61\nf 46/60/60 44/61/61 45/62/62\nf 44/63/63 49/64/64 45/65/65\nf 45/65/65 49/64/64 56/66/66\nf 56/66/66 49/64/64 50/67/67\nf 56/66/66 50/67/67 55/68/68\nf 55/68/68 50/67/67 51/69/69\nf 55/68/68 51/69/69 54/70/70\nf 54/70/70 51/69/69 52/71/71\nf 54/70/70 52/71/71 53/72/72\nf 52/73/73 57/74/74 53/75/75\nf 53/75/75 57/74/74 64/76/76\nf 64/76/76 57/74/74 58/77/77\nf 64/76/76 58/77/77 63/78/78\nf 63/78/78 58/77/77 59/79/79\nf 63/78/78 59/79/79 62/80/80\nf 62/80/80 59/79/79 60/81/81\nf 62/80/80 60/81/81 61/82/82\nf 60/83/83 65/84/84 61/85/85\nf 61/85/85 65/84/84 70/86/86\nf 70/86/86 65/84/84 66/87/87\nf 70/86/86 66/87/87 69/88/88\nf 69/88/88 66/87/87 67/89/89\nf 69/88/88 67/89/89 68/90/90\nf 68/90/90 67/89/89 1/91/91\nf 68/90/90 1/91/91 10/92/92\nf 71/93/93 72/94/94 80/95/95\nf 80/95/95 72/94/94 79/96/96\nf 79/96/96 72/94/94 73/97/97\nf 79/96/96 73/97/97 78/98/98\nf 78/98/98 73/97/97 74/99/99\nf 78/98/98 74/99/99 77/100/100\nf 77/100/100 74/99/99 75/101/101\nf 77/100/100 75/101/101 76/102/102\nf 75/103/103 81/104/104 76/105/105\nf 76/105/105 81/104/104 88/106/106\nf 88/106/106 81/104/104 82/107/107\nf 88/106/106 82/107/107 87/108/108\nf 87/108/108 82/107/107 83/109/109\nf 87/108/108 83/109/109 86/110/110\nf 86/110/110 83/109/109 84/111/111\nf 86/110/110 84/111/111 85/112/112\nf 84/113/113 89/114/114 85/115/115\nf 85/115/115 89/114/114 96/116/116\nf 96/116/116 89/114/114 90/117/117\nf 96/116/116 90/117/117 95/118/118\nf 95/118/118 90/117/117 91/119/119\nf 95/118/118 91/119/119 94/120/120\nf 94/120/120 91/119/119 92/121/121\nf 94/120/120 92/121/121 93/122/122\nf 92/123/123 97/124/124 93/125/125\nf 93/125/125 97/124/124 104/126/126\nf 104/126/126 97/124/124 98/127/127\nf 104/126/126 98/127/127 103/128/128\nf 103/128/128 98/127/127 99/129/129\nf 103/128/128 99/129/129 102/130/130\nf 102/130/130 99/129/129 100/131/131\nf 102/130/130 100/131/131 101/132/132\nf 100/133/133 105/134/134 101/135/135\nf 101/135/135 105/134/134 112/136/136\nf 112/136/136 105/134/134 106/137/137\nf 112/136/136 106/137/137 111/138/138\nf 111/138/138 106/137/137 107/139/139\nf 111/138/138 107/139/139 110/140/140\nf 110/140/140 107/139/139 108/141/141\nf 110/140/140 108/141/141 109/142/142\nf 108/143/143 113/144/144 109/145/145\nf 109/145/145 113/144/144 120/146/146\nf 120/146/146 113/144/144 114/147/147\nf 120/146/146 114/147/147 119/148/148\nf 119/148/148 114/147/147 115/149/149\nf 119/148/148 115/149/149 118/150/150\nf 118/150/150 115/149/149 116/151/151\nf 118/150/150 116/151/151 117/152/152\nf 116/153/153 121/154/154 117/155/155\nf 117/155/155 121/154/154 122/156/156\nf 121/157/157 123/158/158 122/159/159\nf 122/159/159 123/158/158 124/160/160\nf 123/161/161 125/162/162 124/163/163\nf 124/163/163 125/162/162 126/164/164\nf 125/165/165 127/166/166 126/167/167\nf 126/167/167 127/166/166 128/168/168\nf 127/169/169 129/170/170 128/171/171\nf 128/171/171 129/170/170 130/172/172\nf 129/173/173 131/174/174 130/175/175\nf 130/175/175 131/174/174 132/176/176\nf 131/177/177 133/178/178 132/179/179\nf 132/179/179 133/178/178 134/180/180\nf 133/181/181 71/182/182 134/183/183\nf 134/183/183 71/182/182 80/184/184\nf 134/185/185 80/186/186 132/187/187\nf 132/187/187 80/186/186 130/188/188\nf 130/188/188 80/186/186 25/189/189\nf 130/188/188 25/189/189 24/190/190\nf 80/186/186 79/191/191 25/189/189\nf 25/189/189 79/191/191 26/192/192\nf 26/192/192 79/191/191 15/193/193\nf 15/193/193 79/191/191 16/194/194\nf 16/194/194 79/191/191 17/195/195\nf 17/195/195 79/191/191 18/196/196\nf 18/196/196 79/191/191 6/197/197\nf 6/197/197 79/191/191 7/198/198\nf 7/198/198 79/191/191 8/199/199\nf 8/199/199 79/191/191 9/200/200\nf 9/200/200 79/191/191 78/201/201\nf 9/200/200 78/201/201 10/202/202\nf 10/202/202 78/201/201 77/203/203\nf 10/202/202 77/203/203 68/204/204\nf 68/204/204 77/203/203 76/205/205\nf 68/204/204 76/205/205 69/206/206\nf 69/206/206 76/205/205 88/207/207\nf 69/206/206 88/207/207 70/208/208\nf 70/208/208 88/207/207 87/209/209\nf 70/208/208 87/209/209 86/210/210\nf 70/208/208 86/210/210 61/211/211\nf 61/211/211 86/210/210 85/212/212\nf 61/211/211 85/212/212 62/213/213\nf 62/213/213 85/212/212 96/214/214\nf 62/213/213 96/214/214 63/215/215\nf 63/215/215 96/214/214 95/216/216\nf 63/215/215 95/216/216 94/217/217\nf 63/215/215 94/217/217 64/218/218\nf 64/218/218 94/217/217 93/219/219\nf 64/218/218 93/219/219 104/220/220\nf 104/220/220 103/221/221 64/218/218\nf 64/218/218 103/221/221 53/222/222\nf 53/222/222 103/221/221 102/223/223\nf 53/222/222 102/223/223 101/224/224\nf 101/224/224 112/225/225 53/222/222\nf 53/222/222 112/225/225 54/226/226\nf 54/226/226 112/225/225 111/227/227\nf 54/226/226 111/227/227 55/228/228\nf 55/228/228 111/227/227 110/229/229\nf 55/228/228 110/229/229 109/230/230\nf 55/228/228 109/230/230 56/231/231\nf 56/231/231 109/230/230 120/232/232\nf 56/231/231 120/232/232 45/233/233\nf 45/233/233 120/232/232 119/234/234\nf 45/233/233 119/234/234 46/235/235\nf 46/235/235 119/234/234 47/236/236\nf 47/236/236 119/234/234 118/237/237\nf 47/236/236 118/237/237 48/238/238\nf 48/238/238 118/237/237 117/239/239\nf 48/238/238 117/239/239 37/240/240\nf 37/240/240 117/239/239 38/241/241\nf 38/241/241 117/239/239 39/242/242\nf 39/242/242 117/239/239 40/243/243\nf 40/243/243 117/239/239 32/244/244\nf 32/244/244 117/239/239 30/245/245\nf 30/245/245 117/239/239 122/246/246\nf 30/245/245 122/246/246 28/247/247\nf 28/247/247 122/246/246 124/248/248\nf 28/247/247 124/248/248 128/249/249\nf 128/249/249 124/248/248 126/250/250\nf 28/247/247 128/249/249 23/251/251\nf 23/251/251 128/249/249 130/188/188\nf 23/251/251 130/188/188 24/190/190\nf 135/252/252 136/253/253 138/254/254\nf 138/254/254 136/253/253 137/255/255\nf 136/256/256 139/257/257 137/258/258\nf 137/258/258 139/257/257 140/259/259\nf 139/260/260 141/261/261 140/262/262\nf 140/262/262 141/261/261 142/263/263\nf 141/264/264 143/265/265 142/266/266\nf 142/266/266 143/265/265 144/267/267\nf 143/268/268 145/269/269 144/270/270\nf 144/270/270 145/269/269 152/271/271\nf 152/271/271 145/269/269 146/272/272\nf 152/271/271 146/272/272 151/273/273\nf 151/273/273 146/272/272 147/274/274\nf 151/273/273 147/274/274 150/275/275\nf 150/275/275 147/274/274 148/276/276\nf 150/275/275 148/276/276 149/277/277\nf 148/278/278 153/279/279 149/280/280\nf 149/280/280 153/279/279 160/281/281\nf 160/281/281 153/279/279 154/282/282\nf 160/281/281 154/282/282 159/283/283\nf 159/283/283 154/282/282 155/284/284\nf 159/283/283 155/284/284 158/285/285\nf 158/285/285 155/284/284 156/286/286\nf 158/285/285 156/286/286 157/287/287\nf 156/288/288 161/289/289 157/290/290\nf 157/290/290 161/289/289 168/291/291\nf 168/291/291 161/289/289 162/292/292\nf 168/291/291 162/292/292 167/293/293\nf 167/293/293 162/292/292 163/294/294\nf 167/293/293 163/294/294 166/295/295\nf 166/295/295 163/294/294 164/296/296\nf 166/295/295 164/296/296 165/297/297\nf 164/298/298 169/299/299 165/300/300\nf 165/300/300 169/299/299 176/301/301\nf 176/301/301 169/299/299 170/302/302\nf 176/301/301 170/302/302 175/303/303\nf 175/303/303 170/302/302 171/304/304\nf 175/303/303 171/304/304 174/305/305\nf 174/305/305 171/304/304 172/306/306\nf 174/305/305 172/306/306 173/307/307\nf 172/308/308 177/309/309 173/310/310\nf 173/310/310 177/309/309 184/311/311\nf 184/311/311 177/309/309 178/312/312\nf 184/311/311 178/312/312 183/313/313\nf 183/313/313 178/312/312 179/314/314\nf 183/313/313 179/314/314 182/315/315\nf 182/315/315 179/314/314 180/316/316\nf 182/315/315 180/316/316 181/317/317\nf 180/318/318 185/319/319 181/320/320\nf 181/320/320 185/319/319 192/321/321\nf 192/321/321 185/319/319 186/322/322\nf 192/321/321 186/322/322 191/323/323\nf 191/323/323 186/322/322 187/324/324\nf 191/323/323 187/324/324 190/325/325\nf 190/325/325 187/324/324 188/326/326\nf 190/325/325 188/326/326 189/327/327\nf 188/328/328 193/329/329 189/330/330\nf 189/330/330 193/329/329 194/331/331\nf 193/332/332 195/333/333 194/334/334\nf 194/334/334 195/333/333 196/335/335\nf 195/336/336 197/337/337 196/338/338\nf 196/338/338 197/337/337 204/339/339\nf 204/339/339 197/337/337 198/340/340\nf 204/339/339 198/340/340 203/341/341\nf 203/341/341 198/340/340 199/342/342\nf 203/341/341 199/342/342 202/343/343\nf 202/343/343 199/342/342 200/344/344\nf 202/343/343 200/344/344 201/345/345\nf 200/346/346 205/347/347 201/348/348\nf 201/348/348 205/347/347 212/349/349\nf 212/349/349 205/347/347 206/350/350\nf 212/349/349 206/350/350 211/351/351\nf 211/351/351 206/350/350 207/352/352\nf 211/351/351 207/352/352 210/353/353\nf 210/353/353 207/352/352 208/354/354\nf 210/353/353 208/354/354 209/355/355\nf 208/356/356 213/357/357 209/358/358\nf 209/358/358 213/357/357 220/359/359\nf 220/359/359 213/357/357 214/360/360\nf 220/359/359 214/360/360 219/361/361\nf 219/361/361 214/360/360 215/362/362\nf 219/361/361 215/362/362 218/363/363\nf 218/363/363 215/362/362 216/364/364\nf 218/363/363 216/364/364 217/365/365\nf 216/366/366 221/367/367 217/368/368\nf 217/368/368 221/367/367 228/369/369\nf 228/369/369 221/367/367 222/370/370\nf 228/369/369 222/370/370 227/371/371\nf 227/371/371 222/370/370 223/372/372\nf 227/371/371 223/372/372 226/373/373\nf 226/373/373 223/372/372 224/374/374\nf 226/373/373 224/374/374 225/375/375\nf 224/376/376 229/377/377 225/378/378\nf 225/378/378 229/377/377 236/379/379\nf 236/379/379 229/377/377 230/380/380\nf 236/379/379 230/380/380 235/381/381\nf 235/381/381 230/380/380 231/382/382\nf 235/381/381 231/382/382 234/383/383\nf 234/383/383 231/382/382 232/384/384\nf 234/383/383 232/384/384 233/385/385\nf 232/386/386 237/387/387 233/388/388\nf 233/388/388 237/387/387 244/389/389\nf 244/389/389 237/387/387 238/390/390\nf 244/389/389 238/390/390 243/391/391\nf 243/391/391 238/390/390 239/392/392\nf 243/391/391 239/392/392 242/393/393\nf 242/393/393 239/392/392 240/394/394\nf 242/393/393 240/394/394 241/395/395\nf 240/396/396 135/397/397 241/398/398\nf 241/398/398 135/397/397 138/399/399\nf 138/400/400 142/401/401 241/402/402\nf 241/402/402 142/401/401 144/403/403\nf 241/402/402 144/403/403 152/404/404\nf 138/400/400 137/405/405 142/401/401\nf 142/401/401 137/405/405 140/406/406\nf 152/404/404 151/407/407 241/402/402\nf 241/402/402 151/407/407 150/408/408\nf 241/402/402 150/408/408 149/409/409\nf 160/410/410 235/411/411 149/409/409\nf 149/409/409 235/411/411 234/412/412\nf 149/409/409 234/412/412 233/413/413\nf 159/414/414 225/415/415 160/410/410\nf 160/410/410 225/415/415 236/416/416\nf 160/410/410 236/416/416 235/411/411\nf 158/417/417 227/418/418 159/414/414\nf 159/414/414 227/418/418 226/419/419\nf 159/414/414 226/419/419 225/415/415\nf 227/418/418 158/417/417 228/420/420\nf 228/420/420 158/417/417 157/421/421\nf 228/420/420 157/421/421 217/422/422\nf 217/422/422 157/421/421 168/423/423\nf 217/422/422 168/423/423 218/424/424\nf 218/424/424 168/423/423 167/425/425\nf 218/424/424 167/425/425 166/426/426\nf 218/424/424 166/426/426 219/427/427\nf 219/427/427 166/426/426 165/428/428\nf 219/427/427 165/428/428 220/429/429\nf 220/429/429 165/428/428 176/430/430\nf 220/429/429 176/430/430 175/431/431\nf 220/429/429 175/431/431 209/432/432\nf 209/432/432 175/431/431 174/433/433\nf 209/432/432 174/433/433 210/434/434\nf 210/434/434 174/433/433 173/435/435\nf 210/434/434 173/435/435 211/436/436\nf 211/436/436 173/435/435 184/437/437\nf 211/436/436 184/437/437 212/438/438\nf 212/438/438 184/437/437 183/439/439\nf 212/438/438 183/439/439 201/440/440\nf 201/440/440 183/439/439 182/441/441\nf 201/440/440 182/441/441 202/442/442\nf 202/442/442 182/441/441 181/443/443\nf 202/442/442 181/443/443 192/444/444\nf 202/442/442 192/444/444 203/445/445\nf 203/445/445 192/444/444 191/446/446\nf 203/445/445 191/446/446 204/447/447\nf 204/447/447 191/446/446 190/448/448\nf 204/447/447 190/448/448 196/449/449\nf 196/449/449 190/448/448 189/450/450\nf 196/449/449 189/450/450 194/451/451\nf 233/413/413 244/452/452 149/409/409\nf 149/409/409 244/452/452 243/453/453\nf 149/409/409 243/453/453 242/454/454\nf 242/454/454 241/402/402 149/409/409\nf 246/455/455 123/456/456 245/457/457\nf 245/457/457 123/456/456 214/458/458\nf 245/457/457 214/458/458 213/459/459\nf 247/460/460 133/461/461 246/455/455\nf 246/455/455 133/461/461 131/462/462\nf 246/455/455 131/462/462 125/463/463\nf 125/463/463 131/462/462 129/464/464\nf 125/463/463 129/464/464 127/465/465\nf 248/466/466 121/467/467 247/460/460\nf 247/460/460 121/467/467 116/468/468\nf 247/460/460 116/468/468 115/469/469\nf 245/457/457 193/470/470 248/466/466\nf 248/466/466 193/470/470 139/471/471\nf 248/466/466 139/471/471 136/472/472\nf 136/472/472 135/473/473 248/466/466\nf 248/466/466 135/473/473 121/467/467\nf 135/473/473 240/474/474 121/467/467\nf 121/467/467 240/474/474 123/456/456\nf 123/456/456 240/474/474 239/475/475\nf 123/456/456 239/475/475 238/476/476\nf 238/476/476 237/477/477 123/456/456\nf 123/456/456 237/477/477 232/478/478\nf 123/456/456 232/478/478 231/479/479\nf 231/479/479 230/480/480 123/456/456\nf 123/456/456 230/480/480 229/481/481\nf 123/456/456 229/481/481 224/482/482\nf 224/482/482 223/483/483 123/456/456\nf 123/456/456 223/483/483 222/484/484\nf 123/456/456 222/484/484 221/485/485\nf 221/485/485 216/486/486 123/456/456\nf 123/456/456 216/486/486 215/487/487\nf 123/456/456 215/487/487 214/458/458\nf 213/459/459 208/488/488 245/457/457\nf 245/457/457 208/488/488 207/489/489\nf 245/457/457 207/489/489 206/490/490\nf 206/490/490 205/491/491 245/457/457\nf 245/457/457 205/491/491 200/492/492\nf 245/457/457 200/492/492 199/493/493\nf 199/493/493 198/494/494 245/457/457\nf 245/457/457 198/494/494 197/495/495\nf 245/457/457 197/495/495 195/496/496\nf 195/496/496 193/470/470 245/457/457\nf 139/471/471 193/470/470 143/497/497\nf 143/497/497 193/470/470 188/498/498\nf 143/497/497 188/498/498 145/499/499\nf 145/499/499 188/498/498 146/500/500\nf 146/500/500 188/498/498 147/501/501\nf 147/501/501 188/498/498 148/502/502\nf 148/502/502 188/498/498 153/503/503\nf 153/503/503 188/498/498 187/504/504\nf 153/503/503 187/504/504 154/505/505\nf 154/505/505 187/504/504 186/506/506\nf 154/505/505 186/506/506 155/507/507\nf 155/507/507 186/506/506 185/508/508\nf 155/507/507 185/508/508 180/509/509\nf 180/509/509 179/510/510 155/507/507\nf 155/507/507 179/510/510 178/511/511\nf 155/507/507 178/511/511 177/512/512\nf 155/507/507 177/512/512 156/513/513\nf 156/513/513 177/512/512 172/514/514\nf 156/513/513 172/514/514 161/515/515\nf 161/515/515 172/514/514 171/516/516\nf 161/515/515 171/516/516 162/517/517\nf 162/517/517 171/516/516 170/518/518\nf 162/517/517 170/518/518 169/519/519\nf 164/520/520 163/521/521 169/519/519\nf 169/519/519 163/521/521 162/517/517\nf 143/497/497 141/522/522 139/471/471\nf 81/523/523 75/524/524 133/461/461\nf 133/461/461 75/524/524 74/525/525\nf 133/461/461 74/525/525 73/526/526\nf 73/526/526 72/527/527 133/461/461\nf 133/461/461 72/527/527 71/528/528\nf 125/463/463 123/456/456 246/455/455\nf 115/469/469 114/529/529 247/460/460\nf 247/460/460 114/529/529 113/530/530\nf 247/460/460 113/530/530 108/531/531\nf 108/531/531 107/532/532 247/460/460\nf 247/460/460 107/532/532 106/533/533\nf 247/460/460 106/533/533 105/534/534\nf 105/534/534 100/535/535 247/460/460\nf 247/460/460 100/535/535 99/536/536\nf 247/460/460 99/536/536 98/537/537\nf 98/537/537 97/538/538 247/460/460\nf 247/460/460 97/538/538 92/539/539\nf 247/460/460 92/539/539 91/540/540\nf 91/540/540 90/541/541 247/460/460\nf 247/460/460 90/541/541 89/542/542\nf 247/460/460 89/542/542 84/543/543\nf 84/543/543 83/544/544 247/460/460\nf 247/460/460 83/544/544 82/545/545\nf 247/460/460 82/545/545 133/461/461\nf 133/461/461 82/545/545 81/523/523\nf 285/546/546 249/547/547 323/548/548\nf 323/549/548 249/550/547 250/551/549\nf 323/549/548 250/551/549 325/552/550\nf 325/552/550 250/551/549 251/553/551\nf 325/552/550 251/553/551 327/554/552\nf 327/554/552 251/553/551 252/555/553\nf 327/554/552 252/555/553 329/556/554\nf 329/556/554 252/555/553 253/557/555\nf 329/556/554 253/557/555 331/558/556\nf 331/558/556 253/557/555 254/559/557\nf 331/558/556 254/559/557 333/560/558\nf 333/560/558 254/559/557 255/561/559\nf 333/560/558 255/561/559 335/562/560\nf 335/562/560 255/561/559 256/563/561\nf 335/562/560 256/563/561 337/564/562\nf 337/564/562 256/563/561 257/565/563\nf 337/564/562 257/565/563 339/566/564\nf 339/566/564 257/565/563 258/567/565\nf 339/566/564 258/567/565 341/568/566\nf 341/568/566 258/567/565 259/569/567\nf 341/568/566 259/569/567 343/570/568\nf 343/570/568 259/569/567 260/571/569\nf 343/570/568 260/571/569 345/572/570\nf 345/572/570 260/571/569 261/573/571\nf 345/572/570 261/573/571 347/574/572\nf 347/574/572 261/573/571 262/575/573\nf 347/574/572 262/575/573 349/576/574\nf 349/576/574 262/575/573 263/577/575\nf 349/576/574 263/577/575 351/578/576\nf 351/578/576 263/577/575 264/579/577\nf 351/578/576 264/579/577 353/580/578\nf 353/580/578 264/579/577 265/581/579\nf 353/580/578 265/581/579 355/582/580\nf 355/582/580 265/581/579 266/583/581\nf 355/582/580 266/583/581 357/584/582\nf 357/584/582 266/583/581 267/585/583\nf 357/584/582 267/585/583 359/586/584\nf 359/586/584 267/585/583 268/587/585\nf 359/586/584 268/587/585 361/588/586\nf 361/588/586 268/587/585 269/589/587\nf 361/588/586 269/589/587 363/590/588\nf 363/590/588 269/589/587 270/591/589\nf 363/590/588 270/591/589 365/592/590\nf 365/592/590 270/591/589 271/593/591\nf 365/592/590 271/593/591 367/594/592\nf 367/594/592 271/593/591 272/595/593\nf 367/594/592 272/595/593 369/596/594\nf 369/596/594 272/595/593 273/597/595\nf 369/596/594 273/597/595 371/598/596\nf 371/598/596 273/597/595 274/599/597\nf 371/598/596 274/599/597 373/600/598\nf 373/600/598 274/599/597 275/601/599\nf 373/600/598 275/601/599 375/602/600\nf 375/602/600 275/601/599 276/603/601\nf 375/602/600 276/603/601 377/604/602\nf 377/604/602 276/603/601 277/605/603\nf 377/604/602 277/605/603 379/606/604\nf 379/606/604 277/605/603 278/607/605\nf 379/606/604 278/607/605 381/608/606\nf 381/608/606 278/607/605 279/609/607\nf 381/608/606 279/609/607 383/610/608\nf 383/610/608 279/609/607 280/611/609\nf 383/610/608 280/611/609 385/612/610\nf 385/612/610 280/611/609 281/613/611\nf 385/612/610 281/613/611 387/614/612\nf 387/614/612 281/613/611 282/615/613\nf 387/614/612 282/615/613 389/616/614\nf 389/616/614 282/615/613 283/617/615\nf 389/616/614 283/617/615 391/618/616\nf 391/618/616 283/617/615 284/619/617\nf 391/618/616 284/619/617 393/620/618\nf 393/620/618 284/619/617 285/546/546\nf 393/620/618 285/546/546 323/548/548\nf 322/621/619 286/622/620 324/623/621\nf 324/624/621 286/625/620 287/626/622\nf 324/624/621 287/626/622 394/627/623\nf 394/627/623 287/626/622 288/628/624\nf 394/627/623 288/628/624 392/629/625\nf 392/629/625 288/628/624 289/630/626\nf 392/629/625 289/630/626 390/631/627\nf 390/631/627 289/630/626 290/632/628\nf 390/631/627 290/632/628 388/633/629\nf 388/633/629 290/632/628 291/634/630\nf 388/633/629 291/634/630 386/635/631\nf 386/635/631 291/634/630 292/636/632\nf 386/635/631 292/636/632 384/637/633\nf 384/637/633 292/636/632 293/638/634\nf 384/637/633 293/638/634 382/639/635\nf 382/639/635 293/638/634 294/640/636\nf 382/639/635 294/640/636 380/641/637\nf 380/641/637 294/640/636 295/642/638\nf 380/641/637 295/642/638 378/643/639\nf 378/643/639 295/642/638 296/644/640\nf 378/643/639 296/644/640 376/645/641\nf 376/645/641 296/644/640 297/646/642\nf 376/645/641 297/646/642 374/647/643\nf 374/647/643 297/646/642 298/648/644\nf 374/647/643 298/648/644 372/649/645\nf 372/649/645 298/648/644 299/650/646\nf 372/649/645 299/650/646 370/651/647\nf 370/651/647 299/650/646 300/652/648\nf 370/651/647 300/652/648 368/653/649\nf 368/653/649 300/652/648 301/654/650\nf 368/653/649 301/654/650 366/655/651\nf 366/655/651 301/654/650 302/656/652\nf 366/655/651 302/656/652 364/657/653\nf 364/657/653 302/656/652 303/658/654\nf 364/657/653 303/658/654 362/659/655\nf 362/659/655 303/658/654 304/660/656\nf 362/659/655 304/660/656 360/661/657\nf 360/661/657 304/660/656 305/662/658\nf 360/661/657 305/662/658 358/663/659\nf 358/663/659 305/662/658 306/664/660\nf 358/663/659 306/664/660 356/665/661\nf 356/665/661 306/664/660 307/666/662\nf 356/665/661 307/666/662 354/667/663\nf 354/667/663 307/666/662 308/668/664\nf 354/667/663 308/668/664 352/669/665\nf 352/669/665 308/668/664 309/670/666\nf 352/669/665 309/670/666 350/671/667\nf 350/671/667 309/670/666 310/672/668\nf 350/671/667 310/672/668 348/673/669\nf 348/673/669 310/672/668 311/674/670\nf 348/673/669 311/674/670 346/675/671\nf 346/675/671 311/674/670 312/676/672\nf 346/675/671 312/676/672 344/677/673\nf 344/677/673 312/676/672 313/678/674\nf 344/677/673 313/678/674 342/679/675\nf 342/679/675 313/678/674 314/680/676\nf 342/679/675 314/680/676 340/681/677\nf 340/681/677 314/680/676 315/682/678\nf 340/681/677 315/682/678 338/683/679\nf 338/683/679 315/682/678 316/684/680\nf 338/683/679 316/684/680 336/685/681\nf 336/685/681 316/684/680 317/686/682\nf 336/685/681 317/686/682 334/687/683\nf 334/687/683 317/686/682 318/688/684\nf 334/687/683 318/688/684 332/689/685\nf 332/689/685 318/688/684 319/690/686\nf 332/689/685 319/690/686 330/691/687\nf 330/691/687 319/690/686 320/692/688\nf 330/691/687 320/692/688 328/693/689\nf 328/693/689 320/692/688 321/694/690\nf 328/693/689 321/694/690 326/695/691\nf 326/695/691 321/694/690 322/621/619\nf 326/695/691 322/621/619 324/623/621\nf 323/548/548 324/624/621 393/620/618\nf 393/620/618 324/624/621 394/627/623\nf 393/620/618 394/627/623 391/618/616\nf 391/618/616 394/627/623 392/629/625\nf 391/618/616 392/629/625 389/616/614\nf 389/616/614 392/629/625 390/631/627\nf 389/616/614 390/631/627 387/614/612\nf 387/614/612 390/631/627 388/633/629\nf 387/614/612 388/633/629 385/612/610\nf 385/612/610 388/633/629 386/635/631\nf 385/612/610 386/635/631 383/610/608\nf 383/610/608 386/635/631 384/637/633\nf 383/610/608 384/637/633 381/608/606\nf 381/608/606 384/637/633 382/639/635\nf 381/608/606 382/639/635 379/606/604\nf 379/606/604 382/639/635 380/641/637\nf 379/606/604 380/641/637 377/604/602\nf 377/604/602 380/641/637 378/643/639\nf 377/604/602 378/643/639 375/602/600\nf 375/602/600 378/643/639 376/645/641\nf 375/602/600 376/645/641 373/600/598\nf 373/600/598 376/645/641 374/647/643\nf 373/600/598 374/647/643 371/598/596\nf 371/598/596 374/647/643 372/649/645\nf 371/598/596 372/649/645 369/596/594\nf 369/596/594 372/649/645 370/651/647\nf 369/596/594 370/651/647 367/594/592\nf 367/594/592 370/651/647 368/653/649\nf 367/594/592 368/653/649 365/592/590\nf 365/592/590 368/653/649 366/655/651\nf 365/592/590 366/655/651 363/590/588\nf 363/590/588 366/655/651 364/657/653\nf 363/590/588 364/657/653 361/588/586\nf 361/588/586 364/657/653 362/659/655\nf 361/588/586 362/659/655 359/586/584\nf 359/586/584 362/659/655 360/661/657\nf 359/586/584 360/661/657 357/584/582\nf 357/584/582 360/661/657 358/663/659\nf 357/584/582 358/663/659 355/582/580\nf 355/582/580 358/663/659 356/665/661\nf 355/582/580 356/665/661 353/580/578\nf 353/580/578 356/665/661 354/667/663\nf 353/580/578 354/667/663 351/578/576\nf 351/578/576 354/667/663 352/669/665\nf 351/578/576 352/669/665 349/576/574\nf 349/576/574 352/669/665 350/671/667\nf 349/576/574 350/671/667 347/574/572\nf 347/574/572 350/671/667 348/673/669\nf 347/574/572 348/673/669 345/572/570\nf 345/572/570 348/673/669 346/675/671\nf 345/572/570 346/675/671 343/570/568\nf 343/570/568 346/675/671 344/677/673\nf 343/570/568 344/677/673 341/568/566\nf 341/568/566 344/677/673 342/679/675\nf 341/568/566 342/679/675 339/566/564\nf 339/566/564 342/679/675 340/681/677\nf 339/566/564 340/681/677 337/564/562\nf 337/564/562 340/681/677 338/683/679\nf 337/564/562 338/683/679 335/562/560\nf 335/562/560 338/683/679 336/685/681\nf 335/562/560 336/685/681 333/560/558\nf 333/560/558 336/685/681 334/687/683\nf 333/560/558 334/687/683 331/558/556\nf 331/558/556 334/687/683 332/689/685\nf 331/558/556 332/689/685 329/556/554\nf 329/556/554 332/689/685 330/691/687\nf 329/556/554 330/691/687 327/554/552\nf 327/554/552 330/691/687 328/693/689\nf 327/554/552 328/693/689 325/552/550\nf 325/552/550 328/693/689 326/695/691\nf 325/552/550 326/695/691 323/549/548\nf 323/549/548 326/695/691 324/623/621\nf 396/696/692 512/697/693 395/698/694\nf 395/698/694 512/697/693 511/699/695\nf 395/700/694 511/701/695 452/702/696\nf 452/702/696 511/701/695 568/703/697\nf 452/702/696 568/703/697 451/704/698\nf 451/704/698 568/703/697 567/705/699\nf 451/704/698 567/705/699 450/706/700\nf 450/706/700 567/705/699 566/707/701\nf 450/706/700 566/707/701 449/708/702\nf 449/708/702 566/707/701 565/709/703\nf 449/708/702 565/709/703 448/710/704\nf 448/710/704 565/709/703 564/711/705\nf 448/710/704 564/711/705 447/712/706\nf 447/712/706 564/711/705 563/713/707\nf 447/712/706 563/713/707 446/714/708\nf 446/714/708 563/713/707 562/715/709\nf 446/714/708 562/715/709 445/716/710\nf 445/716/710 562/715/709 561/717/711\nf 445/716/710 561/717/711 444/718/712\nf 444/718/712 561/717/711 560/719/713\nf 444/718/712 560/719/713 443/720/714\nf 443/720/714 560/719/713 559/721/715\nf 443/720/714 559/721/715 442/722/716\nf 442/722/716 559/721/715 558/723/717\nf 442/722/716 558/723/717 441/724/718\nf 441/724/718 558/723/717 557/725/719\nf 441/724/718 557/725/719 440/726/720\nf 440/726/720 557/725/719 556/727/721\nf 440/726/720 556/727/721 439/728/722\nf 439/728/722 556/727/721 555/729/723\nf 439/728/722 555/729/723 438/730/724\nf 438/730/724 555/729/723 554/731/725\nf 438/730/724 554/731/725 437/732/726\nf 437/732/726 554/731/725 553/733/727\nf 437/732/726 553/733/727 436/734/728\nf 436/734/728 553/733/727 552/735/729\nf 436/734/728 552/735/729 435/736/730\nf 435/736/730 552/735/729 551/737/731\nf 435/736/730 551/737/731 434/738/732\nf 434/738/732 551/737/731 550/739/733\nf 434/738/732 550/739/733 433/740/734\nf 433/740/734 550/739/733 549/741/735\nf 433/740/734 549/741/735 432/742/736\nf 432/742/736 549/741/735 548/743/737\nf 432/742/736 548/743/737 431/744/738\nf 431/744/738 548/743/737 547/745/739\nf 431/744/738 547/745/739 430/746/740\nf 430/746/740 547/745/739 546/747/741\nf 430/746/740 546/747/741 429/748/742\nf 429/748/742 546/747/741 545/749/743\nf 429/748/742 545/749/743 428/750/744\nf 428/750/744 545/749/743 544/751/745\nf 428/750/744 544/751/745 427/752/746\nf 427/752/746 544/751/745 543/753/747\nf 427/752/746 543/753/747 426/754/748\nf 426/754/748 543/753/747 542/755/749\nf 426/754/748 542/755/749 425/756/750\nf 425/756/750 542/755/749 541/757/751\nf 425/756/750 541/757/751 424/758/752\nf 424/758/752 541/757/751 540/759/753\nf 424/758/752 540/759/753 423/760/754\nf 423/760/754 540/759/753 539/761/755\nf 423/760/754 539/761/755 422/762/756\nf 422/762/756 539/761/755 538/763/757\nf 422/762/756 538/763/757 421/764/758\nf 421/764/758 538/763/757 537/765/759\nf 421/764/758 537/765/759 420/766/760\nf 420/766/760 537/765/759 536/767/761\nf 420/766/760 536/767/761 419/768/762\nf 419/768/762 536/767/761 535/769/763\nf 419/768/762 535/769/763 418/770/764\nf 418/770/764 535/769/763 534/771/765\nf 418/770/764 534/771/765 417/772/766\nf 417/772/766 534/771/765 533/773/767\nf 417/772/766 533/773/767 416/774/768\nf 416/774/768 533/773/767 532/775/769\nf 416/774/768 532/775/769 415/776/770\nf 415/776/770 532/775/769 531/777/771\nf 415/776/770 531/777/771 414/778/772\nf 414/778/772 531/777/771 530/779/773\nf 414/778/772 530/779/773 413/780/774\nf 413/780/774 530/779/773 529/781/775\nf 413/780/774 529/781/775 412/782/776\nf 412/782/776 529/781/775 528/783/777\nf 412/782/776 528/783/777 411/784/778\nf 411/784/778 528/783/777 527/785/779\nf 411/784/778 527/785/779 410/786/780\nf 410/786/780 527/785/779 526/787/781\nf 410/786/780 526/787/781 409/788/782\nf 409/788/782 526/787/781 525/789/783\nf 409/788/782 525/789/783 408/790/784\nf 408/790/784 525/789/783 524/791/785\nf 408/790/784 524/791/785 407/792/786\nf 407/792/786 524/791/785 523/793/787\nf 407/792/786 523/793/787 406/794/788\nf 406/794/788 523/793/787 522/795/789\nf 406/794/788 522/795/789 405/796/790\nf 405/796/790 522/795/789 521/797/791\nf 405/796/790 521/797/791 404/798/792\nf 404/798/792 521/797/791 520/799/793\nf 404/798/792 520/799/793 403/800/794\nf 403/800/794 520/799/793 519/801/795\nf 403/800/794 519/801/795 402/802/796\nf 402/802/796 519/801/795 518/803/797\nf 402/802/796 518/803/797 401/804/798\nf 401/804/798 518/803/797 517/805/799\nf 401/804/798 517/805/799 400/806/800\nf 400/806/800 517/805/799 516/807/801\nf 400/806/800 516/807/801 399/808/802\nf 399/808/802 516/807/801 515/809/803\nf 399/808/802 515/809/803 398/810/804\nf 398/810/804 515/809/803 514/811/805\nf 398/810/804 514/811/805 397/812/806\nf 397/812/806 514/811/805 513/813/807\nf 397/812/806 513/813/807 396/696/692\nf 396/696/692 513/813/807 512/697/693\nf 454/814/808 568/703/697 453/815/809\nf 453/815/809 568/703/697 511/701/695\nf 453/816/809 511/699/695 510/817/810\nf 510/817/810 511/699/695 512/697/693\nf 510/817/810 512/697/693 509/818/811\nf 509/818/811 512/697/693 513/813/807\nf 509/818/811 513/813/807 508/819/812\nf 508/819/812 513/813/807 514/811/805\nf 508/819/812 514/811/805 507/820/813\nf 507/820/813 514/811/805 515/809/803\nf 507/820/813 515/809/803 506/821/814\nf 506/821/814 515/809/803 516/807/801\nf 506/821/814 516/807/801 505/822/815\nf 505/822/815 516/807/801 517/805/799\nf 505/822/815 517/805/799 504/823/816\nf 504/823/816 517/805/799 518/803/797\nf 504/823/816 518/803/797 503/824/817\nf 503/824/817 518/803/797 519/801/795\nf 503/824/817 519/801/795 502/825/818\nf 502/825/818 519/801/795 520/799/793\nf 502/825/818 520/799/793 501/826/819\nf 501/826/819 520/799/793 521/797/791\nf 501/826/819 521/797/791 500/827/820\nf 500/827/820 521/797/791 522/795/789\nf 500/827/820 522/795/789 499/828/821\nf 499/828/821 522/795/789 523/793/787\nf 499/828/821 523/793/787 498/829/822\nf 498/829/822 523/793/787 524/791/785\nf 498/829/822 524/791/785 497/830/823\nf 497/830/823 524/791/785 525/789/783\nf 497/830/823 525/789/783 496/831/824\nf 496/831/824 525/789/783 526/787/781\nf 496/831/824 526/787/781 495/832/825\nf 495/832/825 526/787/781 527/785/779\nf 495/832/825 527/785/779 494/833/826\nf 494/833/826 527/785/779 528/783/777\nf 494/833/826 528/783/777 493/834/827\nf 493/834/827 528/783/777 529/781/775\nf 493/834/827 529/781/775 492/835/828\nf 492/835/828 529/781/775 530/779/773\nf 492/835/828 530/779/773 491/836/829\nf 491/836/829 530/779/773 531/777/771\nf 491/836/829 531/777/771 490/837/830\nf 490/837/830 531/777/771 532/775/769\nf 490/837/830 532/775/769 489/838/831\nf 489/838/831 532/775/769 533/773/767\nf 489/838/831 533/773/767 488/839/832\nf 488/839/832 533/773/767 534/771/765\nf 488/839/832 534/771/765 487/840/833\nf 487/840/833 534/771/765 535/769/763\nf 487/840/833 535/769/763 486/841/834\nf 486/841/834 535/769/763 536/767/761\nf 486/841/834 536/767/761 485/842/835\nf 485/842/835 536/767/761 537/765/759\nf 485/842/835 537/765/759 484/843/836\nf 484/843/836 537/765/759 538/763/757\nf 484/843/836 538/763/757 483/844/837\nf 483/844/837 538/763/757 539/761/755\nf 483/844/837 539/761/755 482/845/838\nf 482/845/838 539/761/755 540/759/753\nf 482/845/838 540/759/753 481/846/839\nf 481/846/839 540/759/753 541/757/751\nf 481/846/839 541/757/751 480/847/840\nf 480/847/840 541/757/751 542/755/749\nf 480/847/840 542/755/749 479/848/841\nf 479/848/841 542/755/749 543/753/747\nf 479/848/841 543/753/747 478/849/842\nf 478/849/842 543/753/747 544/751/745\nf 478/849/842 544/751/745 477/850/843\nf 477/850/843 544/751/745 545/749/743\nf 477/850/843 545/749/743 476/851/844\nf 476/851/844 545/749/743 546/747/741\nf 476/851/844 546/747/741 475/852/845\nf 475/852/845 546/747/741 547/745/739\nf 475/852/845 547/745/739 474/853/846\nf 474/853/846 547/745/739 548/743/737\nf 474/853/846 548/743/737 473/854/847\nf 473/854/847 548/743/737 549/741/735\nf 473/854/847 549/741/735 472/855/848\nf 472/855/848 549/741/735 550/739/733\nf 472/855/848 550/739/733 471/856/849\nf 471/856/849 550/739/733 551/737/731\nf 471/856/849 551/737/731 470/857/850\nf 470/857/850 551/737/731 552/735/729\nf 470/857/850 552/735/729 469/858/851\nf 469/858/851 552/735/729 553/733/727\nf 469/858/851 553/733/727 468/859/852\nf 468/859/852 553/733/727 554/731/725\nf 468/859/852 554/731/725 467/860/853\nf 467/860/853 554/731/725 555/729/723\nf 467/860/853 555/729/723 466/861/854\nf 466/861/854 555/729/723 556/727/721\nf 466/861/854 556/727/721 465/862/855\nf 465/862/855 556/727/721 557/725/719\nf 465/862/855 557/725/719 464/863/856\nf 464/863/856 557/725/719 558/723/717\nf 464/863/856 558/723/717 463/864/857\nf 463/864/857 558/723/717 559/721/715\nf 463/864/857 559/721/715 462/865/858\nf 462/865/858 559/721/715 560/719/713\nf 462/865/858 560/719/713 461/866/859\nf 461/866/859 560/719/713 561/717/711\nf 461/866/859 561/717/711 460/867/860\nf 460/867/860 561/717/711 562/715/709\nf 460/867/860 562/715/709 459/868/861\nf 459/868/861 562/715/709 563/713/707\nf 459/868/861 563/713/707 458/869/862\nf 458/869/862 563/713/707 564/711/705\nf 458/869/862 564/711/705 457/870/863\nf 457/870/863 564/711/705 565/709/703\nf 457/870/863 565/709/703 456/871/864\nf 456/871/864 565/709/703 566/707/701\nf 456/871/864 566/707/701 455/872/865\nf 455/872/865 566/707/701 567/705/699\nf 455/872/865 567/705/699 454/814/808\nf 454/814/808 567/705/699 568/703/697\nf 285/873/866 396/874/867 249/875/868\nf 249/875/868 396/874/867 395/876/869\nf 249/875/868 395/876/869 452/877/870\nf 396/874/867 285/873/866 397/878/871\nf 397/878/871 285/873/866 284/879/872\nf 397/878/871 284/879/872 398/880/873\nf 398/880/873 284/879/872 399/881/874\nf 399/881/874 284/879/872 283/882/875\nf 399/881/874 283/882/875 400/883/876\nf 400/883/876 283/882/875 282/884/877\nf 400/883/876 282/884/877 401/885/878\nf 401/885/878 282/884/877 402/886/879\nf 402/886/879 282/884/877 281/887/880\nf 402/886/879 281/887/880 403/888/881\nf 403/888/881 281/887/880 404/889/882\nf 404/889/882 281/887/880 280/890/883\nf 404/889/882 280/890/883 405/891/884\nf 405/891/884 280/890/883 279/892/885\nf 405/891/884 279/892/885 406/893/886\nf 406/893/886 279/892/885 407/894/887\nf 407/894/887 279/892/885 278/895/888\nf 407/894/887 278/895/888 408/896/889\nf 408/896/889 278/895/888 277/897/890\nf 408/896/889 277/897/890 409/898/891\nf 409/898/891 277/897/890 410/899/892\nf 410/899/892 277/897/890 276/900/893\nf 410/899/892 276/900/893 411/901/894\nf 411/901/894 276/900/893 275/902/895\nf 411/901/894 275/902/895 412/903/896\nf 412/903/896 275/902/895 413/904/897\nf 413/904/897 275/902/895 274/905/898\nf 413/904/897 274/905/898 414/906/899\nf 414/906/899 274/905/898 415/907/900\nf 415/907/900 274/905/898 273/908/901\nf 415/907/900 273/908/901 416/909/902\nf 416/909/902 273/908/901 272/910/903\nf 416/909/902 272/910/903 417/911/904\nf 417/911/904 272/910/903 418/912/905\nf 418/912/905 272/910/903 271/913/906\nf 418/912/905 271/913/906 419/914/907\nf 419/914/907 271/913/906 270/915/908\nf 419/914/907 270/915/908 420/916/909\nf 420/916/909 270/915/908 421/917/910\nf 421/917/910 270/915/908 269/918/911\nf 421/917/910 269/918/911 422/919/912\nf 422/919/912 269/918/911 268/920/913\nf 422/919/912 268/920/913 423/921/914\nf 423/921/914 268/920/913 424/922/915\nf 424/922/915 268/920/913 267/923/916\nf 424/922/915 267/923/916 425/924/917\nf 425/924/917 267/923/916 426/925/918\nf 426/925/918 267/923/916 266/926/919\nf 426/925/918 266/926/919 427/927/920\nf 427/927/920 266/926/919 265/928/921\nf 427/927/920 265/928/921 428/929/922\nf 428/929/922 265/928/921 429/930/923\nf 429/930/923 265/928/921 264/931/924\nf 429/930/923 264/931/924 430/932/925\nf 430/932/925 264/931/924 263/933/926\nf 430/932/925 263/933/926 431/934/927\nf 431/934/927 263/933/926 432/935/928\nf 432/935/928 263/933/926 262/936/929\nf 432/935/928 262/936/929 433/937/930\nf 433/937/930 262/936/929 261/938/931\nf 433/937/930 261/938/931 434/939/932\nf 434/939/932 261/938/931 435/940/933\nf 435/940/933 261/938/931 260/941/934\nf 435/940/933 260/941/934 436/942/935\nf 436/942/935 260/941/934 437/943/936\nf 437/943/936 260/941/934 259/944/937\nf 437/943/936 259/944/937 438/945/938\nf 438/945/938 259/944/937 258/946/939\nf 438/945/938 258/946/939 439/947/940\nf 439/947/940 258/946/939 440/948/941\nf 440/948/941 258/946/939 257/949/942\nf 440/948/941 257/949/942 441/950/943\nf 441/950/943 257/949/942 256/951/944\nf 441/950/943 256/951/944 442/952/945\nf 442/952/945 256/951/944 443/953/946\nf 443/953/946 256/951/944 255/954/947\nf 443/953/946 255/954/947 444/955/948\nf 444/955/948 255/954/947 254/956/949\nf 444/955/948 254/956/949 445/957/950\nf 445/957/950 254/956/949 446/958/951\nf 446/958/951 254/956/949 253/959/952\nf 446/958/951 253/959/952 447/960/953\nf 447/960/953 253/959/952 448/961/954\nf 448/961/954 253/959/952 252/962/955\nf 448/961/954 252/962/955 449/963/956\nf 449/963/956 252/962/955 251/964/957\nf 449/963/956 251/964/957 450/965/958\nf 450/965/958 251/964/957 451/966/959\nf 451/966/959 251/964/957 250/967/960\nf 451/966/959 250/967/960 452/877/870\nf 452/877/870 250/967/960 249/875/868\nf 570/968/961 458/969/962 569/970/963\nf 569/970/963 458/969/962 457/971/964\nf 569/970/963 457/971/964 456/972/965\nf 571/973/966 467/974/967 570/968/961\nf 570/968/961 467/974/967 466/975/968\nf 570/968/961 466/975/968 465/976/969\nf 572/977/970 476/978/971 571/973/966\nf 571/973/966 476/978/971 475/979/972\nf 571/973/966 475/979/972 474/980/973\nf 248/981/974 487/982/975 572/977/970\nf 572/977/970 487/982/975 486/983/976\nf 572/977/970 486/983/976 485/984/977\nf 247/985/978 496/986/979 248/981/974\nf 248/981/974 496/986/979 495/987/980\nf 248/981/974 495/987/980 494/988/981\nf 569/970/963 505/989/982 247/985/978\nf 247/985/978 505/989/982 504/990/983\nf 247/985/978 504/990/983 503/991/984\nf 454/992/985 453/993/986 569/970/963\nf 569/970/963 453/993/986 510/994/987\nf 569/970/963 510/994/987 509/995/988\nf 509/995/988 508/996/989 569/970/963\nf 569/970/963 508/996/989 507/997/990\nf 569/970/963 507/997/990 506/998/991\nf 506/998/991 505/989/982 569/970/963\nf 503/991/984 502/999/992 247/985/978\nf 247/985/978 502/999/992 501/1000/993\nf 247/985/978 501/1000/993 500/1001/994\nf 500/1001/994 499/1002/995 247/985/978\nf 247/985/978 499/1002/995 498/1003/996\nf 247/985/978 498/1003/996 497/1004/997\nf 497/1004/997 496/986/979 247/985/978\nf 494/988/981 493/1005/998 248/981/974\nf 248/981/974 493/1005/998 492/1006/999\nf 248/981/974 492/1006/999 491/1007/1000\nf 491/1007/1000 490/1008/1001 248/981/974\nf 248/981/974 490/1008/1001 489/1009/1002\nf 248/981/974 489/1009/1002 488/1010/1003\nf 488/1010/1003 487/982/975 248/981/974\nf 485/984/977 484/1011/1004 572/977/970\nf 572/977/970 484/1011/1004 483/1012/1005\nf 572/977/970 483/1012/1005 482/1013/1006\nf 482/1013/1006 481/1014/1007 572/977/970\nf 572/977/970 481/1014/1007 480/1015/1008\nf 572/977/970 480/1015/1008 479/1016/1009\nf 479/1016/1009 478/1017/1010 572/977/970\nf 572/977/970 478/1017/1010 477/1018/1011\nf 572/977/970 477/1018/1011 476/978/971\nf 474/980/973 473/1019/1012 571/973/966\nf 571/973/966 473/1019/1012 472/1020/1013\nf 571/973/966 472/1020/1013 471/1021/1014\nf 471/1021/1014 470/1022/1015 571/973/966\nf 571/973/966 470/1022/1015 469/1023/1016\nf 571/973/966 469/1023/1016 468/1024/1017\nf 468/1024/1017 467/974/967 571/973/966\nf 465/976/969 464/1025/1018 570/968/961\nf 570/968/961 464/1025/1018 463/1026/1019\nf 570/968/961 463/1026/1019 462/1027/1020\nf 462/1027/1020 461/1028/1021 570/968/961\nf 570/968/961 461/1028/1021 460/1029/1022\nf 570/968/961 460/1029/1022 459/1030/1023\nf 459/1030/1023 458/969/962 570/968/961\nf 456/972/965 455/1031/1024 569/970/963\nf 569/970/963 455/1031/1024 454/992/985\nf 574/1032/1025 611/1033/1026 573/1034/1027\nf 573/1034/1027 611/1033/1026 612/1035/1028\nf 573/1034/1027 612/1035/1028 613/1036/1029\nf 246/1037/1030 600/1038/1031 574/1032/1025\nf 574/1032/1025 600/1038/1031 601/1039/1032\nf 574/1032/1025 601/1039/1032 602/1040/1033\nf 245/1041/1034 591/1042/1035 246/1037/1030\nf 246/1037/1030 591/1042/1035 592/1043/1036\nf 246/1037/1030 592/1043/1036 593/1044/1037\nf 575/1045/1038 582/1046/1039 245/1041/1034\nf 245/1041/1034 582/1046/1039 583/1047/1040\nf 245/1041/1034 583/1047/1040 584/1048/1041\nf 576/1049/1042 629/1050/1043 575/1045/1038\nf 575/1045/1038 629/1050/1043 630/1051/1044\nf 575/1045/1038 630/1051/1044 631/1052/1045\nf 573/1034/1027 620/1053/1046 576/1049/1042\nf 576/1049/1042 620/1053/1046 621/1054/1047\nf 576/1049/1042 621/1054/1047 622/1055/1048\nf 634/1056/1049 577/1057/1050 575/1045/1038\nf 575/1045/1038 577/1057/1050 578/1058/1051\nf 575/1045/1038 578/1058/1051 579/1059/1052\nf 579/1059/1052 580/1060/1053 575/1045/1038\nf 575/1045/1038 580/1060/1053 581/1061/1054\nf 575/1045/1038 581/1061/1054 582/1046/1039\nf 584/1048/1041 585/1062/1055 245/1041/1034\nf 245/1041/1034 585/1062/1055 586/1063/1056\nf 245/1041/1034 586/1063/1056 587/1064/1057\nf 587/1064/1057 588/1065/1058 245/1041/1034\nf 245/1041/1034 588/1065/1058 589/1066/1059\nf 245/1041/1034 589/1066/1059 590/1067/1060\nf 590/1067/1060 591/1042/1035 245/1041/1034\nf 593/1044/1037 594/1068/1061 246/1037/1030\nf 246/1037/1030 594/1068/1061 595/1069/1062\nf 246/1037/1030 595/1069/1062 596/1070/1063\nf 596/1070/1063 597/1071/1064 246/1037/1030\nf 246/1037/1030 597/1071/1064 598/1072/1065\nf 246/1037/1030 598/1072/1065 599/1073/1066\nf 599/1073/1066 600/1038/1031 246/1037/1030\nf 602/1040/1033 603/1074/1067 574/1032/1025\nf 574/1032/1025 603/1074/1067 604/1075/1068\nf 574/1032/1025 604/1075/1068 605/1076/1069\nf 605/1076/1069 606/1077/1070 574/1032/1025\nf 574/1032/1025 606/1077/1070 607/1078/1071\nf 574/1032/1025 607/1078/1071 608/1079/1072\nf 608/1079/1072 609/1080/1073 574/1032/1025\nf 574/1032/1025 609/1080/1073 610/1081/1074\nf 574/1032/1025 610/1081/1074 611/1033/1026\nf 613/1036/1029 614/1082/1075 573/1034/1027\nf 573/1034/1027 614/1082/1075 615/1083/1076\nf 573/1034/1027 615/1083/1076 616/1084/1077\nf 616/1084/1077 617/1085/1078 573/1034/1027\nf 573/1034/1027 617/1085/1078 618/1086/1079\nf 573/1034/1027 618/1086/1079 619/1087/1080\nf 619/1087/1080 620/1053/1046 573/1034/1027\nf 622/1055/1048 623/1088/1081 576/1049/1042\nf 576/1049/1042 623/1088/1081 624/1089/1082\nf 576/1049/1042 624/1089/1082 625/1090/1083\nf 625/1090/1083 626/1091/1084 576/1049/1042\nf 576/1049/1042 626/1091/1084 627/1092/1085\nf 576/1049/1042 627/1092/1085 628/1093/1086\nf 628/1093/1086 629/1050/1043 576/1049/1042\nf 631/1052/1045 632/1094/1087 575/1045/1038\nf 575/1045/1038 632/1094/1087 633/1095/1088\nf 575/1045/1038 633/1095/1088 634/1056/1049\nf 246/1096/1089 574/1097/1090 247/1098/1091\nf 247/1098/1091 574/1097/1090 569/1099/1092\nf 11/1100/1093 5/1101/1094 35/1102/1095\nf 35/1102/1095 5/1101/1094 4/1103/1096\nf 35/1102/1095 4/1103/1096 3/1104/1097\nf 3/1104/1097 2/1105/1098 35/1102/1095\nf 35/1102/1095 2/1105/1098 67/1106/1099\nf 35/1102/1095 67/1106/1099 66/1107/1100\nf 2/1105/1098 1/1108/1101 67/1106/1099\nf 66/1107/1100 65/1109/1102 35/1102/1095\nf 35/1102/1095 65/1109/1102 36/1110/1103\nf 36/1110/1103 65/1109/1102 60/1111/1104\nf 36/1110/1103 60/1111/1104 41/1112/1105\nf 41/1112/1105 60/1111/1104 59/1113/1106\nf 41/1112/1105 59/1113/1106 42/1114/1107\nf 42/1114/1107 59/1113/1106 43/1115/1108\nf 43/1115/1108 59/1113/1106 58/1116/1109\nf 43/1115/1108 58/1116/1109 44/1117/1110\nf 44/1117/1110 58/1116/1109 57/1118/1111\nf 44/1117/1110 57/1118/1111 49/1119/1112\nf 49/1119/1112 57/1118/1111 51/1120/1113\nf 49/1119/1112 51/1120/1113 50/1121/1114\nf 57/1118/1111 52/1122/1115 51/1120/1113\nf 34/1123/1116 19/1124/1117 35/1102/1095\nf 35/1102/1095 19/1124/1117 14/1125/1118\nf 35/1102/1095 14/1125/1118 13/1126/1119\nf 19/1124/1117 34/1123/1116 20/1127/1120\nf 20/1127/1120 34/1123/1116 33/1128/1121\nf 20/1127/1120 33/1128/1121 21/1129/1122\nf 21/1129/1122 33/1128/1121 31/1130/1123\nf 21/1129/1122 31/1130/1123 22/1131/1124\nf 22/1131/1124 31/1130/1123 29/1132/1125\nf 22/1131/1124 29/1132/1125 27/1133/1126\nf 13/1126/1119 12/1134/1127 35/1102/1095\nf 35/1102/1095 12/1134/1127 11/1100/1093\nf 575/1135/1128 245/1136/1129 572/1137/1130\nf 572/1137/1130 245/1136/1129 248/1138/1131\nf 576/1139/1132 575/1140/1133 571/1141/1134\nf 571/1141/1134 575/1140/1133 572/1142/1135\nf 573/1143/1136 576/1144/1137 570/1145/1138\nf 570/1145/1138 576/1144/1137 571/1146/1139\nf 574/1147/1140 573/1148/1141 569/1149/1142\nf 569/1149/1142 573/1148/1141 570/1150/1143\nf 287/1151/1144 286/1152/1145 301/1153/1146\nf 301/1153/1146 286/1152/1145 322/1154/1147\nf 301/1153/1146 322/1154/1147 321/1155/1148\nf 321/1155/1148 320/1156/1149 301/1153/1146\nf 301/1153/1146 320/1156/1149 319/1157/1150\nf 301/1153/1146 319/1157/1150 318/1158/1151\nf 318/1158/1151 317/1159/1152 301/1153/1146\nf 301/1153/1146 317/1159/1152 316/1160/1153\nf 301/1153/1146 316/1160/1153 315/1161/1154\nf 315/1161/1154 314/1162/1155 301/1153/1146\nf 301/1153/1146 314/1162/1155 313/1163/1156\nf 301/1153/1146 313/1163/1156 312/1164/1157\nf 312/1164/1157 311/1165/1158 301/1153/1146\nf 301/1153/1146 311/1165/1158 310/1166/1159\nf 301/1153/1146 310/1166/1159 309/1167/1160\nf 309/1167/1160 308/1168/1161 301/1153/1146\nf 301/1153/1146 308/1168/1161 302/1169/1162\nf 302/1169/1162 308/1168/1161 307/1170/1163\nf 302/1169/1162 307/1170/1163 303/1171/1164\nf 303/1171/1164 307/1170/1163 306/1172/1165\nf 303/1171/1164 306/1172/1165 304/1173/1166\nf 304/1173/1166 306/1172/1165 305/1174/1167\nf 300/1175/1168 290/1176/1169 301/1153/1146\nf 301/1153/1146 290/1176/1169 289/1177/1170\nf 301/1153/1146 289/1177/1170 288/1178/1171\nf 290/1176/1169 300/1175/1168 291/1179/1172\nf 291/1179/1172 300/1175/1168 299/1180/1173\nf 291/1179/1172 299/1180/1173 292/1181/1174\nf 292/1181/1174 299/1180/1173 298/1182/1175\nf 292/1181/1174 298/1182/1175 293/1183/1176\nf 293/1183/1176 298/1182/1175 297/1184/1177\nf 293/1183/1176 297/1184/1177 294/1185/1178\nf 294/1185/1178 297/1184/1177 296/1186/1179\nf 294/1185/1178 296/1186/1179 295/1187/1180\nf 288/1178/1171 287/1151/1144 301/1153/1146\nf 636/1188/1181 659/1189/1182 635/1190/1183\nf 638/1191/1184 659/1192/1185 637/1193/1186\nf 640/1194/1187 659/1195/1188 639/1196/1189\nf 642/1197/1190 659/1198/1191 641/1199/1192\nf 644/1200/1193 659/1201/1194 643/1202/1195\nf 646/1203/1196 659/1204/1197 645/1205/1198\nf 648/1206/1199 659/1207/1200 647/1208/1201\nf 650/1209/1202 659/1210/1203 649/1211/1204\nf 652/1212/1205 659/1213/1206 651/1214/1207\nf 654/1215/1208 659/1216/1209 653/1217/1210\nf 656/1218/1211 659/1219/1212 655/1220/1213\nf 658/1221/1214 659/1222/1215 657/1223/1216\nf 635/1224/1183 659/1225/1217 658/1221/1214\nf 651/1214/1207 659/1226/1218 650/1209/1202\nf 643/1202/1195 659/1227/1219 642/1197/1190\nf 657/1223/1216 659/1228/1220 656/1218/1211\nf 655/1220/1213 659/1229/1221 654/1215/1208\nf 653/1217/1210 659/1230/1222 652/1212/1205\nf 649/1211/1204 659/1231/1223 648/1206/1199\nf 647/1208/1201 659/1232/1224 646/1203/1196\nf 645/1205/1198 659/1233/1225 644/1200/1193\nf 641/1199/1192 659/1234/1226 640/1194/1187\nf 639/1196/1189 659/1235/1227 638/1191/1184\nf 637/1193/1186 659/1236/1228 636/1188/1181\nf 578/1237/1229 577/1238/1230 660/1239/1231\nf 660/1240/1231 577/1241/1230 634/1242/1232\nf 660/1240/1231 634/1242/1232 696/1243/1233\nf 696/1243/1233 634/1242/1232 633/1244/1234\nf 696/1243/1233 633/1244/1234 695/1245/1235\nf 695/1245/1235 633/1244/1234 632/1246/1236\nf 695/1245/1235 632/1246/1236 631/1247/1237\nf 695/1245/1235 631/1247/1237 694/1248/1238\nf 694/1248/1238 631/1247/1237 630/1249/1239\nf 694/1248/1238 630/1249/1239 693/1250/1240\nf 693/1250/1240 630/1249/1239 629/1251/1241\nf 693/1250/1240 629/1251/1241 628/1252/1242\nf 693/1250/1240 628/1252/1242 692/1253/1243\nf 692/1253/1243 628/1252/1242 627/1254/1244\nf 692/1253/1243 627/1254/1244 626/1255/1245\nf 692/1253/1243 626/1255/1245 691/1256/1246\nf 691/1256/1246 626/1255/1245 625/1257/1247\nf 691/1256/1246 625/1257/1247 690/1258/1248\nf 690/1258/1248 625/1257/1247 624/1259/1249\nf 690/1258/1248 624/1259/1249 623/1260/1250\nf 690/1258/1248 623/1260/1250 689/1261/1251\nf 689/1261/1251 623/1260/1250 622/1262/1252\nf 689/1261/1251 622/1262/1252 688/1263/1253\nf 688/1263/1253 622/1262/1252 621/1264/1254\nf 688/1263/1253 621/1264/1254 620/1265/1255\nf 688/1263/1253 620/1265/1255 687/1266/1256\nf 687/1266/1256 620/1265/1255 619/1267/1257\nf 687/1266/1256 619/1267/1257 686/1268/1258\nf 686/1268/1258 619/1267/1257 618/1269/1259\nf 686/1268/1258 618/1269/1259 617/1270/1260\nf 686/1268/1258 617/1270/1260 685/1271/1261\nf 685/1271/1261 617/1270/1260 616/1272/1262\nf 685/1271/1261 616/1272/1262 615/1273/1263\nf 685/1271/1261 615/1273/1263 684/1274/1264\nf 684/1274/1264 615/1273/1263 614/1275/1265\nf 684/1274/1264 614/1275/1265 683/1276/1266\nf 683/1276/1266 614/1275/1265 613/1277/1267\nf 683/1276/1266 613/1277/1267 612/1278/1268\nf 683/1276/1266 612/1278/1268 682/1279/1269\nf 682/1279/1269 612/1278/1268 611/1280/1270\nf 682/1279/1269 611/1280/1270 681/1281/1271\nf 681/1281/1271 611/1280/1270 610/1282/1272\nf 681/1281/1271 610/1282/1272 609/1283/1273\nf 681/1281/1271 609/1283/1273 680/1284/1274\nf 680/1284/1274 609/1283/1273 608/1285/1275\nf 680/1284/1274 608/1285/1275 679/1286/1276\nf 679/1286/1276 608/1285/1275 607/1287/1277\nf 679/1286/1276 607/1287/1277 606/1288/1278\nf 679/1286/1276 606/1288/1278 678/1289/1279\nf 678/1289/1279 606/1288/1278 605/1290/1280\nf 678/1289/1279 605/1290/1280 604/1291/1281\nf 678/1289/1279 604/1291/1281 677/1292/1282\nf 677/1292/1282 604/1291/1281 603/1293/1283\nf 677/1292/1282 603/1293/1283 676/1294/1284\nf 676/1294/1284 603/1293/1283 602/1295/1285\nf 676/1294/1284 602/1295/1285 601/1296/1286\nf 676/1294/1284 601/1296/1286 675/1297/1287\nf 675/1297/1287 601/1296/1286 600/1298/1288\nf 675/1297/1287 600/1298/1288 674/1299/1289\nf 674/1299/1289 600/1298/1288 599/1300/1290\nf 674/1299/1289 599/1300/1290 598/1301/1291\nf 674/1299/1289 598/1301/1291 673/1302/1292\nf 673/1302/1292 598/1301/1291 597/1303/1293\nf 673/1302/1292 597/1303/1293 672/1304/1294\nf 672/1304/1294 597/1303/1293 596/1305/1295\nf 672/1304/1294 596/1305/1295 595/1306/1296\nf 672/1304/1294 595/1306/1296 671/1307/1297\nf 671/1307/1297 595/1306/1296 594/1308/1298\nf 671/1307/1297 594/1308/1298 593/1309/1299\nf 671/1307/1297 593/1309/1299 670/1310/1300\nf 670/1310/1300 593/1309/1299 592/1311/1301\nf 670/1310/1300 592/1311/1301 669/1312/1302\nf 669/1312/1302 592/1311/1301 591/1313/1303\nf 669/1312/1302 591/1313/1303 590/1314/1304\nf 669/1312/1302 590/1314/1304 668/1315/1305\nf 668/1315/1305 590/1314/1304 589/1316/1306\nf 668/1315/1305 589/1316/1306 667/1317/1307\nf 667/1317/1307 589/1316/1306 588/1318/1308\nf 667/1317/1307 588/1318/1308 587/1319/1309\nf 667/1317/1307 587/1319/1309 666/1320/1310\nf 666/1320/1310 587/1319/1309 586/1321/1311\nf 666/1320/1310 586/1321/1311 665/1322/1312\nf 665/1322/1312 586/1321/1311 585/1323/1313\nf 665/1322/1312 585/1323/1313 584/1324/1314\nf 665/1322/1312 584/1324/1314 664/1325/1315\nf 664/1325/1315 584/1324/1314 583/1326/1316\nf 664/1325/1315 583/1326/1316 582/1327/1317\nf 664/1325/1315 582/1327/1317 663/1328/1318\nf 663/1328/1318 582/1327/1317 581/1329/1319\nf 663/1328/1318 581/1329/1319 662/1330/1320\nf 662/1330/1320 581/1329/1319 580/1331/1321\nf 662/1330/1320 580/1331/1321 579/1332/1322\nf 662/1330/1320 579/1332/1322 661/1333/1323\nf 661/1333/1323 579/1332/1322 578/1237/1229\nf 661/1333/1323 578/1237/1229 660/1239/1231\nf 658/1334/1324 661/1335/1325 635/1336/1326\nf 635/1336/1326 661/1335/1325 660/1337/1327\nf 635/1336/1326 660/1337/1327 696/1338/1328\nf 661/1335/1325 658/1334/1324 662/1339/1329\nf 662/1339/1329 658/1334/1324 657/1340/1330\nf 662/1339/1329 657/1340/1330 663/1341/1331\nf 663/1341/1331 657/1340/1330 664/1342/1332\nf 664/1342/1332 657/1340/1330 656/1343/1333\nf 664/1342/1332 656/1343/1333 665/1344/1334\nf 665/1344/1334 656/1343/1333 655/1345/1335\nf 665/1344/1334 655/1345/1335 666/1346/1336\nf 666/1346/1336 655/1345/1335 667/1347/1337\nf 667/1347/1337 655/1345/1335 654/1348/1338\nf 667/1347/1337 654/1348/1338 668/1349/1339\nf 668/1349/1339 654/1348/1338 653/1350/1340\nf 668/1349/1339 653/1350/1340 669/1351/1341\nf 669/1351/1341 653/1350/1340 670/1352/1342\nf 670/1352/1342 653/1350/1340 652/1353/1343\nf 670/1352/1342 652/1353/1343 671/1354/1344\nf 671/1354/1344 652/1353/1343 672/1355/1345\nf 672/1355/1345 652/1353/1343 651/1356/1346\nf 672/1355/1345 651/1356/1346 673/1357/1347\nf 673/1357/1347 651/1356/1346 650/1358/1348\nf 673/1357/1347 650/1358/1348 674/1359/1349\nf 674/1359/1349 650/1358/1348 675/1360/1350\nf 675/1360/1350 650/1358/1348 649/1361/1351\nf 675/1360/1350 649/1361/1351 676/1362/1352\nf 676/1362/1352 649/1361/1351 648/1363/1353\nf 676/1362/1352 648/1363/1353 677/1364/1354\nf 677/1364/1354 648/1363/1353 678/1365/1355\nf 678/1365/1355 648/1363/1353 647/1366/1356\nf 678/1365/1355 647/1366/1356 679/1367/1357\nf 679/1367/1357 647/1366/1356 646/1368/1358\nf 679/1367/1357 646/1368/1358 680/1369/1359\nf 680/1369/1359 646/1368/1358 681/1370/1360\nf 681/1370/1360 646/1368/1358 645/1371/1361\nf 681/1370/1360 645/1371/1361 682/1372/1362\nf 682/1372/1362 645/1371/1361 644/1373/1363\nf 682/1372/1362 644/1373/1363 683/1374/1364\nf 683/1374/1364 644/1373/1363 684/1375/1365\nf 684/1375/1365 644/1373/1363 643/1376/1366\nf 684/1375/1365 643/1376/1366 685/1377/1367\nf 685/1377/1367 643/1376/1366 642/1378/1368\nf 685/1377/1367 642/1378/1368 686/1379/1369\nf 686/1379/1369 642/1378/1368 687/1380/1370\nf 687/1380/1370 642/1378/1368 641/1381/1371\nf 687/1380/1370 641/1381/1371 688/1382/1372\nf 688/1382/1372 641/1381/1371 689/1383/1373\nf 689/1383/1373 641/1381/1371 640/1384/1374\nf 689/1383/1373 640/1384/1374 690/1385/1375\nf 690/1385/1375 640/1384/1374 639/1386/1376\nf 690/1385/1375 639/1386/1376 691/1387/1377\nf 691/1387/1377 639/1386/1376 692/1388/1378\nf 692/1388/1378 639/1386/1376 638/1389/1379\nf 692/1388/1378 638/1389/1379 693/1390/1380\nf 693/1390/1380 638/1389/1379 637/1391/1381\nf 693/1390/1380 637/1391/1381 694/1392/1382\nf 694/1392/1382 637/1391/1381 695/1393/1383\nf 695/1393/1383 637/1391/1381 636/1394/1384\nf 695/1393/1383 636/1394/1384 696/1338/1328\nf 696/1338/1328 636/1394/1384 635/1336/1326\n# 696 vertices\n# 1394 texture params\n# 1384 normals\n# 1388 facets\n\n# 1 groups\n",this.scene,void 0,void 0,void 0,".obj"),this.hqNozzle&&(this.toolCursorMesh=this.scene.getMeshByName("JRNozzle"),this.toolCursorMesh.parent=this.toolCursor,this.gcodeProcessor.zBelt?this.toolCursorMesh.rotate(Gt.X,Math.PI/2-45*Math.PI/180,ci.LOCAL):this.toolCursorMesh.rotate(Gt.X,Math.PI/2-Math.PI/180,ci.LOCAL),this.toolCursorMesh.rotate(Gt.Y,Math.PI,ci.LOCAL),this.toolCursorMesh.rotate(Gt.Z,Math.PI,ci.LOCAL),this.toolCursorMesh.scaling=new v(-1,1,1)),this.toolCursorMesh.isVisible=this.toolCursorVisible,this.toolCursorMesh.renderingGroupId=2,this.registerClipIgnore(this.toolCursorMesh);var n=new ee("nozzleMaterial",this.scene);this.toolCursorMesh.material=n,n.diffuseColor=new de(1,.766,.336)}}},{key:"updateRenderQuality",value:function(n){this.renderQuality=n,localStorage&&localStorage.setItem("renderQuality",n)}},{key:"registerClipIgnore",value:function(n){var r=this;n!=null&&(n.onBeforeRenderObservable.add(()=>{r.scene.clipPlane=null,r.scene.clipPlane2=null}),n.onAfterRenderObservable.add(()=>{r.scene.clipPlane=new Xt(0,1,0,r.zTopClipValue),r.scene.clipPlane2=new Xt(0,-1,0,r.zBottomClipValue)}))}},{key:"updateCameraInertiaProperties",value:function(){this.cameraInertia?(this.orbitCamera.speed=2,this.orbitCamera.inertia=.9,this.orbitCamera.panningInertia=.9,this.orbitCamera.inputs.attached.keyboard.angularSpeed=.005,this.orbitCamera.inputs.attached.keyboard.zoomingSensibility=2,this.orbitCamera.inputs.attached.keyboard.panningSensibility=2,this.orbitCamera.angularSensibilityX=1e3,this.orbitCamera.angularSensibilityY=1e3,this.orbitCamera.panningSensibility=10,this.orbitCamera.wheelPrecision=1):(this.orbitCamera.speed=500,this.orbitCamera.inertia=0,this.orbitCamera.panningInertia=0,this.orbitCamera.inputs.attached.keyboard.angularSpeed=.05,this.orbitCamera.inputs.attached.keyboard.zoomingSensibility=.5,this.orbitCamera.inputs.attached.keyboard.panningSensibility=.5,this.orbitCamera.angularSensibilityX=200,this.orbitCamera.angularSensibilityY=200,this.orbitCamera.panningSensibility=2,this.orbitCamera.wheelPrecision=.25)}},{key:"setCameraInertia",value:function(n){this.cameraInertia=n,localStorage.setItem("cameraInertia",n),this.updateCameraInertiaProperties()}},{key:"forceRender",value:function(){this.scene&&this.scene.render(!0)}},{key:"getLayers",value:function(){return this.gcodeProcessor.layerDictionary}},{key:"getGCodeLine",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:5;try{var r=Math.max(0,this.gcodeProcessor.currentLineNumber-n),o=Math.min(this.gcodeProcessor.currentLineNumber,this.fileDataArray.length-1);return this.fileDataArray.slice(r,o).join("\r\n").trim()}catch{return""}}},{key:"getGCodeLineNumber",value:function(){return this.gcodeProcessor.currentLineNumber}},{key:"goToGCodeLine",value:function(n){}},{key:"simulateToolPosition",value:function(){this.updateToolPosition(this.gcodeProcessor.nozzlePosition)}},{key:"setZBelt",value:function(n,r){this.gcodeProcessor.zBelt=n,n&&(this.gcodeProcessor.setZBeltAngle(r),this.toolCursorMesh.rotate(Gt.X,Math.PI/2-r*Math.PI/180,ci.LOCAL))}},{key:"setWorkplaceVisiblity",value:function(n){this.workplace.visible=n,this.workplace.setOffsets(this.gcodeProcessor.workplaceOffsets),this.workplace.render(),this.scene.render()}},{key:"startSimulation",value:function(){this.gcodeProcessor.lastFilePositionIndex>=this.gcodeProcessor.renderedLines.length-1&&this.gcodeProcessor.updateFilePositionIndex(1),this.simulation=!0,this.gcodeProcessor.doUpdate()}},{key:"stopSimulation",value:function(){this.simulation=!1,this.simulationStopped()}},{key:"clamp",value:function(n,r,o){return Math.min(Math.max(n,r),o)}},{key:"runSimulation",value:function(){if(this.gcodeProcessor.renderedLines.length!==0){if(this.gcodeProcessor.lastFilePositionIndex>=this.gcodeProcessor.renderedLines.length-1&&(this.simulation=!1,this.simulationStopped()),this.simulationCurrentLine!=this.gcodeProcessor.renderedLines[this.gcodeProcessor.lastFilePositionIndex]){this.simulationCurrentLine=this.gcodeProcessor.renderedLines[this.gcodeProcessor.lastFilePositionIndex],this.updateToolPosition(this.simulationCurrentLine.start),this.simulationLastUpdate=0;var n=this.isMMS?this.simulationCurrentLine.feedRate:this.simulationCurrentLine.feedRate/60;this.simulationTimeToMove=this.simulationCurrentLine.length()/n*1e3,this.simulationUpdatePosition(this.simulationCurrentLine.gcodeFilePosition)}this.simLine=this.simulationCurrentLine.start.clone(),this.simulationLastUpdate+=this.engine.getDeltaTime()*this.simulationMultiplier*this.scene.getAnimationRatio();var r=this.clamp(this.simulationLastUpdate/this.simulationTimeToMove,0,1);if(v.LerpToRef(this.simulationCurrentLine.start,this.simulationCurrentLine.end,r,this.simLine),this.updateToolPosition(this.simLine),this.simulationLastUpdate>=this.simulationTimeToMove||this.simulationTimeToMove==1/0||this.simulationTimeToMove==0){var o=this.simulationMultiplier>10?this.simulationMultiplier:1,h=this.scene.getAnimationRatio();h>3&&(o+=~~h),this.gcodeProcessor.updateFilePositionIndex(this.gcodeProcessor.lastFilePositionIndex+o)}}}},{key:"getCameraPosition",value:function(){return this.scene.cameras[0].position}},{key:"getCameraTarget",value:function(){return this.scene.cameras[0].target}},{key:"setCameraPosition",value:function(n,r,o){var h=Number(n),l=Number(r),c=Number(o);h!==NaN&&l!==NaN&&c!==NaN&&(this.scene.activeCamera.position=new v(Number(n),Number(o),Number(r)),this.forceRender())}},{key:"setCameraTarget",value:function(n,r,o){var h=Number(n),l=Number(r),c=Number(o);h!==NaN&&l!==NaN&&c!==NaN&&(this.scene.activeCamera.target=new v(Number(n),Number(o),Number(r)),this.forceRender())}},{key:"createScreenshot",value:(e=Gi(It().mark(function n(){var r,o,h,l,c=arguments;return It().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return r=c.length>0&&c[0]!==void 0?c[0]:1920,o=c.length>1&&c[1]!==void 0?c[1]:1080,h=this.scene.clearColor,this.scene.clearColor=new H(0,0,0,0),this.displayViewBox(!1),this.gcodeProcessor.forceRender(),this.gcodeProcessor.doUpdate(),this.scene.render(!0,!0),this.scene.onAfterRenderObservable.addOnce(()=>{}),u.next=13,$g.CreateScreenshotAsync(this.engine,this.scene.activeCamera,{width:r,height:o});case 13:return l=u.sent,this.scene.clearColor=h,u.abrupt("return",l);case 16:case"end":return u.stop()}},n,this)})),function(){return e.apply(this,arguments)})},{key:"displayViewBox",value:function(n){(function(r){Ze.meshes.forEach(o=>{o.setEnabled(r)})})(n)}}]),a}(),Kb=Object.defineProperty,Xb=Object.getOwnPropertyDescriptor,Je=(a,e,t,i)=>{for(var s=i>1?void 0:i?Xb(e,t):e,n=a.length-1,r;n>=0;n--)(r=a[n])&&(s=(i?r(e,t,s):r(s))||s);return i&&s&&Kb(e,t,s),s};let Y=null,$e=class extends El(Cl){constructor(){super(...arguments),this.mdiReloadAlert=Mf,this.mdiCameraRetake=Pf,this.mdiToggleSwitch=wf,this.mdiToggleSwitchOffOutline=Df,this.mdiClose=Ff,this.mdiCog=Of,this.mdiVideo3d=Bf,this.mdiPlay=Lf,this.mdiPause=Nf,this.mdiFastForward=Uf,this.mdiBroom=kf,this.mdiSelectionRemove=Vf,this.formatFilesize=Gf,this.isBusy=!1,this.loading=!1,this.loadingPercent=0,this.tracking=!1,this.loadedFile=null,this.reloadRequired=!1,this.fileSize=0,this.renderQuality=this.renderQualities[2],this.scrubPosition=0,this.scrubPlaying=!1,this.scrubSpeed=1,this.scrubInterval=void 0,this.scrubFileSize=0,this.downloadSnackbar={status:!1,filename:"",percent:0,speed:0,total:0,cancelTokenSource:{}},this.excludeObject={bool:!1,name:""},this.fileData="",this.colorModes=[{text:"Extruder",value:0},{text:"Feed Rate",value:1},{text:"Feature",value:2}]}get renderQualities(){return[{label:this.$t("GCodeViewer.Low"),value:2},{label:this.$t("GCodeViewer.Medium"),value:3},{label:this.$t("GCodeViewer.High"),value:4},{label:this.$t("GCodeViewer.Ultra"),value:5},{label:this.$t("GCodeViewer.Max"),value:6}]}async mounted(){var e,t,i,s;this.loadedFile=(t=(e=this.$store.state.gcodeviewer)==null?void 0:e.loadedFileBackup)!=null?t:null,Y=(s=(i=this.$store.state.gcodeviewer)==null?void 0:i.viewerBackup)!=null?s:null,await this.init(),this.loadedFile!==null&&(this.scrubFileSize=Y.fileSize),Y&&(this.fileData=Y.fileData)}beforeDestroy(){Y&&(Y.gcodeProcessor.loadingProgressCallback=null,this.$store.dispatch("gcodeviewer/setLoadedFileBackup",this.loadedFile),this.$store.dispatch("gcodeviewer/setViewerBackup",Y)),this.scrubPlaying=!1,this.scrubInterval&&(clearInterval(this.scrubInterval),this.scrubInterval=void 0)}handleResize(){this.$nextTick(()=>{Y==null||Y.resize()})}get panelTitle(){let e=this.$t("GCodeViewer.Title").toString();return this.loadedFile&&(e+=": ".concat(this.loadedFile)),e}get filePosition(){return this.printerIsPrinting?this.$store.state.printer.virtual_sdcard.file_position:0}get sdCardFilePath(){var e,t;return(t=(e=this.$store.state.printer.print_stats)==null?void 0:e.filename)!=null?t:""}get livePosition(){var e,t;return(t=(e=this.$store.state.printer.motion_report)==null?void 0:e.live_position)!=null?t:[0,0,0,0]}get gcodeOffset(){var e,t,i;return(i=(t=(e=this.$store.state.printer)==null?void 0:e.gcode_move)==null?void 0:t.homing_origin)!=null?i:[0,0,0]}get currentPosition(){return[this.livePosition[0]-this.gcodeOffset[0],this.livePosition[1]-this.gcodeOffset[1],this.livePosition[2]-this.gcodeOffset[2],this.livePosition[3]]}get showTrackingButton(){return this.printerIsPrinting&&this.sdCardFilePath===this.loadedFile}get printing_objects(){var e,t,i;return(i=(t=(e=this.$store.state.printer)==null?void 0:e.exclude_object)==null?void 0:t.objects)!=null?i:[]}printing_objectsChanged(){this.refreshPrintingObjects()}get excluded_objects(){var e,t;return(t=(e=this.$store.state.printer.exclude_object)==null?void 0:e.excluded_objects)!=null?t:[]}excluded_objectsChanged(){this.refreshPrintingObjects()}get nozzle_diameter(){var e,t,i,s;return(s=(i=(t=(e=this.$store.state.printer.configfile)==null?void 0:e.settings)==null?void 0:t.extruder)==null?void 0:i.nozzle_diameter)!=null?s:.4}async init(){var t,i,s,n,r;let e=(i=(t=this.$store.state.gcodeviewer)==null?void 0:t.canvasBackup)!=null?i:null;e===null?(e=document.createElement("canvas"),e.className="viewer",this.viewerCanvasContainer.appendChild(e),await this.$store.dispatch("gcodeviewer/setCanvasBackup",e)):(this.viewerCanvasContainer.appendChild(e),Y!=null&&Y.gcodeProcessor&&Y.gcodeProcessor.updateFilePosition(Y==null?void 0:Y.fileSize)),Y===null&&await this.viewerInit(e),this.registerProgressCallback(),(s=this.$route.query)!=null&&s.filename&&this.loadedFile!==((r=(n=this.$route.query)==null?void 0:n.filename)==null?void 0:r.toString())&&(await this.sleep(1e3),await this.loadFile(this.$route.query.filename.toString()))}async viewerInit(e){Y=new Hb(e),await Y.init(),Y.setBackgroundColor(this.backgroundColor),Y.bed.setBedColor(this.gridColor),Y.setCursorVisiblity(this.showCursor),Y.setZClipPlane(1e6,-1e6),Y.axes.show(this.showAxes),Y.bed.setDelta(this.kinematics.includes("delta")),this.bedMaxSize!==null&&(Y.bed.buildVolume.x.max=this.bedMaxSize[0],Y.bed.buildVolume.y.max=this.bedMaxSize[1],Y.bed.buildVolume.z.max=this.bedMaxSize[2]),this.bedMinSize!==null&&(Y.bed.buildVolume.x.min=this.bedMinSize[0],Y.bed.buildVolume.y.min=this.bedMinSize[1],Y.bed.buildVolume.z.min=this.bedMinSize[2]),Y.gcodeProcessor.useHighQualityExtrusion(this.hdRendering),Y.gcodeProcessor.updateForceWireMode(this.forceLineRendering||this.cncMode),Y.gcodeProcessor.setAlpha(this.transparency),Y.gcodeProcessor.setVoxelMode(this.voxelMode),Y.gcodeProcessor.voxelWidth=this.voxelWidth,Y.gcodeProcessor.voxelHeight=this.voxelHeight,Y.gcodeProcessor.useSpecularColor(this.specularLighting),Y.gcodeProcessor.setLiveTracking(!1),Y.gcodeProcessor.g1AsExtrusion=this.cncMode,Y.buildObjects.objectCallback=this.objectCallback,this.loadToolColors(this.extruderColors),Y.lastLoadFailed()&&(this.renderQuality=this.renderQualities[0],Y.updateRenderQuality(1),Y.clearLoadFlag())}registerProgressCallback(){Y!==null&&(Y.gcodeProcessor.loadingProgressCallback=e=>{this.loadingPercent=Math.ceil(e*100),this.loading=this.loadingPercent<=99})}async cancelRendering(){Y!==null&&(Y.gcodeProcessor.cancelLoad=!0,await this.sleep(1e3))}clearLoadedFile(){Y!==null&&(this.scrubPlaying=!1,this.scrubFileSize=0,Y.clearScene(!0),this.loadedFile=null,this.tracking=!1)}chooseFile(){this.isBusy||this.fileInput.click()}finishLoad(){this.loading=!1,Y.setCursorVisiblity(this.showCursor),this.refreshPrintingObjects(),this.scrubFileSize=Y.fileSize,Y.gcodeProcessor.updateFilePosition(Y.fileSize)}refreshPrintingObjects(){if(this.loadedFile!==this.sdCardFilePath||this.printing_objects.length===0)return;let e=[];this.printing_objects.forEach(t=>{const i=t.polygon.map(n=>n[0]),s=t.polygon.map(n=>n[1]);e.push({cancelled:this.excluded_objects.includes(t.name),name:t.name,x:[Math.min(...i),Math.max(...i)],y:[Math.min(...s),Math.max(...s)]})}),Y==null||Y.buildObjects.loadObjectBoundaries(e),Y==null||Y.buildObjects.showObjectSelection(this.showObjectSelection)}async fileSelected(e){var i,s;const t=new FileReader;t.addEventListener("load",async n=>{if(!n||!n.target)return;const r=n.target.result;typeof r=="string"&&(this.fileSize=r.length,await Y.processFile(r),this.fileData=Y.fileData),this.finishLoad()}),this.tracking=!1,(i=e.target.files)!=null&&i.length&&(this.loadedFile=(s=e==null?void 0:e.target)==null?void 0:s.files[0].name,t.readAsText(e.target.files[0])),e.target.value=""}async loadFile(e){this.downloadSnackbar.status=!0,this.downloadSnackbar.speed=0,this.downloadSnackbar.filename=e.startsWith("gcodes/")?e.slice(7):e;const t=Co.CancelToken;this.downloadSnackbar.cancelTokenSource=t.source();const i=await Co.get(this.apiUrl+"/server/files/"+zf(e),{cancelToken:this.downloadSnackbar.cancelTokenSource.token,responseType:"blob",onDownloadProgress:s=>{var n,r,o;this.downloadSnackbar.percent=((n=s.progress)!=null?n:0)*100,this.downloadSnackbar.speed=(r=s.rate)!=null?r:0,this.downloadSnackbar.total=(o=s.total)!=null?o:0}}).then(s=>s.data.text()).catch(s=>{window.console.error(s.message)});this.downloadSnackbar.status=!1,this.loadedFile=this.downloadSnackbar.filename,Y.updateRenderQuality(this.renderQuality.value),await Y.processFile(i),this.fileData=Y.fileData,this.loadingPercent=100,this.finishLoad(),this.scrubFileSize=Y.fileSize}cancelDownload(){this.downloadSnackbar.cancelTokenSource.cancel("User canceled download gcode file")}async sleep(e){await new Promise(t=>setTimeout(t,e))}async loadCurrentFile(){await this.loadFile("gcodes/"+this.sdCardFilePath),this.loadedFile=this.sdCardFilePath}async reloadViewer(){this.loading&&(Y.gcodeProcessor.cancelLoad=!0,await this.sleep(1e3)),this.reloadRequired=!1,this.loading=!0,this.loadingPercent=0,await Y.reload(),this.fileData=Y.fileData,this.loadingPercent=100,this.finishLoad()}resetCamera(){Y.resetCamera()}setReloadRequiredFlag(){this.loadedFile&&this.loadedFile!=""&&(this.reloadRequired=!0)}async renderQualityChanged(e){Y&&Y.renderQuality!==e&&(Y.updateRenderQuality(e),await this.reloadViewer())}currentPositionChanged(e){if(!Y||!this.tracking||this.scrubPlaying)return;const t=[{axes:"X",position:e[0]},{axes:"Y",position:e[1]},{axes:"Z",position:e[2]}];Y.updateToolPosition(t)}filePositionChanged(e){if(!Y||!this.tracking||this.scrubPlaying)return;const t=350;if(e>0&&this.printerIsPrinting&&this.tracking&&e>t){Y.gcodeProcessor.updateFilePosition(e-t),this.scrubPosition=e-t;return}Y.gcodeProcessor.updateFilePosition(Y.fileSize)}async trackingChanged(e){if(Y!==null){if(e){this.scrubPlaying=!1,Y.gcodeProcessor.updateFilePosition(0),Y==null||Y.forceRender();return}Y.gcodeProcessor.setLiveTracking(!1),await this.reloadViewer()}}printerIsPrintingChanged(){this.tracking=!1}get showCursor(){var e;return(e=this.$store.state.gui.gcodeViewer.showCursor)!=null?e:!1}set showCursor(e){this.$store.dispatch("gui/saveSetting",{name:"gcodeViewer.showCursor",value:e})}showCursorChanged(e){Y==null||Y.setCursorVisiblity(e)}get showTravelMoves(){var e;return(e=this.$store.state.gui.gcodeViewer.showTravelMoves)!=null?e:!1}set showTravelMoves(e){this.$store.dispatch("gui/saveSetting",{name:"gcodeViewer.showTravelMoves",value:e})}get showGCode(){var e;return(e=this.$store.state.gui.gcodeViewer.showGCode)!=null?e:!1}set showGCode(e){this.$store.dispatch("gui/saveSetting",{name:"gcodeViewer.showGCode",value:e}),e&&Y&&(this.fileData=Y.fileData),this.handleResize()}showTravelMovesChanged(e){Y==null||Y.toggleTravels(e)}get showObjectSelection(){var e;return(e=this.$store.state.gui.gcodeViewer.showObjectSelection)!=null?e:!1}set showObjectSelection(e){this.$store.dispatch("gui/saveSetting",{name:"gcodeViewer.showObjectSelection",value:e})}showObjectSelectionChanged(e){Y==null||Y.buildObjects.showObjectSelection(e)}get hdRendering(){return this.$store.state.gui.gcodeViewer.hdRendering}set hdRendering(e){this.$store.dispatch("gui/saveSetting",{name:"gcodeViewer.hdRendering",value:e})}async hdRenderingChanged(e){Y!==null&&(Y.gcodeProcessor.useHighQualityExtrusion(e),await this.reloadViewer())}get forceLineRendering(){return this.$store.state.gui.gcodeViewer.forceLineRendering}set forceLineRendering(e){this.$store.dispatch("gui/saveSetting",{name:"gcodeViewer.forceLineRendering",value:e})}async forceLineRenderingChanged(e){Y!==null&&(Y.gcodeProcessor.updateForceWireMode(e||this.cncMode),await this.reloadViewer())}get transparency(){return this.$store.state.gui.gcodeViewer.transparency}set transparency(e){this.$store.dispatch("gui/saveSetting",{name:"gcodeViewer.transparency",value:e})}async transparencyChanged(e){Y!==null&&(Y.gcodeProcessor.setAlpha(e),await this.reloadViewer())}get voxelMode(){return this.$store.state.gui.gcodeViewer.voxelMode}set voxelMode(e){this.$store.dispatch("gui/saveSetting",{name:"gcodeViewer.voxelMode",value:e})}async voxelModeChanged(e){Y!==null&&(Y.gcodeProcessor.setVoxelMode(e),Y.gcodeProcessor.voxelWidth=this.voxelWidth,Y.gcodeProcessor.voxelHeight=this.voxelHeight,await this.reloadViewer())}get voxelWidth(){var e;return(e=this.$store.state.gui.gcodeViewer.voxelWidth)!=null?e:1}set voxelWidth(e){this.$store.dispatch("gui/saveSetting",{name:"gcodeViewer.voxelWidth",value:e})}get voxelHeight(){var e;return(e=this.$store.state.gui.gcodeViewer.voxelHeight)!=null?e:1}set voxelHeight(e){this.$store.dispatch("gui/saveSetting",{name:"gcodeViewer.voxelHeight",value:e})}get specularLighting(){return this.$store.state.gui.gcodeViewer.specularLighting}set specularLighting(e){this.$store.dispatch("gui/saveSetting",{name:"gcodeViewer.specularLighting",value:e})}async specularLightingChanged(e){Y!==null&&Y.gcodeProcessor.useSpecularColor(e)}get cncMode(){return this.$store.state.gui.gcodeViewer.cncMode}set cncMode(e){this.$store.dispatch("gui/saveSetting",{name:"gcodeViewer.cncMode",value:e}),Y.gcodeProcessor.g1AsExtrusion=e,Y.gcodeProcessor.updateForceWireMode(this.forceLineRendering||e),this.reloadViewer()}get extruderColors(){var e,t;return(t=(e=this.$store.state.gui.gcodeViewer)==null?void 0:e.extruderColors)!=null?t:!1}loadToolColors(e){Y&&e.length&&(Y.gcodeProcessor.resetTools(),e.forEach(t=>{Y.gcodeProcessor.addTool(t,this.nozzle_diameter)}),this.setReloadRequiredFlag())}extruderColorsChanged(e){Y&&e&&e.length&&(this.loadToolColors(e),this.setReloadRequiredFlag())}get colorMode(){var e,t;return(t=(e=this.$store.state.gui.gcodeViewer)==null?void 0:e.colorMode)!=null?t:2}set colorMode(e){this.$store.dispatch("gui/saveSetting",{name:"gcodeViewer.colorMode",value:e}),Y&&Y.gcodeProcessor.colorMode!==e&&(Y.gcodeProcessor.setColorMode(e),this.reloadViewer())}get backgroundColor(){var e,t;return(t=(e=this.$store.state.gui.gcodeViewer)==null?void 0:e.backgroundColor)!=null?t:"#121212"}backgroundColorChanged(e){Y!==null&&Y.setBackgroundColor(e)}get gridColor(){var e,t;return(t=(e=this.$store.state.gui.gcodeViewer)==null?void 0:e.gridColor)!=null?t:"#B3B3B3"}gridColorChanged(e){Y!==null&&Y.bed.setBedColor(e)}get showAxes(){var e,t;return(t=(e=this.$store.state.gui.gcodeViewer)==null?void 0:e.showAxes)!=null?t:!0}showAxesChanged(e){Y!==null&&Y.axes.show(e)}get minFeed(){var e,t;return(t=(e=this.$store.state.gui.gcodeViewer)==null?void 0:e.minFeed)!=null?t:20}minFeedChanged(e){Y!==null&&Y.gcodeProcessor.updateColorRate(e*60,this.maxFeed*60)}get maxFeed(){var e,t;return(t=(e=this.$store.state.gui.gcodeViewer)==null?void 0:e.maxFeed)!=null?t:100}maxFeedChanged(e){Y!==null&&Y.gcodeProcessor.updateColorRate(this.minFeed*60,e*60)}get minFeedColor(){var e,t;return(t=(e=this.$store.state.gui.gcodeViewer)==null?void 0:e.minFeedColor)!=null?t:"#0000FF"}minFeedColorUpdated(e){Y!==null&&(Y.gcodeProcessor.updateMinFeedColor(e),this.setReloadRequiredFlag())}get maxFeedColor(){var e,t;return(t=(e=this.$store.state.gui.gcodeViewer)==null?void 0:e.maxFeedColor)!=null?t:"#FF0000"}maxFeedColorUpdated(e){Y!==null&&(Y.gcodeProcessor.updateMaxFeedColor(e),this.setReloadRequiredFlag())}get kinematics(){var e,t,i,s,n,r,o,h;return(h=(o=(i=(t=(e=this.$store.state.printer.configfile)==null?void 0:e.settings)==null?void 0:t.printer)==null?void 0:i.kinematics)!=null?o:(r=(n=(s=this.$store.state.gui)==null?void 0:s.gcodeViewer)==null?void 0:n.klipperCache)==null?void 0:r.kinematics)!=null?h:""}get bedMaxSize(){var e,t,i,s,n,r;return(r=(n=(e=this.$store.state.printer.toolhead)==null?void 0:e.axis_maximum)!=null?n:(s=(i=(t=this.$store.state.gui)==null?void 0:t.gcodeViewer)==null?void 0:i.klipperCache)==null?void 0:s.axis_maximum)!=null?r:null}get bedMinSize(){var e,t,i,s,n,r;return(r=(n=(e=this.$store.state.printer.toolhead)==null?void 0:e.axis_minimum)!=null?n:(s=(i=(t=this.$store.state.gui)==null?void 0:t.gcodeViewer)==null?void 0:i.klipperCache)==null?void 0:s.axis_minimum)!=null?r:null}kinematicsChanged(e){Y===null||!e||Y.bed.setDelta(e.includes("delta"))}bedMinSizeChanged(e){e===null||Y===null||Y.bed===null||(Y.bed.buildVolume.x.min=e[0],Y.bed.buildVolume.y.min=e[1],Y.bed.buildVolume.z.min=e[2])}bedMaxSizeChanged(e){e===null||Y===null||Y.bed===null||(Y.bed.buildVolume.x.max=e[0],Y.bed.buildVolume.y.max=e[1],Y.bed.buildVolume.z.max=e[2])}get progressColor(){var e,t;return(t=(e=this.$store.state.gui.gcodeViewer)==null?void 0:e.progressColor)!=null?t:"#FFFFFF"}progressColorChanged(e){Y==null||Y.setProgressColor(e)}scrubPlayingChanged(e){if(!e){this.scrubInterval&&clearInterval(this.scrubInterval),this.scrubPlaying=!1,this.scrubInterval=void 0;return}this.scrubInterval&&(clearInterval(this.scrubInterval),this.scrubInterval=void 0),this.scrubPlaying=!0,this.scrubPosition>=this.scrubFileSize&&(this.scrubPosition=0),Y.gcodeProcessor.updateFilePosition(this.scrubPosition-3e4),this.scrubInterval=setInterval(()=>{this.scrubPosition+=100*this.scrubSpeed,Y.gcodeProcessor.updateFilePosition(this.scrubPosition),Y.simulateToolPosition(),(this.tracking||this.scrubPosition>=this.scrubFileSize)&&(this.scrubPlaying=!1)},200)}get showScrubber(){return!this.tracking&&this.scrubFileSize>0}updateScrubPosition(e){Y===null||this.tracking||(Y.gcodeProcessor.updateFilePosition(e),Y.simulateToolPosition())}fastForward(){this.scrubPosition=this.scrubFileSize,Y.gcodeProcessor.updateFilePosition(this.scrubPosition)}objectCallback(e){var t;(e==null?void 0:e.cancelled)===!1&&(this.excludeObject.name=(t=e.name)!=null?t:"UNKNOWN",this.excludeObject.bool=!0)}cancelObject(){this.$socket.emit("printer.gcode.script",{script:"EXCLUDE_OBJECT NAME="+this.excludeObject.name}),this.excludeObject.bool=!1}};Je([Vr({type:String,default:"",required:!1})],$e.prototype,"filename",2);Je([Sl("fileInput")],$e.prototype,"fileInput",2);Je([Sl("viewerCanvasContainer")],$e.prototype,"viewerCanvasContainer",2);Je([Ml(200)],$e.prototype,"handleResize",1);Je([nt("printing_objects")],$e.prototype,"printing_objectsChanged",1);Je([nt("excluded_objects")],$e.prototype,"excluded_objectsChanged",1);Je([nt("renderQuality")],$e.prototype,"renderQualityChanged",1);Je([nt("currentPosition")],$e.prototype,"currentPositionChanged",1);Je([nt("filePosition")],$e.prototype,"filePositionChanged",1);Je([nt("tracking")],$e.prototype,"trackingChanged",1);Je([nt("printerIsPrinting")],$e.prototype,"printerIsPrintingChanged",1);Je([nt("showCursor")],$e.prototype,"showCursorChanged",1);Je([nt("showTravelMoves")],$e.prototype,"showTravelMovesChanged",1);Je([nt("showObjectSelection")],$e.prototype,"showObjectSelectionChanged",1);Je([nt("hdRendering")],$e.prototype,"hdRenderingChanged",1);Je([nt("forceLineRendering")],$e.prototype,"forceLineRenderingChanged",1);Je([nt("transparency")],$e.prototype,"transparencyChanged",1);Je([nt("voxelMode")],$e.prototype,"voxelModeChanged",1);Je([nt("specularLighting")],$e.prototype,"specularLightingChanged",1);Je([nt("extruderColors")],$e.prototype,"extruderColorsChanged",1);Je([nt("backgroundColor")],$e.prototype,"backgroundColorChanged",1);Je([nt("gridColor")],$e.prototype,"gridColorChanged",1);Je([nt("showAxes")],$e.prototype,"showAxesChanged",1);Je([nt("minFeed")],$e.prototype,"minFeedChanged",1);Je([nt("maxFeed")],$e.prototype,"maxFeedChanged",1);Je([nt("minFeedColor")],$e.prototype,"minFeedColorUpdated",1);Je([nt("maxFeedColor")],$e.prototype,"maxFeedColorUpdated",1);Je([nt("kinematics",{immediate:!0})],$e.prototype,"kinematicsChanged",1);Je([nt("bedMinSize",{deep:!0,immediate:!0})],$e.prototype,"bedMinSizeChanged",1);Je([nt("bedMaxSize",{deep:!0,immediate:!0})],$e.prototype,"bedMaxSizeChanged",1);Je([nt("progressColor")],$e.prototype,"progressColorChanged",1);Je([nt("scrubPlaying")],$e.prototype,"scrubPlayingChanged",1);Je([Ml(200),nt("scrubPosition")],$e.prototype,"updateScrubPosition",1);$e=Je([a0({components:{Panel:Pl,CodeStream:wl}})],$e);var Yb=function(){var e=this,t=e._self._c;return e._self._setupProxy,t("div",[t(Pl,{attrs:{title:e.panelTitle,icon:e.mdiVideo3d,"card-class":"gcode-viewer-panel","margin-bottom":!1},scopedSlots:e._u([{key:"buttons",fn:function(){return[t(Bt,{directives:[{name:"show",rawName:"v-show",value:e.reloadRequired,expression:"reloadRequired"}],staticClass:"ml-3",attrs:{icon:e.$vuetify.breakpoint.xs,text:e.$vuetify.breakpoint.smAndUp,tile:"",color:"info"},on:{click:e.reloadViewer}},[t("span",{staticClass:"d-none d-sm-block"},[e._v(e._s(e.$t("GCodeViewer.ReloadRequired")))]),t(Ri,{staticClass:"d-sm-none"},[e._v(e._s(e.mdiReloadAlert))])],1),t(Bt,{attrs:{icon:"",tile:""},on:{click:e.resetCamera}},[t(Ri,[e._v(e._s(e.mdiCameraRetake))])],1)]},proxy:!0}])},[t(Ro,[t(sr,{class:e.showScrubber?"withScrubber":""},[t(ds,{attrs:{cols:e.showGCode?8:12}},[t("div",{ref:"viewerCanvasContainer"})]),t(ds,{directives:[{name:"show",rawName:"v-show",value:e.showGCode,expression:"showGCode"}],attrs:{cols:"4"}},[t("div",{staticClass:"viewer"},[t(wl,{ref:"gcodestream",attrs:{shown:e.showGCode,currentline:e.scrubPosition,document:e.fileData,"is-simulating":!e.printerIsPrinting},on:{"update:currentline":function(i){e.scrubPosition=i}}})],1)])],1),t(sr,{directives:[{name:"show",rawName:"v-show",value:e.showScrubber,expression:"showScrubber"}],staticClass:"scrubber"},[t(ds,{staticClass:"pt-0"},[t(gf,{attrs:{hint:e.scrubPosition+"/"+e.scrubFileSize,max:e.scrubFileSize,dense:"",min:"0","persistent-hint":""},model:{value:e.scrubPosition,callback:function(i){e.scrubPosition=i},expression:"scrubPosition"}})],1),t(ds,{staticClass:"col-auto pt-0 text-center"},[t(Bt,{staticClass:"px-2 minwidth-0",attrs:{color:"primary"},on:{click:function(i){e.scrubPlaying=!e.scrubPlaying}}},[e.scrubPlaying?t(Ri,[e._v(e._s(e.mdiPause))]):t(Ri,[e._v(e._s(e.mdiPlay))])],1),t(Bt,{staticClass:"px-2 minwidth-0 mx-3",attrs:{color:"primary"},on:{click:e.fastForward}},[t(Ri,[e._v(e._s(e.mdiFastForward))])],1),t(mf,{staticClass:"mt-3 mt-sm-0",attrs:{dense:"",mandatory:"",rounded:""},model:{value:e.scrubSpeed,callback:function(i){e.scrubSpeed=i},expression:"scrubSpeed"}},[t(Bt,{attrs:{value:1}},[e._v("1x")]),t(Bt,{attrs:{value:2}},[e._v("2x")]),t(Bt,{attrs:{value:5}},[e._v("5x")]),t(Bt,{attrs:{value:10}},[e._v("10x")]),t(Bt,{attrs:{value:20}},[e._v("20x")])],1)],1)],1),t(sr,{staticClass:"mt-0 d-flex align-top"},[t(ds,[t(sr,[t(ds,{staticClass:"d-flex align-content-space-around justify-center flex-wrap flex-md-nowrap col-12 col-md-4",attrs:{"order-md":"2"}},[e.loadedFile===null?[e.sdCardFilePath!==""&&e.sdCardFilePath!==e.loadedFile?t(Bt,{staticClass:"mr-3",on:{click:e.loadCurrentFile}},[e._v(" "+e._s(e.$t("GCodeViewer.LoadCurrentFile"))+" ")]):e._e(),t(Bt,{on:{click:e.chooseFile}},[e._v(e._s(e.$t("GCodeViewer.LoadLocal")))])]:[e.showTrackingButton?t(Bt,{staticClass:"mr-3",on:{click:function(i){e.tracking=!e.tracking}}},[t(Ri,{staticClass:"mr-2",domProps:{innerHTML:e._s(e.tracking?e.mdiToggleSwitch:e.mdiToggleSwitchOffOutline)}}),e._v(" "+e._s(e.$t("GCodeViewer.Tracking"))+" ")],1):e._e(),t(Bt,{on:{click:e.clearLoadedFile}},[t(Ri,{attrs:{left:""}},[e._v(e._s(e.mdiBroom))]),e._v(" "+e._s(e.$t("GCodeViewer.ClearLoadedFile"))+" ")],1)]],2),t(ds,{staticClass:"col-12 col-sm-6 col-md-4"},[t(Io,{attrs:{items:e.colorModes,label:e.$t("GCodeViewer.ColorMode"),"item-text":"text",dense:"","hide-details":"",outlined:""},model:{value:e.colorMode,callback:function(i){e.colorMode=i},expression:"colorMode"}})],1),t(ds,{staticClass:"col-12 col-sm-6 col-md-4 d-flex",attrs:{"order-md":"3"}},[t(Io,{attrs:{items:e.renderQualities,label:e.$t("GCodeViewer.RenderQuality"),"item-text":"label",dense:"","hide-details":"",outlined:""},model:{value:e.renderQuality,callback:function(i){e.renderQuality=i},expression:"renderQuality"}}),t(vf,{attrs:{"offset-y":!0,"offset-x":!0,top:"","close-on-content-click":!1,title:e.$t("Files.SetupCurrentList")},scopedSlots:e._u([{key:"activator",fn:function({on:i,attrs:s}){return[t(Bt,e._g(e._b({staticClass:"minwidth-0 px-2 ml-3"},"v-btn",s,!1),i),[t(Ri,[e._v(e._s(e.mdiCog))])],1)]}}])},[t(bf,[t(Bi,{staticClass:"minHeight36"},[t(Li,{staticClass:"mt-0",attrs:{"hide-details":"",label:e.$t("GCodeViewer.ShowToolhead")},model:{value:e.showCursor,callback:function(i){e.showCursor=i},expression:"showCursor"}})],1),t(Bi,{staticClass:"minHeight36"},[t(Li,{staticClass:"mt-0",attrs:{"hide-details":"",label:e.$t("GCodeViewer.ShowTravelMoves")},model:{value:e.showTravelMoves,callback:function(i){e.showTravelMoves=i},expression:"showTravelMoves"}})],1),t(Bi,{staticClass:"minHeight36"},[t(Li,{staticClass:"mt-0",attrs:{"hide-details":"",label:e.$t("GCodeViewer.ShowGCode")},model:{value:e.showGCode,callback:function(i){e.showGCode=i},expression:"showGCode"}})],1),e.loadedFile===e.sdCardFilePath&&e.printing_objects.length?t(Bi,{staticClass:"minHeight36"},[t(Li,{staticClass:"mt-0",attrs:{"hide-details":"",label:e.$t("GCodeViewer.ShowObjectSelection")},model:{value:e.showObjectSelection,callback:function(i){e.showObjectSelection=i},expression:"showObjectSelection"}})],1):e._e(),t(xf),t(Bi,{staticClass:"minHeight36"},[t(Li,{staticClass:"mt-0",attrs:{"hide-details":"",label:e.$t("GCodeViewer.HDRendering")},model:{value:e.hdRendering,callback:function(i){e.hdRendering=i},expression:"hdRendering"}})],1),t(Bi,{staticClass:"minHeight36"},[t(Li,{staticClass:"mt-0",attrs:{"hide-details":"",label:e.$t("GCodeViewer.ForceLineRendering")},model:{value:e.forceLineRendering,callback:function(i){e.forceLineRendering=i},expression:"forceLineRendering"}})],1),t(Bi,{staticClass:"minHeight36"},[t(Li,{staticClass:"mt-0",attrs:{"hide-details":"",label:e.$t("GCodeViewer.Transparency")},model:{value:e.transparency,callback:function(i){e.transparency=i},expression:"transparency"}})],1),t(Bi,{staticClass:"minHeight36"},[t(Li,{staticClass:"mt-0",attrs:{"hide-details":"",label:e.$t("GCodeViewer.VoxelMode")},model:{value:e.voxelMode,callback:function(i){e.voxelMode=i},expression:"voxelMode"}})],1),t(Bi,{staticClass:"minHeight36"},[t(Li,{staticClass:"mt-0",attrs:{"hide-details":"",label:e.$t("GCodeViewer.SpecularLighting")},model:{value:e.specularLighting,callback:function(i){e.specularLighting=i},expression:"specularLighting"}})],1),t(Bi,{staticClass:"minHeight36"},[t(Li,{staticClass:"mt-0",attrs:{"hide-details":"",label:e.$t("GCodeViewer.CNCMode")},model:{value:e.cncMode,callback:function(i){e.cncMode=i},expression:"cncMode"}})],1)],1)],1)],1)],1)],1)],1),t("input",{ref:"fileInput",attrs:{accept:".g,.gcode,.gc,.gco,.nc,.ngc,.tap",hidden:"",multiple:"",type:"file"},on:{change:e.fileSelected}})],1),t("resize-observer",{on:{notify:e.handleResize}})],1),t(Eo,{attrs:{timeout:-1,fixed:"",right:"",bottom:""},scopedSlots:e._u([{key:"action",fn:function({attrs:i}){return[t(Bt,e._b({staticStyle:{"min-width":"auto"},attrs:{color:"red",text:""},on:{click:function(s){return e.cancelRendering()}}},"v-btn",i,!1),[t(Ri,{staticClass:"0"},[e._v(e._s(e.mdiClose))])],1)]}}]),model:{value:e.loading,callback:function(i){e.loading=i},expression:"loading"}},[t("div",[e._v(" "+e._s(e.$t("GCodeViewer.Rendering"))+" - "+e._s(e.loadingPercent)+"% "),t("br"),t("strong",[e._v(e._s(e.loadedFile))])]),t(da,{staticClass:"mt-2",attrs:{value:e.loadingPercent}})],1),t(Eo,{attrs:{timeout:-1,fixed:"",right:"",bottom:""},scopedSlots:e._u([{key:"action",fn:function({attrs:i}){return[t(Bt,e._b({staticStyle:{"min-width":"auto"},attrs:{color:"red",text:""},on:{click:e.cancelDownload}},"v-btn",i,!1),[t(Ri,{staticClass:"0"},[e._v(e._s(e.mdiClose))])],1)]}}]),model:{value:e.downloadSnackbar.status,callback:function(i){e.$set(e.downloadSnackbar,"status",i)},expression:"downloadSnackbar.status"}},[e.downloadSnackbar.total>0?[t("div",[e._v(" "+e._s(e.$t("GCodeViewer.Downloading"))+" - "+e._s(Math.round(e.downloadSnackbar.percent))+" % @ "+e._s(e.formatFilesize(Math.round(e.downloadSnackbar.speed)))+"/s "),t("br"),t("strong",[e._v(e._s(e.downloadSnackbar.filename))])]),t(da,{staticClass:"mt-2",attrs:{value:e.downloadSnackbar.percent}})]:[t("div",[e._v(" "+e._s(e.$t("GCodeViewer.Downloading"))+" "),t("br"),t("strong",[e._v(e._s(e.downloadSnackbar.filename))])]),t(da,{staticClass:"mt-2",attrs:{indeterminate:""}})]],2),t(yf,{attrs:{"max-width":"400"},model:{value:e.excludeObject.bool,callback:function(i){e.$set(e.excludeObject,"bool",i)},expression:"excludeObject.bool"}},[t(Tf,[t(Af,{attrs:{flat:"",dense:""}},[t(Rf,[t("span",{staticClass:"subheading"},[t(Ri,{attrs:{left:""}},[e._v(e._s(e.mdiSelectionRemove))]),e._v(" "+e._s(e.$t("Panels.StatusPanel.ExcludeObject.ExcludeObjectHeadline"))+" ")],1)])],1),t(Ro,{staticClass:"mt-3"},[e._v(" "+e._s(e.$t("Panels.StatusPanel.ExcludeObject.ExcludeObjectText",{name:e.excludeObject.name}))+" ")]),t(If,[t(Ef),t(Bt,{attrs:{text:""},on:{click:function(i){e.excludeObject.bool=!1}}},[e._v(" "+e._s(e.$t("Panels.StatusPanel.ExcludeObject.Cancel"))+" ")]),t(Bt,{attrs:{color:"primary",text:""},on:{click:e.cancelObject}},[e._v(" "+e._s(e.$t("Panels.StatusPanel.ExcludeObject.ExcludeObject"))+" ")])],1)],1)],1)],1)},qb=[],jb=o0($e,Yb,qb,!1,null,"4c02d29b");const _f=jb.exports;var $b=Object.getOwnPropertyDescriptor,Zb=(a,e,t,i)=>{for(var s=i>1?void 0:i?$b(e,t):e,n=a.length-1,r;n>=0;n--)(r=a[n])&&(s=r(s)||s);return s};let r0=class extends El(Cl){};r0=Zb([a0({components:{Viewer:_f}})],r0);var Qb=function(){var e=this,t=e._self._c;return e._self._setupProxy,t(_f)},Jb=[],ex=o0(r0,Qb,Jb,!1,null,null);const tx=ex.exports,ox=Object.freeze(Object.defineProperty({__proto__:null,default:tx},Symbol.toStringTag,{value:"Module"}));export{ae as A,st as B,ht as C,sp as F,ft as I,b0 as L,mt as P,g0 as R,Me as S,rx as T,v as V,Nd as _,U as a,Ir as b,de as c,On as d,Wd as e,J as f,ie as g,ec as h,ox as i};
|